QGIS API Documentation 3.41.0-Master (3440c17df1d)
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
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
74 QgsLabelPosition() = default;
75
76#ifdef SIP_RUN
77 SIP_PYOBJECT __repr__();
78 % MethodCode
79 const QString text = sipCpp->labelText;
80 QString str = QStringLiteral( "<QgsLabelPosition: \"%1\"%2>" ).arg( text, sipCpp->isUnplaced ? QStringLiteral( " (unplaced)" ) : QString() );
81 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
82 % End
83#endif
84
89
93 double rotation = 0;
94
95 QVector< QgsPointXY > cornerPoints;
97
103
107 double width = 0;
108
112 double height = 0;
113
117 QString layerID;
118
122 QString labelText;
123
128
132 bool upsideDown = false;
133
137 bool isDiagram = false;
138
142 bool isPinned = false;
143
147 QString providerID;
148
153 bool isUnplaced = false;
154
160 long long groupedLabelId = 0;
161};
162
163#endif // QGSLABELPOSITION_H
A geometry is the spatial representation of a feature.
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
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.
#define str(x)
Definition qgis.cpp:39
#define FID_NULL
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features