43 mToolName = tr(
"Annotation tool" );
51QgsMapTool *QgsMapToolCaptureAnnotationItem::mapTool()
56QgsMapLayer *QgsMapToolCaptureAnnotationItem::layer()
const
58 return mHandler->targetLayer();
62QgsMapToolCapture::Capabilities QgsMapToolCaptureAnnotationItem::capabilities()
const
65 return SupportsCurves;
93QgsCreatePointTextItemMapTool::~QgsCreatePointTextItemMapTool() =
default;
95void QgsCreatePointTextItemMapTool::cadCanvasPressEvent(
QgsMapMouseEvent *event )
97 if ( event->button() != Qt::LeftButton )
100 const QgsPointXY layerPoint = toLayerCoordinates( mHandler->targetLayer(), event->
mapPoint() );
102 std::unique_ptr< QgsAnnotationPointTextItem > createdItem = std::make_unique< QgsAnnotationPointTextItem >( tr(
"Text" ), layerPoint );
103 createdItem->setAlignment( Qt::AlignLeft );
106 createdItem->setUseSymbologyReferenceScale(
true );
107 createdItem->setSymbologyReferenceScale( canvas()->scale() );
108 mHandler->pushCreatedItem( createdItem.release() );
116QgsMapTool *QgsCreatePointTextItemMapTool::mapTool()
128 : QgsMapToolCaptureAnnotationItem( canvas, cadDockWidget, CapturePoint )
133void QgsCreateMarkerItemMapTool::cadCanvasReleaseEvent(
QgsMapMouseEvent *event )
135 if ( event->button() != Qt::LeftButton )
138 const QgsPointXY layerPoint = toLayerCoordinates( mHandler->targetLayer(), event->
mapPoint() );
139 std::unique_ptr< QgsAnnotationMarkerItem > createdItem = std::make_unique< QgsAnnotationMarkerItem >(
QgsPoint( layerPoint ) );
144 createdItem->setSymbol( markerSymbol.release() );
147 createdItem->setSymbologyReferenceScale( canvas()->scale() );
149 mHandler->pushCreatedItem( createdItem.release() );
153 cadDockWidget()->clearPoints();
161 : QgsMapToolCaptureAnnotationItem( canvas, cadDockWidget, CaptureLine )
166void QgsCreateLineItemMapTool::lineCaptured(
const QgsCurve *line )
170 if ( qgsgeometry_cast< QgsCurve * >( geometry.get() ) )
172 std::unique_ptr< QgsAnnotationLineItem > createdItem = std::make_unique< QgsAnnotationLineItem >( qgsgeometry_cast< QgsCurve * >( geometry.release() ) );
177 createdItem->setSymbol( lineSymbol.release() );
180 createdItem->setSymbologyReferenceScale( canvas()->scale() );
182 mHandler->pushCreatedItem( createdItem.release() );
191 : QgsMapToolCaptureAnnotationItem( canvas, cadDockWidget, CapturePolygon )
196void QgsCreatePolygonItemMapTool::polygonCaptured(
const QgsCurvePolygon *polygon )
199 if ( qgsgeometry_cast< QgsCurve * >( geometry.get() ) )
201 std::unique_ptr< QgsCurvePolygon > newPolygon = std::make_unique< QgsCurvePolygon >();
202 newPolygon->setExteriorRing( qgsgeometry_cast< QgsCurve * >( geometry.release() ) );
203 std::unique_ptr< QgsAnnotationPolygonItem > createdItem = std::make_unique< QgsAnnotationPolygonItem >( newPolygon.release() );
208 createdItem->setSymbol( fillSymbol.release() );
211 createdItem->setSymbologyReferenceScale( canvas()->scale() );
213 mHandler->pushCreatedItem( createdItem.release() );
222 : QgsMapToolCaptureAnnotationItem( canvas, cadDockWidget, CaptureLine )
227void QgsCreateLineTextItemMapTool::lineCaptured(
const QgsCurve *line )
231 if ( qgsgeometry_cast< QgsCurve * >( geometry.get() ) )
233 std::unique_ptr< QgsAnnotationLineTextItem > createdItem = std::make_unique< QgsAnnotationLineTextItem >( tr(
"Text" ), qgsgeometry_cast< QgsCurve * >( geometry.release() ) );
242 createdItem->setUseSymbologyReferenceScale(
true );
243 createdItem->setSymbologyReferenceScale( canvas()->scale() );
244 mHandler->pushCreatedItem( createdItem.release() );
CaptureTechnique
Capture technique.
@ 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).
virtual const QgsAbstractGeometry * simplifiedTypeRef() const
Returns a reference to the simplest lossless representation of this geometry, e.g.
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
static QgsRecentStyleHandler * recentStyleHandler()
Returns the handler for recently used style items.
Curve polygon geometry type.
const QgsCurve * exteriorRing() const
Returns the curve polygon's exterior ring.
Abstract base class for curved geometry type.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
A line symbol type, for rendering LineString and MultiLineString geometries.
Map canvas is a class for displaying all GIS data types on a canvas.
Base class for all map layer types.
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
QgsPointXY mapPoint() const
mapPoint returns the point in coordinates
A marker symbol type, for rendering Point and MultiPoint geometries.
A class to represent a 2D point.
Point geometry type, with support for z-dimension and m-values.
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...
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.
static QgsSymbol * defaultSymbol(Qgis::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
#define BUILTIN_UNREACHABLE