[QGIS Commit] r11282 - trunk/qgis/src/app

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Aug 6 06:43:29 EDT 2009


Author: wonder
Date: 2009-08-06 06:43:28 -0400 (Thu, 06 Aug 2009)
New Revision: 11282

Modified:
   trunk/qgis/src/app/qgsmaptoolnodetool.cpp
Log:
Fixed #1737. Contributed by Richard Kostecky.


Modified: trunk/qgis/src/app/qgsmaptoolnodetool.cpp
===================================================================
--- trunk/qgis/src/app/qgsmaptoolnodetool.cpp	2009-08-06 02:34:14 UTC (rev 11281)
+++ trunk/qgis/src/app/qgsmaptoolnodetool.cpp	2009-08-06 10:43:28 UTC (rev 11282)
@@ -783,6 +783,8 @@
 {
   QgsMapLayer* currentLayer = mCanvas->currentLayer();
   QgsVectorLayer* vlayer = 0;
+  int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );
+  QMultiMap<double, QgsSnappingResult> currentResultList;
   if ( currentLayer )
   {
     vlayer = dynamic_cast<QgsVectorLayer*>( currentLayer );
@@ -805,11 +807,31 @@
       {
         QgsPoint coords = snapResults.first().snappedVertex;
         QgsPoint layerCoords = toLayerCoordinates( vlayer, coords );
-        //QgsPoint coords = mCanvas->getCoordinateTransform()->toMapPoint( e->pos().x(),  e->pos().y() );
-        //add vertex
+        if ( topologicalEditing )
+        {
+          //snapp from adding position to this vertex when topological editing is enabled
+          currentResultList.clear();
+          vlayer->snapWithContext( layerCoords, ZERO_TOLERANCE, currentResultList, QgsSnapper::SnapToSegment );
+        }
+
         vlayer->beginEditCommand( tr( "Inserted vertex" ) );
         mChangingGeometry = true;
+
+        //add vertex
         vlayer->insertVertex( layerCoords.x(), layerCoords.y(), mSelectionFeature->featureId(), snapResults.first().afterVertexNr );
+
+        if ( topologicalEditing )
+        {
+          QMultiMap<double, QgsSnappingResult>::iterator resultIt =  currentResultList.begin();
+
+          for ( ; resultIt != currentResultList.end(); ++resultIt )
+          {
+            //create vertexes on same position when topological editing is enabled
+            if ( mSelectionFeature->featureId() !=  resultIt.value().snappedAtGeometry )
+              vlayer->insertVertex( layerCoords.x(), layerCoords.y(), resultIt.value().snappedAtGeometry, resultIt.value().afterVertexNr );
+          }
+        }
+
         vlayer->endEditCommand();
 
         mSelectionFeature->updateFromFeature();



More information about the QGIS-commit mailing list