41 mToolName = tr(
"Annotation tool" );
49 QgsMapTool *QgsMapToolCaptureAnnotationItem::mapTool()
54 QgsMapLayer *QgsMapToolCaptureAnnotationItem::layer()
const
56 return mHandler->targetLayer();
60 QgsMapToolCapture::Capabilities QgsMapToolCaptureAnnotationItem::capabilities()
const
63 return SupportsCurves;
91 QgsCreatePointTextItemMapTool::~QgsCreatePointTextItemMapTool() =
default;
93 void 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() );
114 QgsMapTool *QgsCreatePointTextItemMapTool::mapTool()
126 : QgsMapToolCaptureAnnotationItem( canvas, cadDockWidget, CapturePoint )
131 void 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 )
164 void 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 )
194 void 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() );