18#include "moc_qgsmaptooladvanceddigitizing.cpp"
27 , mCadDockWidget( cadDockWidget )
41 if ( !e->isAccepted() )
52 if ( mSnapToLayerGridEnabled &&
layer )
65 if ( !e->isAccepted() )
76 if ( mSnapToGridCanvasItem && mSnapToLayerGridEnabled &&
layer )
90 if ( !e->isAccepted() )
101 if ( mSnapToGridCanvasItem && mSnapToLayerGridEnabled &&
layer )
107 if ( mSnapIndicator )
127 mSnapToGridCanvasItem->
setEnabled( mSnapToLayerGridEnabled );
135 delete mSnapToGridCanvasItem;
136 mSnapToGridCanvasItem =
nullptr;
138 if ( mSnapIndicator )
149 return static_cast<bool>( mSnapIndicator.get() );
154 if ( enabled && !mSnapIndicator )
156 mSnapIndicator = std::make_unique<QgsSnapIndicator>(
mCanvas );
158 else if ( !enabled && mSnapIndicator )
160 mSnapIndicator.reset();
164void QgsMapToolAdvancedDigitizing::cadPointChanged(
const QgsPointXY &point )
167 QMouseEvent *ev =
new QMouseEvent( QEvent::MouseMove,
mCanvas->mouseLastXY(), Qt::NoButton, Qt::NoButton, Qt::NoModifier );
168 qApp->postEvent(
mCanvas->viewport(), ev );
171void QgsMapToolAdvancedDigitizing::onCurrentLayerChanged()
173 if ( mSnapToGridCanvasItem )
176 if (
layer && mSnapToLayerGridEnabled )
178 mSnapToGridCanvasItem->
setPrecision(
layer->geometryOptions()->geometryPrecision() );
190 mSnapToGridCanvasItem->
setEnabled( mSnapToLayerGridEnabled );
197 return mSnapToLayerGridEnabled;
202 mSnapToLayerGridEnabled = snapToGridEnabled;
204 if ( mSnapToGridCanvasItem )
206 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