Skip to content

Commit

Permalink
fix snapping in move feature tool
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Jun 12, 2017
1 parent e6f423b commit b3bd45b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/app/qgsmaptoolmovefeature.cpp
Expand Up @@ -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 );
Expand Down Expand Up @@ -146,7 +148,6 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
mRubberBand->setColor( QColor( 255, 0, 0, 65 ) );
mRubberBand->setWidth( 2 );
mRubberBand->show();

}
else
{
Expand All @@ -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:
Expand Down

0 comments on commit b3bd45b

Please sign in to comment.