41 mToolName = tr(
"Annotation tool" );
49QgsMapTool *QgsMapToolCaptureAnnotationItem::mapTool()
54QgsMapLayer *QgsMapToolCaptureAnnotationItem::layer()
const
56 return mHandler->targetLayer();
60QgsMapToolCapture::Capabilities QgsMapToolCaptureAnnotationItem::capabilities()
const
63 return SupportsCurves;
91QgsCreatePointTextItemMapTool::~QgsCreatePointTextItemMapTool() =
default;
93void QgsCreatePointTextItemMapTool::cadCanvasPressEvent(
QgsMapMouseEvent *event )
95 if ( event->button() != Qt::LeftButton )
98 const QgsPointXY layerPoint = toLayerCoordinates( mHandler->targetLayer(), event->
mapPoint() );
100 std::unique_ptr< QgsAnnotationPointTextItem > createdItem = std::make_unique< QgsAnnotationPointTextItem >( tr(
"Text" ), layerPoint );
101 createdItem->setAlignment( Qt::AlignLeft );
104 createdItem->setUseSymbologyReferenceScale(
true );
105 createdItem->setSymbologyReferenceScale( canvas()->scale() );
106 mHandler->pushCreatedItem( createdItem.release() );
114QgsMapTool *QgsCreatePointTextItemMapTool::mapTool()
126 : QgsMapToolCaptureAnnotationItem( canvas, cadDockWidget, CapturePoint )
131void QgsCreateMarkerItemMapTool::cadCanvasReleaseEvent(
QgsMapMouseEvent *event )
133 if ( event->button() != Qt::LeftButton )
136 const QgsPointXY layerPoint = toLayerCoordinates( mHandler->targetLayer(), event->
mapPoint() );
137 std::unique_ptr< QgsAnnotationMarkerItem > createdItem = std::make_unique< QgsAnnotationMarkerItem >(
QgsPoint( layerPoint ) );
142 createdItem->setSymbol( markerSymbol.release() );
145 createdItem->setSymbologyReferenceScale( canvas()->scale() );
147 mHandler->pushCreatedItem( createdItem.release() );
151 cadDockWidget()->clearPoints();
159 : QgsMapToolCaptureAnnotationItem( canvas, cadDockWidget, CaptureLine )
164void QgsCreateLineItemMapTool::lineCaptured(
const QgsCurve *line )
168 if ( qgsgeometry_cast< QgsCurve * >( geometry.get() ) )
170 std::unique_ptr< QgsAnnotationLineItem > createdItem = std::make_unique< QgsAnnotationLineItem >( qgsgeometry_cast< QgsCurve * >( geometry.release() ) );
175 createdItem->setSymbol( lineSymbol.release() );
178 createdItem->setSymbologyReferenceScale( canvas()->scale() );
180 mHandler->pushCreatedItem( createdItem.release() );
189 : QgsMapToolCaptureAnnotationItem( canvas, cadDockWidget, CapturePolygon )
194void QgsCreatePolygonItemMapTool::polygonCaptured(
const QgsCurvePolygon *polygon )
197 if ( qgsgeometry_cast< QgsCurve * >( geometry.get() ) )
199 std::unique_ptr< QgsCurvePolygon > newPolygon = std::make_unique< QgsCurvePolygon >();
200 newPolygon->setExteriorRing( qgsgeometry_cast< QgsCurve * >( geometry.release() ) );
201 std::unique_ptr< QgsAnnotationPolygonItem > createdItem = std::make_unique< QgsAnnotationPolygonItem >( newPolygon.release() );
206 createdItem->setSymbol( fillSymbol.release() );
209 createdItem->setSymbologyReferenceScale( canvas()->scale() );
211 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 SIP_HOLDGIL
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 SIP_HOLDGIL
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(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
#define BUILTIN_UNREACHABLE