Skip to content

Commit

Permalink
Update highlighted nodes when features are changed or deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Apr 6, 2017
1 parent d1f23e9 commit f004468
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/app/nodetool/qgsnodetool2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,9 @@ void QgsNodeTool2::onCachedGeometryChanged( QgsFeatureId fid, const QgsGeometry
QHash<QgsFeatureId, QgsGeometry> &layerCache = mCache[layer];
if ( layerCache.contains( fid ) )
layerCache[fid] = geom;

// refresh highlighted nodes - their position may have changed
setHighlightedNodes( mSelectedNodes );
}

void QgsNodeTool2::onCachedGeometryDeleted( QgsFeatureId fid )
Expand All @@ -851,6 +854,9 @@ void QgsNodeTool2::onCachedGeometryDeleted( QgsFeatureId fid )
QHash<QgsFeatureId, QgsGeometry> &layerCache = mCache[layer];
if ( layerCache.contains( fid ) )
layerCache.remove( fid );

// refresh highlighted nodes - some may have been deleted
setHighlightedNodes( mSelectedNodes );
}


Expand Down Expand Up @@ -1518,23 +1524,27 @@ void QgsNodeTool2::deleteVertex()

}

void QgsNodeTool2::setHighlightedNodes( const QList<Vertex> &listNodes )
void QgsNodeTool2::setHighlightedNodes( QList<Vertex> listNodes )
{
qDeleteAll( mSelectedNodesMarkers );
mSelectedNodesMarkers.clear();
mSelectedNodes.clear();

Q_FOREACH ( const Vertex &node, listNodes )
{
QgsGeometry geom = cachedGeometryForVertex( node );
QgsVertexId vid;
if ( !geom.vertexIdFromVertexNr( node.vertexId, vid ) )
continue; // node may not exist anymore
QgsVertexMarker *marker = new QgsVertexMarker( canvas() );
marker->setIconType( QgsVertexMarker::ICON_CIRCLE );
marker->setPenWidth( 3 );
marker->setColor( Qt::blue );
marker->setFillColor( Qt::blue );
marker->setCenter( toMapCoordinates( node.layer, geom.vertexAt( node.vertexId ) ) );
mSelectedNodes.append( node );
mSelectedNodesMarkers.append( marker );
}
mSelectedNodes = listNodes;
}

void QgsNodeTool2::setHighlightedNodesVisible( bool visible )
Expand Down
2 changes: 1 addition & 1 deletion src/app/nodetool/qgsnodetool2.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class APP_EXPORT QgsNodeTool2 : public QgsMapToolAdvancedDigitizing

void applyEditsToLayers( NodeEdits &edits );

void setHighlightedNodes( const QList<Vertex> &listNodes );
void setHighlightedNodes( QList<Vertex> listNodes );

void setHighlightedNodesVisible( bool visible );

Expand Down

0 comments on commit f004468

Please sign in to comment.