QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
layout
qgslayoutmeasurement.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgslayoutmeasurement.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 QGSLAYOUTMEASUREMENT_H
19
#define QGSLAYOUTMEASUREMENT_H
20
21
#include "
qgis.h
"
22
#include "qgis_core.h"
23
#include "
qgsunittypes.h
"
24
25
#include <QString>
26
27
using namespace
Qt::StringLiterals;
28
36
class
CORE_EXPORT
QgsLayoutMeasurement
37
{
38
public
:
44
explicit
QgsLayoutMeasurement
(
double
length
,
Qgis::LayoutUnit
units
=
Qgis::LayoutUnit::Millimeters
);
45
50
double
length
()
const
{
return
mLength; }
51
56
void
setLength
(
const
double
length
) { mLength =
length
; }
57
62
Qgis::LayoutUnit
units
()
const
{
return
mUnits; }
63
69
void
setUnits
(
const
Qgis::LayoutUnit
units
) { mUnits =
units
; }
70
75
QString encodeMeasurement()
const
;
76
81
static
QgsLayoutMeasurement
decodeMeasurement(
const
QString &
string
);
82
83
bool
operator==
(
QgsLayoutMeasurement
other )
const
;
84
bool
operator!=
(
QgsLayoutMeasurement
other )
const
;
85
89
QgsLayoutMeasurement
operator+
(
double
v )
const
;
90
94
QgsLayoutMeasurement
operator+=(
double
v );
95
99
QgsLayoutMeasurement
operator-
(
double
v )
const
;
100
104
QgsLayoutMeasurement
operator-=(
double
v );
105
109
QgsLayoutMeasurement
operator*
(
double
v )
const
;
110
114
QgsLayoutMeasurement
operator*=(
double
v );
115
119
QgsLayoutMeasurement
operator/
(
double
v )
const
;
120
124
QgsLayoutMeasurement
operator/=(
double
v );
125
126
#ifdef SIP_RUN
127
// clang-format off
128
SIP_PYOBJECT __repr__();
129
% MethodCode
130
QString str = u
"<QgsLayoutMeasurement: %1 %2 >"
_s.arg( sipCpp->length() ).arg(
QgsUnitTypes::toAbbreviatedString
( sipCpp->units() ) );
131
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
132
% End
133
// clang-format on
134
#endif
135
136
// clang-format off
137
private
:
138
// clang-format on
139
140
double
mLength
141
= 0.0;
142
Qgis::LayoutUnit
mUnits =
Qgis::LayoutUnit::Millimeters
;
143
};
144
145
#endif
// QGSLAYOUTMEASUREMENT_H
Qgis::LayoutUnit
LayoutUnit
Layout measurement units.
Definition
qgis.h:5778
Qgis::LayoutUnit::Millimeters
@ Millimeters
Millimeters.
Definition
qgis.h:5779
QgsLayoutMeasurement
Provides a method of storing measurements for use in QGIS layouts using a variety of different measur...
Definition
qgslayoutmeasurement.h:37
QgsLayoutMeasurement::setLength
void setLength(const double length)
Sets the length of the measurement.
Definition
qgslayoutmeasurement.h:56
QgsLayoutMeasurement::units
Qgis::LayoutUnit units() const
Returns the units for the measurement.
Definition
qgslayoutmeasurement.h:62
QgsLayoutMeasurement::QgsLayoutMeasurement
QgsLayoutMeasurement(double length, Qgis::LayoutUnit units=Qgis::LayoutUnit::Millimeters)
Constructor for QgsLayoutMeasurement.
Definition
qgslayoutmeasurement.cpp:28
QgsLayoutMeasurement::setUnits
void setUnits(const Qgis::LayoutUnit units)
Sets the units for the measurement.
Definition
qgslayoutmeasurement.h:69
QgsLayoutMeasurement::length
double length() const
Returns the length of the measurement.
Definition
qgslayoutmeasurement.h:50
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-
QgsInterval operator-(QDate date1, QDate date2)
Returns the interval between two dates.
Definition
qgsinterval.cpp:315
operator+
QDateTime operator+(const QDateTime &start, const QgsInterval &interval)
Adds an interval to a datetime.
Definition
qgsinterval.cpp:310
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
qgsunittypes.h
Generated on
for QGIS API Documentation by
1.17.0