Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fb8c8b2

Browse files
vcloarecnyalldawson
authored andcommittedApr 18, 2021
backport #42713
1 parent 4ff8708 commit fb8c8b2

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed
 

‎src/app/qgsmaptooladdcircularstring.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ void QgsMapToolAddCircularString::activate()
144144
{
145145
//mParentTool->captureCurve() is in layer coordinates, but we need map coordinates
146146
QgsPoint endPointLayerCoord = curve->endPoint();
147-
QgsPointXY mapPoint = toMapCoordinates( mCanvas->currentLayer(), QgsPointXY( endPointLayerCoord.x(), endPointLayerCoord.y() ) );
148-
mPoints.append( QgsPoint( mapPoint ) );
147+
QgsPoint mapPoint = toMapCoordinates( mCanvas->currentLayer(), endPointLayerCoord );
148+
mPoints.append( mapPoint );
149149
if ( !mTempRubberBand )
150150
{
151151
mTempRubberBand = createGeometryRubberBand( mLayerType, true );

‎src/gui/qgsmaptoolcapture.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ int QgsMapToolCapture::addVertex( const QgsPointXY &point, const QgsPointLocator
600600
mCaptureLastPoint = mapPoint;
601601
mTempRubberBand->reset( mCaptureMode == CapturePolygon ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, mDigitizingType, firstCapturedMapPoint() );
602602
}
603-
else if ( mCaptureCurve.numPoints() == 0 )
603+
else if ( mTempRubberBand->pointsCount() == 0 )
604604
{
605605
mCaptureLastPoint = mapPoint;
606606
mCaptureCurve.addVertex( layerPoint );

‎tests/src/app/testqgsmaptoolcircularstring.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class TestQgsMapToolCircularString : public QObject
4242
void testAddCircularStringRadius();
4343
void testAddCircularStringCurvePointWithDeletedVertex();
4444
void testAddCircularStringRadiusWithDeletedVertex();
45+
void testAddCircularStringAfterClassicDigitizing();
4546

4647
private:
4748
QgisApp *mQgisApp = nullptr;
@@ -187,5 +188,41 @@ void TestQgsMapToolCircularString::testAddCircularStringRadiusWithDeletedVertex(
187188
mLayer->rollBack();
188189
QgsSettings().setValue( QStringLiteral( "/qgis/digitizing/default_z_value" ), 0 );
189190
}
191+
192+
void TestQgsMapToolCircularString::testAddCircularStringAfterClassicDigitizing()
193+
{
194+
QgsSettings().setValue( QStringLiteral( "/qgis/digitizing/default_z_value" ), 333 );
195+
mLayer->startEditing();
196+
197+
TestQgsMapToolAdvancedDigitizingUtils utilsClassic( mParentTool );
198+
199+
mCanvas->setMapTool( mParentTool );
200+
utilsClassic.mouseClick( 2, 1, Qt::LeftButton );
201+
utilsClassic.mouseClick( 2, 0, Qt::LeftButton );
202+
utilsClassic.mouseClick( 0, 0, Qt::LeftButton );
203+
204+
QgsMapToolCircularStringCurvePoint mapTool( mParentTool, mCanvas );
205+
mCanvas->setMapTool( &mapTool );
206+
207+
TestQgsMapToolAdvancedDigitizingUtils utilsCircular( &mapTool );
208+
utilsCircular.mouseClick( 1, 1, Qt::LeftButton );
209+
utilsCircular.mouseClick( 0, 2, Qt::LeftButton );
210+
211+
mCanvas->setMapTool( mParentTool );
212+
utilsClassic.mouseClick( 2, 2, Qt::LeftButton );
213+
utilsClassic.mouseClick( 4, 2, Qt::LeftButton );
214+
215+
utilsCircular.mouseClick( 4, 2, Qt::RightButton );
216+
QgsFeatureId newFid = utilsCircular.newFeatureId();
217+
218+
QCOMPARE( mLayer->featureCount(), ( long )1 );
219+
QgsFeature f = mLayer->getFeature( newFid );
220+
221+
QString wkt = "CompoundCurveZ ((2 1 333, 2 0 333),(2 0 333, 0 0 333),CircularStringZ (0 0 333, 1 1 333, 0 2 333),(0 2 333, 2 2 333),(2 2 333, 4 2 333))";
222+
QCOMPARE( f.geometry().asWkt(), wkt );
223+
224+
mLayer->rollBack();
225+
QgsSettings().setValue( QStringLiteral( "/qgis/digitizing/default_z_value" ), 0 );
226+
}
190227
QGSTEST_MAIN( TestQgsMapToolCircularString )
191228
#include "testqgsmaptoolcircularstring.moc"

0 commit comments

Comments
 (0)
Please sign in to comment.