QGIS API Documentation 3.41.0-Master (092dc69654e)
Loading...
Searching...
No Matches
qgslayoutmeasurement.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutmeasurement.h
3 --------------------
4 begin : June 2017
5 copyright : (C) 2017 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSLAYOUTMEASUREMENT_H
19#define QGSLAYOUTMEASUREMENT_H
20
21#include "qgis_core.h"
22#include "qgis.h"
23#include "qgsunittypes.h"
24
32class CORE_EXPORT QgsLayoutMeasurement
33{
34 public:
35
42
47 double length() const { return mLength; }
48
53 void setLength( const double length ) { mLength = length; }
54
59 Qgis::LayoutUnit units() const { return mUnits; }
60
66 void setUnits( const Qgis::LayoutUnit units ) { mUnits = units; }
67
72 QString encodeMeasurement() const;
73
78 static QgsLayoutMeasurement decodeMeasurement( const QString &string );
79
80 bool operator==( QgsLayoutMeasurement other ) const;
81 bool operator!=( QgsLayoutMeasurement other ) const;
82
86 QgsLayoutMeasurement operator+( double v ) const;
87
91 QgsLayoutMeasurement operator+=( double v );
92
96 QgsLayoutMeasurement operator-( double v ) const;
97
101 QgsLayoutMeasurement operator-=( double v );
102
106 QgsLayoutMeasurement operator*( double v ) const;
107
111 QgsLayoutMeasurement operator*=( double v );
112
116 QgsLayoutMeasurement operator/( double v ) const;
117
121 QgsLayoutMeasurement operator/=( double v );
122
123#ifdef SIP_RUN
124 SIP_PYOBJECT __repr__();
125 % MethodCode
126 QString str = QStringLiteral( "<QgsLayoutMeasurement: %1 %2 >" ).arg( sipCpp->length() ).arg( QgsUnitTypes::toAbbreviatedString( sipCpp->units() ) );
127 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
128 % End
129#endif
130
131 private:
132
133 double mLength = 0.0;
135
136};
137
138#endif // QGSLAYOUTMEASUREMENT_H
LayoutUnit
Layout measurement units.
Definition qgis.h:4859
@ Millimeters
Millimeters.
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
void setLength(const double length)
Sets the length of the measurement.
Qgis::LayoutUnit units() const
Returns the units for the measurement.
void setUnits(const Qgis::LayoutUnit units)
Sets the units for the measurement.
double length() const
Returns the length of the measurement.
static Q_INVOKABLE QString toAbbreviatedString(Qgis::DistanceUnit unit)
Returns a translated abbreviation representing a distance unit.
#define str(x)
Definition qgis.cpp:39
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QgsInterval operator-(QDate date1, QDate date2)
Returns the interval between two dates.
QDateTime operator+(const QDateTime &start, const QgsInterval &interval)
Adds an interval to a datetime.
QgsMargins operator*(const QgsMargins &margins, double factor)
Returns a QgsMargins object that is formed by multiplying each component of the given margins by fact...
Definition qgsmargins.h:241
QgsMargins operator/(const QgsMargins &margins, double divisor)
Returns a QgsMargins object that is formed by dividing the components of the given margins by the giv...
Definition qgsmargins.h:261