26 , mCadDockWidget( cadDockWidget )
40 if ( !e->isAccepted() )
51 if ( mSnapToLayerGridEnabled &&
layer )
64 if ( !e->isAccepted() )
75 if ( mSnapToGridCanvasItem && mSnapToLayerGridEnabled &&
layer )
89 if ( !e->isAccepted() )
100 if ( mSnapToGridCanvasItem && mSnapToLayerGridEnabled &&
layer )
106 if ( mSnapIndicator )
126 mSnapToGridCanvasItem->
setEnabled( mSnapToLayerGridEnabled );
134 delete mSnapToGridCanvasItem;
135 mSnapToGridCanvasItem =
nullptr;
137 if ( mSnapIndicator )
148 return static_cast< bool >( mSnapIndicator.get() );
153 if ( enabled && !mSnapIndicator )
155 mSnapIndicator = std::make_unique< QgsSnapIndicator >(
mCanvas );
157 else if ( !enabled && mSnapIndicator )
159 mSnapIndicator.reset();
163void QgsMapToolAdvancedDigitizing::cadPointChanged(
const QgsPointXY &point )
166 QMouseEvent *ev =
new QMouseEvent( QEvent::MouseMove,
mCanvas->mouseLastXY(), Qt::NoButton, Qt::NoButton, Qt::NoModifier );
167 qApp->postEvent(
mCanvas->viewport(), ev );
170void QgsMapToolAdvancedDigitizing::onCurrentLayerChanged()
172 if ( mSnapToGridCanvasItem )
175 if (
layer && mSnapToLayerGridEnabled )
177 mSnapToGridCanvasItem->
setPrecision(
layer->geometryOptions()->geometryPrecision() );
189 mSnapToGridCanvasItem->
setEnabled( mSnapToLayerGridEnabled );
196 return mSnapToLayerGridEnabled;
201 mSnapToLayerGridEnabled = snapToGridEnabled;
203 if ( mSnapToGridCanvasItem )
205 mSnapToGridCanvasItem->
setEnabled( snapToGridEnabled );
Map canvas is a class for displaying all GIS data types on a canvas.
void currentLayerChanged(QgsMapLayer *layer)
Emitted when the current layer is changed.
QgsMapLayer * currentLayer()
returns current layer (set by legend widget)
Base class for all map layer types.
virtual bool isSpatial() const
Returns true if the layer is considered a spatial layer, ie it has some form of geometry associated w...
QgsCoordinateReferenceSystem crs
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.
void snapToGrid(double precision, const QgsCoordinateReferenceSystem &crs)
Snaps the mapPoint to a grid with the given precision.
QgsPointXY snapPoint()
snapPoint will snap the points using the map canvas snapping utils configuration
A class to represent a 2D point.
Shows a grid on the map canvas given a spatial resolution.
void setCrs(const QgsCoordinateReferenceSystem &crs)
The CRS in which the grid should be calculated.
void setPoint(const QgsPointXY &point)
A point that will be highlighted on the map canvas.
void setEnabled(bool enabled)
Enable this item.
void setPrecision(double precision)
The resolution of the grid in map units.
Represents a vector layer which manages a vector based data sets.
const QgsCoordinateReferenceSystem & crs