Skip to content
Permalink
Browse files

node tool: show rubberband when moving (fixes #12959)

(cherry picked from commit c54013c)
  • Loading branch information
jef-n committed Jun 14, 2015
1 parent 361857b commit 8f33dc464e2c16ea285388ec0aa057ca82ad0216
Showing with 42 additions and 45 deletions.
  1. +42 −45 src/app/nodetool/qgsmaptoolnodetool.cpp
@@ -137,6 +137,7 @@ void QgsMapToolNodeTool::createMovingRubberBands()
vertexMap[vertex]->setRubberBandValues( true, lastRubberBand, index );
index++;
}
rb->show();
mRubberBands.append( rb );
lastRubberBand++;
}
@@ -475,7 +476,6 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
mSelectedFeature->deselectAllVertexes();
}
}

}
}

@@ -534,61 +534,58 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QMouseEvent * e )
mSelectAnother = false;
}
}
else
else if ( mMoving )
{
if ( mMoving )
{
mMoving = false;
QgsPoint releaseMapCoords, pressMapCoords;
mMoving = false;
QgsPoint releaseMapCoords, pressMapCoords;

QgsExcludePointFilter excludePointFilter( mClosestMapVertex );
QgsPointLocator::Match match = mCanvas->snappingUtils()->snapToMap( e->pos(), &excludePointFilter );
QgsExcludePointFilter excludePointFilter( mClosestMapVertex );
QgsPointLocator::Match match = mCanvas->snappingUtils()->snapToMap( e->pos(), &excludePointFilter );

if ( match.isValid() )
{
releaseMapCoords = match.point();
pressMapCoords = mClosestMapVertex;
}
else
{
releaseMapCoords = toMapCoordinates( e->pos() );
pressMapCoords = toMapCoordinates( mPressCoordinates );
}
if ( match.isValid() )
{
releaseMapCoords = match.point();
pressMapCoords = mClosestMapVertex;
}
else
{
releaseMapCoords = toMapCoordinates( e->pos() );
pressMapCoords = toMapCoordinates( mPressCoordinates );
}

QgsPoint releaseLayerCoords = toLayerCoordinates( vlayer, releaseMapCoords );
QgsPoint pressLayerCoords = toLayerCoordinates( vlayer, pressMapCoords );
QgsPoint releaseLayerCoords = toLayerCoordinates( vlayer, releaseMapCoords );
QgsPoint pressLayerCoords = toLayerCoordinates( vlayer, pressMapCoords );

if ( match.isValid() )
if ( match.isValid() )
{
int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );
if ( topologicalEditing )
{
int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );
if ( topologicalEditing )
{
addTopologicalPoints( QList<QgsPoint>() << releaseMapCoords );
}
addTopologicalPoints( QList<QgsPoint>() << releaseMapCoords );
}

mSelectedFeature->moveSelectedVertexes( releaseLayerCoords - pressLayerCoords );
mCanvas->refresh();
}
else // selecting vertexes by rubberband
{
// coordinates has to be coordinates from layer not canvas
QgsRectangle r( toLayerCoordinates( vlayer, mPressCoordinates ),
toLayerCoordinates( vlayer, e->pos() ) );

QList<QgsVertexEntry*> &vertexMap = mSelectedFeature->vertexMap();
if ( !mCtrl )
{
mSelectedFeature->deselectAllVertexes();
}
mSelectedFeature->moveSelectedVertexes( releaseLayerCoords - pressLayerCoords );
mCanvas->refresh();
}
else // selecting vertexes by rubberband
{
// coordinates has to be coordinates from layer not canvas
QgsRectangle r( toLayerCoordinates( vlayer, mPressCoordinates ),
toLayerCoordinates( vlayer, e->pos() ) );

for ( int i = 0; i < vertexMap.size(); i++ )
QList<QgsVertexEntry*> &vertexMap = mSelectedFeature->vertexMap();
if ( !mCtrl )
{
mSelectedFeature->deselectAllVertexes();
}

for ( int i = 0; i < vertexMap.size(); i++ )
{
if ( r.contains( vertexMap[i]->point() ) )
{
if ( r.contains( vertexMap[i]->point() ) )
{
// inverting selection is enough because all were deselected if ctrl is not pressed
mSelectedFeature->invertVertexSelection( i, false );
}
// inverting selection is enough because all were deselected if ctrl is not pressed
mSelectedFeature->invertVertexSelection( i, false );
}
}
}

0 comments on commit 8f33dc4

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