QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
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 "qgsconfig.h"
22
23#include "qgis.h"
24#include "qgis_core.h"
25
26#include <QPointF>
27
43class CORE_EXPORT QgsLayoutPoint
44{
45 public:
46
51
56
62
69 void setPoint( const double x, const double y ) { mX = x; mY = y; }
70
76 double x() const { return mX; }
77
83 void setX( const double x )
84 {
85#ifdef QGISDEBUG
86 Q_ASSERT_X( !std::isnan( x ), "QgsLayoutPoint", "Layout point with NaN coordinates created" );
87#endif
88 mX = x;
89 }
90
96 double y() const { return mY; }
97
103 void setY( const double y )
104 {
105#ifdef QGISDEBUG
106 Q_ASSERT_X( !std::isnan( y ), "QgsLayoutPoint", "Layout point with NaN coordinates created" );
107#endif
108 mY = y;
109 }
110
115 Qgis::LayoutUnit units() const { return mUnits; }
116
122 void setUnits( const Qgis::LayoutUnit units ) { mUnits = units; }
123
129 bool isNull() const;
130
136 QPointF toQPointF() const;
137
142 QString encodePoint() const;
143
148 static QgsLayoutPoint decodePoint( const QString &string );
149
150 bool operator==( const QgsLayoutPoint &other ) const;
151 bool operator!=( const QgsLayoutPoint &other ) const;
152
156 QgsLayoutPoint operator*( double v ) const;
157
161 QgsLayoutPoint operator*=( double v );
162
166 QgsLayoutPoint operator/( double v ) const;
167
171 QgsLayoutPoint operator/=( double v );
172
173#ifdef SIP_RUN
174 SIP_PYOBJECT __repr__();
175 % MethodCode
176 QString str = QStringLiteral( "<QgsLayoutPoint: %1, %2 %3 >" ).arg( sipCpp->x() ).arg( sipCpp->y() ).arg( QgsUnitTypes::toAbbreviatedString( sipCpp->units() ) );
177 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
178 % End
179#endif
180
181 private:
182
183 double mX = 0.0;
184 double mY = 0.0;
186
187};
188
189#endif // QGSLAYOUTPOINT_H
LayoutUnit
Layout measurement units.
Definition qgis.h:5203
@ Millimeters
Millimeters.
Definition qgis.h:5204
Provides a method of storing points, consisting of an x and y coordinate, for use in QGIS layouts.
double x() const
Returns x coordinate of point.
void setX(const double x)
Sets the x coordinate of point.
void setUnits(const Qgis::LayoutUnit units)
Sets the units for the point.
double y() const
Returns y coordinate of point.
QgsLayoutPoint(double x, double y, Qgis::LayoutUnit units=Qgis::LayoutUnit::Millimeters)
Constructor for QgsLayoutPoint.
Qgis::LayoutUnit units() const
Returns the units for the point.
void setY(const double y)
Sets y coordinate of point.
void setPoint(const double x, const double y)
Sets new x and y coordinates for the point.
static Q_INVOKABLE QString toAbbreviatedString(Qgis::DistanceUnit unit)
Returns a translated abbreviation representing a distance unit.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
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:250
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:270