Skip to content

Commit 401cea1

Browse files
committedJan 23, 2019
[node editor] When a feature is bound to the editor panel, only allow vertex/edge move vertex and creation on that feature
1 parent b5cb74f commit 401cea1

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed
 

‎src/app/vertextool/qgsvertextool.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,6 @@ void QgsVertexTool::cadCanvasPressEvent( QgsMapMouseEvent *e )
442442
{
443443
if ( !mSelectionRect && !mDraggingVertex && !mDraggingEdge )
444444
{
445-
// show popup menu - if we are on top of a feature
446445
if ( mLastMouseMoveMatch.isValid() && mLastMouseMoveMatch.layer() )
447446
{
448447
showVertexEditor(); //#spellok
@@ -462,6 +461,9 @@ void QgsVertexTool::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
462461
if ( mNewVertexFromDoubleClick )
463462
{
464463
QgsPointLocator::Match m( *mNewVertexFromDoubleClick );
464+
if ( mSelectedFeature && ( mSelectedFeature->featureId() != m.featureId() || mSelectedFeature->layer() != m.layer() ) )
465+
return; // when a feature is bound to the vector editor, only process actions on that feature
466+
465467
mNewVertexFromDoubleClick.reset();
466468

467469
// dragging of edges and double clicking on edges to add vertex are slightly overlapping
@@ -822,11 +824,12 @@ void QgsVertexTool::mouseMoveNotDragging( QgsMapMouseEvent *e )
822824

823825
// do not use snap from mouse event, use our own with any editable layer
824826
QgsPointLocator::Match m = snapToEditableLayer( e );
827+
bool targetIsAllowed = ( !mSelectedFeature || ( mSelectedFeature->featureId() == m.featureId() && mSelectedFeature->layer() == m.layer() ) );
825828

826829
mLastMouseMoveMatch = m;
827830

828831
// possibility to move a vertex
829-
if ( m.type() == QgsPointLocator::Vertex )
832+
if ( m.type() == QgsPointLocator::Vertex && targetIsAllowed )
830833
{
831834
updateVertexBand( m );
832835

@@ -857,7 +860,7 @@ void QgsVertexTool::mouseMoveNotDragging( QgsMapMouseEvent *e )
857860
}
858861

859862
// possibility to create new vertex here - or to move the edge
860-
if ( m.type() == QgsPointLocator::Edge )
863+
if ( m.type() == QgsPointLocator::Edge && targetIsAllowed )
861864
{
862865
QgsPointXY mapPoint = toMapCoordinates( e->pos() );
863866
bool isCircularEdge = false;
@@ -941,6 +944,7 @@ void QgsVertexTool::updateFeatureBand( const QgsPointLocator::Match &m )
941944
{
942945
if ( mFeatureBandLayer == m.layer() && mFeatureBandFid == m.featureId() )
943946
return; // skip regeneration of rubber band if not needed
947+
944948
QgsGeometry geom = cachedGeometry( m.layer(), m.featureId() );
945949
mFeatureBandMarkers->setToGeometry( geometryToMultiPoint( geom ), m.layer() );
946950
mFeatureBandMarkers->setVisible( true );
@@ -1197,6 +1201,8 @@ void QgsVertexTool::startDragging( QgsMapMouseEvent *e )
11971201
QgsPointLocator::Match m = snapToEditableLayer( e );
11981202
if ( !m.isValid() )
11991203
return;
1204+
if ( mSelectedFeature && ( mSelectedFeature->featureId() != m.featureId() || mSelectedFeature->layer() != m.layer() ) )
1205+
return; // when a feature is bound to the vertex editor, only process actions for that feature
12001206

12011207
// activate advanced digitizing dock
12021208
setAdvancedDigitizingAllowed( true );
@@ -1636,6 +1642,7 @@ void QgsVertexTool::moveVertex( const QgsPointXY &mapPoint, const QgsPointLocato
16361642

16371643
QgsVectorLayer *dragLayer = mDraggingVertex->layer;
16381644
QgsFeatureId dragFid = mDraggingVertex->fid;
1645+
16391646
int dragVertexId = mDraggingVertex->vertexId;
16401647
bool addingVertex = mDraggingVertexType == AddingVertex || mDraggingVertexType == AddingEndpoint;
16411648
bool addingAtEndpoint = mDraggingVertexType == AddingEndpoint;

0 commit comments

Comments
 (0)
Please sign in to comment.