QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
32class CORE_EXPORT QgsLabelPosition
33{
34 public:
35
54 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(),
55 const QgsGeometry &labelGeometry = QgsGeometry(), bool isUnplaced = false )
56 : featureId( id )
57 , rotation( r )
58 , cornerPoints( corners )
59 , labelRect( rect )
61 , width( w )
62 , height( h )
63 , layerID( layer )
64 , labelText( labeltext )
65 , labelFont( labelfont )
66 , upsideDown( upside_down )
67 , isDiagram( diagram )
68 , isPinned( pinned )
69 , providerID( providerId )
71 {}
72
73 QgsLabelPosition() = default;
74
75#ifdef SIP_RUN
76 SIP_PYOBJECT __repr__();
77 % MethodCode
78 const QString text = sipCpp->labelText;
79 QString str = QStringLiteral( "<QgsLabelPosition: \"%1\"%2>" ).arg( text, sipCpp->isUnplaced ? QStringLiteral( " (unplaced)" ) : QString() );
80 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
81 % End
82#endif
83
88
92 double rotation = 0;
93
94 QVector< QgsPointXY > cornerPoints;
96
102
106 double width = 0;
107
111 double height = 0;
112
116 QString layerID;
117
121 QString labelText;
122
127
131 bool upsideDown = false;
132
136 bool isDiagram = false;
137
141 bool isPinned = false;
142
146 QString providerID;
147
152 bool isUnplaced = false;
153
159 long long groupedLabelId = 0;
160};
161
162#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