49 QgsMapTool *QgsMapToolCaptureAnnotationItem::mapTool()
54 QgsMapLayer *QgsMapToolCaptureAnnotationItem::layer()
const
56 return mHandler->targetLayer();
60 QgsMapToolCapture::Capabilities QgsMapToolCaptureAnnotationItem::capabilities()
const
63 return SupportsCurves;
66 bool QgsMapToolCaptureAnnotationItem::supportsTechnique( CaptureTechnique )
const
85 QgsCreatePointTextItemMapTool::~QgsCreatePointTextItemMapTool() =
default;
87 void QgsCreatePointTextItemMapTool::cadCanvasPressEvent(
QgsMapMouseEvent *event )
89 if ( event->button() != Qt::LeftButton )
92 const QgsPointXY layerPoint = toLayerCoordinates( mHandler->targetLayer(), event->
mapPoint() );
94 std::unique_ptr< QgsAnnotationPointTextItem > createdItem = std::make_unique< QgsAnnotationPointTextItem >( tr(
"Text" ), layerPoint );
95 createdItem->setAlignment( Qt::AlignLeft );
98 createdItem->setUseSymbologyReferenceScale(
true );
99 createdItem->setSymbologyReferenceScale( canvas()->scale() );
100 mHandler->pushCreatedItem( createdItem.release() );
108 QgsMapTool *QgsCreatePointTextItemMapTool::mapTool()
120 : QgsMapToolCaptureAnnotationItem( canvas, cadDockWidget, CapturePoint )
125 void QgsCreateMarkerItemMapTool::cadCanvasReleaseEvent(
QgsMapMouseEvent *event )
127 if ( event->button() != Qt::LeftButton )
130 const QgsPointXY layerPoint = toLayerCoordinates( mHandler->targetLayer(), event->
mapPoint() );
131 std::unique_ptr< QgsAnnotationMarkerItem > createdItem = std::make_unique< QgsAnnotationMarkerItem >(
QgsPoint( layerPoint ) );
136 createdItem->setSymbol( markerSymbol.release() );
139 createdItem->setSymbologyReferenceScale( canvas()->scale() );
141 mHandler->pushCreatedItem( createdItem.release() );
145 cadDockWidget()->clearPoints();
153 : QgsMapToolCaptureAnnotationItem( canvas, cadDockWidget, CaptureLine )
161 if ( e->button() == Qt::LeftButton )
167 emit messageEmitted( tr(
"Cannot transform the point to the layers coordinate system" ), Qgis::MessageLevel::Warning );
173 else if ( e->button() == Qt::RightButton )
175 deleteTempRubberBand();
185 std::unique_ptr< QgsAbstractGeometry > geometry( captureCurve()->simplifiedTypeRef()->clone() );
186 if ( qgsgeometry_cast< QgsCurve * >( geometry.get() ) )
188 std::unique_ptr< QgsAnnotationLineItem > createdItem = std::make_unique< QgsAnnotationLineItem >( qgsgeometry_cast< QgsCurve * >( geometry.release() ) );
193 createdItem->setSymbol( lineSymbol.release() );
196 createdItem->setSymbologyReferenceScale( canvas()->scale() );
198 mHandler->pushCreatedItem( createdItem.release() );
209 : QgsMapToolCaptureAnnotationItem( canvas, cadDockWidget, CapturePolygon )
214 void QgsCreatePolygonItemMapTool::cadCanvasReleaseEvent(
QgsMapMouseEvent *e )
217 if ( e->button() == Qt::LeftButton )
223 emit messageEmitted( tr(
"Cannot transform the point to the layers coordinate system" ), Qgis::MessageLevel::Warning );
229 else if ( e->button() == Qt::RightButton )
231 deleteTempRubberBand();
242 std::unique_ptr< QgsAbstractGeometry > geometry( captureCurve()->simplifiedTypeRef()->clone() );
243 if ( qgsgeometry_cast< QgsCurve * >( geometry.get() ) )
245 std::unique_ptr< QgsCurvePolygon > newPolygon = std::make_unique< QgsCurvePolygon >();
246 newPolygon->setExteriorRing( qgsgeometry_cast< QgsCurve * >( geometry.release() ) );
247 std::unique_ptr< QgsAnnotationPolygonItem > createdItem = std::make_unique< QgsAnnotationPolygonItem >( newPolygon.release() );
252 createdItem->setSymbol( fillSymbol.release() );
255 createdItem->setSymbologyReferenceScale( canvas()->scale() );
257 mHandler->pushCreatedItem( createdItem.release() );
static QgsRecentStyleHandler * recentStyleHandler()
Returns the handler for recently used style items.
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
QgsPointLocator::Match mapPointMatch() const
Returns the matching data from the most recently snapped point.
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.
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 QgsStyle * defaultStyle()
Returns default application-wide style.
@ Labeling
Text format used in labeling.
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type.