Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
node tool: show rubberband when moving (fixes #12959)
(cherry picked from commit c54013c)
  • Loading branch information
jef-n committed Jun 29, 2015
1 parent 361857b commit 8f33dc4
Showing 1 changed file with 42 additions and 45 deletions.
87 changes: 42 additions & 45 deletions src/app/nodetool/qgsmaptoolnodetool.cpp
Expand Up @@ -137,6 +137,7 @@ void QgsMapToolNodeTool::createMovingRubberBands()
vertexMap[vertex]->setRubberBandValues( true, lastRubberBand, index );
index++;
}
rb->show();
mRubberBands.append( rb );
lastRubberBand++;
}
Expand Down Expand Up @@ -475,7 +476,6 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
mSelectedFeature->deselectAllVertexes();
}
}

}
}

Expand Down Expand Up @@ -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 );
}
}
}
Expand Down

0 comments on commit 8f33dc4

Please sign in to comment.