Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Adjust snapping options on layer change
- Loading branch information
|
@@ -25,6 +25,7 @@ QgsMapToolAdvancedDigitizing::QgsMapToolAdvancedDigitizing( QgsMapCanvas *canvas |
|
|
: QgsMapToolEdit( canvas ) |
|
|
, mCadDockWidget( cadDockWidget ) |
|
|
{ |
|
|
connect( canvas, &QgsMapCanvas::currentLayerChanged, this, &QgsMapToolAdvancedDigitizing::onCurrentLayerChanged ); |
|
|
} |
|
|
|
|
|
void QgsMapToolAdvancedDigitizing::canvasPressEvent( QgsMapMouseEvent *e ) |
|
@@ -143,6 +144,20 @@ void QgsMapToolAdvancedDigitizing::cadPointChanged( const QgsPointXY &point ) |
|
|
qApp->postEvent( mCanvas->viewport(), ev ); // event queue will delete the event when processed |
|
|
} |
|
|
|
|
|
void QgsMapToolAdvancedDigitizing::onCurrentLayerChanged() |
|
|
{ |
|
|
QgsVectorLayer *layer = currentVectorLayer(); |
|
|
if ( mSnapToGridCanvasItem && layer && mSnapToGridEnabled ) |
|
|
{ |
|
|
mSnapToGridCanvasItem->setPrecision( layer->geometryFixes()->geometryPrecision() ); |
|
|
mSnapToGridCanvasItem->setCrs( layer->crs() ); |
|
|
mSnapToGridCanvasItem->setEnabled( true ); |
|
|
} |
|
|
|
|
|
if ( !layer ) |
|
|
mSnapToGridCanvasItem->setEnabled( false ); |
|
|
} |
|
|
|
|
|
bool QgsMapToolAdvancedDigitizing::snapToGridEnabled() const |
|
|
{ |
|
|
return mSnapToGridEnabled; |
|
|
|
@@ -167,6 +167,8 @@ class GUI_EXPORT QgsMapToolAdvancedDigitizing : public QgsMapToolEdit |
|
|
*/ |
|
|
void cadPointChanged( const QgsPointXY &point ); |
|
|
|
|
|
void onCurrentLayerChanged(); |
|
|
|
|
|
private: |
|
|
QgsAdvancedDigitizingDockWidget *mCadDockWidget = nullptr; |
|
|
|
|
|