QGIS API Documentation  3.6.0-Noosa (5873452)
qgslayoutsize.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayoutsize.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 QGSLAYOUTSIZE_H
19 #define QGSLAYOUTSIZE_H
20 
21 #include "qgis_core.h"
22 #include "qgsunittypes.h"
23 #include <QSizeF>
24 
25 
40 class CORE_EXPORT QgsLayoutSize
41 {
42  public:
43 
50  QgsLayoutSize( double width, double height, QgsUnitTypes::LayoutUnit units = QgsUnitTypes::LayoutMillimeters );
51 
56 
62 
69  void setSize( const double width, const double height ) { mWidth = width; mHeight = height; }
70 
76  double width() const { return mWidth; }
77 
83  void setWidth( const double width ) { mWidth = width; }
84 
90  double height() const { return mHeight; }
91 
97  void setHeight( const double height ) { mHeight = height; }
98 
103  QgsUnitTypes::LayoutUnit units() const { return mUnits; }
104 
110  void setUnits( const QgsUnitTypes::LayoutUnit units ) { mUnits = units; }
111 
117  bool isEmpty() const;
118 
124  QSizeF toQSizeF() const;
125 
130  QString encodeSize() const;
131 
136  static QgsLayoutSize decodeSize( const QString &string );
137 
138  bool operator==( const QgsLayoutSize &other ) const;
139  bool operator!=( const QgsLayoutSize &other ) const;
140 
144  QgsLayoutSize operator*( double v ) const;
145 
149  QgsLayoutSize operator*=( double v );
150 
154  QgsLayoutSize operator/( double v ) const;
155 
159  QgsLayoutSize operator/=( double v );
160 
161  private:
162 
163  double mWidth = 0.0;
164  double mHeight = 0.0;
166 
167 };
168 
169 #endif // QGSLAYOUTSIZE_H
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
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
QgsUnitTypes::LayoutUnit units() const
Returns the units for the size.
void setHeight(const double height)
Sets the height for the size.
Definition: qgslayoutsize.h:97
LayoutUnit
Layout measurement units.
Definition: qgsunittypes.h:125
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
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
Definition: qgslayoutsize.h:40
double height() const
Returns the height of the size.
Definition: qgslayoutsize.h:90
void setSize(const double width, const double height)
Sets new width and height for the size.
Definition: qgslayoutsize.h:69
void setWidth(const double width)
Sets the width for the size.
Definition: qgslayoutsize.h:83
void setUnits(const QgsUnitTypes::LayoutUnit units)
Sets the units for the size.
double width() const
Returns the width of the size.
Definition: qgslayoutsize.h:76