QGIS API Documentation 3.38.0-Grenoble (exported)
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 "qgis_core.h"
22#include "qgis.h"
23#include <QPointF>
24
38class CORE_EXPORT QgsLayoutPoint
39{
40 public:
41
46
50 explicit QgsLayoutPoint( QPointF point, Qgis::LayoutUnit units = Qgis::LayoutUnit::Millimeters );
51
57
64 void setPoint( const double x, const double y ) { mX = x; mY = y; }
65
71 double x() const { return mX; }
72
78 void setX( const double x ) { mX = x; }
79
85 double y() const { return mY; }
86
92 void setY( const double y ) { mY = y; }
93
98 Qgis::LayoutUnit units() const { return mUnits; }
99
105 void setUnits( const Qgis::LayoutUnit units ) { mUnits = units; }
106
112 bool isNull() const;
113
119 QPointF toQPointF() const;
120
125 QString encodePoint() const;
126
131 static QgsLayoutPoint decodePoint( const QString &string );
132
133 bool operator==( const QgsLayoutPoint &other ) const;
134 bool operator!=( const QgsLayoutPoint &other ) const;
135
139 QgsLayoutPoint operator*( double v ) const;
140
144 QgsLayoutPoint operator*=( double v );
145
149 QgsLayoutPoint operator/( double v ) const;
150
154 QgsLayoutPoint operator/=( double v );
155
156#ifdef SIP_RUN
157 SIP_PYOBJECT __repr__();
158 % MethodCode
159 QString str = QStringLiteral( "<QgsLayoutPoint: %1, %2 %3 >" ).arg( sipCpp->x() ).arg( sipCpp->y() ).arg( QgsUnitTypes::toAbbreviatedString( sipCpp->units() ) );
160 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
161 % End
162#endif
163
164 private:
165
166 double mX = 0.0;
167 double mY = 0.0;
169
170};
171
172#endif // QGSLAYOUTPOINT_H
LayoutUnit
Layout measurement units.
Definition qgis.h:4509
@ Millimeters
Millimeters.
This class provides a method of storing points, consisting of an x and y coordinate,...
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.
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.
#define str(x)
Definition qgis.cpp:38
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: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