diff --git a/python/core/auto_generated/geometry/qgsgeometry.sip.in b/python/core/auto_generated/geometry/qgsgeometry.sip.in index c476e34a418..3629e20bcf5 100644 --- a/python/core/auto_generated/geometry/qgsgeometry.sip.in +++ b/python/core/auto_generated/geometry/qgsgeometry.sip.in @@ -894,7 +894,6 @@ Splits this geometry according to a given curve. :param topological: ``True`` if topological editing is enabled \param[out] topologyTestPoints points that need to be tested for topological completeness in the dataset :param splitFeature: Set to True if you want to split a feature, otherwise set to False to split parts - fix this bug? :return: OperationResult a result code: success or reason of failure diff --git a/python/gui/auto_generated/qgsgeometryrubberband.sip.in b/python/gui/auto_generated/qgsgeometryrubberband.sip.in index 179f044b1c2..3082c66be14 100644 --- a/python/gui/auto_generated/qgsgeometryrubberband.sip.in +++ b/python/gui/auto_generated/qgsgeometryrubberband.sip.in @@ -87,7 +87,7 @@ Sets brush style %Docstring Sets vertex marker icon type %End - void setIsVerticesDrawn( bool isVerticesDrawn ); + void setVertexDrawingEnabled( bool isVerticesDrawn ); %Docstring Sets whether the vertices are drawn %End diff --git a/python/gui/auto_generated/qgsmaptoolcapture.sip.in b/python/gui/auto_generated/qgsmaptoolcapture.sip.in index c59a2f1b41a..d2882de4279 100644 --- a/python/gui/auto_generated/qgsmaptoolcapture.sip.in +++ b/python/gui/auto_generated/qgsmaptoolcapture.sip.in @@ -119,7 +119,7 @@ transfers ownership to the caller. %End public slots: - void setCircularDigitizingEnable( bool enable ); + void setCircularDigitizingEnabled( bool enable ); %Docstring Enable the digitizing with curve %End diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 2906ef8609f..3489a65c349 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -9926,9 +9926,8 @@ void QgisApp::snappingOptions() void QgisApp::enableDigitizeWithCurve( bool enable ) { - mMapTools.mAddFeature->setCircularDigitizingEnable( enable ); - static_cast( mMapTools.mSplitFeatures )->setCircularDigitizingEnable( enable ); - static_cast( mMapTools.mReshapeFeatures )->setCircularDigitizingEnable( enable ); + mMapTools.mAddFeature->setCircularDigitizingEnabled( enable ); + static_cast( mMapTools.mSplitFeatures )->setCircularDigitizingEnabled( enable ); QgsSettings settings; settings.setValue( QStringLiteral( "UI/digitizeWithCurve" ), enable ? 1 : 0 ); } @@ -9941,7 +9940,6 @@ void QgisApp::enableDigitizeWithCurveAction( bool enable ) if ( sender && sender != this ) enable &= ( sender == mActionAddFeature && mMapTools.mAddFeature->mode() != QgsMapToolCapture::CapturePoint ) || sender == mActionSplitFeatures; - else enable &= ( mMapCanvas->mapTool() == mMapTools.mAddFeature && mMapTools.mAddFeature->mode() != QgsMapToolCapture::CapturePoint ) || mMapCanvas->mapTool() == mMapTools.mSplitFeatures; diff --git a/src/core/geometry/qgsgeometry.h b/src/core/geometry/qgsgeometry.h index 1d0fd75418d..e60a3c04d1f 100644 --- a/src/core/geometry/qgsgeometry.h +++ b/src/core/geometry/qgsgeometry.h @@ -920,7 +920,6 @@ class CORE_EXPORT QgsGeometry * \param topological TRUE if topological editing is enabled * \param[out] topologyTestPoints points that need to be tested for topological completeness in the dataset * \param splitFeature Set to True if you want to split a feature, otherwise set to False to split parts - * fix this bug? * \returns OperationResult a result code: success or reason of failure * \since QGIS 3.16 */ diff --git a/src/gui/qgsgeometryrubberband.cpp b/src/gui/qgsgeometryrubberband.cpp index cdb8aa137e4..595e7a8c055 100644 --- a/src/gui/qgsgeometryrubberband.cpp +++ b/src/gui/qgsgeometryrubberband.cpp @@ -160,7 +160,7 @@ void QgsGeometryRubberBand::setBrushStyle( Qt::BrushStyle brushStyle ) mBrush.setStyle( brushStyle ); } -void QgsGeometryRubberBand::setIsVerticesDrawn( bool isVerticesDrawn ) +void QgsGeometryRubberBand::setVertexDrawingEnabled( bool isVerticesDrawn ) { mDrawVertices = isVerticesDrawn; } diff --git a/src/gui/qgsgeometryrubberband.h b/src/gui/qgsgeometryrubberband.h index 80e1a2be61e..88ef4dff4f1 100644 --- a/src/gui/qgsgeometryrubberband.h +++ b/src/gui/qgsgeometryrubberband.h @@ -113,7 +113,7 @@ class GUI_EXPORT QgsGeometryRubberBand: public QgsMapCanvasItem //! Sets vertex marker icon type void setIconType( IconType iconType ) { mIconType = iconType; } //! Sets whether the vertices are drawn - void setIsVerticesDrawn( bool isVerticesDrawn ); + void setVertexDrawingEnabled( bool isVerticesDrawn ); protected: void paint( QPainter *painter ) override; diff --git a/src/gui/qgsmaptoolcapture.cpp b/src/gui/qgsmaptoolcapture.cpp index 6cbbcd5261a..85da06ded2e 100644 --- a/src/gui/qgsmaptoolcapture.cpp +++ b/src/gui/qgsmaptoolcapture.cpp @@ -151,21 +151,12 @@ bool QgsMapToolCapture::tracingEnabled() QgsPointXY QgsMapToolCapture::tracingStartPoint() { -//There is already a try/catch in the toLayerCoordinate() method if transform fails. Can we remove this try/catch? - try - { - // if we have starting point from previous trace, then preferably use that one - // (useful when tracing with offset) - if ( mTracingStartPoint != QgsPointXY() ) - return mTracingStartPoint; + // if we have starting point from previous trace, then preferably use that one + // (useful when tracing with offset) + if ( mTracingStartPoint != QgsPointXY() ) + return mTracingStartPoint; - return lastCapturedMapPoint(); - } - catch ( QgsCsException & ) - { - QgsDebugMsg( QStringLiteral( "transformation to layer coordinate failed" ) ); - return QgsPointXY(); - } + return lastCapturedMapPoint(); } @@ -305,10 +296,10 @@ bool QgsMapToolCapture::tracingAddVertex( const QgsPointXY &point ) return true; } -QgsMapToolCaptureRubberband *QgsMapToolCapture::createCurveRubberBand() const +QgsMapToolCaptureRubberBand *QgsMapToolCapture::createCurveRubberBand() const { QgsSettings settings; - QgsMapToolCaptureRubberband *rb = new QgsMapToolCaptureRubberband( mCanvas ); + QgsMapToolCaptureRubberBand *rb = new QgsMapToolCaptureRubberBand( mCanvas ); QColor color = digitizingStrokeColor(); double alphaScale = settings.value( QStringLiteral( "qgis/digitizing/line_color_alpha_scale" ), 0.75 ).toDouble(); @@ -349,7 +340,7 @@ QgsRubberBand *QgsMapToolCapture::takeRubberBand() return mRubberBand.release(); } -void QgsMapToolCapture::setCircularDigitizingEnable( bool enable ) +void QgsMapToolCapture::setCircularDigitizingEnabled( bool enable ) { mDigitizingType = enable ? QgsWkbTypes::CircularString : QgsWkbTypes::LineString; if ( mTempRubberBand ) @@ -995,13 +986,13 @@ void QgsMapToolCapture::updateExtraSnapLayer() } } -QgsMapToolCaptureRubberband::QgsMapToolCaptureRubberband( QgsMapCanvas *mapCanvas, QgsWkbTypes::GeometryType geomType ): +QgsMapToolCaptureRubberBand::QgsMapToolCaptureRubberBand( QgsMapCanvas *mapCanvas, QgsWkbTypes::GeometryType geomType ): QgsGeometryRubberBand( mapCanvas, geomType ) { - setIsVerticesDrawn( false ); + setVertexDrawingEnabled( false ); } -QgsCurve *QgsMapToolCaptureRubberband::curve() +QgsCurve *QgsMapToolCaptureRubberBand::curve() { if ( mPoints.empty() ) return nullptr; @@ -1024,13 +1015,13 @@ QgsCurve *QgsMapToolCaptureRubberband::curve() } } -bool QgsMapToolCaptureRubberband::curveIsComplete() const +bool QgsMapToolCaptureRubberBand::curveIsComplete() const { return ( mStringType == QgsWkbTypes::LineString && mPoints.count() > 1 ) || ( mStringType == QgsWkbTypes::CircularString && mPoints.count() > 2 ); } -void QgsMapToolCaptureRubberband::reset( QgsWkbTypes::GeometryType geomType, QgsWkbTypes::Type stringType, const QgsPoint &firstPolygonPoint ) +void QgsMapToolCaptureRubberBand::reset( QgsWkbTypes::GeometryType geomType, QgsWkbTypes::Type stringType, const QgsPoint &firstPolygonPoint ) { if ( !( geomType == QgsWkbTypes::LineGeometry || geomType == QgsWkbTypes::PolygonGeometry ) ) return; @@ -1041,13 +1032,13 @@ void QgsMapToolCaptureRubberband::reset( QgsWkbTypes::GeometryType geomType, Qgs setRubberBandGeometryType( geomType ); } -void QgsMapToolCaptureRubberband::setRubberBandGeometryType( QgsWkbTypes::GeometryType geomType ) +void QgsMapToolCaptureRubberBand::setRubberBandGeometryType( QgsWkbTypes::GeometryType geomType ) { QgsGeometryRubberBand::setGeometryType( geomType ); updateCurve(); } -void QgsMapToolCaptureRubberband::addPoint( const QgsPoint &point, bool doUpdate ) +void QgsMapToolCaptureRubberBand::addPoint( const QgsPoint &point, bool doUpdate ) { if ( mPoints.count() == 0 ) mPoints.append( point ); @@ -1058,7 +1049,7 @@ void QgsMapToolCaptureRubberband::addPoint( const QgsPoint &point, bool doUpdate updateCurve(); } -void QgsMapToolCaptureRubberband::movePoint( const QgsPoint &point ) +void QgsMapToolCaptureRubberBand::movePoint( const QgsPoint &point ) { if ( mPoints.count() > 0 ) mPoints.last() = point ; @@ -1066,7 +1057,7 @@ void QgsMapToolCaptureRubberband::movePoint( const QgsPoint &point ) updateCurve(); } -void QgsMapToolCaptureRubberband::movePoint( int index, const QgsPoint &point ) +void QgsMapToolCaptureRubberBand::movePoint( int index, const QgsPoint &point ) { if ( mPoints.count() > 0 && mPoints.size() > index ) mPoints[index] = point; @@ -1074,17 +1065,17 @@ void QgsMapToolCaptureRubberband::movePoint( int index, const QgsPoint &point ) updateCurve(); } -int QgsMapToolCaptureRubberband::pointsCount() +int QgsMapToolCaptureRubberBand::pointsCount() { return mPoints.size(); } -QgsWkbTypes::Type QgsMapToolCaptureRubberband::stringType() const +QgsWkbTypes::Type QgsMapToolCaptureRubberBand::stringType() const { return mStringType; } -void QgsMapToolCaptureRubberband::setStringType( const QgsWkbTypes::Type &type ) +void QgsMapToolCaptureRubberBand::setStringType( const QgsWkbTypes::Type &type ) { if ( ( type != QgsWkbTypes::CircularString && type != QgsWkbTypes::LineString ) || type == mStringType ) return; @@ -1095,11 +1086,11 @@ void QgsMapToolCaptureRubberband::setStringType( const QgsWkbTypes::Type &type ) mPoints.removeAt( 1 ); } - setIsVerticesDrawn( type == QgsWkbTypes::CircularString ); + setVertexDrawingEnabled( type == QgsWkbTypes::CircularString ); updateCurve(); } -QgsPoint QgsMapToolCaptureRubberband::lastPoint() const +QgsPoint QgsMapToolCaptureRubberBand::lastPoint() const { if ( mPoints.empty() ) return QgsPoint(); @@ -1107,7 +1098,7 @@ QgsPoint QgsMapToolCaptureRubberband::lastPoint() const return mPoints.last(); } -QgsPoint QgsMapToolCaptureRubberband::pointFromEnd( int posFromEnd ) const +QgsPoint QgsMapToolCaptureRubberBand::pointFromEnd( int posFromEnd ) const { if ( posFromEnd < mPoints.size() ) return mPoints.at( mPoints.size() - 1 - posFromEnd ); @@ -1115,7 +1106,7 @@ QgsPoint QgsMapToolCaptureRubberband::pointFromEnd( int posFromEnd ) const return QgsPoint(); } -void QgsMapToolCaptureRubberband::removeLastPoint() +void QgsMapToolCaptureRubberBand::removeLastPoint() { if ( mPoints.count() > 1 ) mPoints.removeLast(); @@ -1123,12 +1114,12 @@ void QgsMapToolCaptureRubberband::removeLastPoint() updateCurve(); } -void QgsMapToolCaptureRubberband::setGeometry( QgsAbstractGeometry *geom ) +void QgsMapToolCaptureRubberBand::setGeometry( QgsAbstractGeometry *geom ) { QgsGeometryRubberBand::setGeometry( geom ); } -void QgsMapToolCaptureRubberband::updateCurve() +void QgsMapToolCaptureRubberBand::updateCurve() { std::unique_ptr curve; switch ( mStringType ) @@ -1156,7 +1147,7 @@ void QgsMapToolCaptureRubberband::updateCurve() } } -QgsCurve *QgsMapToolCaptureRubberband::createLinearString() +QgsCurve *QgsMapToolCaptureRubberBand::createLinearString() { std::unique_ptr curve( new QgsLineString ); if ( geometryType() == QgsWkbTypes::PolygonGeometry ) @@ -1171,7 +1162,7 @@ QgsCurve *QgsMapToolCaptureRubberband::createLinearString() return curve.release(); } -QgsCurve *QgsMapToolCaptureRubberband::createCircularString() +QgsCurve *QgsMapToolCaptureRubberBand::createCircularString() { std::unique_ptr curve( new QgsCircularString ); curve->setPoints( mPoints ); diff --git a/src/gui/qgsmaptoolcapture.h b/src/gui/qgsmaptoolcapture.h index d390921d406..f6895157cac 100644 --- a/src/gui/qgsmaptoolcapture.h +++ b/src/gui/qgsmaptoolcapture.h @@ -34,7 +34,7 @@ class QgsSnapIndicator; class QgsVertexMarker; class QgsMapLayer; class QgsGeometryValidator; -class QgsMapToolCaptureRubberband; +class QgsMapToolCaptureRubberBand; #ifndef SIP_RUN @@ -42,15 +42,15 @@ class QgsMapToolCaptureRubberband; ///@cond PRIVATE /** - * Class that reprensents a rubber can that can be linear or circular. + * Class that reprensents a rubber band that can be linear or circular. * * \since QGIS 3.16 */ -class QgsMapToolCaptureRubberband: public QgsGeometryRubberBand +class QgsMapToolCaptureRubberBand: public QgsGeometryRubberBand { public: //! Constructor - QgsMapToolCaptureRubberband( QgsMapCanvas *mapCanvas, QgsWkbTypes::GeometryType geomType = QgsWkbTypes::LineGeometry ); + QgsMapToolCaptureRubberBand( QgsMapCanvas *mapCanvas, QgsWkbTypes::GeometryType geomType = QgsWkbTypes::LineGeometry ); //! Returns the curve defined by the rubber band, the caller has to take the ownership, nullptr if no curve is defined. QgsCurve *curve(); @@ -213,7 +213,7 @@ class GUI_EXPORT QgsMapToolCapture : public QgsMapToolAdvancedDigitizing public slots: //! Enable the digitizing with curve - void setCircularDigitizingEnable( bool enable ); + void setCircularDigitizingEnabled( bool enable ); private slots: void addError( const QgsGeometry::Error &error ); @@ -378,7 +378,7 @@ class GUI_EXPORT QgsMapToolCapture : public QgsMapToolAdvancedDigitizing bool tracingAddVertex( const QgsPointXY &point ); //! create a curve rubber band - QgsMapToolCaptureRubberband *createCurveRubberBand() const; + QgsMapToolCaptureRubberBand *createCurveRubberBand() const; //! Returns extemity point of the captured curve in map coordinates QgsPoint firstCapturedMapPoint(); @@ -398,7 +398,7 @@ class GUI_EXPORT QgsMapToolCapture : public QgsMapToolAdvancedDigitizing QObjectUniquePtr mRubberBand; //! Temporary rubber band for polylines and polygons. this connects the last added point to the mouse cursor position - std::unique_ptr mTempRubberBand; + std::unique_ptr mTempRubberBand; //! List to store the points of digitized lines and polygons (in layer coordinates) QgsCompoundCurve mCaptureCurve; diff --git a/tests/src/app/testqgsmaptooladdfeatureline.cpp b/tests/src/app/testqgsmaptooladdfeatureline.cpp index de6ee992085..c29f958bbd6 100644 --- a/tests/src/app/testqgsmaptooladdfeatureline.cpp +++ b/tests/src/app/testqgsmaptooladdfeatureline.cpp @@ -283,7 +283,7 @@ void TestQgsMapToolAddFeatureLine::testNoTracing() mLayerLine->undoStack()->undo(); QCOMPARE( mLayerLine->undoStack()->index(), 1 ); - mCaptureTool->setCircularDigitizingEnable( true ); + mCaptureTool->setCircularDigitizingEnabled( true ); utils.mouseClick( 1, 1, Qt::LeftButton ); utils.mouseClick( 3, 2, Qt::LeftButton ); @@ -305,7 +305,7 @@ void TestQgsMapToolAddFeatureLine::testNoTracing() mLayerLine->undoStack()->undo(); QCOMPARE( mLayerLine->undoStack()->index(), 1 ); - mCaptureTool->setCircularDigitizingEnable( false ); + mCaptureTool->setCircularDigitizingEnabled( false ); } void TestQgsMapToolAddFeatureLine::testTracing()