Skip to content
Permalink
Browse files

Use the standard snap indicator with move features tool

Fixes #18957
  • Loading branch information
nyalldawson committed May 21, 2018
1 parent c5ff6b9 commit 19b3325be6da4c14d7e8992391e913830b674da8
Showing with 15 additions and 1 deletion.
  1. +10 −1 src/app/qgsmaptoolmovefeature.cpp
  2. +5 −0 src/app/qgsmaptoolmovefeature.h
@@ -24,7 +24,7 @@
#include "qgstolerance.h"
#include "qgsvectorlayer.h"
#include "qgsvectorlayertools.h"

#include "qgssnapindicator.h"

#include <QMessageBox>
#include <QMouseEvent>
@@ -34,6 +34,7 @@

QgsMapToolMoveFeature::QgsMapToolMoveFeature( QgsMapCanvas *canvas, MoveMode mode )
: QgsMapToolAdvancedDigitizing( canvas, QgisApp::instance()->cadDockWidget() )
, mSnapIndicator( qgis::make_unique< QgsSnapIndicator>( canvas ) )
, mMode( mode )
{
mToolName = tr( "Move feature" );
@@ -54,6 +55,7 @@ void QgsMapToolMoveFeature::cadCanvasMoveEvent( QgsMapMouseEvent *e )
mRubberBand->setTranslationOffset( offsetX, offsetY );
mRubberBand->updatePosition();
mRubberBand->update();
mSnapIndicator->setMatch( e->mapPointMatch() );
}
}

@@ -64,6 +66,7 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
{
delete mRubberBand;
mRubberBand = nullptr;
mSnapIndicator->setMatch( QgsPointLocator::Match() );
cadDockWidget()->clear();
notifyNotEditableLayer();
return;
@@ -152,6 +155,7 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
mMovedFeatures.clear();
delete mRubberBand;
mRubberBand = nullptr;
mSnapIndicator->setMatch( QgsPointLocator::Match() );
return;
}
}
@@ -170,6 +174,7 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
cadDockWidget()->clear();
delete mRubberBand;
mRubberBand = nullptr;
mSnapIndicator->setMatch( QgsPointLocator::Match() );
return;
}

@@ -190,6 +195,7 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
}
delete mRubberBand;
mRubberBand = nullptr;
mSnapIndicator->setMatch( QgsPointLocator::Match() );
cadDockWidget()->clear();
break;

@@ -202,6 +208,7 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
emit messageEmitted( *errorMsg, Qgis::Critical );
delete mRubberBand;
mRubberBand = nullptr;
mSnapIndicator->setMatch( QgsPointLocator::Match() );
}
break;
}
@@ -216,6 +223,7 @@ void QgsMapToolMoveFeature::deactivate()
//delete rubber band
delete mRubberBand;
mRubberBand = nullptr;
mSnapIndicator->setMatch( QgsPointLocator::Match() );

QgsMapTool::deactivate();
}
@@ -227,5 +235,6 @@ void QgsMapToolMoveFeature::keyReleaseEvent( QKeyEvent *e )
cadDockWidget()->clear();
delete mRubberBand;
mRubberBand = nullptr;
mSnapIndicator->setMatch( QgsPointLocator::Match() );
}
}
@@ -19,6 +19,8 @@
#include "qgsmaptooladvanceddigitizing.h"
#include "qgis_app.h"

class QgsSnapIndicator;

//! Map tool for translating feature position by mouse drag
class APP_EXPORT QgsMapToolMoveFeature: public QgsMapToolAdvancedDigitizing
{
@@ -50,6 +52,9 @@ class APP_EXPORT QgsMapToolMoveFeature: public QgsMapToolAdvancedDigitizing
//! Rubberband that shows the feature being moved
QgsRubberBand *mRubberBand = nullptr;

//! Snapping indicators
std::unique_ptr<QgsSnapIndicator> mSnapIndicator;

//! Id of moved feature
QgsFeatureIds mMovedFeatures;

0 comments on commit 19b3325

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