QGIS API Documentation  3.2.0-Bonn (bc43194)
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 
23 #include "qgsunittypes.h"
24 
33 class CORE_EXPORT QgsLayoutMeasurement
34 {
35  public:
36 
43 
48  double length() const { return mLength; }
49 
54  void setLength( const double length ) { mLength = length; }
55 
60  QgsUnitTypes::LayoutUnit units() const { return mUnits; }
61 
67  void setUnits( const QgsUnitTypes::LayoutUnit units ) { mUnits = units; }
68 
73  QString encodeMeasurement() const;
74 
79  static QgsLayoutMeasurement decodeMeasurement( const QString &string );
80 
81  bool operator==( const QgsLayoutMeasurement &other ) const;
82  bool operator!=( const QgsLayoutMeasurement &other ) const;
83 
87  QgsLayoutMeasurement operator+( double v ) const;
88 
92  QgsLayoutMeasurement operator+=( double v );
93 
97  QgsLayoutMeasurement operator-( double v ) const;
98 
102  QgsLayoutMeasurement operator-=( double v );
103 
107  QgsLayoutMeasurement operator*( double v ) const;
108 
112  QgsLayoutMeasurement operator*=( double v );
113 
117  QgsLayoutMeasurement operator/( double v ) const;
118 
122  QgsLayoutMeasurement operator/=( double v );
123 
124  private:
125 
126  double mLength = 0.0;
128 
129 };
130 
131 #endif // QGSLAYOUTMEASUREMENT_H
QgsUnitTypes::LayoutUnit units() const
Returns the units for the measurement.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
void setLength(const double length)
Sets the length of the measurement.
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
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:262
QDateTime operator+(const QDateTime &start, QgsInterval interval)
QgsInterval operator-(const QDateTime &dt1, const QDateTime &dt2)
Returns the interval between two datetimes.
void setUnits(const QgsUnitTypes::LayoutUnit units)
Sets the units for the measurement.
double length() const
Returns the length of the measurement.
LayoutUnit
Layout measurement units.
Definition: qgsunittypes.h:114
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:242