QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
layout
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 "qgsconfig.h"
22
23
#include "
qgis.h
"
24
#include "qgis_core.h"
25
26
#include <QSizeF>
27
#include <QString>
28
29
using namespace
Qt::StringLiterals;
30
46
class
CORE_EXPORT
QgsLayoutSize
47
{
48
public
:
55
QgsLayoutSize
(
double
width
,
double
height
,
Qgis::LayoutUnit
units
=
Qgis::LayoutUnit::Millimeters
);
56
60
explicit
QgsLayoutSize
( QSizeF size,
Qgis::LayoutUnit
units
=
Qgis::LayoutUnit::Millimeters
);
61
66
explicit
QgsLayoutSize
(
Qgis::LayoutUnit
units
=
Qgis::LayoutUnit::Millimeters
);
67
74
void
setSize
(
const
double
width
,
const
double
height
)
75
{
76
mWidth =
width
;
77
mHeight =
height
;
78
#ifdef QGISDEBUG
79
Q_ASSERT_X( !std::isnan(
width
) && !std::isnan(
height
),
"QgsLayoutSize"
,
"Layout size with NaN dimensions created"
);
80
#endif
81
}
82
88
double
width
()
const
{
return
mWidth; }
89
95
void
setWidth
(
const
double
width
)
96
{
97
mWidth =
width
;
98
#ifdef QGISDEBUG
99
Q_ASSERT_X( !std::isnan(
width
),
"QgsLayoutSize"
,
"Layout size with NaN dimensions created"
);
100
#endif
101
}
102
108
double
height
()
const
{
return
mHeight; }
109
115
void
setHeight
(
const
double
height
)
116
{
117
mHeight =
height
;
118
#ifdef QGISDEBUG
119
Q_ASSERT_X( !std::isnan(
height
),
"QgsLayoutSize"
,
"Layout size with NaN dimensions created"
);
120
#endif
121
}
122
127
Qgis::LayoutUnit
units
()
const
{
return
mUnits; }
128
134
void
setUnits
(
const
Qgis::LayoutUnit
units
) { mUnits =
units
; }
135
141
bool
isEmpty()
const
;
142
148
QSizeF toQSizeF()
const
;
149
154
QString encodeSize()
const
;
155
160
static
QgsLayoutSize
decodeSize(
const
QString &
string
);
161
162
bool
operator==
(
const
QgsLayoutSize
&other )
const
;
163
bool
operator!=
(
const
QgsLayoutSize
&other )
const
;
164
168
QgsLayoutSize
operator*
(
double
v )
const
;
169
173
QgsLayoutSize
operator*=(
double
v );
174
178
QgsLayoutSize
operator/
(
double
v )
const
;
179
183
QgsLayoutSize
operator/=(
double
v );
184
185
#ifdef SIP_RUN
186
// clang-format off
187
SIP_PYOBJECT __repr__();
188
% MethodCode
189
QString str = u
"<QgsLayoutSize: %1 x %2 %3 >"
_s.arg( sipCpp->width() ).arg( sipCpp->height() ).arg(
QgsUnitTypes::toAbbreviatedString
( sipCpp->units() ) );
190
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
191
% End
192
// clang-format on
193
#endif
194
195
// clang-format off
196
private
:
197
// clang-format on
198
199
double
mWidth
200
= 0.0;
201
double
mHeight = 0.0;
202
Qgis::LayoutUnit
mUnits =
Qgis::LayoutUnit::Millimeters
;
203
};
204
205
#endif
// QGSLAYOUTSIZE_H
Qgis::LayoutUnit
LayoutUnit
Layout measurement units.
Definition
qgis.h:5778
Qgis::LayoutUnit::Millimeters
@ Millimeters
Millimeters.
Definition
qgis.h:5779
QgsLayoutSize
Provides a method of storing sizes, consisting of a width and height, for use in QGIS layouts.
Definition
qgslayoutsize.h:47
QgsLayoutSize::setUnits
void setUnits(const Qgis::LayoutUnit units)
Sets the units for the size.
Definition
qgslayoutsize.h:134
QgsLayoutSize::setSize
void setSize(const double width, const double height)
Sets new width and height for the size.
Definition
qgslayoutsize.h:74
QgsLayoutSize::height
double height() const
Returns the height of the size.
Definition
qgslayoutsize.h:108
QgsLayoutSize::setWidth
void setWidth(const double width)
Sets the width for the size.
Definition
qgslayoutsize.h:95
QgsLayoutSize::units
Qgis::LayoutUnit units() const
Returns the units for the size.
Definition
qgslayoutsize.h:127
QgsLayoutSize::width
double width() const
Returns the width of the size.
Definition
qgslayoutsize.h:88
QgsLayoutSize::setHeight
void setHeight(const double height)
Sets the height for the size.
Definition
qgslayoutsize.h:115
QgsLayoutSize::QgsLayoutSize
QgsLayoutSize(double width, double height, Qgis::LayoutUnit units=Qgis::LayoutUnit::Millimeters)
Constructor for QgsLayoutSize.
Definition
qgslayoutsize.cpp:28
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