30 mCanvasDestroyedConnection = QObject::connect( canvas, &QgsMapCanvas::destroyed, [ = ]()
33 mSnappingMarker =
nullptr;
39 if ( mSnappingMarker && mCanvas )
41 mCanvas->scene()->removeItem( mSnappingMarker );
42 delete mSnappingMarker;
45 QObject::disconnect( mCanvasDestroyedConnection );
54 if ( mSnappingMarker )
56 mCanvas->scene()->removeItem( mSnappingMarker );
57 delete mSnappingMarker;
59 mSnappingMarker =
nullptr;
64 if ( !mSnappingMarker )
73 QColor color = s.
value( QStringLiteral(
"/qgis/digitizing/snap_color" ), QColor( Qt::magenta ) ).value<QColor>();
94 if ( s.
value( QStringLiteral(
"/qgis/digitizing/snap_tooltip" ),
false ).toBool() )
97 QPoint ptGlobal = mCanvas->mapToGlobal( ptCanvas );
98 QRect rect( ptCanvas.x(), ptCanvas.y(), 1, 1 );
99 QString layerName = match.
layer() ? match.
layer()->
name() : QString();
100 QToolTip::showText( ptGlobal, layerName, mCanvas, rect );
107 if ( mSnappingMarker )
108 mSnappingMarker->setVisible( visible );
113 if ( mSnappingMarker )
114 return mSnappingMarker->isVisible();
void setMatch(const QgsPointLocator::Match &match)
Sets snapping match that should be displayed in map canvas. Invalid match hides the indicator...
QgsVectorLayer * layer() const
The vector layer where the snap occurred.
This class is a composition of two QSettings instances:
QgsPointLocator::Match match() const
Returns currently displayed snapping match.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly...
void setPenWidth(int width)
Map canvas is a class for displaying all GIS data types on a canvas.
void setCenter(const QgsPointXY &point)
A class for marking vertices of features using e.g.
void setIconSize(int iconSize)
QgsPointXY point() const
for vertex / edge match coords depending on what class returns it (geom.cache: layer coords...
bool isVisible() const
Returns whether the snapping indicator is visible.
QPointF toCanvasCoordinates(const QgsPointXY &point) const
transformation from map coordinates to screen coordinates
void setVisible(bool visible=true)
Sets whether the snapping indicator is visible.
void setColor(const QColor &color)
Sets the stroke color for the marker.
QgsSnapIndicator(QgsMapCanvas *canvas)
Constructs an indicator for the given map canvas.
void setIconType(int iconType)