diff --git a/src/gui/qgsadvanceddigitizingdockwidget.cpp b/src/gui/qgsadvanceddigitizingdockwidget.cpp index fa601aef2b9d..36775a113d9e 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.cpp +++ b/src/gui/qgsadvanceddigitizingdockwidget.cpp @@ -554,7 +554,17 @@ bool QgsAdvancedDigitizingDockWidget::applyConstraints( QgsMapMouseEvent *e ) e->setMapPoint( point ); mSnapMatch = context.snappingUtils->snapToMap( point ); - + /* + * Constraints are applied in 2D, they are always called when using the tool + * but they do not take into account if when you snap on a vertex it has + * a Z value. + * To get the value we use the snapPoint method. However, we only apply it + * when the snapped point corresponds to the constrained point. + */ + if ( mSnapMatch.hasVertex() && ( point == mSnapMatch.point() ) ) + { + e->snapPoint(); + } // update the point list updateCurrentPoint( point ); diff --git a/src/gui/qgsmaptooladvanceddigitizing.cpp b/src/gui/qgsmaptooladvanceddigitizing.cpp index 0e121d69ab2b..4ec23381e0c2 100644 --- a/src/gui/qgsmaptooladvanceddigitizing.cpp +++ b/src/gui/qgsmaptooladvanceddigitizing.cpp @@ -34,11 +34,6 @@ void QgsMapToolAdvancedDigitizing::canvasPressEvent( QgsMapMouseEvent *e ) { mCadDockWidget->applyConstraints( e ); // updates event's map point - if ( mCadDockWidget->mapPointMatch().hasVertex() ) - { - e->snapPoint(); - } - if ( mCadDockWidget->constructionMode() ) return; // decided to eat the event and not pass it to the map tool (construction mode) } @@ -78,11 +73,6 @@ void QgsMapToolAdvancedDigitizing::canvasReleaseEvent( QgsMapMouseEvent *e ) mCadDockWidget->releaseLocks( false ); - if ( mCadDockWidget->mapPointMatch().hasVertex() ) - { - e->snapPoint(); - } - if ( mCadDockWidget->constructionMode() ) return; // decided to eat the event and not pass it to the map tool (construction mode) }