Fix issues with reprojection

This commit is contained in:
Marco Hugentobler 2015-07-23 16:09:50 +02:00
parent 81bdbbc4eb
commit 149810748a
2 changed files with 11 additions and 9 deletions

View File

@ -102,12 +102,13 @@ void QgsMapToolNodeTool::canvasMapPressEvent( QgsMapMouseEvent* e )
} }
//select or move vertices if selected feature has not been changed //select or move vertices if selected feature has not been changed
QgsPoint layerPoint = toLayerCoordinates( vlayer, e->mapPoint() );
if ( mSelectedFeature->featureId() == bkFeatureId ) if ( mSelectedFeature->featureId() == bkFeatureId )
{ {
if ( mSelectedFeature->hasSelection() && !ctrlModifier ) //move vertices if ( mSelectedFeature->hasSelection() && !ctrlModifier ) //move vertices
{ {
QgsPoint targetCoords = e->mapPoint(); QgsPoint targetCoords = layerPoint;
mSelectedFeature->moveSelectedVertexes( targetCoords - mClosestMapVertex ); mSelectedFeature->moveSelectedVertexes( targetCoords - mClosestLayerVertex );
mCanvas->refresh(); mCanvas->refresh();
mSelectedFeature->deselectAllVertexes(); mSelectedFeature->deselectAllVertexes();
} }
@ -115,8 +116,7 @@ void QgsMapToolNodeTool::canvasMapPressEvent( QgsMapMouseEvent* e )
{ {
int atVertex, beforeVertex, afterVertex; int atVertex, beforeVertex, afterVertex;
double dist; double dist;
QgsPoint closestLayerVertex = mSelectedFeature->geometry()->closestVertex( layerPoint, atVertex, beforeVertex, afterVertex, dist );
QgsPoint closestLayerVertex = mSelectedFeature->geometry()->closestVertex( e->mapPoint(), atVertex, beforeVertex, afterVertex, dist );
mSelectedFeature->selectVertex( atVertex ); mSelectedFeature->selectVertex( atVertex );
} }
} }
@ -160,11 +160,12 @@ void QgsMapToolNodeTool::canvasMapMoveEvent( QgsMapMouseEvent* e )
{ {
// move rubberband // move rubberband
QList<QgsSnappingResult> snapResults; 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() ); QgsPoint curPos = snapPointFromResults( snapResults, e->pos() );
double diffX = curPos.x() - mClosestMapVertex.x(); double diffX = curPos.x() - origPos.x();
double diffY = curPos.y() - mClosestMapVertex.y(); double diffY = curPos.y() - origPos.y();
foreach ( const QgsFeatureId& fid, mMoveRubberBands.keys() ) foreach ( const QgsFeatureId& fid, mMoveRubberBands.keys() )
{ {
@ -375,7 +376,8 @@ int QgsMapToolNodeTool::insertSegmentVerticesForSnap( const QList<QgsSnappingRes
void QgsMapToolNodeTool::changeLastVertex( const QgsPointV2& pt ) 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() void QgsMapToolNodeTool::removeRubberBands()

View File

@ -127,7 +127,7 @@ class QgsMapToolNodeTool: public QgsMapToolEdit
QPoint mPressCoordinates; QPoint mPressCoordinates;
/** Closest vertex to click in map coordinates */ /** Closest vertex to click in map coordinates */
QgsPoint mClosestMapVertex; QgsPoint mClosestLayerVertex;
/** Rectangle defining area for selecting vertexes */ /** Rectangle defining area for selecting vertexes */
QRect* mRect; QRect* mRect;