QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
qgslabelposition.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslabelposition.h
3 -------------------
4 begin : February 2021
5 copyright : (C) Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSLABELPOSITION_H
17#define QGSLABELPOSITION_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21#include "qgsgeometry.h"
22#include "qgspointxy.h"
23#include "qgsrectangle.h"
24
25#include <QFont>
26#include <QString>
27
28using namespace Qt::StringLiterals;
29
35class CORE_EXPORT QgsLabelPosition
36{
37 public:
57 QgsFeatureId id,
58 double r,
59 const QVector< QgsPointXY > &corners,
60 const QgsRectangle &rect,
61 double w,
62 double h,
63 const QString &layer,
64 const QString &labeltext,
65 const QFont &labelfont,
66 bool upside_down,
67 bool diagram = false,
68 bool pinned = false,
69 const QString &providerId = QString(),
71 bool isUnplaced = false
72 )
73 : featureId( id )
74 , rotation( r )
75 , cornerPoints( corners )
76 , labelRect( rect )
78 , width( w )
79 , height( h )
80 , layerID( layer )
81 , labelText( labeltext )
82 , labelFont( labelfont )
83 , upsideDown( upside_down )
84 , isDiagram( diagram )
85 , isPinned( pinned )
86 , providerID( providerId )
88 {}
89
90 QgsLabelPosition() = default;
91
92#ifdef SIP_RUN
93 // clang-format off
94 SIP_PYOBJECT __repr__();
95 % MethodCode
96 const QString text = sipCpp->labelText;
97 QString str = u"<QgsLabelPosition: \"%1\"%2>"_s.arg( text, sipCpp->isUnplaced ? u" (unplaced)"_s : QString() );
98 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
99 % End
100// clang-format on
101#endif
102
107 = FID_NULL;
108
112 double rotation = 0;
113
114 QVector< QgsPointXY > cornerPoints;
116
122
126 double width = 0;
127
131 double height = 0;
132
136 QString layerID;
137
141 QString labelText;
142
147
151 bool upsideDown = false;
152
156 bool isDiagram = false;
157
161 bool isPinned = false;
162
166 QString providerID;
167
172 bool isUnplaced = false;
173
179 long long groupedLabelId = 0;
180};
181
182#endif // QGSLABELPOSITION_H
A geometry is the spatial representation of a feature.
QgsGeometry labelGeometry
A polygon geometry representing the label's bounds in map coordinates.
QgsLabelPosition(QgsFeatureId id, double r, const QVector< QgsPointXY > &corners, const QgsRectangle &rect, double w, double h, const QString &layer, const QString &labeltext, const QFont &labelfont, bool upside_down, bool diagram=false, bool pinned=false, const QString &providerId=QString(), const QgsGeometry &labelGeometry=QgsGeometry(), bool isUnplaced=false)
Constructor for QgsLabelPosition.
bool isDiagram
true if label is a diagram.
QgsFeatureId featureId
ID of feature associated with this label.
QString labelText
String shown in label.
QString providerID
ID of the associated label provider.
bool isUnplaced
true if label position corresponds to an unplaced label.
long long groupedLabelId
If non zero, indicates that the label position is part of a group of label positions (i....
QgsLabelPosition()=default
QFont labelFont
Font which the label is rendered using.
double width
Width of label bounding box, in map units.
double height
Heeght of label bounding box, in map units.
double rotation
Rotation of label, in degrees clockwise.
bool upsideDown
true if label is upside down.
QgsRectangle labelRect
bool isPinned
true if label position has been pinned.
QVector< QgsPointXY > cornerPoints
QString layerID
ID of associated map layer.
A rectangle specified with double values.
#define FID_NULL
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features