40 mSnappingMarker.reset();
45 if ( !mSnappingMarker )
48 mSnappingMarker->setPenWidth( 3 );
53 QColor color = s.
value( QStringLiteral(
"/qgis/digitizing/snap_color" ), QColor( Qt::magenta ) ).value<QColor>();
54 mSnappingMarker->setColor( color );
68 mSnappingMarker->setIconType( iconType );
70 mSnappingMarker->setCenter( match.
point() );
73 if ( s.
value( QStringLiteral(
"/qgis/digitizing/snap_tooltip" ),
false ).toBool() )
75 QPoint ptCanvas = mSnappingMarker->toCanvasCoordinates( match.
point() ).toPoint();
76 QPoint ptGlobal = mCanvas->mapToGlobal( ptCanvas );
77 QRect rect( ptCanvas.x(), ptCanvas.y(), 1, 1 );
78 QString layerName = match.
layer() ? match.
layer()->
name() : QString();
79 QToolTip::showText( ptGlobal, layerName, mCanvas, rect );
86 mSnappingMarker->setVisible( visible );
91 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.
Map canvas is a class for displaying all GIS data types on a canvas.
A class for marking vertices of features using e.g.
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.
void setVisible(bool visible=true)
Sets whether the snapping indicator is visible.
QgsSnapIndicator(QgsMapCanvas *canvas)
Constructs an indicator for the given map canvas.