Skip to content
Permalink
Browse files

Adjust snapping options on layer change

  • Loading branch information
m-kuhn committed Aug 26, 2018
1 parent 6ae03af commit 5c814cf9f325e9f641abd37253fc3bdd9a89b7f3
Showing with 17 additions and 0 deletions.
  1. +15 −0 src/gui/qgsmaptooladvanceddigitizing.cpp
  2. +2 −0 src/gui/qgsmaptooladvanceddigitizing.h
@@ -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;

0 comments on commit 5c814cf

Please sign in to comment.
You can’t perform that action at this time.