Skip to content

Commit c54013c

Browse files
committedJun 14, 2015
node tool: show rubberband when moving (fixes #12959)
1 parent 37ed839 commit c54013c

File tree

1 file changed

+42
-45
lines changed

1 file changed

+42
-45
lines changed
 

‎src/app/nodetool/qgsmaptoolnodetool.cpp

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ void QgsMapToolNodeTool::createMovingRubberBands()
137137
vertexMap[vertex]->setRubberBandValues( true, lastRubberBand, index );
138138
index++;
139139
}
140+
rb->show();
140141
mRubberBands.append( rb );
141142
lastRubberBand++;
142143
}
@@ -475,7 +476,6 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
475476
mSelectedFeature->deselectAllVertexes();
476477
}
477478
}
478-
479479
}
480480
}
481481

@@ -534,61 +534,58 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QMouseEvent * e )
534534
mSelectAnother = false;
535535
}
536536
}
537-
else
537+
else if ( mMoving )
538538
{
539-
if ( mMoving )
540-
{
541-
mMoving = false;
542-
QgsPoint releaseMapCoords, pressMapCoords;
539+
mMoving = false;
540+
QgsPoint releaseMapCoords, pressMapCoords;
543541

544-
QgsExcludePointFilter excludePointFilter( mClosestMapVertex );
545-
QgsPointLocator::Match match = mCanvas->snappingUtils()->snapToMap( e->pos(), &excludePointFilter );
542+
QgsExcludePointFilter excludePointFilter( mClosestMapVertex );
543+
QgsPointLocator::Match match = mCanvas->snappingUtils()->snapToMap( e->pos(), &excludePointFilter );
546544

547-
if ( match.isValid() )
548-
{
549-
releaseMapCoords = match.point();
550-
pressMapCoords = mClosestMapVertex;
551-
}
552-
else
553-
{
554-
releaseMapCoords = toMapCoordinates( e->pos() );
555-
pressMapCoords = toMapCoordinates( mPressCoordinates );
556-
}
545+
if ( match.isValid() )
546+
{
547+
releaseMapCoords = match.point();
548+
pressMapCoords = mClosestMapVertex;
549+
}
550+
else
551+
{
552+
releaseMapCoords = toMapCoordinates( e->pos() );
553+
pressMapCoords = toMapCoordinates( mPressCoordinates );
554+
}
557555

558-
QgsPoint releaseLayerCoords = toLayerCoordinates( vlayer, releaseMapCoords );
559-
QgsPoint pressLayerCoords = toLayerCoordinates( vlayer, pressMapCoords );
556+
QgsPoint releaseLayerCoords = toLayerCoordinates( vlayer, releaseMapCoords );
557+
QgsPoint pressLayerCoords = toLayerCoordinates( vlayer, pressMapCoords );
560558

561-
if ( match.isValid() )
559+
if ( match.isValid() )
560+
{
561+
int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );
562+
if ( topologicalEditing )
562563
{
563-
int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );
564-
if ( topologicalEditing )
565-
{
566-
addTopologicalPoints( QList<QgsPoint>() << releaseMapCoords );
567-
}
564+
addTopologicalPoints( QList<QgsPoint>() << releaseMapCoords );
568565
}
569-
570-
mSelectedFeature->moveSelectedVertexes( releaseLayerCoords - pressLayerCoords );
571-
mCanvas->refresh();
572566
}
573-
else // selecting vertexes by rubberband
574-
{
575-
// coordinates has to be coordinates from layer not canvas
576-
QgsRectangle r( toLayerCoordinates( vlayer, mPressCoordinates ),
577-
toLayerCoordinates( vlayer, e->pos() ) );
578567

579-
QList<QgsVertexEntry*> &vertexMap = mSelectedFeature->vertexMap();
580-
if ( !mCtrl )
581-
{
582-
mSelectedFeature->deselectAllVertexes();
583-
}
568+
mSelectedFeature->moveSelectedVertexes( releaseLayerCoords - pressLayerCoords );
569+
mCanvas->refresh();
570+
}
571+
else // selecting vertexes by rubberband
572+
{
573+
// coordinates has to be coordinates from layer not canvas
574+
QgsRectangle r( toLayerCoordinates( vlayer, mPressCoordinates ),
575+
toLayerCoordinates( vlayer, e->pos() ) );
584576

585-
for ( int i = 0; i < vertexMap.size(); i++ )
577+
QList<QgsVertexEntry*> &vertexMap = mSelectedFeature->vertexMap();
578+
if ( !mCtrl )
579+
{
580+
mSelectedFeature->deselectAllVertexes();
581+
}
582+
583+
for ( int i = 0; i < vertexMap.size(); i++ )
584+
{
585+
if ( r.contains( vertexMap[i]->point() ) )
586586
{
587-
if ( r.contains( vertexMap[i]->point() ) )
588-
{
589-
// inverting selection is enough because all were deselected if ctrl is not pressed
590-
mSelectedFeature->invertVertexSelection( i, false );
591-
}
587+
// inverting selection is enough because all were deselected if ctrl is not pressed
588+
mSelectedFeature->invertVertexSelection( i, false );
592589
}
593590
}
594591
}

0 commit comments

Comments
 (0)
Please sign in to comment.