Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improve docs
  • Loading branch information
nyalldawson committed Apr 6, 2023
1 parent 28b1159 commit 492beea
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
16 changes: 9 additions & 7 deletions python/core/auto_generated/qgsscalecalculator.sip.in
Expand Up @@ -47,31 +47,33 @@ Returns the DPI (dots per inch) used in scale calculations.

void setMapUnits( Qgis::DistanceUnit mapUnits );
%Docstring
Set the map units
Set the map units.

:param mapUnits: Units of the data on the map. Must match a value from the
.. seealso:: :py:func:`mapUnits`
%End

Qgis::DistanceUnit mapUnits() const;
%Docstring
Returns current map units
Returns current map units.

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

double calculate( const QgsRectangle &mapExtent, double canvasWidth ) const;
%Docstring
Calculate the scale denominator
Calculate the scale denominator.

:param mapExtent: :py:class:`QgsRectangle` containing the current map extent
:param mapExtent: :py:class:`QgsRectangle` containing the current map extent. Units are specified by :py:func:`~QgsScaleCalculator.mapUnits`.
:param canvasWidth: Width of the map canvas in pixel (physical) units

:return: scale denominator of current map view, e.g. 1000.0 for a 1:1000 map.
%End

QSizeF calculateImageSize( const QgsRectangle &mapExtent, double scale ) const;
%Docstring
Calculate the image size in pixel (physical) units
Calculate the image size in pixel (physical) units.

:param mapExtent: :py:class:`QgsRectangle` containing the current map extent
:param mapExtent: :py:class:`QgsRectangle` containing the current map extent. Units are specified by :py:func:`~QgsScaleCalculator.mapUnits`
:param scale: Scale denominator, e.g. 1000.0 for a 1:1000 map

:return: image size
Expand Down
27 changes: 18 additions & 9 deletions src/core/qgsscalecalculator.h
Expand Up @@ -56,26 +56,35 @@ class CORE_EXPORT QgsScaleCalculator
double dpi() const;

/**
* Set the map units
* \param mapUnits Units of the data on the map. Must match a value from the
* Set the map units.
*
* \see mapUnits()
*/
void setMapUnits( Qgis::DistanceUnit mapUnits );

//! Returns current map units
/**
* Returns current map units.
*
* \see setMapUnits()
*/
Qgis::DistanceUnit mapUnits() const;

/**
* Calculate the scale denominator
* \param mapExtent QgsRectangle containing the current map extent
* Calculate the scale denominator.
*
* \param mapExtent QgsRectangle containing the current map extent. Units are specified by mapUnits().
* \param canvasWidth Width of the map canvas in pixel (physical) units
*
* \returns scale denominator of current map view, e.g. 1000.0 for a 1:1000 map.
*/
double calculate( const QgsRectangle &mapExtent, double canvasWidth ) const;

/**
* Calculate the image size in pixel (physical) units
* \param mapExtent QgsRectangle containing the current map extent
* Calculate the image size in pixel (physical) units.
*
* \param mapExtent QgsRectangle containing the current map extent. Units are specified by mapUnits()
* \param scale Scale denominator, e.g. 1000.0 for a 1:1000 map
*
* \returns image size
* \since QGIS 3.24
*/
Expand All @@ -95,10 +104,10 @@ class CORE_EXPORT QgsScaleCalculator
void calculateMetrics( const QgsRectangle &mapExtent, double &delta, double &conversionFactor ) const;

//! dpi member
double mDpi;
double mDpi = 96;

//! map unit member
Qgis::DistanceUnit mMapUnits;
Qgis::DistanceUnit mMapUnits = Qgis::DistanceUnit::Unknown;
};

#endif // #ifndef QGSSCALECALCULATOR_H

0 comments on commit 492beea

Please sign in to comment.