diff --git a/python/PyQt6/core/auto_additions/qgis.py b/python/PyQt6/core/auto_additions/qgis.py index 3f0acb5a87d..28a4da2216d 100644 --- a/python/PyQt6/core/auto_additions/qgis.py +++ b/python/PyQt6/core/auto_additions/qgis.py @@ -11161,6 +11161,23 @@ Qgis.PointCloudZoomOutRenderBehavior.__doc__ = """Point cloud zoom out options """ # -- Qgis.PointCloudZoomOutRenderBehavior.baseClass = Qgis +# monkey patching scoped based enum +Qgis.SegmentCalculationMethod.Standard.__doc__ = "Standard sagitta-based calculation" +Qgis.SegmentCalculationMethod.Adaptive.__doc__ = "Adaptive calculation based on radius size" +Qgis.SegmentCalculationMethod.AreaError.__doc__ = "Calculation based on area error" +Qgis.SegmentCalculationMethod.ConstantDensity.__doc__ = "Simple calculation with constant segment density" +Qgis.SegmentCalculationMethod.__doc__ = """brief Method used to calculate the number of segments for circle approximation + +.. versionadded:: 3.44 + +* ``Standard``: Standard sagitta-based calculation +* ``Adaptive``: Adaptive calculation based on radius size +* ``AreaError``: Calculation based on area error +* ``ConstantDensity``: Simple calculation with constant segment density + +""" +# -- +Qgis.SegmentCalculationMethod.baseClass = Qgis try: Qgis.__attribute_docs__ = {'QGIS_DEV_VERSION': 'The development version', 'DEFAULT_SEARCH_RADIUS_MM': 'Identify search radius in mm', 'DEFAULT_MAPTOPIXEL_THRESHOLD': 'Default threshold between map coordinates and device coordinates for map2pixel simplification', 'DEFAULT_HIGHLIGHT_COLOR': 'Default highlight color. The transparency is expected to only be applied to polygon\nfill. Lines and outlines are rendered opaque.', 'DEFAULT_HIGHLIGHT_BUFFER_MM': 'Default highlight buffer in mm.', 'DEFAULT_HIGHLIGHT_MIN_WIDTH_MM': 'Default highlight line/stroke minimum width in mm.', 'SCALE_PRECISION': 'Fudge factor used to compare two scales. The code is often going from scale to scale\ndenominator. So it looses precision and, when a limit is inclusive, can lead to errors.\nTo avoid that, use this factor instead of using <= or >=.\n\n.. deprecated:: 3.40\n\n No longer used by QGIS and will be removed in QGIS 4.0.', 'DEFAULT_Z_COORDINATE': 'Default Z coordinate value.\nThis value have to be assigned to the Z coordinate for the vertex.', 'DEFAULT_M_COORDINATE': 'Default M coordinate value.\nThis value have to be assigned to the M coordinate for the vertex.\n\n.. versionadded:: 3.20', 'UI_SCALE_FACTOR': 'UI scaling factor. This should be applied to all widget sizes obtained from font metrics,\nto account for differences in the default font sizes across different platforms.', 'DEFAULT_SNAP_TOLERANCE': 'Default snapping distance tolerance.', 'DEFAULT_SNAP_UNITS': 'Default snapping distance units.'} Qgis.version = staticmethod(Qgis.version) diff --git a/python/PyQt6/core/auto_additions/qgscircle.py b/python/PyQt6/core/auto_additions/qgscircle.py index 05b32ed8dfb..78dcca726e5 100644 --- a/python/PyQt6/core/auto_additions/qgscircle.py +++ b/python/PyQt6/core/auto_additions/qgscircle.py @@ -1,20 +1,4 @@ # The following has been generated automatically from src/core/geometry/qgscircle.h -# monkey patching scoped based enum -QgsCircle.SegmentCalculationMethod.Standard.__doc__ = "Standard sagitta-based calculation" -QgsCircle.SegmentCalculationMethod.Adaptive.__doc__ = "Adaptive calculation based on radius size" -QgsCircle.SegmentCalculationMethod.AreaError.__doc__ = "Calculation based on area error" -QgsCircle.SegmentCalculationMethod.ConstantDensity.__doc__ = "Simple calculation with constant segment density" -QgsCircle.SegmentCalculationMethod.__doc__ = """Method used to calculate the number of segments for circle approximation - -.. versionadded:: 3.44 - -* ``Standard``: Standard sagitta-based calculation -* ``Adaptive``: Adaptive calculation based on radius size -* ``AreaError``: Calculation based on area error -* ``ConstantDensity``: Simple calculation with constant segment density - -""" -# -- try: QgsCircle.from2Points = staticmethod(QgsCircle.from2Points) QgsCircle.from3Points = staticmethod(QgsCircle.from3Points) @@ -25,6 +9,7 @@ try: QgsCircle.fromExtent = staticmethod(QgsCircle.fromExtent) QgsCircle.minimalCircleFrom3Points = staticmethod(QgsCircle.minimalCircleFrom3Points) QgsCircle.calculateSegments = staticmethod(QgsCircle.calculateSegments) + QgsCircle.calculateSegmentsStandard = staticmethod(QgsCircle.calculateSegmentsStandard) QgsCircle.calculateSegmentsAdaptive = staticmethod(QgsCircle.calculateSegmentsAdaptive) QgsCircle.calculateSegmentsByAreaError = staticmethod(QgsCircle.calculateSegmentsByAreaError) QgsCircle.calculateSegmentsByConstant = staticmethod(QgsCircle.calculateSegmentsByConstant) diff --git a/python/PyQt6/core/auto_generated/geometry/qgscircle.sip.in b/python/PyQt6/core/auto_generated/geometry/qgscircle.sip.in index 63b1d62dd54..501b91fb1f2 100644 --- a/python/PyQt6/core/auto_generated/geometry/qgscircle.sip.in +++ b/python/PyQt6/core/auto_generated/geometry/qgscircle.sip.in @@ -377,15 +377,7 @@ Coordinates are taken from quadrant North, East and South. .. seealso:: :py:func:`asGml2` %End - enum class SegmentCalculationMethod - { - Standard, - Adaptive, - AreaError, - ConstantDensity - }; - - static int calculateSegments( double radius, double parameter, int minSegments, SegmentCalculationMethod method ); + static int calculateSegments( double radius, double parameter, int minSegments, Qgis::SegmentCalculationMethod method ); %Docstring Calculates the number of segments needed to approximate a circle. @@ -414,7 +406,7 @@ Calculates the number of segments needed to approximate a circle. private : - static int + static int calculateSegmentsStandard( double radius, double tolerance, int minSegments ); %Docstring Calculate the number of segments needed to approximate a circle within a given tolerance. @@ -445,7 +437,6 @@ cos(θ/2) = 1 - tolerance/radius This is a private helper method %End - calculateSegmentsStandard( double radius, double tolerance, int minSegments ); static int calculateSegmentsAdaptive( double radius, double tolerance, int minSegments ); %Docstring diff --git a/python/PyQt6/core/auto_generated/qgis.sip.in b/python/PyQt6/core/auto_generated/qgis.sip.in index 2c8ae9e630e..1e0c27a9c2e 100644 --- a/python/PyQt6/core/auto_generated/qgis.sip.in +++ b/python/PyQt6/core/auto_generated/qgis.sip.in @@ -3271,6 +3271,14 @@ The development version RenderOverviewAndExtents }; + enum class SegmentCalculationMethod /BaseType=IntEnum/ + { + Standard, + Adaptive, + AreaError, + ConstantDensity + }; + static const double DEFAULT_SEARCH_RADIUS_MM; static const float DEFAULT_MAPTOPIXEL_THRESHOLD; diff --git a/python/core/auto_additions/qgis.py b/python/core/auto_additions/qgis.py index a45fb29ec11..ce7a57dbe50 100644 --- a/python/core/auto_additions/qgis.py +++ b/python/core/auto_additions/qgis.py @@ -11070,6 +11070,23 @@ Qgis.PointCloudZoomOutRenderBehavior.__doc__ = """Point cloud zoom out options """ # -- Qgis.PointCloudZoomOutRenderBehavior.baseClass = Qgis +# monkey patching scoped based enum +Qgis.SegmentCalculationMethod.Standard.__doc__ = "Standard sagitta-based calculation" +Qgis.SegmentCalculationMethod.Adaptive.__doc__ = "Adaptive calculation based on radius size" +Qgis.SegmentCalculationMethod.AreaError.__doc__ = "Calculation based on area error" +Qgis.SegmentCalculationMethod.ConstantDensity.__doc__ = "Simple calculation with constant segment density" +Qgis.SegmentCalculationMethod.__doc__ = """brief Method used to calculate the number of segments for circle approximation + +.. versionadded:: 3.44 + +* ``Standard``: Standard sagitta-based calculation +* ``Adaptive``: Adaptive calculation based on radius size +* ``AreaError``: Calculation based on area error +* ``ConstantDensity``: Simple calculation with constant segment density + +""" +# -- +Qgis.SegmentCalculationMethod.baseClass = Qgis from enum import Enum diff --git a/python/core/auto_additions/qgscircle.py b/python/core/auto_additions/qgscircle.py index 05b32ed8dfb..78dcca726e5 100644 --- a/python/core/auto_additions/qgscircle.py +++ b/python/core/auto_additions/qgscircle.py @@ -1,20 +1,4 @@ # The following has been generated automatically from src/core/geometry/qgscircle.h -# monkey patching scoped based enum -QgsCircle.SegmentCalculationMethod.Standard.__doc__ = "Standard sagitta-based calculation" -QgsCircle.SegmentCalculationMethod.Adaptive.__doc__ = "Adaptive calculation based on radius size" -QgsCircle.SegmentCalculationMethod.AreaError.__doc__ = "Calculation based on area error" -QgsCircle.SegmentCalculationMethod.ConstantDensity.__doc__ = "Simple calculation with constant segment density" -QgsCircle.SegmentCalculationMethod.__doc__ = """Method used to calculate the number of segments for circle approximation - -.. versionadded:: 3.44 - -* ``Standard``: Standard sagitta-based calculation -* ``Adaptive``: Adaptive calculation based on radius size -* ``AreaError``: Calculation based on area error -* ``ConstantDensity``: Simple calculation with constant segment density - -""" -# -- try: QgsCircle.from2Points = staticmethod(QgsCircle.from2Points) QgsCircle.from3Points = staticmethod(QgsCircle.from3Points) @@ -25,6 +9,7 @@ try: QgsCircle.fromExtent = staticmethod(QgsCircle.fromExtent) QgsCircle.minimalCircleFrom3Points = staticmethod(QgsCircle.minimalCircleFrom3Points) QgsCircle.calculateSegments = staticmethod(QgsCircle.calculateSegments) + QgsCircle.calculateSegmentsStandard = staticmethod(QgsCircle.calculateSegmentsStandard) QgsCircle.calculateSegmentsAdaptive = staticmethod(QgsCircle.calculateSegmentsAdaptive) QgsCircle.calculateSegmentsByAreaError = staticmethod(QgsCircle.calculateSegmentsByAreaError) QgsCircle.calculateSegmentsByConstant = staticmethod(QgsCircle.calculateSegmentsByConstant) diff --git a/python/core/auto_generated/geometry/qgscircle.sip.in b/python/core/auto_generated/geometry/qgscircle.sip.in index 63b1d62dd54..501b91fb1f2 100644 --- a/python/core/auto_generated/geometry/qgscircle.sip.in +++ b/python/core/auto_generated/geometry/qgscircle.sip.in @@ -377,15 +377,7 @@ Coordinates are taken from quadrant North, East and South. .. seealso:: :py:func:`asGml2` %End - enum class SegmentCalculationMethod - { - Standard, - Adaptive, - AreaError, - ConstantDensity - }; - - static int calculateSegments( double radius, double parameter, int minSegments, SegmentCalculationMethod method ); + static int calculateSegments( double radius, double parameter, int minSegments, Qgis::SegmentCalculationMethod method ); %Docstring Calculates the number of segments needed to approximate a circle. @@ -414,7 +406,7 @@ Calculates the number of segments needed to approximate a circle. private : - static int + static int calculateSegmentsStandard( double radius, double tolerance, int minSegments ); %Docstring Calculate the number of segments needed to approximate a circle within a given tolerance. @@ -445,7 +437,6 @@ cos(θ/2) = 1 - tolerance/radius This is a private helper method %End - calculateSegmentsStandard( double radius, double tolerance, int minSegments ); static int calculateSegmentsAdaptive( double radius, double tolerance, int minSegments ); %Docstring diff --git a/python/core/auto_generated/qgis.sip.in b/python/core/auto_generated/qgis.sip.in index f6e2c40a25d..48b8be7b6c0 100644 --- a/python/core/auto_generated/qgis.sip.in +++ b/python/core/auto_generated/qgis.sip.in @@ -3271,6 +3271,14 @@ The development version RenderOverviewAndExtents }; + enum class SegmentCalculationMethod + { + Standard, + Adaptive, + AreaError, + ConstantDensity + }; + static const double DEFAULT_SEARCH_RADIUS_MM; static const float DEFAULT_MAPTOPIXEL_THRESHOLD; diff --git a/src/core/geometry/qgscircle.cpp b/src/core/geometry/qgscircle.cpp index 21122253a53..350abf28f56 100644 --- a/src/core/geometry/qgscircle.cpp +++ b/src/core/geometry/qgscircle.cpp @@ -485,7 +485,7 @@ QDomElement QgsCircle::asGml3( QDomDocument &doc, int precision, const QString & return elemCircle; } -int QgsCircle::calculateSegments( double radius, double parameter, int minSegments, SegmentCalculationMethod method ) +int QgsCircle::calculateSegments( double radius, double parameter, int minSegments, Qgis::SegmentCalculationMethod method ) { if ( radius <= 0.0 ) { @@ -504,13 +504,13 @@ int QgsCircle::calculateSegments( double radius, double parameter, int minSegmen switch ( method ) { - case SegmentCalculationMethod::Standard: + case Qgis::SegmentCalculationMethod::Standard: return calculateSegmentsStandard( radius, parameter, minSegments ); - case SegmentCalculationMethod::Adaptive: + case Qgis::SegmentCalculationMethod::Adaptive: return calculateSegmentsAdaptive( radius, parameter, minSegments ); - case SegmentCalculationMethod::AreaError: + case Qgis::SegmentCalculationMethod::AreaError: return calculateSegmentsByAreaError( radius, parameter, minSegments ); - case SegmentCalculationMethod::ConstantDensity: + case Qgis::SegmentCalculationMethod::ConstantDensity: return calculateSegmentsByConstant( radius, parameter, minSegments ); default: return calculateSegmentsStandard( radius, parameter, minSegments ); diff --git a/src/core/geometry/qgscircle.h b/src/core/geometry/qgscircle.h index df0ace2f978..429e16110ae 100644 --- a/src/core/geometry/qgscircle.h +++ b/src/core/geometry/qgscircle.h @@ -356,19 +356,6 @@ class CORE_EXPORT QgsCircle : public QgsEllipse */ QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const; - /** - * \brief Method used to calculate the number of segments for circle approximation - * \ingroup core - * \since QGIS 3.44 - */ - enum class SegmentCalculationMethod - { - Standard = 0, //!< Standard sagitta-based calculation - Adaptive, //!< Adaptive calculation based on radius size - AreaError, //!< Calculation based on area error - ConstantDensity //!< Simple calculation with constant segment density - }; - /** * Calculates the number of segments needed to approximate a circle. * @@ -385,7 +372,7 @@ class CORE_EXPORT QgsCircle : public QgsEllipse * * \since QGIS 3.44 */ - static int calculateSegments( double radius, double parameter, int minSegments, SegmentCalculationMethod method ); + static int calculateSegments( double radius, double parameter, int minSegments, Qgis::SegmentCalculationMethod method ); #ifdef SIP_RUN @@ -425,8 +412,7 @@ class CORE_EXPORT QgsCircle : public QgsEllipse * \returns The number of segments needed * \note This is a private helper method */ - static int - calculateSegmentsStandard( double radius, double tolerance, int minSegments ) + static int calculateSegmentsStandard( double radius, double tolerance, int minSegments ) { if ( tolerance >= radius ) { diff --git a/src/core/qgis.h b/src/core/qgis.h index 701dfaa6d32..8cff42bde3c 100644 --- a/src/core/qgis.h +++ b/src/core/qgis.h @@ -5766,6 +5766,19 @@ class CORE_EXPORT Qgis }; Q_ENUM( PointCloudZoomOutRenderBehavior ) + /** + * brief Method used to calculate the number of segments for circle approximation + * \since QGIS 3.44 + */ + enum class SegmentCalculationMethod : int + { + Standard = 0, //!< Standard sagitta-based calculation + Adaptive, //!< Adaptive calculation based on radius size + AreaError, //!< Calculation based on area error + ConstantDensity //!< Simple calculation with constant segment density + }; + Q_ENUM( SegmentCalculationMethod ) + /** * Identify search radius in mm */ diff --git a/tests/src/python/test_qgscircle.py b/tests/src/python/test_qgscircle.py index dd12c0c7ecd..53caa50b076 100644 --- a/tests/src/python/test_qgscircle.py +++ b/tests/src/python/test_qgscircle.py @@ -12,7 +12,7 @@ __copyright__ = "Copyright 2025, The QGIS Project" import qgis # NOQA -from qgis.core import QgsCircle, QgsPoint +from qgis.core import Qgis, QgsCircle, QgsPoint import unittest from qgis.testing import start_app, QgisTestCase @@ -55,25 +55,25 @@ class TestQgsCircularString(QgisTestCase): radius, tolerance, min_segments, - QgsCircle.SegmentCalculationMethod.Standard, + Qgis.SegmentCalculationMethod.Standard, ) adaptive_segments = circle.calculateSegments( radius, tolerance, min_segments, - QgsCircle.SegmentCalculationMethod.Adaptive, + Qgis.SegmentCalculationMethod.Adaptive, ) area_segments = circle.calculateSegments( radius, tolerance, min_segments, - QgsCircle.SegmentCalculationMethod.AreaError, + Qgis.SegmentCalculationMethod.AreaError, ) constant_segments = circle.calculateSegments( radius, constant, min_segments, - QgsCircle.SegmentCalculationMethod.ConstantDensity, + Qgis.SegmentCalculationMethod.ConstantDensity, ) # Store current results