Skip to content

Commit

Permalink
Add clarification re meaning of number of subdivisions
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 7, 2020
1 parent 4d5a8a3 commit 6e9b7ae
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
10 changes: 10 additions & 0 deletions python/core/auto_generated/layout/qgslayoutitemscalebar.sip.in
Expand Up @@ -80,6 +80,11 @@ Sets the number of ``segments`` included in the left part of the scalebar.
%Docstring
Returns the number of subdivisions for segments included in the right part of the scalebar (only used for some scalebar types).

.. note::

The number of subdivisions represents the number of subdivision segments, not the number of subdivision lines. E.g.
if the number is 1 then NO subdivision lines will be shown.

.. seealso:: :py:func:`setNumberOfSubdivisions`

.. versionadded:: 3.14
Expand All @@ -89,6 +94,11 @@ Returns the number of subdivisions for segments included in the right part of th
%Docstring
Sets the number of ``subdivisions`` for segments included in the right part of the scalebar (only used for some scalebar types).

.. note::

The number of subdivisions represents the number of subdivision segments, not the number of subdivision lines. E.g.
if the number is 1 then NO subdivision lines will be shown.

.. seealso:: :py:func:`numberOfSubdivisions`

.. versionadded:: 3.14
Expand Down
10 changes: 10 additions & 0 deletions python/core/auto_generated/scalebar/qgsscalebarsettings.sip.in
Expand Up @@ -101,6 +101,11 @@ Sets the number of ``segments`` included in the left part of the scalebar.
%Docstring
Returns the number of subdivisions for segments included in the right part of the scalebar (only used for some scalebar types).

.. note::

The number of subdivisions represents the number of subdivision segments, not the number of subdivision lines. E.g.
if the number is 1 then NO subdivision lines will be shown.

.. seealso:: :py:func:`setNumberOfSubdivisions`

.. versionadded:: 3.14
Expand All @@ -110,6 +115,11 @@ Returns the number of subdivisions for segments included in the right part of th
%Docstring
Sets the number of ``subdivisions`` for segments included in the right part of the scalebar (only used for some scalebar types).

.. note::

The number of subdivisions represents the number of subdivision segments, not the number of subdivision lines. E.g.
if the number is 1 then NO subdivision lines will be shown.

.. seealso:: :py:func:`numberOfSubdivisions`

.. versionadded:: 3.14
Expand Down
2 changes: 1 addition & 1 deletion src/core/layout/qgslayoutitemscalebar.cpp
Expand Up @@ -839,7 +839,7 @@ bool QgsLayoutItemScaleBar::readPropertiesFromElement( const QDomElement &itemEl
mSettings.setBoxContentSpace( itemElem.attribute( QStringLiteral( "boxContentSpace" ), QStringLiteral( "1.0" ) ).toDouble() );
mSettings.setNumberOfSegments( itemElem.attribute( QStringLiteral( "numSegments" ), QStringLiteral( "2" ) ).toInt() );
mSettings.setNumberOfSegmentsLeft( itemElem.attribute( QStringLiteral( "numSegmentsLeft" ), QStringLiteral( "0" ) ).toInt() );
mSettings.setNumberOfSubdivisions( itemElem.attribute( QStringLiteral( "numSubdivisions" ), QStringLiteral( "0" ) ).toInt() );
mSettings.setNumberOfSubdivisions( itemElem.attribute( QStringLiteral( "numSubdivisions" ), QStringLiteral( "1" ) ).toInt() );
mSettings.setSubdivisionsHeight( itemElem.attribute( QStringLiteral( "subdivisionsHeight" ), QStringLiteral( "1.5" ) ).toDouble() );
mSettings.setUnitsPerSegment( itemElem.attribute( QStringLiteral( "numUnitsPerSegment" ), QStringLiteral( "1.0" ) ).toDouble() );
mSettings.setSegmentSizeMode( static_cast<QgsScaleBarSettings::SegmentSizeMode>( itemElem.attribute( QStringLiteral( "segmentSizeMode" ), QStringLiteral( "0" ) ).toInt() ) );
Expand Down
8 changes: 8 additions & 0 deletions src/core/layout/qgslayoutitemscalebar.h
Expand Up @@ -84,13 +84,21 @@ class CORE_EXPORT QgsLayoutItemScaleBar: public QgsLayoutItem

/**
* Returns the number of subdivisions for segments included in the right part of the scalebar (only used for some scalebar types).
*
* \note The number of subdivisions represents the number of subdivision segments, not the number of subdivision lines. E.g.
* if the number is 1 then NO subdivision lines will be shown.
*
* \see setNumberOfSubdivisions()
* \since QGIS 3.14
*/
int numberOfSubdivisions() const { return mSettings.numberOfSubdivisions(); }

/**
* Sets the number of \a subdivisions for segments included in the right part of the scalebar (only used for some scalebar types).
*
* \note The number of subdivisions represents the number of subdivision segments, not the number of subdivision lines. E.g.
* if the number is 1 then NO subdivision lines will be shown.
*
* \see numberOfSubdivisions()
* \since QGIS 3.14
*/
Expand Down
10 changes: 9 additions & 1 deletion src/core/scalebar/qgsscalebarsettings.h
Expand Up @@ -122,13 +122,21 @@ class CORE_EXPORT QgsScaleBarSettings

/**
* Returns the number of subdivisions for segments included in the right part of the scalebar (only used for some scalebar types).
*
* \note The number of subdivisions represents the number of subdivision segments, not the number of subdivision lines. E.g.
* if the number is 1 then NO subdivision lines will be shown.
*
* \see setNumberOfSubdivisions()
* \since QGIS 3.14
*/
int numberOfSubdivisions() const { return mNumSubdivisions; }

/**
* Sets the number of \a subdivisions for segments included in the right part of the scalebar (only used for some scalebar types).
*
* \note The number of subdivisions represents the number of subdivision segments, not the number of subdivision lines. E.g.
* if the number is 1 then NO subdivision lines will be shown.
*
* \see numberOfSubdivisions()
* \since QGIS 3.14
*/
Expand Down Expand Up @@ -614,7 +622,7 @@ class CORE_EXPORT QgsScaleBarSettings
//! Number of segments on left side
int mNumSegmentsLeft = 0;
//! Number of subdivisions on right side
int mNumSubdivisions = 0;
int mNumSubdivisions = 1;
//! Height of subdivisions on right side
double mSubdivisionsHeight = 1.5;
//! Size of a segment (in map units)
Expand Down

0 comments on commit 6e9b7ae

Please sign in to comment.