@@ -490,6 +490,12 @@ void QgsVertexTool::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
490
490
QList<Vertex> selectedVertices;
491
491
QList<Vertex> editorVertices;
492
492
493
+ // the logic for selecting vertices using rectangle:
494
+ // - if we have a bound (locked) feature, we only allow selection of its vertices
495
+ // - if we don't have a bound feature, we can select vertices from any feature,
496
+ // but if there are some vertices coming from layer(s) with selected feature,
497
+ // we give them precedence.
498
+
493
499
// for each editable layer, select vertices
494
500
const auto layers = canvas ()->layers ();
495
501
const auto editableLayers = editableVectorLayers ();
@@ -498,11 +504,17 @@ void QgsVertexTool::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
498
504
if ( mMode == ActiveLayer && vlayer != currentVectorLayer () )
499
505
continue ;
500
506
507
+ if ( mSelectedFeature && mSelectedFeature ->layer () != vlayer )
508
+ continue ; // with locked feature we only allow selection of its vertices
509
+
501
510
QgsRectangle layerRect = toLayerCoordinates ( vlayer, map_rect );
502
511
QgsFeature f;
503
512
QgsFeatureIterator fi = vlayer->getFeatures ( QgsFeatureRequest ( layerRect ).setNoAttributes () );
504
513
while ( fi.nextFeature ( f ) )
505
514
{
515
+ if ( mSelectedFeature && mSelectedFeature ->featureId () != f.id () )
516
+ continue ; // with locked feature we only allow selection of its vertices
517
+
506
518
bool isFeatureSelected = vlayer->selectedFeatureIds ().contains ( f.id () );
507
519
QgsGeometry g = f.geometry ();
508
520
for ( int i = 0 ; i < g.constGet ()->nCoordinates (); ++i )
@@ -514,22 +526,13 @@ void QgsVertexTool::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
514
526
515
527
if ( isFeatureSelected )
516
528
selectedVertices << Vertex ( vlayer, f.id (), i );
517
-
518
- if ( mSelectedFeature && mSelectedFeature ->featureId () == f.id () && mSelectedFeature ->layer () == vlayer )
519
- editorVertices << Vertex ( vlayer, f.id (), i );
520
529
}
521
530
}
522
531
}
523
532
}
524
533
525
- // If there were any vertices that come from a feature currently binded to the node editor, use just verices from
526
- // that feature, otherwise if there were any vertices from selected features, use just vertices from those selected features.
527
- // This allows user to select a bunch of features in complex situations to constrain the selection.
528
- if ( !editorVertices.isEmpty () )
529
- {
530
- vertices = editorVertices;
531
- }
532
- else if ( !selectedVertices.isEmpty () )
534
+ // here's where we give precedence to vertices of selected features in case there's no bound (locked) feature
535
+ if ( !mSelectedFeature && !selectedVertices.isEmpty () )
533
536
{
534
537
vertices = selectedVertices;
535
538
}
@@ -1122,7 +1125,9 @@ void QgsVertexTool::mouseMoveNotDragging( QgsMapMouseEvent *e )
1122
1125
m = snapToPolygonInterior ( e );
1123
1126
}
1124
1127
1125
- updateFeatureBand ( m );
1128
+ // when we are "locked" to a feature, we don't want to highlight any other features
1129
+ // so the user does not get distracted
1130
+ updateFeatureBand ( mSelectedFeature ? QgsPointLocator::Match () : m );
1126
1131
}
1127
1132
1128
1133
void QgsVertexTool::updateVertexBand ( const QgsPointLocator::Match &m )
0 commit comments