Skip to content

Commit 47af594

Browse files
author
wonder
committed
Fixed #1737. Contributed by Richard Kostecky.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11282 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 5ac95c4 commit 47af594

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/app/qgsmaptoolnodetool.cpp

+24-2
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,8 @@ void QgsMapToolNodeTool::canvasDoubleClickEvent( QMouseEvent * e )
783783
{
784784
QgsMapLayer* currentLayer = mCanvas->currentLayer();
785785
QgsVectorLayer* vlayer = 0;
786+
int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );
787+
QMultiMap<double, QgsSnappingResult> currentResultList;
786788
if ( currentLayer )
787789
{
788790
vlayer = dynamic_cast<QgsVectorLayer*>( currentLayer );
@@ -805,11 +807,31 @@ void QgsMapToolNodeTool::canvasDoubleClickEvent( QMouseEvent * e )
805807
{
806808
QgsPoint coords = snapResults.first().snappedVertex;
807809
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+
810817
vlayer->beginEditCommand( tr( "Inserted vertex" ) );
811818
mChangingGeometry = true;
819+
820+
//add vertex
812821
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+
813835
vlayer->endEditCommand();
814836

815837
mSelectionFeature->updateFromFeature();

0 commit comments

Comments
 (0)