Skip to content

Commit

Permalink
Fix issues with reprojection
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jul 23, 2015
1 parent 81bdbbc commit 1498107
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions src/app/nodetool/qgsmaptoolnodetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,21 @@ void QgsMapToolNodeTool::canvasMapPressEvent( QgsMapMouseEvent* e )
}

//select or move vertices if selected feature has not been changed
QgsPoint layerPoint = toLayerCoordinates( vlayer, e->mapPoint() );
if ( mSelectedFeature->featureId() == bkFeatureId )
{
if ( mSelectedFeature->hasSelection() && !ctrlModifier ) //move vertices
{
QgsPoint targetCoords = e->mapPoint();
mSelectedFeature->moveSelectedVertexes( targetCoords - mClosestMapVertex );
QgsPoint targetCoords = layerPoint;
mSelectedFeature->moveSelectedVertexes( targetCoords - mClosestLayerVertex );
mCanvas->refresh();
mSelectedFeature->deselectAllVertexes();
}
else //add vertex selection
{
int atVertex, beforeVertex, afterVertex;
double dist;

QgsPoint closestLayerVertex = mSelectedFeature->geometry()->closestVertex( e->mapPoint(), atVertex, beforeVertex, afterVertex, dist );
QgsPoint closestLayerVertex = mSelectedFeature->geometry()->closestVertex( layerPoint, atVertex, beforeVertex, afterVertex, dist );
mSelectedFeature->selectVertex( atVertex );
}
}
Expand Down Expand Up @@ -160,11 +160,12 @@ void QgsMapToolNodeTool::canvasMapMoveEvent( QgsMapMouseEvent* e )
{
// move rubberband
QList<QgsSnappingResult> snapResults;
mSnapper.snapToBackgroundLayers( e->pos(), snapResults, QList<QgsPoint>() << mClosestMapVertex );
mSnapper.snapToBackgroundLayers( e->pos(), snapResults, QList<QgsPoint>() << mClosestLayerVertex );

QgsPoint origPos = toMapCoordinates( vlayer, mClosestLayerVertex );
QgsPoint curPos = snapPointFromResults( snapResults, e->pos() );
double diffX = curPos.x() - mClosestMapVertex.x();
double diffY = curPos.y() - mClosestMapVertex.y();
double diffX = curPos.x() - origPos.x();
double diffY = curPos.y() - origPos.y();

foreach ( const QgsFeatureId& fid, mMoveRubberBands.keys() )
{
Expand Down Expand Up @@ -375,7 +376,8 @@ int QgsMapToolNodeTool::insertSegmentVerticesForSnap( const QList<QgsSnappingRes

void QgsMapToolNodeTool::changeLastVertex( const QgsPointV2& pt )
{
mClosestMapVertex = toMapCoordinates( currentVectorLayer(), QgsPoint( pt.x(), pt.y() ) );
mClosestLayerVertex.setX( pt.x() );
mClosestLayerVertex.setY( pt.y() );
}

void QgsMapToolNodeTool::removeRubberBands()
Expand Down
2 changes: 1 addition & 1 deletion src/app/nodetool/qgsmaptoolnodetool.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class QgsMapToolNodeTool: public QgsMapToolEdit
QPoint mPressCoordinates;

/** Closest vertex to click in map coordinates */
QgsPoint mClosestMapVertex;
QgsPoint mClosestLayerVertex;

/** Rectangle defining area for selecting vertexes */
QRect* mRect;
Expand Down

0 comments on commit 1498107

Please sign in to comment.