Skip to content

Commit

Permalink
Merge pull request #4767 from nyalldawson/layouts3
Browse files Browse the repository at this point in the history
[layouts] Add layout measurement and size classes
  • Loading branch information
nyalldawson authored Jun 27, 2017
2 parents 0f83a5f + 8791aac commit 9f5e33a
Show file tree
Hide file tree
Showing 22 changed files with 2,677 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ IF(WITH_APIDOC)
${CMAKE_SOURCE_DIR}/src/core/geometry
${CMAKE_SOURCE_DIR}/src/core/gps
${CMAKE_SOURCE_DIR}/src/core/layertree
${CMAKE_SOURCE_DIR}/src/core/layout
${CMAKE_SOURCE_DIR}/src/core/metadata
${CMAKE_SOURCE_DIR}/src/core/pal
${CMAKE_SOURCE_DIR}/src/core/processing
Expand Down
1 change: 1 addition & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/src/core/geometry
${CMAKE_SOURCE_DIR}/src/core/gps
${CMAKE_SOURCE_DIR}/src/core/layertree
${CMAKE_SOURCE_DIR}/src/core/layout
${CMAKE_SOURCE_DIR}/src/core/metadata
${CMAKE_SOURCE_DIR}/src/core/processing
${CMAKE_SOURCE_DIR}/src/core/providers
Expand Down
5 changes: 5 additions & 0 deletions python/core/core.sip
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,11 @@ done:
%Include layertree/qgslayertreeregistrybridge.sip
%Include layertree/qgslayertreeutils.sip

%Include layout/qgslayoutmeasurement.sip
%Include layout/qgslayoutmeasurementconverter.sip
%Include layout/qgslayoutpoint.sip
%Include layout/qgslayoutsize.sip

%Include metadata/qgslayermetadata.sip
%Include metadata/qgslayermetadatavalidator.sip

Expand Down
137 changes: 137 additions & 0 deletions python/core/layout/qgslayoutmeasurement.sip
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutmeasurement.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/





class QgsLayoutMeasurement
{
%Docstring
This class provides a method of storing measurements for use in QGIS layouts
using a variety of different measurement units.
.. seealso:: QgsLayoutMeasurementConverter
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgslayoutmeasurement.h"
%End
public:

explicit QgsLayoutMeasurement( const double length, const QgsUnitTypes::LayoutUnit units = QgsUnitTypes::LayoutMillimeters );
%Docstring
Constructor for QgsLayoutMeasurement.
\param length measurement length
\param units measurement units
%End

double length() const;
%Docstring
Returns the length of the measurement.
.. seealso:: setLength()
:rtype: float
%End

void setLength( const double length );
%Docstring
Sets the ``length`` of the measurement.
.. seealso:: length()
%End

QgsUnitTypes::LayoutUnit units() const;
%Docstring
Returns the units for the measurement.
.. seealso:: setUnits()
:rtype: QgsUnitTypes.LayoutUnit
%End

void setUnits( const QgsUnitTypes::LayoutUnit units );
%Docstring
Sets the ``units`` for the measurement. Does not alter the stored length,
ie. no length conversion is done.
.. seealso:: units()
%End

QString encodeMeasurement() const;
%Docstring
Encodes the layout measurement to a string
.. seealso:: decodeMeasurement()
:rtype: str
%End

static QgsLayoutMeasurement decodeMeasurement( const QString &string );
%Docstring
Decodes a measurement from a ``string``.
.. seealso:: encodeMeasurement()
:rtype: QgsLayoutMeasurement
%End

bool operator==( const QgsLayoutMeasurement &other ) const;
bool operator!=( const QgsLayoutMeasurement &other ) const;
%Docstring
:rtype: bool
%End

QgsLayoutMeasurement operator+( const double v ) const;
%Docstring
Adds a scalar value to the measurement.
:rtype: QgsLayoutMeasurement
%End

QgsLayoutMeasurement operator+=( const double v );
%Docstring
Adds a scalar value to the measurement.
:rtype: QgsLayoutMeasurement
%End

QgsLayoutMeasurement operator-( const double v ) const;
%Docstring
Subtracts a scalar value from the measurement.
:rtype: QgsLayoutMeasurement
%End

QgsLayoutMeasurement operator-=( const double v );
%Docstring
Subtracts a scalar value from the measurement.
:rtype: QgsLayoutMeasurement
%End

QgsLayoutMeasurement operator*( const double v ) const;
%Docstring
Multiplies the measurement by a scalar value.
:rtype: QgsLayoutMeasurement
%End

QgsLayoutMeasurement operator*=( const double v );
%Docstring
Multiplies the measurement by a scalar value.
:rtype: QgsLayoutMeasurement
%End

QgsLayoutMeasurement operator/( const double v ) const;
%Docstring
Divides the measurement by a scalar value.
:rtype: QgsLayoutMeasurement
%End

QgsLayoutMeasurement operator/=( const double v );
%Docstring
Divides the measurement by a scalar value.
:rtype: QgsLayoutMeasurement
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutmeasurement.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
84 changes: 84 additions & 0 deletions python/core/layout/qgslayoutmeasurementconverter.sip
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutmeasurementconverter.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/





class QgsLayoutMeasurementConverter
{
%Docstring
This class provides a method of converting QgsLayoutMeasurements from
one unit to another. Conversion to or from pixel units utilizes a specified
dots per inch (DPI) property for the converter. Converters default to using
300 DPI.
.. seealso:: QgsLayoutMeasurement
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgslayoutmeasurementconverter.h"
%End
public:

QgsLayoutMeasurementConverter();
%Docstring
Constructor for QgsLayoutMeasurementConverter.
%End

void setDpi( const double dpi );
%Docstring
Sets the dots per inch (``dpi``) for the measurement converter. This is used
when converting measurements to and from pixels.
.. seealso:: dpi()
%End

double dpi() const;
%Docstring
Returns the Dots per inch (DPI) of the measurement converter. This is used
when converting measurements to and from pixels.
.. seealso:: setDpi()
:rtype: float
%End

QgsLayoutMeasurement convert( const QgsLayoutMeasurement &measurement, const QgsUnitTypes::LayoutUnit targetUnits ) const;
%Docstring
Converts a measurement from one unit to another.
\param measurement measurement to convert
\param targetUnits units to convert measurement into
:return: measurement converted to target units
:rtype: QgsLayoutMeasurement
%End

QgsLayoutSize convert( const QgsLayoutSize &size, const QgsUnitTypes::LayoutUnit targetUnits ) const;
%Docstring
Converts a layout size from one unit to another.
\param size layout size to convert
\param targetUnits units to convert size into
:return: size converted to target units
:rtype: QgsLayoutSize
%End

QgsLayoutPoint convert( const QgsLayoutPoint &point, const QgsUnitTypes::LayoutUnit targetUnits ) const;
%Docstring
Converts a layout point from one unit to another.
\param point layout point to convert
\param targetUnits units to convert point into
:return: point converted to target units
:rtype: QgsLayoutPoint
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutmeasurementconverter.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
Loading

0 comments on commit 9f5e33a

Please sign in to comment.