20 #include "qgssettingsregistrycore.h"
34 mCanvasDestroyedConnection = QObject::connect( canvas, &QgsMapCanvas::destroyed, canvas, [ = ]()
37 mSnappingMarker =
nullptr;
43 if ( mSnappingMarker && mCanvas )
45 mCanvas->scene()->removeItem( mSnappingMarker );
46 delete mSnappingMarker;
49 QObject::disconnect( mCanvasDestroyedConnection );
58 if ( mSnappingMarker )
60 mCanvas->scene()->removeItem( mSnappingMarker );
61 delete mSnappingMarker;
63 mSnappingMarker =
nullptr;
68 if ( !mSnappingMarker )
75 QColor color = QgsSettingsRegistryCore::settingsDigitizingSnapColor.value();
112 if ( QgsSettingsRegistryCore::settingsDigitizingSnapTooltip.value() )
115 QPoint ptGlobal = mCanvas->mapToGlobal( ptCanvas );
116 QRect rect( ptCanvas.x(), ptCanvas.y(), 1, 1 );
118 QToolTip::showText( ptGlobal, layerName, mCanvas, rect );
125 if ( mSnappingMarker )
126 mSnappingMarker->setVisible( visible );
131 if ( mSnappingMarker )
132 return mSnappingMarker->isVisible();
QPointF toCanvasCoordinates(const QgsPointXY &point) const
transformation from map coordinates to screen coordinates
Map canvas is a class for displaying all GIS data types on a canvas.
QgsPointLocator::Match match() const
Returns currently displayed snapping match.
void setVisible(bool visible=true)
Sets whether the snapping indicator is visible.
void setMatch(const QgsPointLocator::Match &match)
Sets snapping match that should be displayed in map canvas. Invalid match hides the indicator.
QgsSnapIndicator(QgsMapCanvas *canvas)
Constructs an indicator for the given map canvas.
bool isVisible() const
Returns whether the snapping indicator is visible.
A class for marking vertices of features using e.g.
void setPenWidth(int width)
@ ICON_TRIANGLE
Added in QGIS 3.12.
@ ICON_DOUBLE_TRIANGLE
Added in QGIS 3.0.
@ ICON_INVERTED_TRIANGLE
Added in QGIS 3.20.
@ ICON_RHOMBUS
Added in QGIS 3.12.
void setIconSize(int iconSize)
void setCenter(const QgsPointXY &point)
Sets the center point of the marker, in map coordinates.
void setIconType(int iconType)
void setColor(const QColor &color)
Sets the stroke color for the marker.
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...
QgsVectorLayer * layer() const
The vector layer where the snap occurred.
bool hasCentroid() const
Returns true if the Match is a centroid.
QgsPointXY point() const
for vertex / edge match coords depending on what class returns it (geom.cache: layer coords,...
bool hasArea() const
Returns true if the Match is an area.
bool hasLineEndpoint() const
Returns true if the Match is a line endpoint (start or end vertex).
bool hasMiddleSegment() const
Returns true if the Match is the middle of a segment.
bool hasVertex() const
Returns true if the Match is a vertex.