QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
layout
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
#include <QString>
28
29
using namespace
Qt::StringLiterals;
30
46
class
CORE_EXPORT
QgsLayoutPoint
47
{
48
public
:
52
QgsLayoutPoint
(
double
x
,
double
y
,
Qgis::LayoutUnit
units
=
Qgis::LayoutUnit::Millimeters
);
53
57
explicit
QgsLayoutPoint
( QPointF point,
Qgis::LayoutUnit
units
=
Qgis::LayoutUnit::Millimeters
);
58
63
explicit
QgsLayoutPoint
(
Qgis::LayoutUnit
units
=
Qgis::LayoutUnit::Millimeters
);
64
71
void
setPoint
(
const
double
x
,
const
double
y
)
72
{
73
mX =
x
;
74
mY =
y
;
75
}
76
82
double
x
()
const
{
return
mX; }
83
89
void
setX
(
const
double
x
)
90
{
91
#ifdef QGISDEBUG
92
Q_ASSERT_X( !std::isnan(
x
),
"QgsLayoutPoint"
,
"Layout point with NaN coordinates created"
);
93
#endif
94
mX =
x
;
95
}
96
102
double
y
()
const
{
return
mY; }
103
109
void
setY
(
const
double
y
)
110
{
111
#ifdef QGISDEBUG
112
Q_ASSERT_X( !std::isnan(
y
),
"QgsLayoutPoint"
,
"Layout point with NaN coordinates created"
);
113
#endif
114
mY =
y
;
115
}
116
121
Qgis::LayoutUnit
units
()
const
{
return
mUnits; }
122
128
void
setUnits
(
const
Qgis::LayoutUnit
units
) { mUnits =
units
; }
129
135
bool
isNull()
const
;
136
142
QPointF toQPointF()
const
;
143
148
QString encodePoint()
const
;
149
154
static
QgsLayoutPoint
decodePoint(
const
QString &
string
);
155
156
bool
operator==
(
const
QgsLayoutPoint
&other )
const
;
157
bool
operator!=
(
const
QgsLayoutPoint
&other )
const
;
158
162
QgsLayoutPoint
operator*
(
double
v )
const
;
163
167
QgsLayoutPoint
operator*=(
double
v );
168
172
QgsLayoutPoint
operator/
(
double
v )
const
;
173
177
QgsLayoutPoint
operator/=(
double
v );
178
179
#ifdef SIP_RUN
180
// clang-format off
181
SIP_PYOBJECT __repr__();
182
% MethodCode
183
QString str = u
"<QgsLayoutPoint: %1, %2 %3 >"
_s.arg( sipCpp->x() ).arg( sipCpp->y() ).arg(
QgsUnitTypes::toAbbreviatedString
( sipCpp->units() ) );
184
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
185
% End
186
// clang-format on
187
#endif
188
189
// clang-format off
190
private
:
191
// clang-format on
192
193
double
mX
194
= 0.0;
195
double
mY = 0.0;
196
Qgis::LayoutUnit
mUnits =
Qgis::LayoutUnit::Millimeters
;
197
};
198
199
#endif
// QGSLAYOUTPOINT_H
Qgis::LayoutUnit
LayoutUnit
Layout measurement units.
Definition
qgis.h:5778
Qgis::LayoutUnit::Millimeters
@ Millimeters
Millimeters.
Definition
qgis.h:5779
QgsLayoutPoint
Provides a method of storing points, consisting of an x and y coordinate, for use in QGIS layouts.
Definition
qgslayoutpoint.h:47
QgsLayoutPoint::x
double x() const
Returns x coordinate of point.
Definition
qgslayoutpoint.h:82
QgsLayoutPoint::setX
void setX(const double x)
Sets the x coordinate of point.
Definition
qgslayoutpoint.h:89
QgsLayoutPoint::setUnits
void setUnits(const Qgis::LayoutUnit units)
Sets the units for the point.
Definition
qgslayoutpoint.h:128
QgsLayoutPoint::y
double y() const
Returns y coordinate of point.
Definition
qgslayoutpoint.h:102
QgsLayoutPoint::QgsLayoutPoint
QgsLayoutPoint(double x, double y, Qgis::LayoutUnit units=Qgis::LayoutUnit::Millimeters)
Constructor for QgsLayoutPoint.
Definition
qgslayoutpoint.cpp:28
QgsLayoutPoint::units
Qgis::LayoutUnit units() const
Returns the units for the point.
Definition
qgslayoutpoint.h:121
QgsLayoutPoint::setY
void setY(const double y)
Sets y coordinate of point.
Definition
qgslayoutpoint.h:109
QgsLayoutPoint::setPoint
void setPoint(const double x, const double y)
Sets new x and y coordinates for the point.
Definition
qgslayoutpoint.h:71
QgsUnitTypes::toAbbreviatedString
static Q_INVOKABLE QString toAbbreviatedString(Qgis::DistanceUnit unit)
Returns a translated abbreviation representing a distance unit.
Definition
qgsunittypes.cpp:590
qgis.h
operator==
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition
qgsfeatureiterator.h:427
operator!=
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition
qgsfeatureiterator.h:432
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:245
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:263
Generated on
for QGIS API Documentation by
1.17.0