QGIS API Documentation 4.3.0-Master (6e9a7aceb6d)
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
19#include "qgsannotationlayer.h"
27#include "qgsapplication.h"
28#include "qgscurvepolygon.h"
29#include "qgsfillsymbol.h"
30#include "qgsimagecache.h"
31#include "qgslinesymbol.h"
32#include "qgsmapcanvas.h"
33#include "qgsmapmouseevent.h"
34#include "qgsmarkersymbol.h"
36#include "qgsrubberband.h"
38#include "qgsstyle.h"
39#include "qgssvgcache.h"
40
41#include <QFileDialog>
42#include <QImageReader>
43#include <QString>
44
45#include "moc_qgscreateannotationitemmaptool_impl.cpp"
46
47using namespace Qt::StringLiterals;
48
50
51//
52// QgsMapToolCaptureAnnotationItem
53//
54
56 : QgsMapToolCapture( canvas, cadDockWidget, mode )
57{
58 mToolName = tr( "Annotation tool" );
59}
60
62{
63 return mHandler;
64}
65
67{
68 return this;
69}
70
72{
73 return mHandler->targetLayer();
74}
75
76
78{
79 // no geometry validation!
80 return SupportsCurves;
81}
82
84{
85 switch ( technique )
86 {
93 return true;
94 }
96}
97
98
99//
100// QgsCreatePointTextItemMapTool
101//
102
104 : QgsMapToolAdvancedDigitizing( canvas, cadDockWidget )
105 , mHandler( new QgsCreateAnnotationItemMapToolHandler( canvas, cadDockWidget ) )
106{
107 setUseSnappingIndicator( true );
108}
109
111
113{
114 if ( event->button() != Qt::LeftButton )
115 return;
116
117 const QgsPointXY layerPoint = toLayerCoordinates( mHandler->targetLayer(), event->mapPoint() );
118
119 auto createdItem = std::make_unique<QgsAnnotationPointTextItem>( tr( "Text" ), layerPoint );
120 createdItem->setAlignment( Qt::AlignLeft );
122 // default to HTML formatting
123 format.setAllowHtmlFormatting( true );
124 createdItem->setFormat( format );
125 // newly created point text items default to using symbology reference scale at the current map scale
126 createdItem->setUseSymbologyReferenceScale( true );
127 createdItem->setSymbologyReferenceScale( canvas()->scale() );
128 mHandler->pushCreatedItem( createdItem.release() );
129}
130
132{
133 return mHandler;
134}
135
137{
138 return this;
139}
140
141
142//
143// QgsCreateMarkerMapTool
144//
145
147 : QgsMapToolCaptureAnnotationItem( canvas, cadDockWidget, CapturePoint )
148{
149 mHandler = new QgsCreateAnnotationItemMapToolHandler( canvas, cadDockWidget, this );
150}
151
153{
154 if ( event->button() != Qt::LeftButton )
155 return;
156
157 const QgsPointXY layerPoint = toLayerCoordinates( mHandler->targetLayer(), event->mapPoint() );
158 auto createdItem = std::make_unique<QgsAnnotationMarkerItem>( QgsPoint( layerPoint ) );
159
160 std::unique_ptr<QgsMarkerSymbol> markerSymbol = QgsApplication::recentStyleHandler()->recentSymbol<QgsMarkerSymbol>( u"marker_annotation_item"_s );
161 if ( !markerSymbol )
162 markerSymbol.reset( qgis::down_cast<QgsMarkerSymbol *>( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ) );
163 createdItem->setSymbol( markerSymbol.release() );
164
165 // set reference scale to match canvas scale, but don't enable it by default for marker items
166 createdItem->setSymbologyReferenceScale( canvas()->scale() );
167
168 mHandler->pushCreatedItem( createdItem.release() );
169
171
173}
174
175//
176// QgsCreateLineMapTool
177//
178
180 : QgsMapToolCaptureAnnotationItem( canvas, cadDockWidget, CaptureLine )
181{
182 mHandler = new QgsCreateAnnotationItemMapToolHandler( canvas, cadDockWidget, this );
183}
184
185void QgsCreateLineItemMapTool::lineCaptured( const QgsCurve *line )
186{
187 if ( line->isEmpty() )
188 return;
189
190 // do it!
191 std::unique_ptr<QgsAbstractGeometry> geometry( line->simplifiedTypeRef()->clone() );
192 if ( qgsgeometry_cast<QgsCurve *>( geometry.get() ) )
193 {
194 auto createdItem = std::make_unique<QgsAnnotationLineItem>( qgis::down_cast<QgsCurve *>( geometry.release() ) );
195
196 std::unique_ptr<QgsLineSymbol> lineSymbol = QgsApplication::recentStyleHandler()->recentSymbol<QgsLineSymbol>( u"line_annotation_item"_s );
197 if ( !lineSymbol )
198 lineSymbol.reset( qgis::down_cast<QgsLineSymbol *>( QgsSymbol::defaultSymbol( Qgis::GeometryType::Line ) ) );
199 createdItem->setSymbol( lineSymbol.release() );
200
201 // set reference scale to match canvas scale, but don't enable it by default for marker items
202 createdItem->setSymbologyReferenceScale( canvas()->scale() );
203
204 mHandler->pushCreatedItem( createdItem.release() );
205 }
206}
207
208//
209// QgsCreatePolygonItemMapTool
210//
211
213 : QgsMapToolCaptureAnnotationItem( canvas, cadDockWidget, CapturePolygon )
214{
215 mHandler = new QgsCreateAnnotationItemMapToolHandler( canvas, cadDockWidget, this );
216}
217
218void QgsCreatePolygonItemMapTool::polygonCaptured( const QgsCurvePolygon *polygon )
219{
220 if ( polygon->isEmpty() )
221 return;
222
223 std::unique_ptr<QgsAbstractGeometry> geometry( polygon->exteriorRing()->simplifiedTypeRef()->clone() );
224 if ( qgsgeometry_cast<QgsCurve *>( geometry.get() ) )
225 {
226 auto newPolygon = std::make_unique<QgsCurvePolygon>();
227 newPolygon->setExteriorRing( qgis::down_cast<QgsCurve *>( geometry.release() ) );
228 auto createdItem = std::make_unique<QgsAnnotationPolygonItem>( newPolygon.release() );
229
230 std::unique_ptr<QgsFillSymbol> fillSymbol = QgsApplication::recentStyleHandler()->recentSymbol<QgsFillSymbol>( u"polygon_annotation_item"_s );
231 if ( !fillSymbol )
232 fillSymbol.reset( qgis::down_cast<QgsFillSymbol *>( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ) );
233 createdItem->setSymbol( fillSymbol.release() );
234
235 // set reference scale to match canvas scale, but don't enable it by default for marker items
236 createdItem->setSymbologyReferenceScale( canvas()->scale() );
237
238 mHandler->pushCreatedItem( createdItem.release() );
239 }
240}
241
242
243//
244// QgsCreatePictureItemMapTool
245//
246
248 = new QgsSettingsEntryString( u"last-source-folder"_s, sTreePicture, QString(), u"Last used folder for picture annotation source files"_s );
249
251 : QgsMapToolAdvancedDigitizing( canvas, cadDockWidget )
252 , mHandler( new QgsCreateAnnotationItemMapToolHandler( canvas, cadDockWidget, this ) )
253{
254 setUseSnappingIndicator( true );
255}
256
258{
259 if ( event->button() == Qt::RightButton && mRubberBand )
260 {
261 mRubberBand.reset();
263 return;
264 }
265
266 if ( event->button() != Qt::LeftButton )
267 return;
268
269 if ( !mRubberBand )
270 {
271 mFirstPoint = event->snapPoint();
272
274 mRubberBand->setWidth( digitizingStrokeWidth() );
275 QColor color = digitizingStrokeColor();
276
278 color.setAlphaF( color.alphaF() * alphaScale );
279 mRubberBand->setLineStyle( Qt::DotLine );
280 mRubberBand->setStrokeColor( color );
281
282 const QColor fillColor = digitizingFillColor();
283 mRubberBand->setFillColor( fillColor );
284 }
285 else
286 {
287 mRubberBand.reset();
288
289 QStringList formatsFilter;
290 formatsFilter.append( u"*.svg"_s );
291 const QByteArrayList supportedFormats = QImageReader::supportedImageFormats();
292 for ( const auto &format : supportedFormats )
293 {
294 formatsFilter.append( QString( u"*.%1"_s ).arg( QString( format ) ) );
295 }
296 const QString dialogFilter = u"%1 (%2);;%3 (*.*)"_s.arg( tr( "Images" ), formatsFilter.join( ' '_L1 ), tr( "All files" ) );
297 const QString initialDir = settingLastSourceFolder->value();
298 const QString imagePath = QFileDialog::getOpenFileName( nullptr, tr( "Add Picture Annotation" ), initialDir.isEmpty() ? QDir::homePath() : initialDir, dialogFilter );
299
300 if ( imagePath.isEmpty() )
301 {
302 return; //canceled by the user
303 }
304
305 settingLastSourceFolder->setValue( QFileInfo( imagePath ).path() );
306
307 const QgsPointXY point1 = toLayerCoordinates( mHandler->targetLayer(), mFirstPoint );
308 const QgsPointXY point2 = toLayerCoordinates( mHandler->targetLayer(), event->snapPoint() );
309
310 const QgsPointXY devicePoint1 = toCanvasCoordinates( mFirstPoint );
311 const QgsPointXY devicePoint2 = toCanvasCoordinates( event->snapPoint() );
312 const double initialWidthPixels = std::abs( devicePoint1.x() - devicePoint2.x() );
313 const double initialHeightPixels = std::abs( devicePoint1.y() - devicePoint2.y() );
314
315 const QFileInfo pathInfo( imagePath );
317
318 QSizeF size;
319 if ( pathInfo.suffix().compare( "svg"_L1, Qt::CaseInsensitive ) == 0 )
320 {
322 size = QgsApplication::svgCache()->svgViewboxSize( imagePath, 100, QColor(), QColor(), 1, 1 );
323 }
324 else
325 {
327 size = QgsApplication::imageCache()->originalSize( imagePath );
328 }
329
331
332 auto createdItem = std::make_unique<QgsAnnotationPictureItem>( format, imagePath, QgsRectangle( point1, point2 ) );
333 if ( size.isValid() )
334 {
335 const double pixelsToMm = mCanvas->mapSettings().outputDpi() / 25.4;
336 if ( size.width() / size.height() > initialWidthPixels / initialHeightPixels )
337 {
338 createdItem->setFixedSize( QSizeF( initialWidthPixels / pixelsToMm, size.height() / size.width() * initialWidthPixels / pixelsToMm ) );
339 }
340 else
341 {
342 createdItem->setFixedSize( QSizeF( size.width() / size.height() * initialHeightPixels / pixelsToMm, initialHeightPixels / pixelsToMm ) );
343 }
344 createdItem->setFixedSizeUnit( Qgis::RenderUnit::Millimeters );
345 }
346
347 mHandler->pushCreatedItem( createdItem.release() );
348 }
349}
350
352{
353 if ( !mRubberBand )
354 return;
355
356 // Keep the preview rectangle aligned to the screen, matching the placed item
357 // which ignores map rotation by default.
358 const QgsPointXY firstCanvasPoint = toCanvasCoordinates( mFirstPoint );
359 const QgsPointXY currentCanvasPoint = toCanvasCoordinates( event->snapPoint() );
360
361 const QgsMapToPixel *transform = mCanvas->getCoordinateTransform();
362 const QgsPointXY topLeft = transform->toMapCoordinates( firstCanvasPoint.x(), firstCanvasPoint.y() );
363 const QgsPointXY topRight = transform->toMapCoordinates( currentCanvasPoint.x(), firstCanvasPoint.y() );
364 const QgsPointXY bottomRight = transform->toMapCoordinates( currentCanvasPoint.x(), currentCanvasPoint.y() );
365 const QgsPointXY bottomLeft = transform->toMapCoordinates( firstCanvasPoint.x(), currentCanvasPoint.y() );
366
367 mRubberBand->reset( Qgis::GeometryType::Polygon );
368 mRubberBand->setToGeometry( QgsGeometry::fromPolygonXY( { { bottomLeft, bottomRight, topRight, topLeft } } ) );
369}
370
371void QgsCreatePictureItemMapTool::keyPressEvent( QKeyEvent *event )
372{
373 if ( event->key() == Qt::Key_Escape )
374 {
375 if ( mRubberBand )
376 {
377 mRubberBand.reset();
379 event->ignore();
380 }
381 }
382}
383
385{
386 return mHandler;
387}
388
390{
391 return this;
392}
393
394
395//
396// QgsCreateRectangleTextItemMapTool
397//
398
400 : QgsMapToolAdvancedDigitizing( canvas, cadDockWidget )
401 , mHandler( new QgsCreateAnnotationItemMapToolHandler( canvas, cadDockWidget, this ) )
402{
403 setUseSnappingIndicator( true );
404}
405
407{
408 if ( event->button() == Qt::RightButton && mRubberBand )
409 {
410 mRubberBand.reset();
412 return;
413 }
414
415 if ( event->button() != Qt::LeftButton )
416 return;
417
418 if ( !mRubberBand )
419 {
420 mFirstPoint = event->snapPoint();
421
423 mRubberBand->setWidth( digitizingStrokeWidth() );
424 QColor color = digitizingStrokeColor();
425
427 color.setAlphaF( color.alphaF() * alphaScale );
428 mRubberBand->setLineStyle( Qt::DotLine );
429 mRubberBand->setStrokeColor( color );
430
431 const QColor fillColor = digitizingFillColor();
432 mRubberBand->setFillColor( fillColor );
433 }
434 else
435 {
436 mRubberBand.reset();
437
438 const QgsPointXY point1 = toLayerCoordinates( mHandler->targetLayer(), mFirstPoint );
439 const QgsPointXY point2 = toLayerCoordinates( mHandler->targetLayer(), event->snapPoint() );
440
442
443 auto createdItem = std::make_unique<QgsAnnotationRectangleTextItem>( tr( "Text" ), QgsRectangle( point1, point2 ) );
444
446 // default to HTML formatting
447 format.setAllowHtmlFormatting( true );
448 createdItem->setFormat( format );
449
450 // newly created rect text items default to using symbology reference scale at the current map scale
451 createdItem->setUseSymbologyReferenceScale( true );
452 createdItem->setSymbologyReferenceScale( canvas()->scale() );
453 mHandler->pushCreatedItem( createdItem.release() );
454 }
455}
456
458{
459 if ( !mRubberBand )
460 return;
461
462 // Keep the preview rectangle aligned to the screen, matching the placed item
463 // which ignores map rotation by default.
464 const QgsPointXY firstCanvasPoint = toCanvasCoordinates( mFirstPoint );
465 const QgsPointXY currentCanvasPoint = toCanvasCoordinates( event->snapPoint() );
466
467 const QgsMapToPixel *transform = mCanvas->getCoordinateTransform();
468 const QgsPointXY topLeft = transform->toMapCoordinates( firstCanvasPoint.x(), firstCanvasPoint.y() );
469 const QgsPointXY topRight = transform->toMapCoordinates( currentCanvasPoint.x(), firstCanvasPoint.y() );
470 const QgsPointXY bottomRight = transform->toMapCoordinates( currentCanvasPoint.x(), currentCanvasPoint.y() );
471 const QgsPointXY bottomLeft = transform->toMapCoordinates( firstCanvasPoint.x(), currentCanvasPoint.y() );
472
473 mRubberBand->reset( Qgis::GeometryType::Polygon );
474 mRubberBand->setToGeometry( QgsGeometry::fromPolygonXY( { { bottomLeft, bottomRight, topRight, topLeft } } ) );
475}
476
478{
479 if ( event->key() == Qt::Key_Escape )
480 {
481 if ( mRubberBand )
482 {
483 mRubberBand.reset();
485 event->ignore();
486 }
487 }
488}
489
491{
492 return mHandler;
493}
494
496{
497 return this;
498}
499
500
501//
502// QgsCreateLineTextItemMapTool
503//
504
506 : QgsMapToolCaptureAnnotationItem( canvas, cadDockWidget, CaptureLine )
507{
508 mHandler = new QgsCreateAnnotationItemMapToolHandler( canvas, cadDockWidget, this );
509}
510
511void QgsCreateLineTextItemMapTool::lineCaptured( const QgsCurve *line )
512{
513 if ( line->isEmpty() )
514 return;
515
516 // do it!
517 std::unique_ptr<QgsAbstractGeometry> geometry( line->simplifiedTypeRef()->clone() );
518 if ( qgsgeometry_cast<QgsCurve *>( geometry.get() ) )
519 {
520 auto createdItem = std::make_unique<QgsAnnotationLineTextItem>( tr( "Text" ), qgis::down_cast<QgsCurve *>( geometry.release() ) );
521
522 std::unique_ptr<QgsLineSymbol> lineSymbol = QgsApplication::recentStyleHandler()->recentSymbol<QgsLineSymbol>( u"line_annotation_item"_s );
523 if ( !lineSymbol )
524 lineSymbol.reset( qgis::down_cast<QgsLineSymbol *>( QgsSymbol::defaultSymbol( Qgis::GeometryType::Line ) ) );
525
527 // default to HTML formatting
528 format.setAllowHtmlFormatting( true );
529 createdItem->setFormat( format );
530
531 // newly created point text items default to using symbology reference scale at the current map scale
532 createdItem->setUseSymbologyReferenceScale( true );
533 createdItem->setSymbologyReferenceScale( canvas()->scale() );
534 mHandler->pushCreatedItem( createdItem.release() );
535 }
536}
537
CaptureTechnique
Capture technique.
Definition qgis.h:418
@ NurbsCurve
Digitizes NURBS curves with control points (curve is attracted to but does not pass through control p...
Definition qgis.h:424
@ Shape
Digitize shapes.
Definition qgis.h:422
@ StraightSegments
Default capture mode - capture occurs with straight line segments.
Definition qgis.h:419
@ CircularString
Capture in circular strings.
Definition qgis.h:420
@ Streaming
Streaming points digitizing mode (points are automatically added as the mouse cursor moves).
Definition qgis.h:421
@ PolyBezier
Digitizes poly-Bézier curves with anchors and tangent handles (curve passes through anchor points).
Definition qgis.h:423
PictureFormat
Picture formats.
Definition qgis.h:5749
@ Raster
Raster image.
Definition qgis.h:5751
@ Unknown
Invalid or unknown image type.
Definition qgis.h:5752
@ SVG
SVG image.
Definition qgis.h:5750
@ Point
Points.
Definition qgis.h:380
@ Line
Lines.
Definition qgis.h:381
@ Polygon
Polygons.
Definition qgis.h:382
@ Millimeters
Millimeters.
Definition qgis.h:5656
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.
A dockable widget used to handle the CAD tools on top of a selection of map tools.
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.
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:36
static QgsGeometry fromPolygonXY(const QgsPolygonXY &polygon)
Creates a new geometry from a QgsPolygonXY.
QSize originalSize(const QString &path, bool blocking=false) const
Returns the original size (in pixels) of the image at the specified path.
Map canvas is a class for displaying all GIS data types on a canvas.
Base class for all map layer types.
Definition qgsmaplayer.h:83
A mouse event which is the result of a user interaction with 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
QgsPointXY toMapCoordinates(int x, int y) const
Transforms device coordinates to map (world) coordinates.
A QgsMapTool which gives events directly in map coordinates and allows filtering of events.
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.
Base class for map tools 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:74
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:403
QPoint toCanvasCoordinates(const QgsPointXY &point) const
Transforms a point from map coordinates to screen coordinates.
double y
Definition qgspointxy.h:66
double x
Definition qgspointxy.h:65
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...
T value(const QString &dynamicKeyPart=QString()) const
Returns 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.
Definition qgsstyle.h:828
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.
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:8122
T qgsgeometry_cast(QgsAbstractGeometry *geom)
constexpr QObjectUniquePtr< Tp > make_qobject_unique(Args &&...args)
Create an object owned by a QObjectUniquePtr.