Skip to content

Commit

Permalink
Promote scalebar enums to enum class, move to Qgis
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 3, 2024
1 parent ebcb7f9 commit 82d2189
Show file tree
Hide file tree
Showing 25 changed files with 348 additions and 222 deletions.
56 changes: 56 additions & 0 deletions python/PyQt6/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4584,6 +4584,62 @@
Qgis.LayoutUnitType.__doc__ = "Types of layout units\n\n.. note::\n\n Prior to QGIS 3.30 this was available as :py:class:`QgsUnitTypes`.LayoutUnitType.\n\n.. versionadded:: 3.30\n\n" + '* ``LayoutPaperUnits``: ' + Qgis.LayoutUnitType.PaperUnits.__doc__ + '\n' + '* ``LayoutScreenUnits``: ' + Qgis.LayoutUnitType.ScreenUnits.__doc__
# --
Qgis.LayoutUnitType.baseClass = Qgis
QgsScaleBarSettings.Alignment = Qgis.ScaleBarAlignment
# monkey patching scoped based enum
QgsScaleBarSettings.AlignLeft = Qgis.ScaleBarAlignment.Left
QgsScaleBarSettings.Alignment.AlignLeft = Qgis.ScaleBarAlignment.Left
QgsScaleBarSettings.AlignLeft.is_monkey_patched = True
QgsScaleBarSettings.AlignLeft.__doc__ = "Left aligned"
QgsScaleBarSettings.AlignMiddle = Qgis.ScaleBarAlignment.Middle
QgsScaleBarSettings.Alignment.AlignMiddle = Qgis.ScaleBarAlignment.Middle
QgsScaleBarSettings.AlignMiddle.is_monkey_patched = True
QgsScaleBarSettings.AlignMiddle.__doc__ = "Center aligned"
QgsScaleBarSettings.AlignRight = Qgis.ScaleBarAlignment.Right
QgsScaleBarSettings.Alignment.AlignRight = Qgis.ScaleBarAlignment.Right
QgsScaleBarSettings.AlignRight.is_monkey_patched = True
QgsScaleBarSettings.AlignRight.__doc__ = "Right aligned"
Qgis.ScaleBarAlignment.__doc__ = "Scalebar alignment.\n\n.. note::\n\n Prior to QGIS 3.40 this was available as :py:class:`QgsScaleBarSettings`.Alignment.\n\n.. versionadded:: 3.40\n\n" + '* ``AlignLeft``: ' + Qgis.ScaleBarAlignment.Left.__doc__ + '\n' + '* ``AlignMiddle``: ' + Qgis.ScaleBarAlignment.Middle.__doc__ + '\n' + '* ``AlignRight``: ' + Qgis.ScaleBarAlignment.Right.__doc__
# --
Qgis.ScaleBarAlignment.baseClass = Qgis
QgsScaleBarSettings.SegmentSizeMode = Qgis.ScaleBarSegmentSizeMode
# monkey patching scoped based enum
QgsScaleBarSettings.SegmentSizeFixed = Qgis.ScaleBarSegmentSizeMode.Fixed
QgsScaleBarSettings.SegmentSizeMode.SegmentSizeFixed = Qgis.ScaleBarSegmentSizeMode.Fixed
QgsScaleBarSettings.SegmentSizeFixed.is_monkey_patched = True
QgsScaleBarSettings.SegmentSizeFixed.__doc__ = "Scale bar segment size is fixed to a map unit"
QgsScaleBarSettings.SegmentSizeFitWidth = Qgis.ScaleBarSegmentSizeMode.FitWidth
QgsScaleBarSettings.SegmentSizeMode.SegmentSizeFitWidth = Qgis.ScaleBarSegmentSizeMode.FitWidth
QgsScaleBarSettings.SegmentSizeFitWidth.is_monkey_patched = True
QgsScaleBarSettings.SegmentSizeFitWidth.__doc__ = "Scale bar segment size is calculated to fit a size range"
Qgis.ScaleBarSegmentSizeMode.__doc__ = "Modes for setting size for scale bar segments.\n\n.. note::\n\n Prior to QGIS 3.40 this was available as :py:class:`QgsScaleBarSettings`.SegmentSizeMode.\n\n.. versionadded:: 3.40\n\n" + '* ``SegmentSizeFixed``: ' + Qgis.ScaleBarSegmentSizeMode.Fixed.__doc__ + '\n' + '* ``SegmentSizeFitWidth``: ' + Qgis.ScaleBarSegmentSizeMode.FitWidth.__doc__
# --
Qgis.ScaleBarSegmentSizeMode.baseClass = Qgis
QgsScaleBarSettings.LabelVerticalPlacement = Qgis.ScaleBarDistanceLabelVerticalPlacement
# monkey patching scoped based enum
QgsScaleBarSettings.LabelAboveSegment = Qgis.ScaleBarDistanceLabelVerticalPlacement.AboveSegment
QgsScaleBarSettings.LabelVerticalPlacement.LabelAboveSegment = Qgis.ScaleBarDistanceLabelVerticalPlacement.AboveSegment
QgsScaleBarSettings.LabelAboveSegment.is_monkey_patched = True
QgsScaleBarSettings.LabelAboveSegment.__doc__ = "Labels are drawn above the scalebar"
QgsScaleBarSettings.LabelBelowSegment = Qgis.ScaleBarDistanceLabelVerticalPlacement.BelowSegment
QgsScaleBarSettings.LabelVerticalPlacement.LabelBelowSegment = Qgis.ScaleBarDistanceLabelVerticalPlacement.BelowSegment
QgsScaleBarSettings.LabelBelowSegment.is_monkey_patched = True
QgsScaleBarSettings.LabelBelowSegment.__doc__ = "Labels are drawn below the scalebar"
Qgis.ScaleBarDistanceLabelVerticalPlacement.__doc__ = "Scale bar distance label vertical placement.\n\n.. note::\n\n Prior to QGIS 3.40 this was available as :py:class:`QgsScaleBarSettings`.LabelVerticalPlacement.\n\n.. versionadded:: 3.40\n\n" + '* ``LabelAboveSegment``: ' + Qgis.ScaleBarDistanceLabelVerticalPlacement.AboveSegment.__doc__ + '\n' + '* ``LabelBelowSegment``: ' + Qgis.ScaleBarDistanceLabelVerticalPlacement.BelowSegment.__doc__
# --
Qgis.ScaleBarDistanceLabelVerticalPlacement.baseClass = Qgis
QgsScaleBarSettings.LabelHorizontalPlacement = Qgis.ScaleBarDistanceLabelHorizontalPlacement
# monkey patching scoped based enum
QgsScaleBarSettings.LabelCenteredEdge = Qgis.ScaleBarDistanceLabelHorizontalPlacement.CenteredEdge
QgsScaleBarSettings.LabelHorizontalPlacement.LabelCenteredEdge = Qgis.ScaleBarDistanceLabelHorizontalPlacement.CenteredEdge
QgsScaleBarSettings.LabelCenteredEdge.is_monkey_patched = True
QgsScaleBarSettings.LabelCenteredEdge.__doc__ = "Labels are drawn centered relative to segment's edge"
QgsScaleBarSettings.LabelCenteredSegment = Qgis.ScaleBarDistanceLabelHorizontalPlacement.CenteredSegment
QgsScaleBarSettings.LabelHorizontalPlacement.LabelCenteredSegment = Qgis.ScaleBarDistanceLabelHorizontalPlacement.CenteredSegment
QgsScaleBarSettings.LabelCenteredSegment.is_monkey_patched = True
QgsScaleBarSettings.LabelCenteredSegment.__doc__ = "Labels are drawn centered relative to segment"
Qgis.ScaleBarDistanceLabelHorizontalPlacement.__doc__ = "Scale bar distance label horizontal placement.\n\n.. note::\n\n Prior to QGIS 3.40 this was available as :py:class:`QgsScaleBarSettings`.LabelHorizontalPlacement.\n\n.. versionadded:: 3.40\n\n" + '* ``LabelCenteredEdge``: ' + Qgis.ScaleBarDistanceLabelHorizontalPlacement.CenteredEdge.__doc__ + '\n' + '* ``LabelCenteredSegment``: ' + Qgis.ScaleBarDistanceLabelHorizontalPlacement.CenteredSegment.__doc__
# --
Qgis.ScaleBarDistanceLabelHorizontalPlacement.baseClass = Qgis
# monkey patching scoped based enum
Qgis.InputControllerType.Map2D.__doc__ = "2D map controller"
Qgis.InputControllerType.Map3D.__doc__ = "3D map controller"
Expand Down
10 changes: 0 additions & 10 deletions python/PyQt6/core/auto_additions/qgsscalebarsettings.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Sets the number of scalebar ``units`` per segment.
.. seealso:: :py:func:`unitsPerSegment`
%End

QgsScaleBarSettings::SegmentSizeMode segmentSizeMode() const;
Qgis::ScaleBarSegmentSizeMode segmentSizeMode() const;
%Docstring
Returns the size mode for the scale bar segments.

Expand All @@ -145,7 +145,7 @@ Returns the size mode for the scale bar segments.
.. seealso:: :py:func:`maximumBarWidth`
%End

void setSegmentSizeMode( QgsScaleBarSettings::SegmentSizeMode mode );
void setSegmentSizeMode( Qgis::ScaleBarSegmentSizeMode mode );
%Docstring
Sets the size ``mode`` for scale bar segments.

Expand Down Expand Up @@ -617,7 +617,7 @@ Sets the ``space`` (margin) between the scalebar box and content in millimeters.
.. seealso:: :py:func:`boxContentSpace`
%End

QgsScaleBarSettings::LabelVerticalPlacement labelVerticalPlacement() const;
Qgis::ScaleBarDistanceLabelVerticalPlacement labelVerticalPlacement() const;
%Docstring
Returns the vertical placement of text labels.

Expand All @@ -626,7 +626,7 @@ Returns the vertical placement of text labels.
.. versionadded:: 3.10
%End

void setLabelVerticalPlacement( QgsScaleBarSettings::LabelVerticalPlacement placement );
void setLabelVerticalPlacement( Qgis::ScaleBarDistanceLabelVerticalPlacement placement );
%Docstring
Sets the vertical ``placement`` of text labels.

Expand All @@ -635,7 +635,7 @@ Sets the vertical ``placement`` of text labels.
.. versionadded:: 3.10
%End

QgsScaleBarSettings::LabelHorizontalPlacement labelHorizontalPlacement() const;
Qgis::ScaleBarDistanceLabelHorizontalPlacement labelHorizontalPlacement() const;
%Docstring
Returns the horizontal placement of text labels.

Expand All @@ -644,7 +644,7 @@ Returns the horizontal placement of text labels.
.. versionadded:: 3.10
%End

void setLabelHorizontalPlacement( QgsScaleBarSettings::LabelHorizontalPlacement placement );
void setLabelHorizontalPlacement( Qgis::ScaleBarDistanceLabelHorizontalPlacement placement );
%Docstring
Sets the horizontal ``placement`` of text labels.

Expand All @@ -653,14 +653,14 @@ Sets the horizontal ``placement`` of text labels.
.. versionadded:: 3.10
%End

QgsScaleBarSettings::Alignment alignment() const;
Qgis::ScaleBarAlignment alignment() const;
%Docstring
Returns the scalebar alignment.

.. seealso:: :py:func:`setAlignment`
%End

void setAlignment( QgsScaleBarSettings::Alignment alignment );
void setAlignment( Qgis::ScaleBarAlignment alignment );
%Docstring
Sets the scalebar ``alignment``.

Expand Down
25 changes: 25 additions & 0 deletions python/PyQt6/core/auto_generated/qgis.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -2542,6 +2542,31 @@ The development version
ScreenUnits
};

enum class ScaleBarAlignment /BaseType=IntEnum/
{
Left,
Middle,
Right,
};

enum class ScaleBarSegmentSizeMode /BaseType=IntEnum/
{
Fixed,
FitWidth
};

enum class ScaleBarDistanceLabelVerticalPlacement /BaseType=IntEnum/
{
AboveSegment,
BelowSegment,
};

enum class ScaleBarDistanceLabelHorizontalPlacement /BaseType=IntEnum/
{
CenteredEdge,
CenteredSegment,
};

enum class InputControllerType /BaseType=IntEnum/
{
Map2D,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,6 @@ for scalebar drawing with :py:class:`QgsScaleBarRenderer`.
%End
public:

enum Alignment /BaseType=IntEnum/
{
AlignLeft,
AlignMiddle,
AlignRight,
};

enum SegmentSizeMode /BaseType=IntEnum/
{
SegmentSizeFixed,
SegmentSizeFitWidth
};

enum LabelVerticalPlacement /BaseType=IntEnum/
{
LabelAboveSegment,
LabelBelowSegment,
};

enum LabelHorizontalPlacement /BaseType=IntEnum/
{
LabelCenteredEdge,
LabelCenteredSegment,
};

QgsScaleBarSettings();
%Docstring
Constructor for QgsScaleBarSettings.
Expand Down Expand Up @@ -155,7 +130,7 @@ Sets the number of scalebar ``units`` per segment.
.. seealso:: :py:func:`unitsPerSegment`
%End

SegmentSizeMode segmentSizeMode() const;
Qgis::ScaleBarSegmentSizeMode segmentSizeMode() const;
%Docstring
Returns the size mode for the scale bar segments.

Expand All @@ -166,7 +141,7 @@ Returns the size mode for the scale bar segments.
.. seealso:: :py:func:`maximumBarWidth`
%End

void setSegmentSizeMode( SegmentSizeMode mode );
void setSegmentSizeMode( Qgis::ScaleBarSegmentSizeMode mode );
%Docstring
Sets the size ``mode`` for scale bar segments.

Expand Down Expand Up @@ -657,7 +632,7 @@ Sets the spacing (in millimeters) between labels and the scalebar.
.. seealso:: :py:func:`labelBarSpace`
%End

LabelVerticalPlacement labelVerticalPlacement() const;
Qgis::ScaleBarDistanceLabelVerticalPlacement labelVerticalPlacement() const;
%Docstring
Returns the vertical placement of text labels.

Expand All @@ -666,7 +641,7 @@ Returns the vertical placement of text labels.
.. versionadded:: 3.10
%End

void setLabelVerticalPlacement( LabelVerticalPlacement placement );
void setLabelVerticalPlacement( Qgis::ScaleBarDistanceLabelVerticalPlacement placement );
%Docstring
Sets the vertical ``placement`` of text labels.

Expand All @@ -675,7 +650,7 @@ Sets the vertical ``placement`` of text labels.
.. versionadded:: 3.10
%End

LabelHorizontalPlacement labelHorizontalPlacement() const;
Qgis::ScaleBarDistanceLabelHorizontalPlacement labelHorizontalPlacement() const;
%Docstring
Returns the horizontal placement of text labels.

Expand All @@ -684,7 +659,7 @@ Returns the horizontal placement of text labels.
.. versionadded:: 3.10
%End

void setLabelHorizontalPlacement( LabelHorizontalPlacement placement );
void setLabelHorizontalPlacement( Qgis::ScaleBarDistanceLabelHorizontalPlacement placement );
%Docstring
Sets the horizontal ``placement`` of text labels.

Expand All @@ -707,14 +682,14 @@ Sets the ``space`` (margin) between the scalebar box and content in millimeters.
.. seealso:: :py:func:`boxContentSpace`
%End

Alignment alignment() const;
Qgis::ScaleBarAlignment alignment() const;
%Docstring
Returns the scalebar alignment.

.. seealso:: :py:func:`setAlignment`
%End

void setAlignment( Alignment alignment );
void setAlignment( Qgis::ScaleBarAlignment alignment );
%Docstring
Sets the scalebar ``alignment``.

Expand Down
56 changes: 56 additions & 0 deletions python/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4514,6 +4514,62 @@
Qgis.LayoutUnitType.__doc__ = "Types of layout units\n\n.. note::\n\n Prior to QGIS 3.30 this was available as :py:class:`QgsUnitTypes`.LayoutUnitType.\n\n.. versionadded:: 3.30\n\n" + '* ``LayoutPaperUnits``: ' + Qgis.LayoutUnitType.PaperUnits.__doc__ + '\n' + '* ``LayoutScreenUnits``: ' + Qgis.LayoutUnitType.ScreenUnits.__doc__
# --
Qgis.LayoutUnitType.baseClass = Qgis
QgsScaleBarSettings.Alignment = Qgis.ScaleBarAlignment
# monkey patching scoped based enum
QgsScaleBarSettings.AlignLeft = Qgis.ScaleBarAlignment.Left
QgsScaleBarSettings.Alignment.AlignLeft = Qgis.ScaleBarAlignment.Left
QgsScaleBarSettings.AlignLeft.is_monkey_patched = True
QgsScaleBarSettings.AlignLeft.__doc__ = "Left aligned"
QgsScaleBarSettings.AlignMiddle = Qgis.ScaleBarAlignment.Middle
QgsScaleBarSettings.Alignment.AlignMiddle = Qgis.ScaleBarAlignment.Middle
QgsScaleBarSettings.AlignMiddle.is_monkey_patched = True
QgsScaleBarSettings.AlignMiddle.__doc__ = "Center aligned"
QgsScaleBarSettings.AlignRight = Qgis.ScaleBarAlignment.Right
QgsScaleBarSettings.Alignment.AlignRight = Qgis.ScaleBarAlignment.Right
QgsScaleBarSettings.AlignRight.is_monkey_patched = True
QgsScaleBarSettings.AlignRight.__doc__ = "Right aligned"
Qgis.ScaleBarAlignment.__doc__ = "Scalebar alignment.\n\n.. note::\n\n Prior to QGIS 3.40 this was available as :py:class:`QgsScaleBarSettings`.Alignment.\n\n.. versionadded:: 3.40\n\n" + '* ``AlignLeft``: ' + Qgis.ScaleBarAlignment.Left.__doc__ + '\n' + '* ``AlignMiddle``: ' + Qgis.ScaleBarAlignment.Middle.__doc__ + '\n' + '* ``AlignRight``: ' + Qgis.ScaleBarAlignment.Right.__doc__
# --
Qgis.ScaleBarAlignment.baseClass = Qgis
QgsScaleBarSettings.SegmentSizeMode = Qgis.ScaleBarSegmentSizeMode
# monkey patching scoped based enum
QgsScaleBarSettings.SegmentSizeFixed = Qgis.ScaleBarSegmentSizeMode.Fixed
QgsScaleBarSettings.SegmentSizeMode.SegmentSizeFixed = Qgis.ScaleBarSegmentSizeMode.Fixed
QgsScaleBarSettings.SegmentSizeFixed.is_monkey_patched = True
QgsScaleBarSettings.SegmentSizeFixed.__doc__ = "Scale bar segment size is fixed to a map unit"
QgsScaleBarSettings.SegmentSizeFitWidth = Qgis.ScaleBarSegmentSizeMode.FitWidth
QgsScaleBarSettings.SegmentSizeMode.SegmentSizeFitWidth = Qgis.ScaleBarSegmentSizeMode.FitWidth
QgsScaleBarSettings.SegmentSizeFitWidth.is_monkey_patched = True
QgsScaleBarSettings.SegmentSizeFitWidth.__doc__ = "Scale bar segment size is calculated to fit a size range"
Qgis.ScaleBarSegmentSizeMode.__doc__ = "Modes for setting size for scale bar segments.\n\n.. note::\n\n Prior to QGIS 3.40 this was available as :py:class:`QgsScaleBarSettings`.SegmentSizeMode.\n\n.. versionadded:: 3.40\n\n" + '* ``SegmentSizeFixed``: ' + Qgis.ScaleBarSegmentSizeMode.Fixed.__doc__ + '\n' + '* ``SegmentSizeFitWidth``: ' + Qgis.ScaleBarSegmentSizeMode.FitWidth.__doc__
# --
Qgis.ScaleBarSegmentSizeMode.baseClass = Qgis
QgsScaleBarSettings.LabelVerticalPlacement = Qgis.ScaleBarDistanceLabelVerticalPlacement
# monkey patching scoped based enum
QgsScaleBarSettings.LabelAboveSegment = Qgis.ScaleBarDistanceLabelVerticalPlacement.AboveSegment
QgsScaleBarSettings.LabelVerticalPlacement.LabelAboveSegment = Qgis.ScaleBarDistanceLabelVerticalPlacement.AboveSegment
QgsScaleBarSettings.LabelAboveSegment.is_monkey_patched = True
QgsScaleBarSettings.LabelAboveSegment.__doc__ = "Labels are drawn above the scalebar"
QgsScaleBarSettings.LabelBelowSegment = Qgis.ScaleBarDistanceLabelVerticalPlacement.BelowSegment
QgsScaleBarSettings.LabelVerticalPlacement.LabelBelowSegment = Qgis.ScaleBarDistanceLabelVerticalPlacement.BelowSegment
QgsScaleBarSettings.LabelBelowSegment.is_monkey_patched = True
QgsScaleBarSettings.LabelBelowSegment.__doc__ = "Labels are drawn below the scalebar"
Qgis.ScaleBarDistanceLabelVerticalPlacement.__doc__ = "Scale bar distance label vertical placement.\n\n.. note::\n\n Prior to QGIS 3.40 this was available as :py:class:`QgsScaleBarSettings`.LabelVerticalPlacement.\n\n.. versionadded:: 3.40\n\n" + '* ``LabelAboveSegment``: ' + Qgis.ScaleBarDistanceLabelVerticalPlacement.AboveSegment.__doc__ + '\n' + '* ``LabelBelowSegment``: ' + Qgis.ScaleBarDistanceLabelVerticalPlacement.BelowSegment.__doc__
# --
Qgis.ScaleBarDistanceLabelVerticalPlacement.baseClass = Qgis
QgsScaleBarSettings.LabelHorizontalPlacement = Qgis.ScaleBarDistanceLabelHorizontalPlacement
# monkey patching scoped based enum
QgsScaleBarSettings.LabelCenteredEdge = Qgis.ScaleBarDistanceLabelHorizontalPlacement.CenteredEdge
QgsScaleBarSettings.LabelHorizontalPlacement.LabelCenteredEdge = Qgis.ScaleBarDistanceLabelHorizontalPlacement.CenteredEdge
QgsScaleBarSettings.LabelCenteredEdge.is_monkey_patched = True
QgsScaleBarSettings.LabelCenteredEdge.__doc__ = "Labels are drawn centered relative to segment's edge"
QgsScaleBarSettings.LabelCenteredSegment = Qgis.ScaleBarDistanceLabelHorizontalPlacement.CenteredSegment
QgsScaleBarSettings.LabelHorizontalPlacement.LabelCenteredSegment = Qgis.ScaleBarDistanceLabelHorizontalPlacement.CenteredSegment
QgsScaleBarSettings.LabelCenteredSegment.is_monkey_patched = True
QgsScaleBarSettings.LabelCenteredSegment.__doc__ = "Labels are drawn centered relative to segment"
Qgis.ScaleBarDistanceLabelHorizontalPlacement.__doc__ = "Scale bar distance label horizontal placement.\n\n.. note::\n\n Prior to QGIS 3.40 this was available as :py:class:`QgsScaleBarSettings`.LabelHorizontalPlacement.\n\n.. versionadded:: 3.40\n\n" + '* ``LabelCenteredEdge``: ' + Qgis.ScaleBarDistanceLabelHorizontalPlacement.CenteredEdge.__doc__ + '\n' + '* ``LabelCenteredSegment``: ' + Qgis.ScaleBarDistanceLabelHorizontalPlacement.CenteredSegment.__doc__
# --
Qgis.ScaleBarDistanceLabelHorizontalPlacement.baseClass = Qgis
# monkey patching scoped based enum
Qgis.InputControllerType.Map2D.__doc__ = "2D map controller"
Qgis.InputControllerType.Map3D.__doc__ = "3D map controller"
Expand Down
Loading

0 comments on commit 82d2189

Please sign in to comment.