mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-18 00:03:05 -04:00
Merge pull request #9971 from olivierdalang/node-tool-chain-add
[nodetool] chained add vertex at endpoint
This commit is contained in:
commit
e693e81053
@ -2040,6 +2040,18 @@ void QgsVertexTool::moveVertex( const QgsPointXY &mapPoint, const QgsPointLocato
|
||||
|
||||
setHighlightedVertices( mSelectedVertices ); // update positions of existing highlighted vertices
|
||||
setHighlightedVerticesVisible( true ); // time to show highlighted vertices again
|
||||
|
||||
// restart startDraggingAddVertexAtEndpoint right after it finishes
|
||||
if ( addingAtEndpoint )
|
||||
{
|
||||
if ( mMouseAtEndpoint->vertexId != 0 )
|
||||
{
|
||||
// If we were adding at the end of the feature, we need to update the index
|
||||
mMouseAtEndpoint.reset( new Vertex( mMouseAtEndpoint->layer, mMouseAtEndpoint->fid, mMouseAtEndpoint->vertexId + 1 ) );
|
||||
}
|
||||
// And then we just restart the drag
|
||||
startDraggingAddVertexAtEndpoint( mapPoint );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -387,6 +387,7 @@ void TestQgsVertexTool::testAddVertexAtEndpoint()
|
||||
mouseMove( 1, 3 ); // first we need to move to the vertex
|
||||
mouseClick( 1, 3 + offsetInMapUnits, Qt::LeftButton );
|
||||
mouseClick( 2, 3, Qt::LeftButton );
|
||||
mouseClick( 2, 3, Qt::RightButton ); // we need a right click to stop adding new nodes
|
||||
|
||||
QCOMPARE( mLayerLine->undoStack()->index(), 2 );
|
||||
QCOMPARE( mLayerLine->getFeature( mFidLineF1 ).geometry(), QgsGeometry::fromWkt( "LINESTRING(2 1, 1 1, 1 3, 2 3)" ) );
|
||||
@ -401,6 +402,7 @@ void TestQgsVertexTool::testAddVertexAtEndpoint()
|
||||
mouseMove( 2, 1 ); // first we need to move to the vertex
|
||||
mouseClick( 2 + offsetInMapUnits, 1, Qt::LeftButton );
|
||||
mouseClick( 2, 2, Qt::LeftButton );
|
||||
mouseClick( 2, 2, Qt::RightButton ); // we need a right click to stop adding new nodes
|
||||
|
||||
QCOMPARE( mLayerLine->undoStack()->index(), 2 );
|
||||
QCOMPARE( mLayerLine->getFeature( mFidLineF1 ).geometry(), QgsGeometry::fromWkt( "LINESTRING(2 2, 2 1, 1 1, 1 3)" ) );
|
||||
@ -409,6 +411,25 @@ void TestQgsVertexTool::testAddVertexAtEndpoint()
|
||||
QCOMPARE( mLayerLine->undoStack()->index(), 1 );
|
||||
|
||||
QCOMPARE( mLayerLine->getFeature( mFidLineF1 ).geometry(), QgsGeometry::fromWkt( "LINESTRING(2 1, 1 1, 1 3)" ) );
|
||||
|
||||
// add three vertices at once
|
||||
|
||||
mouseMove( 2, 1 ); // first we need to move to the vertex
|
||||
mouseClick( 2 + offsetInMapUnits, 1, Qt::LeftButton );
|
||||
mouseClick( 2, 2, Qt::LeftButton );
|
||||
mouseClick( 2, 3, Qt::LeftButton );
|
||||
mouseClick( 2, 4, Qt::LeftButton );
|
||||
mouseClick( 2, 2, Qt::RightButton ); // we need a right click to stop adding new nodes
|
||||
|
||||
QCOMPARE( mLayerLine->undoStack()->index(), 4 );
|
||||
QCOMPARE( mLayerLine->getFeature( mFidLineF1 ).geometry(), QgsGeometry::fromWkt( "LINESTRING(2 4, 2 3, 2 2, 2 1, 1 1, 1 3)" ) );
|
||||
|
||||
mLayerLine->undoStack()->undo();
|
||||
mLayerLine->undoStack()->undo();
|
||||
mLayerLine->undoStack()->undo();
|
||||
QCOMPARE( mLayerLine->undoStack()->index(), 1 );
|
||||
|
||||
QCOMPARE( mLayerLine->getFeature( mFidLineF1 ).geometry(), QgsGeometry::fromWkt( "LINESTRING(2 1, 1 1, 1 3)" ) );
|
||||
}
|
||||
|
||||
void TestQgsVertexTool::testAddVertexDoubleClick()
|
||||
|
Loading…
x
Reference in New Issue
Block a user