QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
33 class 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 
89  QgsFeatureId featureId = FID_NULL;
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 
128  QFont labelFont;
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
qgsrectangle.h
FID_NULL
#define FID_NULL
Definition: qgsfeatureid.h:29
QgsLabelPosition::labelFont
QFont labelFont
Font which the label is rendered using.
Definition: qgslabelposition.h:128
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsLabelPosition::QgsLabelPosition
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.
Definition: qgslabelposition.h:55
QgsLabelPosition
Represents the calculated placement of a map label.
Definition: qgslabelposition.h:33
QgsLabelPosition::providerID
QString providerID
ID of the associated label provider.
Definition: qgslabelposition.h:149
QgsLabelPosition::labelRect
QgsRectangle labelRect
Definition: qgslabelposition.h:97
qgis_sip.h
QgsLabelPosition::labelText
QString labelText
String shown in label.
Definition: qgslabelposition.h:123
QgsLabelPosition::layerID
QString layerID
ID of associated map layer.
Definition: qgslabelposition.h:118
qgsgeometry.h
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
str
#define str(x)
Definition: qgis.cpp:37
QgsLabelPosition::labelGeometry
QgsGeometry labelGeometry
A polygon geometry representing the label's bounds in map coordinates.
Definition: qgslabelposition.h:103
QgsLabelPosition::cornerPoints
QVector< QgsPointXY > cornerPoints
Definition: qgslabelposition.h:96
qgspointxy.h
QgsFeatureId
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28