Skip to content

Commit

Permalink
[node editor] When a feature is bound to the editor panel, only allow…
Browse files Browse the repository at this point in the history
… vertex/edge move vertex and creation on that feature
  • Loading branch information
nirvn committed Jan 23, 2019
1 parent 63ee9a3 commit 52df292
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/app/vertextool/qgsvertextool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,6 @@ void QgsVertexTool::cadCanvasPressEvent( QgsMapMouseEvent *e )
{
if ( !mSelectionRect && !mDraggingVertex && !mDraggingEdge )
{
// show popup menu - if we are on top of a feature
if ( mLastMouseMoveMatch.isValid() && mLastMouseMoveMatch.layer() )
{
showVertexEditor(); //#spellok
Expand All @@ -462,6 +461,9 @@ void QgsVertexTool::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
if ( mNewVertexFromDoubleClick )
{
QgsPointLocator::Match m( *mNewVertexFromDoubleClick );
if ( mSelectedFeature && ( mSelectedFeature->featureId() != m.featureId() || mSelectedFeature->layer() != m.layer() ) )
return; // when a feature is bound to the vector editor, only process actions on that feature

mNewVertexFromDoubleClick.reset();

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

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

mLastMouseMoveMatch = m;

// possibility to move a vertex
if ( m.type() == QgsPointLocator::Vertex )
if ( m.type() == QgsPointLocator::Vertex && targetIsAllowed )
{
updateVertexBand( m );

Expand Down Expand Up @@ -857,7 +860,7 @@ void QgsVertexTool::mouseMoveNotDragging( QgsMapMouseEvent *e )
}

// possibility to create new vertex here - or to move the edge
if ( m.type() == QgsPointLocator::Edge )
if ( m.type() == QgsPointLocator::Edge && targetIsAllowed )
{
QgsPointXY mapPoint = toMapCoordinates( e->pos() );
bool isCircularEdge = false;
Expand Down Expand Up @@ -941,6 +944,7 @@ void QgsVertexTool::updateFeatureBand( const QgsPointLocator::Match &m )
{
if ( mFeatureBandLayer == m.layer() && mFeatureBandFid == m.featureId() )
return; // skip regeneration of rubber band if not needed

QgsGeometry geom = cachedGeometry( m.layer(), m.featureId() );
mFeatureBandMarkers->setToGeometry( geometryToMultiPoint( geom ), m.layer() );
mFeatureBandMarkers->setVisible( true );
Expand Down Expand Up @@ -1197,6 +1201,8 @@ void QgsVertexTool::startDragging( QgsMapMouseEvent *e )
QgsPointLocator::Match m = snapToEditableLayer( e );
if ( !m.isValid() )
return;
if ( mSelectedFeature && ( mSelectedFeature->featureId() != m.featureId() || mSelectedFeature->layer() != m.layer() ) )
return; // when a feature is bound to the vertex editor, only process actions for that feature

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

QgsVectorLayer *dragLayer = mDraggingVertex->layer;
QgsFeatureId dragFid = mDraggingVertex->fid;

int dragVertexId = mDraggingVertex->vertexId;
bool addingVertex = mDraggingVertexType == AddingVertex || mDraggingVertexType == AddingEndpoint;
bool addingAtEndpoint = mDraggingVertexType == AddingEndpoint;
Expand Down

0 comments on commit 52df292

Please sign in to comment.