QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgslayoutpoint.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayoutpoint.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 QGSLAYOUTPOINT_H
19 #define QGSLAYOUTPOINT_H
20 
21 #include "qgis_core.h"
22 #include "qgsunittypes.h"
23 #include <QPointF>
24 
39 class CORE_EXPORT QgsLayoutPoint
40 {
41  public:
42 
47 
52 
58 
65  void setPoint( const double x, const double y ) { mX = x; mY = y; }
66 
72  double x() const { return mX; }
73 
79  void setX( const double x ) { mX = x; }
80 
86  double y() const { return mY; }
87 
93  void setY( const double y ) { mY = y; }
94 
99  QgsUnitTypes::LayoutUnit units() const { return mUnits; }
100 
106  void setUnits( const QgsUnitTypes::LayoutUnit units ) { mUnits = units; }
107 
113  bool isNull() const;
114 
120  QPointF toQPointF() const;
121 
126  QString encodePoint() const;
127 
132  static QgsLayoutPoint decodePoint( const QString &string );
133 
134  bool operator==( const QgsLayoutPoint &other ) const;
135  bool operator!=( const QgsLayoutPoint &other ) const;
136 
140  QgsLayoutPoint operator*( double v ) const;
141 
145  QgsLayoutPoint operator*=( double v );
146 
150  QgsLayoutPoint operator/( double v ) const;
151 
155  QgsLayoutPoint operator/=( double v );
156 
157 #ifdef SIP_RUN
158  SIP_PYOBJECT __repr__();
159  % MethodCode
160  QString str = QStringLiteral( "<QgsLayoutPoint: %1, %2 %3 >" ).arg( sipCpp->x() ).arg( sipCpp->y() ).arg( QgsUnitTypes::toAbbreviatedString( sipCpp->units() ) );
161  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
162  % End
163 #endif
164 
165  private:
166 
167  double mX = 0.0;
168  double mY = 0.0;
170 
171 };
172 
173 #endif // QGSLAYOUTPOINT_H
operator==
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition: qgsfeatureiterator.h:399
QgsUnitTypes::toAbbreviatedString
static Q_INVOKABLE QString toAbbreviatedString(QgsUnitTypes::DistanceUnit unit)
Returns a translated abbreviation representing a distance unit.
Definition: qgsunittypes.cpp:269
QgsUnitTypes::LayoutUnit
LayoutUnit
Layout measurement units.
Definition: qgsunittypes.h:180
QgsLayoutPoint::y
double y() const
Returns y coordinate of point.
Definition: qgslayoutpoint.h:86
qgsunittypes.h
operator/
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
QgsLayoutPoint::setPoint
void setPoint(const double x, const double y)
Sets new x and y coordinates for the point.
Definition: qgslayoutpoint.h:65
operator!=
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition: qgsfeatureiterator.h:404
QgsLayoutPoint::setY
void setY(const double y)
Sets y coordinate of point.
Definition: qgslayoutpoint.h:93
operator*
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
QgsLayoutPoint::setX
void setX(const double x)
Sets the x coordinate of point.
Definition: qgslayoutpoint.h:79
QgsUnitTypes::LayoutMillimeters
@ LayoutMillimeters
Millimeters.
Definition: qgsunittypes.h:182
QgsLayoutPoint
This class provides a method of storing points, consisting of an x and y coordinate,...
Definition: qgslayoutpoint.h:39
QgsLayoutPoint::setUnits
void setUnits(const QgsUnitTypes::LayoutUnit units)
Sets the units for the point.
Definition: qgslayoutpoint.h:106
QgsLayoutPoint::x
double x() const
Returns x coordinate of point.
Definition: qgslayoutpoint.h:72
QgsLayoutPoint::units
QgsUnitTypes::LayoutUnit units() const
Returns the units for the point.
Definition: qgslayoutpoint.h:99