QGIS API Documentation 3.29.0-Master (19d7edcfed)
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
22#include "qgspointxy.h"
23#include "qgsrectangle.h"
24#include "qgsgeometry.h"
25
26#include <QFont>
27
33class CORE_EXPORT QgsLabelPosition
34{
35 public:
36
55 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(),
56 const QgsGeometry &labelGeometry = QgsGeometry(), bool isUnplaced = false )
57 : featureId( id )
58 , rotation( r )
59 , cornerPoints( corners )
60 , labelRect( rect )
61 , labelGeometry( labelGeometry )
62 , width( w )
63 , height( h )
64 , layerID( layer )
65 , labelText( labeltext )
66 , labelFont( labelfont )
67 , upsideDown( upside_down )
68 , isDiagram( diagram )
69 , isPinned( pinned )
70 , providerID( providerId )
71 , isUnplaced( isUnplaced )
72 {}
73
75 QgsLabelPosition() = default;
76
77#ifdef SIP_RUN
78 SIP_PYOBJECT __repr__();
79 % MethodCode
80 const QString text = sipCpp->labelText;
81 QString str = QStringLiteral( "<QgsLabelPosition: \"%1\"%2>" ).arg( text, sipCpp->isUnplaced ? QStringLiteral( " (unplaced)" ) : QString() );
82 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
83 % End
84#endif
85
90
94 double rotation = 0;
95
96 QVector< QgsPointXY > cornerPoints;
98
104
108 double width = 0;
109
113 double height = 0;
114
118 QString layerID;
119
123 QString labelText;
124
129
133 bool upsideDown = false;
134
138 bool isDiagram = false;
139
143 bool isPinned = false;
144
149 QString providerID;
150
155 bool isUnplaced = false;
156
162 long long groupedLabelId = 0;
163};
164
165#endif // QGSLABELPOSITION_H
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:164
Represents the calculated placement of a map label.
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.
QString labelText
String shown in label.
QString providerID
ID of the associated label provider.
QgsLabelPosition()=default
Constructor for QgsLabelPosition.
QFont labelFont
Font which the label is rendered using.
QgsRectangle labelRect
QVector< QgsPointXY > cornerPoints
QString layerID
ID of associated map layer.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
#define str(x)
Definition: qgis.cpp:37
#define FID_NULL
Definition: qgsfeatureid.h:29
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28