Skip to content
Permalink
Browse files

fix snapping in move feature tool

  • Loading branch information
3nids committed Jun 12, 2017
1 parent e6f423b commit b3bd45b052cd4a0a6e0030a91b701121b5a948c2
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/app/qgsmaptoolmovefeature.cpp
@@ -80,9 +80,11 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e )

if ( !mRubberBand )
{
// ideally we would snap preferably on the moved feature
e->snapPoint( QgsMapMouseEvent::SnapProjectConfig );

//find first geometry under mouse cursor and store iterator to it
QgsPointXY layerCoords = toLayerCoordinates( vlayer, e->pos() );
QgsPointXY layerCoords = toLayerCoordinates( vlayer, e->mapPoint() );
double searchRadius = QgsTolerance::vertexSearchRadius( mCanvas->currentLayer(), mCanvas->mapSettings() );
QgsRectangle selectRect( layerCoords.x() - searchRadius, layerCoords.y() - searchRadius,
layerCoords.x() + searchRadius, layerCoords.y() + searchRadius );
@@ -146,7 +148,6 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
mRubberBand->setColor( QColor( 255, 0, 0, 65 ) );
mRubberBand->setWidth( 2 );
mRubberBand->show();

}
else
{
@@ -158,17 +159,16 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
mRubberBand = nullptr;
return;
}
e->snapPoint( QgsMapMouseEvent::SnapProjectConfig );

QgsPointXY startPointLayerCoords = toLayerCoordinates( ( QgsMapLayer * )vlayer, mStartPointMapCoords );
QgsPointXY stopPointLayerCoords = toLayerCoordinates( ( QgsMapLayer * )vlayer, e->mapPoint() );

double dx = stopPointLayerCoords.x() - startPointLayerCoords.x();
double dy = stopPointLayerCoords.y() - startPointLayerCoords.y();


vlayer->beginEditCommand( mMode == Move ? tr( "Feature moved" ) : tr( "Feature copied and moved" ) );


switch ( mMode )
{
case Move:

0 comments on commit b3bd45b

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