Skip to content
Permalink
Browse files

Fix issues with reprojection

  • Loading branch information
mhugent committed Jul 23, 2015
1 parent 81bdbbc commit 149810748af3e63953bbd7a4abecc2b4817df70b
Showing with 11 additions and 9 deletions.
  1. +10 −8 src/app/nodetool/qgsmaptoolnodetool.cpp
  2. +1 −1 src/app/nodetool/qgsmaptoolnodetool.h
@@ -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 );
}
}
@@ -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() )
{
@@ -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()
@@ -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;

0 comments on commit 1498107

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