QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
qgscreateannotationitemmaptool_impl.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgscreateannotationitemmaptool_impl.cpp
3 ------------------------
4 Date : September 2021
5 Copyright : (C) 2021 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17#include "moc_qgscreateannotationitemmaptool_impl.cpp"
18#include "qgsmapmouseevent.h"
26#include "qgsannotationlayer.h"
27#include "qgsstyle.h"
28#include "qgsmapcanvas.h"
29#include "qgsmarkersymbol.h"
30#include "qgslinesymbol.h"
31#include "qgsfillsymbol.h"
33#include "qgsapplication.h"
35#include "qgscurvepolygon.h"
36#include "qgsrubberband.h"
38#include "qgssvgcache.h"
39#include "qgsimagecache.h"
40
41#include <QFileDialog>
42#include <QImageReader>
43
45
46//
47// QgsMapToolCaptureAnnotationItem
48//
49
51 : QgsMapToolCapture( canvas, cadDockWidget, mode )
52{
53 mToolName = tr( "Annotation tool" );
54}
55
57{
58 return mHandler;
59}
60
62{
63 return this;
64}
65
67{
68 return mHandler->targetLayer();
69}
70
71
73{
74 // no geometry validation!
75 return SupportsCurves;
76}
77
79{
80 switch ( technique )
81 {
86 return true;
87 }
89}
90
91
92//
93// QgsCreatePointTextItemMapTool
94//
95
97 : QgsMapToolAdvancedDigitizing( canvas, cadDockWidget )
98 , mHandler( new QgsCreateAnnotationItemMapToolHandler( canvas, cadDockWidget ) )
99{
100 setUseSnappingIndicator( true );
101}
102
104
106{
107 if ( event->button() != Qt::LeftButton )
108 return;
109
110 const QgsPointXY layerPoint = toLayerCoordinates( mHandler->targetLayer(), event->mapPoint() );
111
112 std::unique_ptr<QgsAnnotationPointTextItem> createdItem = std::make_unique<QgsAnnotationPointTextItem>( tr( "Text" ), layerPoint );
113 createdItem->setAlignment( Qt::AlignLeft );
115 // default to HTML formatting
116 format.setAllowHtmlFormatting( true );
117 createdItem->setFormat( format );
118 // newly created point text items default to using symbology reference scale at the current map scale
119 createdItem->setUseSymbologyReferenceScale( true );
120 createdItem->setSymbologyReferenceScale( canvas()->scale() );
121 mHandler->pushCreatedItem( createdItem.release() );
122}
123
125{
126 return mHandler;
127}
128
130{
131 return this;
132}
133
134
135//
136// QgsCreateMarkerMapTool
137//
138
140 : QgsMapToolCaptureAnnotationItem( canvas, cadDockWidget, CapturePoint )
141{
142 mHandler = new QgsCreateAnnotationItemMapToolHandler( canvas, cadDockWidget, this );
143}
144
146{
147 if ( event->button() != Qt::LeftButton )
148 return;
149
150 const QgsPointXY layerPoint = toLayerCoordinates( mHandler->targetLayer(), event->mapPoint() );
151 std::unique_ptr<QgsAnnotationMarkerItem> createdItem = std::make_unique<QgsAnnotationMarkerItem>( QgsPoint( layerPoint ) );
152
153 std::unique_ptr<QgsMarkerSymbol> markerSymbol = QgsApplication::recentStyleHandler()->recentSymbol<QgsMarkerSymbol>( QStringLiteral( "marker_annotation_item" ) );
154 if ( !markerSymbol )
155 markerSymbol.reset( qgis::down_cast<QgsMarkerSymbol *>( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ) );
156 createdItem->setSymbol( markerSymbol.release() );
157
158 // set reference scale to match canvas scale, but don't enable it by default for marker items
159 createdItem->setSymbologyReferenceScale( canvas()->scale() );
160
161 mHandler->pushCreatedItem( createdItem.release() );
162
164
166}
167
168//
169// QgsCreateLineMapTool
170//
171
173 : QgsMapToolCaptureAnnotationItem( canvas, cadDockWidget, CaptureLine )
174{
175 mHandler = new QgsCreateAnnotationItemMapToolHandler( canvas, cadDockWidget, this );
176}
177
178void QgsCreateLineItemMapTool::lineCaptured( const QgsCurve *line )
179{
180 if ( line->isEmpty() )
181 return;
182
183 // do it!
184 std::unique_ptr<QgsAbstractGeometry> geometry( line->simplifiedTypeRef()->clone() );
185 if ( qgsgeometry_cast<QgsCurve *>( geometry.get() ) )
186 {
187 std::unique_ptr<QgsAnnotationLineItem> createdItem = std::make_unique<QgsAnnotationLineItem>( qgsgeometry_cast<QgsCurve *>( geometry.release() ) );
188
189 std::unique_ptr<QgsLineSymbol> lineSymbol = QgsApplication::recentStyleHandler()->recentSymbol<QgsLineSymbol>( QStringLiteral( "line_annotation_item" ) );
190 if ( !lineSymbol )
191 lineSymbol.reset( qgis::down_cast<QgsLineSymbol *>( QgsSymbol::defaultSymbol( Qgis::GeometryType::Line ) ) );
192 createdItem->setSymbol( lineSymbol.release() );
193
194 // set reference scale to match canvas scale, but don't enable it by default for marker items
195 createdItem->setSymbologyReferenceScale( canvas()->scale() );
196
197 mHandler->pushCreatedItem( createdItem.release() );
198 }
199}
200
201//
202// QgsCreatePolygonItemMapTool
203//
204
206 : QgsMapToolCaptureAnnotationItem( canvas, cadDockWidget, CapturePolygon )
207{
208 mHandler = new QgsCreateAnnotationItemMapToolHandler( canvas, cadDockWidget, this );
209}
210
211void QgsCreatePolygonItemMapTool::polygonCaptured( const QgsCurvePolygon *polygon )
212{
213 if ( polygon->isEmpty() )
214 return;
215
216 std::unique_ptr<QgsAbstractGeometry> geometry( polygon->exteriorRing()->simplifiedTypeRef()->clone() );
217 if ( qgsgeometry_cast<QgsCurve *>( geometry.get() ) )
218 {
219 std::unique_ptr<QgsCurvePolygon> newPolygon = std::make_unique<QgsCurvePolygon>();
220 newPolygon->setExteriorRing( qgsgeometry_cast<QgsCurve *>( geometry.release() ) );
221 std::unique_ptr<QgsAnnotationPolygonItem> createdItem = std::make_unique<QgsAnnotationPolygonItem>( newPolygon.release() );
222
223 std::unique_ptr<QgsFillSymbol> fillSymbol = QgsApplication::recentStyleHandler()->recentSymbol<QgsFillSymbol>( QStringLiteral( "polygon_annotation_item" ) );
224 if ( !fillSymbol )
225 fillSymbol.reset( qgis::down_cast<QgsFillSymbol *>( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ) );
226 createdItem->setSymbol( fillSymbol.release() );
227
228 // set reference scale to match canvas scale, but don't enable it by default for marker items
229 createdItem->setSymbologyReferenceScale( canvas()->scale() );
230
231 mHandler->pushCreatedItem( createdItem.release() );
232 }
233}
234
235
236//
237// QgsCreatePictureItemMapTool
238//
239
240const QgsSettingsEntryString *QgsCreatePictureItemMapTool::settingLastSourceFolder = new QgsSettingsEntryString( QStringLiteral( "last-source-folder" ), sTreePicture, QString(), QStringLiteral( "Last used folder for picture annotation source files" ) );
241
243 : QgsMapToolAdvancedDigitizing( canvas, cadDockWidget )
244 , mHandler( new QgsCreateAnnotationItemMapToolHandler( canvas, cadDockWidget, this ) )
245{
246 setUseSnappingIndicator( true );
247}
248
250{
251 if ( event->button() == Qt::RightButton && mRubberBand )
252 {
253 mRubberBand.reset();
255 return;
256 }
257
258 if ( event->button() != Qt::LeftButton )
259 return;
260
261 if ( !mRubberBand )
262 {
263 mFirstPoint = event->snapPoint();
264 mRect.setRect( mFirstPoint.x(), mFirstPoint.y(), mFirstPoint.x(), mFirstPoint.y() );
265
267 mRubberBand->setWidth( digitizingStrokeWidth() );
268 QColor color = digitizingStrokeColor();
269
271 color.setAlphaF( color.alphaF() * alphaScale );
272 mRubberBand->setLineStyle( Qt::DotLine );
273 mRubberBand->setStrokeColor( color );
274
275 const QColor fillColor = digitizingFillColor();
276 mRubberBand->setFillColor( fillColor );
277 }
278 else
279 {
280 mRubberBand.reset();
281
282 QStringList formatsFilter;
283 formatsFilter.append( QStringLiteral( "*.svg" ) );
284 const QByteArrayList supportedFormats = QImageReader::supportedImageFormats();
285 for ( const auto &format : supportedFormats )
286 {
287 formatsFilter.append( QString( QStringLiteral( "*.%1" ) ).arg( QString( format ) ) );
288 }
289 const QString dialogFilter = QStringLiteral( "%1 (%2);;%3 (*.*)" ).arg( tr( "Images" ), formatsFilter.join( QLatin1Char( ' ' ) ), tr( "All files" ) );
290 const QString initialDir = settingLastSourceFolder->value();
291 const QString imagePath = QFileDialog::getOpenFileName( nullptr, tr( "Add Picture Annotation" ), initialDir.isEmpty() ? QDir::homePath() : initialDir, dialogFilter );
292
293 if ( imagePath.isEmpty() )
294 {
295 return; //canceled by the user
296 }
297
298 settingLastSourceFolder->setValue( QFileInfo( imagePath ).path() );
299
300 const QgsPointXY point1 = toLayerCoordinates( mHandler->targetLayer(), mFirstPoint );
301 const QgsPointXY point2 = toLayerCoordinates( mHandler->targetLayer(), event->snapPoint() );
302
303 const QgsPointXY devicePoint1 = toCanvasCoordinates( mFirstPoint );
304 const QgsPointXY devicePoint2 = toCanvasCoordinates( event->snapPoint() );
305 const double initialWidthPixels = std::abs( devicePoint1.x() - devicePoint2.x() );
306 const double initialHeightPixels = std::abs( devicePoint1.y() - devicePoint2.y() );
307
308 const QFileInfo pathInfo( imagePath );
310
311 QSizeF size;
312 if ( pathInfo.suffix().compare( QLatin1String( "svg" ), Qt::CaseInsensitive ) == 0 )
313 {
315 size = QgsApplication::svgCache()->svgViewboxSize( imagePath, 100, QColor(), QColor(), 1, 1 );
316 }
317 else
318 {
320 size = QgsApplication::imageCache()->originalSize( imagePath );
321 }
322
324
325 std::unique_ptr<QgsAnnotationPictureItem> createdItem = std::make_unique<QgsAnnotationPictureItem>( format, imagePath, QgsRectangle( point1, point2 ) );
326 if ( size.isValid() )
327 {
328 const double pixelsToMm = mCanvas->mapSettings().outputDpi() / 25.4;
329 if ( size.width() / size.height() > initialWidthPixels / initialHeightPixels )
330 {
331 createdItem->setFixedSize( QSizeF( initialWidthPixels / pixelsToMm, size.height() / size.width() * initialWidthPixels / pixelsToMm ) );
332 }
333 else
334 {
335 createdItem->setFixedSize( QSizeF( size.width() / size.height() * initialHeightPixels / pixelsToMm, initialHeightPixels / pixelsToMm ) );
336 }
337 createdItem->setFixedSizeUnit( Qgis::RenderUnit::Millimeters );
338 }
339
340 mHandler->pushCreatedItem( createdItem.release() );
341 }
342}
343
345{
346 if ( !mRubberBand )
347 return;
348
349 const QgsPointXY mapPoint = event->snapPoint();
350 mRect.setBottomRight( mapPoint.toQPointF() );
351
352 mRubberBand->reset( Qgis::GeometryType::Polygon );
353 mRubberBand->addPoint( mRect.bottomLeft(), false );
354 mRubberBand->addPoint( mRect.bottomRight(), false );
355 mRubberBand->addPoint( mRect.topRight(), false );
356 mRubberBand->addPoint( mRect.topLeft(), true );
357}
358
359void QgsCreatePictureItemMapTool::keyPressEvent( QKeyEvent *event )
360{
361 if ( event->key() == Qt::Key_Escape )
362 {
363 if ( mRubberBand )
364 {
365 mRubberBand.reset();
367 event->ignore();
368 }
369 }
370}
371
373{
374 return mHandler;
375}
376
378{
379 return this;
380}
381
382
383//
384// QgsCreateRectangleTextItemMapTool
385//
386
388 : QgsMapToolAdvancedDigitizing( canvas, cadDockWidget )
389 , mHandler( new QgsCreateAnnotationItemMapToolHandler( canvas, cadDockWidget, this ) )
390{
391 setUseSnappingIndicator( true );
392}
393
395{
396 if ( event->button() == Qt::RightButton && mRubberBand )
397 {
398 mRubberBand.reset();
400 return;
401 }
402
403 if ( event->button() != Qt::LeftButton )
404 return;
405
406 if ( !mRubberBand )
407 {
408 mFirstPoint = event->snapPoint();
409 mRect.setRect( mFirstPoint.x(), mFirstPoint.y(), mFirstPoint.x(), mFirstPoint.y() );
410
412 mRubberBand->setWidth( digitizingStrokeWidth() );
413 QColor color = digitizingStrokeColor();
414
416 color.setAlphaF( color.alphaF() * alphaScale );
417 mRubberBand->setLineStyle( Qt::DotLine );
418 mRubberBand->setStrokeColor( color );
419
420 const QColor fillColor = digitizingFillColor();
421 mRubberBand->setFillColor( fillColor );
422 }
423 else
424 {
425 mRubberBand.reset();
426
427 const QgsPointXY point1 = toLayerCoordinates( mHandler->targetLayer(), mFirstPoint );
428 const QgsPointXY point2 = toLayerCoordinates( mHandler->targetLayer(), event->snapPoint() );
429
431
432 std::unique_ptr<QgsAnnotationRectangleTextItem> createdItem = std::make_unique<QgsAnnotationRectangleTextItem>( tr( "Text" ), QgsRectangle( point1, point2 ) );
433
435 // default to HTML formatting
436 format.setAllowHtmlFormatting( true );
437 createdItem->setFormat( format );
438
439 // newly created rect text items default to using symbology reference scale at the current map scale
440 createdItem->setUseSymbologyReferenceScale( true );
441 createdItem->setSymbologyReferenceScale( canvas()->scale() );
442 mHandler->pushCreatedItem( createdItem.release() );
443 }
444}
445
447{
448 if ( !mRubberBand )
449 return;
450
451 const QgsPointXY mapPoint = event->snapPoint();
452 mRect.setBottomRight( mapPoint.toQPointF() );
453
454 mRubberBand->reset( Qgis::GeometryType::Polygon );
455 mRubberBand->addPoint( mRect.bottomLeft(), false );
456 mRubberBand->addPoint( mRect.bottomRight(), false );
457 mRubberBand->addPoint( mRect.topRight(), false );
458 mRubberBand->addPoint( mRect.topLeft(), true );
459}
460
462{
463 if ( event->key() == Qt::Key_Escape )
464 {
465 if ( mRubberBand )
466 {
467 mRubberBand.reset();
469 event->ignore();
470 }
471 }
472}
473
475{
476 return mHandler;
477}
478
480{
481 return this;
482}
483
484
485//
486// QgsCreateLineTextItemMapTool
487//
488
490 : QgsMapToolCaptureAnnotationItem( canvas, cadDockWidget, CaptureLine )
491{
492 mHandler = new QgsCreateAnnotationItemMapToolHandler( canvas, cadDockWidget, this );
493}
494
495void QgsCreateLineTextItemMapTool::lineCaptured( const QgsCurve *line )
496{
497 if ( line->isEmpty() )
498 return;
499
500 // do it!
501 std::unique_ptr<QgsAbstractGeometry> geometry( line->simplifiedTypeRef()->clone() );
502 if ( qgsgeometry_cast<QgsCurve *>( geometry.get() ) )
503 {
504 std::unique_ptr<QgsAnnotationLineTextItem> createdItem = std::make_unique<QgsAnnotationLineTextItem>( tr( "Text" ), qgsgeometry_cast<QgsCurve *>( geometry.release() ) );
505
506 std::unique_ptr<QgsLineSymbol> lineSymbol = QgsApplication::recentStyleHandler()->recentSymbol<QgsLineSymbol>( QStringLiteral( "line_annotation_item" ) );
507 if ( !lineSymbol )
508 lineSymbol.reset( qgis::down_cast<QgsLineSymbol *>( QgsSymbol::defaultSymbol( Qgis::GeometryType::Line ) ) );
509
511 // default to HTML formatting
512 format.setAllowHtmlFormatting( true );
513 createdItem->setFormat( format );
514
515 // newly created point text items default to using symbology reference scale at the current map scale
516 createdItem->setUseSymbologyReferenceScale( true );
517 createdItem->setSymbologyReferenceScale( canvas()->scale() );
518 mHandler->pushCreatedItem( createdItem.release() );
519 }
520}
521
void reset(T *p=nullptr)
Will reset the managed pointer to p.
CaptureTechnique
Capture technique.
Definition qgis.h:376
@ Shape
Digitize shapes.
@ StraightSegments
Default capture mode - capture occurs with straight line segments.
@ CircularString
Capture in circular strings.
@ Streaming
Streaming points digitizing mode (points are automatically added as the mouse cursor moves).
PictureFormat
Picture formats.
Definition qgis.h:4964
@ Raster
Raster image.
@ Unknown
Invalid or unknown image type.
@ Polygon
Polygons.
@ Millimeters
Millimeters.
virtual const QgsAbstractGeometry * simplifiedTypeRef() const
Returns a reference to the simplest lossless representation of this geometry, e.g.
virtual bool isEmpty() const
Returns true if the geometry is empty.
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
The QgsAdvancedDigitizingDockWidget class is a dockable widget used to handle the CAD tools on top of...
void clearPoints()
Removes all points from the CAD point list.
static QgsRecentStyleHandler * recentStyleHandler()
Returns the handler for recently used style items.
static QgsImageCache * imageCache()
Returns the application's image cache, used for caching resampled versions of raster images.
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
A handler object for map tools which create annotation items.
QgsAnnotationLayer * targetLayer()
Returns the target layer for newly created items.
void pushCreatedItem(QgsAnnotationItem *item)
Pushes a created item to the handler.
QgsCreateLineItemMapTool(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget)
Constructor.
QgsCreateLineTextItemMapTool(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget)
Constructor.
QgsCreateMarkerItemMapTool(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget)
Constructor.
void cadCanvasReleaseEvent(QgsMapMouseEvent *event) override
Override this method when subclassing this class.
void cadCanvasMoveEvent(QgsMapMouseEvent *event) override
Override this method when subclassing this class.
static const QgsSettingsEntryString * settingLastSourceFolder
QgsCreateAnnotationItemMapToolHandler * handler() const override
Returns the handler object for the map tool.
void cadCanvasPressEvent(QgsMapMouseEvent *event) override
Override this method when subclassing this class.
void keyPressEvent(QKeyEvent *event) override
Key event for overriding. Default implementation does nothing.
QgsCreatePictureItemMapTool(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget)
Constructor.
QgsMapTool * mapTool() override
Returns a reference to the associated map tool.
~QgsCreatePointTextItemMapTool() override
QgsMapTool * mapTool() override
Returns a reference to the associated map tool.
void cadCanvasPressEvent(QgsMapMouseEvent *event) override
Override this method when subclassing this class.
QgsCreatePointTextItemMapTool(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget)
Constructor.
QgsCreateAnnotationItemMapToolHandler * handler() const override
Returns the handler object for the map tool.
QgsCreatePolygonItemMapTool(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget)
Constructor.
QgsCreateRectangleTextItemMapTool(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget)
Constructor.
QgsMapTool * mapTool() override
Returns a reference to the associated map tool.
void cadCanvasMoveEvent(QgsMapMouseEvent *event) override
Override this method when subclassing this class.
void cadCanvasPressEvent(QgsMapMouseEvent *event) override
Override this method when subclassing this class.
void keyPressEvent(QKeyEvent *event) override
Key event for overriding. Default implementation does nothing.
QgsCreateAnnotationItemMapToolHandler * handler() const override
Returns the handler object for the map tool.
Curve polygon geometry type.
const QgsCurve * exteriorRing() const
Returns the curve polygon's exterior ring.
bool isEmpty() const override
Returns true if the geometry is empty.
Abstract base class for curved geometry type.
Definition qgscurve.h:35
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
QSize originalSize(const QString &path, bool blocking=false) const
Returns the original size (in pixels) of the image at the specified path.
A line symbol type, for rendering LineString and MultiLineString geometries.
Map canvas is a class for displaying all GIS data types on a canvas.
double scale() const
Returns the last reported scale of the canvas.
Base class for all map layer types.
Definition qgsmaplayer.h:76
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
QgsPointXY mapPoint() const
mapPoint returns the point in coordinates
QgsPointXY snapPoint()
snapPoint will snap the points using the map canvas snapping utils configuration
The QgsMapToolAdvancedDigitizing class is a QgsMapTool which gives event directly in map coordinates ...
QgsAdvancedDigitizingDockWidget * cadDockWidget() const
A base class to digitize annotation items using QgsMapToolCapture.
QgsMapToolCaptureAnnotationItem(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget, CaptureMode mode)
Constructor.
QgsMapTool * mapTool() override
Returns a reference to the associated map tool.
bool supportsTechnique(Qgis::CaptureTechnique technique) const override
Returns true if the tool supports the specified capture technique.
QgsMapLayer * layer() const override
Returns the layer associated with the map tool.
QgsCreateAnnotationItemMapToolHandler * mHandler
QgsMapToolCapture::Capabilities capabilities() const override
Returns flags containing the supported capabilities.
QgsCreateAnnotationItemMapToolHandler * handler() const override
Returns the handler object for the map tool.
QgsMapToolCapture is a base class capable of capturing point, lines and polygons.
void stopCapturing()
Stop capturing.
QFlags< Capability > Capabilities
@ SupportsCurves
Supports curved geometries input.
static QColor digitizingFillColor()
Returns fill color for rubber bands (from global settings)
static QColor digitizingStrokeColor()
Returns stroke color for rubber bands (from global settings)
static int digitizingStrokeWidth()
Returns stroke width for rubber bands (from global settings)
Abstract base class for all map tools.
Definition qgsmaptool.h:71
QgsPoint toLayerCoordinates(const QgsMapLayer *layer, const QgsPoint &point)
Transforms a point from map coordinates to layer coordinates.
QgsMapCanvas * canvas() const
returns pointer to the tool's map canvas
QPointer< QgsMapCanvas > mCanvas
The pointer to the map canvas.
Definition qgsmaptool.h:338
QPoint toCanvasCoordinates(const QgsPointXY &point) const
Transforms a point from map coordinates to screen coordinates.
A marker symbol type, for rendering Point and MultiPoint geometries.
A class to represent a 2D point.
Definition qgspointxy.h:60
double y
Definition qgspointxy.h:64
double x
Definition qgspointxy.h:63
QPointF toQPointF() const
Converts a point to a QPointF.
Definition qgspointxy.h:165
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:49
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsSymbol * recentSymbol(const QString &identifier) const
Returns a copy of the recently used symbol with the specified identifier, or nullptr if no symbol wit...
A rectangle specified with double values.
A class for drawing transient features (e.g.
void setWidth(double width)
Sets the width of the line.
void reset(Qgis::GeometryType geometryType=Qgis::GeometryType::Line)
Clears all the geometries in this rubberband.
void setStrokeColor(const QColor &color)
Sets the stroke color for the rubberband.
void setLineStyle(Qt::PenStyle penStyle)
Sets the style of the line.
void setFillColor(const QColor &color)
Sets the fill color for the rubberband.
void addPoint(const QgsPointXY &p, bool doUpdate=true, int geometryIndex=0, int ringIndex=0)
Adds a vertex to the rubberband and update canvas.
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
bool setValue(const T &value, const QString &dynamicKeyPart=QString()) const
Set settings value.
A string settings entry.
static const QgsSettingsEntryDouble * settingsDigitizingLineColorAlphaScale
Settings entry digitizing line color alpha scale.
static QgsTextFormat defaultTextFormatForProject(QgsProject *project, QgsStyle::TextFormatContext context=QgsStyle::TextFormatContext::Labeling)
Returns the default text format to use for new text based objects for the specified project,...
@ Labeling
Text format used in labeling.
QSizeF svgViewboxSize(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, double fixedAspectRatio=0, bool blocking=false, const QMap< QString, QString > &parameters=QMap< QString, QString >())
Calculates the viewbox size of a (possibly cached) SVG file.
static QgsSymbol * defaultSymbol(Qgis::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
Container for all settings relating to text rendering.
void setAllowHtmlFormatting(bool allow)
Sets whether text should be treated as a HTML document and HTML tags should be used for formatting th...
#define BUILTIN_UNREACHABLE
Definition qgis.h:6720