@@ -783,6 +783,8 @@ void QgsMapToolNodeTool::canvasDoubleClickEvent( QMouseEvent * e )
783
783
{
784
784
QgsMapLayer* currentLayer = mCanvas ->currentLayer ();
785
785
QgsVectorLayer* vlayer = 0 ;
786
+ int topologicalEditing = QgsProject::instance ()->readNumEntry ( " Digitizing" , " /TopologicalEditing" , 0 );
787
+ QMultiMap<double , QgsSnappingResult> currentResultList;
786
788
if ( currentLayer )
787
789
{
788
790
vlayer = dynamic_cast <QgsVectorLayer*>( currentLayer );
@@ -805,11 +807,31 @@ void QgsMapToolNodeTool::canvasDoubleClickEvent( QMouseEvent * e )
805
807
{
806
808
QgsPoint coords = snapResults.first ().snappedVertex ;
807
809
QgsPoint layerCoords = toLayerCoordinates ( vlayer, coords );
808
- // QgsPoint coords = mCanvas->getCoordinateTransform()->toMapPoint( e->pos().x(), e->pos().y() );
809
- // add vertex
810
+ if ( topologicalEditing )
811
+ {
812
+ // snapp from adding position to this vertex when topological editing is enabled
813
+ currentResultList.clear ();
814
+ vlayer->snapWithContext ( layerCoords, ZERO_TOLERANCE, currentResultList, QgsSnapper::SnapToSegment );
815
+ }
816
+
810
817
vlayer->beginEditCommand ( tr ( " Inserted vertex" ) );
811
818
mChangingGeometry = true ;
819
+
820
+ // add vertex
812
821
vlayer->insertVertex ( layerCoords.x (), layerCoords.y (), mSelectionFeature ->featureId (), snapResults.first ().afterVertexNr );
822
+
823
+ if ( topologicalEditing )
824
+ {
825
+ QMultiMap<double , QgsSnappingResult>::iterator resultIt = currentResultList.begin ();
826
+
827
+ for ( ; resultIt != currentResultList.end (); ++resultIt )
828
+ {
829
+ // create vertexes on same position when topological editing is enabled
830
+ if ( mSelectionFeature ->featureId () != resultIt.value ().snappedAtGeometry )
831
+ vlayer->insertVertex ( layerCoords.x (), layerCoords.y (), resultIt.value ().snappedAtGeometry , resultIt.value ().afterVertexNr );
832
+ }
833
+ }
834
+
813
835
vlayer->endEditCommand ();
814
836
815
837
mSelectionFeature ->updateFromFeature ();
0 commit comments