QGIS API Documentation 4.3.0-Master (0ff9723465c)
Loading...
Searching...
No Matches
qgspallabeling.h
Go to the documentation of this file.
1/***************************************************************************
2 qgspallabeling.h
3 Smart labeling for vector layers
4 -------------------
5 begin : June 2009
6 copyright : (C) Martin Dobias
7 email : wonder dot sk at gmail dot com
8
9 ***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSPALLABELING_H
19#define QGSPALLABELING_H
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
24#include "qgsexpression.h"
25#include "qgsfeature.h"
26#include "qgsfields.h"
27#include "qgsgeometry.h"
33#include "qgsmapunitscale.h"
34#include "qgspointxy.h"
36#include "qgsstringutils.h"
37#include "qgstextformat.h"
38
39#include <QColor>
40#include <QFont>
41#include <QFontDatabase>
42#include <QHash>
43#include <QList>
44#include <QMap>
45#include <QPainter>
46#include <QRectF>
47#include <QString>
48
49class QgsTextDocument;
52
53namespace pal SIP_SKIP
54{
55 class Pal;
56 class Layer;
57 class LabelPosition;
58} //namespace pal
59
61class QgsRectangle;
62class QgsMapToPixel;
63class QgsFeature;
65class QgsVectorLayer;
66class QgsExpression;
67class QFontMetricsF;
68class QPainter;
69class QPicture;
70class QgsGeometry;
73class QgsMapLayer;
74class QgsMapSettings;
75class QgsLabelFeature;
79class QgsDxfExport;
82class QgsCallout;
83class QMimeData;
84
90class CORE_EXPORT QgsPalLayerSettings
91{
92 public:
96
99
100 // *INDENT-OFF*
103 {
104 // text style
105 Size = 0,
106 Bold = 1,
107 Italic = 2,
108 Underline = 3,
109 Color = 4,
110 Strikeout = 5,
111 Family = 6,
112 FontStyle = 21,
113 FontSizeUnit = 22,
114 FontTransp = 18,
115 FontOpacity = 92,
116 FontCase = 27,
117 FontLetterSpacing = 28,
118 FontWordSpacing = 29,
119 FontBlendMode = 30,
120 FontStretchFactor = 113,
121
122 // text formatting
123 MultiLineWrapChar = 31,
124 AutoWrapLength = 101,
125 MultiLineHeight = 32,
126 MultiLineAlignment = 33,
127 TextOrientation = 110,
128 TabStopDistance = 120,
129 DirSymbDraw = 34,
130 DirSymbLeft = 35,
131 DirSymbRight = 36,
132 DirSymbPlacement = 37,
133 DirSymbReverse = 38,
134 NumFormat = 39,
135 NumDecimals = 40,
136 NumPlusSign = 41,
137
138 // text buffer
139 BufferDraw = 42,
140 BufferSize = 7,
141 BufferUnit = 43,
142 BufferColor = 8,
143 BufferTransp = 19,
144 BufferOpacity = 94,
145 BufferJoinStyle = 44,
146 BufferBlendMode = 45,
147
148 // mask buffer
149 MaskEnabled = 104,
150 MaskBufferSize = 105,
151 MaskBufferUnit = 106,
152 MaskOpacity = 107,
153 MaskJoinStyle = 108,
154
155 // background
156 ShapeDraw = 46,
157 ShapeKind = 47,
158 ShapeSVGFile = 48,
159 ShapeSizeType = 49,
160 ShapeSizeX = 50,
161 ShapeSizeY = 85,
162 ShapeSizeUnits = 51,
163 ShapeRotationType = 52,
164 ShapeRotation = 53,
165 ShapeOffset = 54,
166 ShapeOffsetUnits = 55,
167 ShapeRadii = 56,
168 ShapeRadiiUnits = 57,
169 ShapeTransparency = 63,
170 ShapeOpacity = 93,
171 ShapeBlendMode = 64,
172 ShapeFillColor = 58,
173 ShapeStrokeColor = 59,
174 ShapeStrokeWidth = 60,
175 ShapeStrokeWidthUnits = 61,
176 ShapeJoinStyle = 62,
177
178 // drop shadow
179 ShadowDraw = 65,
180 ShadowUnder = 66,
181 ShadowOffsetAngle = 67,
182 ShadowOffsetDist = 68,
183 ShadowOffsetUnits = 69,
184 ShadowRadius = 70,
185 ShadowRadiusUnits = 71,
186 ShadowTransparency = 72,
187 ShadowOpacity = 95,
188 ShadowScale = 73,
189 ShadowColor = 74,
190 ShadowBlendMode = 75,
191
192 // placement
193 CentroidWhole = 76,
194 OffsetQuad = 77,
195 OffsetXY = 78,
196 OffsetUnits = 80,
197 LabelDistance = 13,
198 MaximumDistance = 119,
199 DistanceUnits = 81,
200 OffsetRotation = 82,
201 CurvedCharAngleInOut = 83,
202 // (data defined only)
203 PositionX = 9,
204 PositionY = 10,
205 PositionPoint = 114,
206 Hali = 11,
207 Vali = 12,
208 Rotation = 14,
209 LabelRotation = 96,
210 RepeatDistance = 84,
211 RepeatDistanceUnit = 86,
212 Priority = 87,
213 PredefinedPositionOrder = 91,
214 LinePlacementOptions = 99,
215 OverrunDistance = 102,
216
217 // TODO QGIS 5.0 - rename this
218 LabelAllParts = 103,
219
220 PolygonLabelOutside = 109,
221 LineAnchorPercent = 111,
222 LineAnchorClipping = 112,
223 LineAnchorType = 115,
224 LineAnchorTextPoint = 116,
225 CurvedLabelMode = 124,
226
227 // rendering
228 ScaleVisibility = 23,
229 MinScale = 16,
230 MinimumScale = 97,
231 MaxScale = 17,
232 MaximumScale = 98,
233 FontLimitPixel = 24,
234 FontMinPixel = 25,
235 FontMaxPixel = 26,
236 IsObstacle = 88,
237 ObstacleFactor = 89,
238 ZIndex = 90,
239 CalloutDraw = 100,
240
241 AllowDegradedPlacement = 117,
242 OverlapHandling = 118,
243 WhitespaceCollisionHandling = 125,
244
245 LabelMarginDistance = 121,
246 RemoveDuplicateLabels = 122,
247 RemoveDuplicateLabelDistance = 123,
248
249 // (data defined only)
250 Show = 15,
251 AlwaysShow = 20
252 };
253 // *INDENT-ON*
254
266 bool prepare( QgsRenderContext &context, QSet<QString> &attributeNames SIP_INOUT, const QgsFields &fields, const QgsMapSettings &mapSettings, const QgsCoordinateReferenceSystem &crs );
267
272 QSet<QString> referencedFields( const QgsRenderContext &context ) const;
273
282 void startRender( QgsRenderContext &context );
283
291 void stopRender( QgsRenderContext &context );
292
298 bool containsAdvancedEffects() const;
299
303 static const QgsPropertiesDefinition &propertyDefinitions();
304
312 bool drawLabels = true;
313
314 //-- text style
315
321 QString fieldName;
322
327 bool isExpression = false;
328
333
337 Q_DECL_DEPRECATED QColor previewBkgrdColor = Qt::white;
338
342 bool useSubstitutions = false;
343
344 //-- text formatting
345
350 QString wrapChar;
351
360
372
375
382 bool formatNumbers = false;
383
389 int decimals = 3;
390
396 bool plusSign = false;
397
398 //-- placement
399
402
409 Qgis::LabelPolygonPlacementFlags polygonPlacementFlags() const { return mPolygonPlacementFlags; }
410
417 void setPolygonPlacementFlags( Qgis::LabelPolygonPlacementFlags flags ) { mPolygonPlacementFlags = flags; }
418
423 bool centroidWhole = false;
424
430 bool centroidInside = false;
431
435 bool fitInPolygonOnly = false;
436
442 double dist = 0;
443
450
457
460
466 double repeatDistance = 0;
467
474
481
488 double xOffset = 0;
489
496 double yOffset = 0;
497
505
513
515 double angleOffset = 0;
516
518 bool preserveRotation = true;
519
526
532 void setRotationUnit( Qgis::AngleUnit angleUnit );
533
538 double maxCurvedCharAngleIn = 25.0;
539
544 double maxCurvedCharAngleOut = -25.0;
545
550 int priority = 5;
551
552 //-- rendering
553
559 bool scaleVisibility = false;
560
571 double maximumScale = 0;
572
583 double minimumScale = 0;
584
590 bool fontLimitPixelSize = false;
591
598
604 int fontMaxPixelSize = 10000;
605
608
610 double zIndex = 0;
611
614
617
620
626
631 void setLegendString( const QString &legendString ) { mLegendString = legendString; }
632
637 QString legendString() const { return mLegendString; }
638
651 Q_DECL_DEPRECATED void calculateLabelSize(
652 const QFontMetricsF *fm,
653 const QString &text,
654 double &labelX,
655 double &labelY,
656 const QgsFeature *f = nullptr,
657 QgsRenderContext *context = nullptr,
658 double *rotatedLabelX SIP_OUT = nullptr,
659 double *rotatedLabelY SIP_OUT = nullptr
661
671 void registerFeature( const QgsFeature &f, QgsRenderContext &context );
672
673#ifndef SIP_RUN
674
687 std::vector< std::unique_ptr< QgsLabelFeature > > registerFeatureWithDetails( const QgsFeature &feature, QgsRenderContext &context, const QgsLabelFeatureDetails &details );
688
689#endif
690
694 void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
695
699 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
700
705 QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
706
713 const QgsPropertyCollection &dataDefinedProperties() const SIP_SKIP { return mDataDefinedProperties; }
714
721 void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
722
727 const QgsTextFormat &format() const { return mFormat; }
728
734 void setFormat( const QgsTextFormat &format ) { mFormat = format; }
735
744 QgsCallout *callout() const { return mCallout.get(); }
745
754 void setCallout( QgsCallout *callout SIP_TRANSFER );
755
764 const QgsLabelLineSettings &lineSettings() const SIP_SKIP { return mLineSettings; }
765
773 QgsLabelLineSettings &lineSettings() { return mLineSettings; }
774
782 void setLineSettings( const QgsLabelLineSettings &settings ) { mLineSettings = settings; }
783
793 const QgsLabelPointSettings &pointSettings() const SIP_SKIP { return mPointSettings; }
794
803 QgsLabelPointSettings &pointSettings() { return mPointSettings; }
804
813 void setPointSettings( const QgsLabelPointSettings &settings ) { mPointSettings = settings; }
814
821 const QgsLabelObstacleSettings &obstacleSettings() const SIP_SKIP { return mObstacleSettings; }
822
828 QgsLabelObstacleSettings &obstacleSettings() { return mObstacleSettings; }
829
835 void setObstacleSettings( const QgsLabelObstacleSettings &settings ) { mObstacleSettings = settings; }
836
843 const QgsLabelThinningSettings &thinningSettings() const SIP_SKIP { return mThinningSettings; }
844
850 QgsLabelThinningSettings &thinningSettings() { return mThinningSettings; }
851
857 void setThinningSettings( const QgsLabelThinningSettings &settings ) { mThinningSettings = settings; }
858
865 const QgsLabelPlacementSettings &placementSettings() const SIP_SKIP { return mPlacementSettings; }
866
872 QgsLabelPlacementSettings &placementSettings() { return mPlacementSettings; }
873
879 void setPlacementSettings( const QgsLabelPlacementSettings &settings ) { mPlacementSettings = settings; }
880
890 static QPixmap labelSettingsPreviewPixmap(
891 const QgsPalLayerSettings &settings, QSize size, const QString &previewText = QString(), int padding = 0, const QgsScreenProperties &screen = QgsScreenProperties()
892 );
893
900 Qgis::UnplacedLabelVisibility unplacedVisibility() const;
901
908 void setUnplacedVisibility( Qgis::UnplacedLabelVisibility visibility );
909
917 QMimeData *toMimeData() const SIP_FACTORY;
918
926 static QgsPalLayerSettings fromMimeData( const QMimeData *data, bool *ok SIP_OUT = nullptr );
927
928 // temporary stuff: set when layer gets prepared or labeled
929 const QgsFeature *mCurFeat = nullptr;
931 int fieldIndex = 0;
932 const QgsMapToPixel *xform = nullptr;
934
938 int mFeaturesToLabel = 0; // total features that will probably be labeled, may be less (figured before PAL)
939#ifndef SIP_RUN
940 mutable int mFeatsSendingToPal = 0; // total features tested for sending into PAL (relative to maxNumLabels)
941 mutable int mFeatsRegPal = 0; // number of features registered in PAL, when using limitNumLabels
942#else
943 int mFeatsSendingToPal; // total features tested for sending into PAL (relative to maxNumLabels)
944 int mFeatsRegPal; // number of features registered in PAL, when using limitNumLabels
945#endif
946
947 private:
948 friend class QgsVectorLayer; // to allow calling readFromLayerCustomProperties()
949
953 void readFromLayerCustomProperties( QgsVectorLayer *layer );
954
958 void readOldDataDefinedPropertyMap( QgsVectorLayer *layer, QDomElement *parentElem );
959
963 void readOldDataDefinedProperty( QgsVectorLayer *layer, QgsPalLayerSettings::Property p );
964
972 void calculateLabelMetrics(
973 const QFontMetricsF &fm, QgsRenderContext &context, const QgsTextFormat &format, QgsTextDocument &document, QgsTextDocumentMetrics &documentMetrics, QSizeF &size, QSizeF &rotatedSize, QRectF &outerBounds
974 ) const;
975
976
977 enum DataDefinedValueType
978 {
979 DDBool,
980 DDInt,
981 DDIntPos,
982 DDDouble,
983 DDDoublePos,
984 DDRotation180,
985 DDOpacity,
986 DDString,
987 DDUnits,
988 DDColor,
989 DDJoinStyle,
990 DDBlendMode,
991 DDPointF,
992 DDSizeF,
993 };
994
995 // convenience data defined evaluation function
996 bool dataDefinedValEval( DataDefinedValueType valType, QgsPalLayerSettings::Property p, QVariant &exprVal, QgsExpressionContext &context, const QVariant &originalValue = QVariant() );
997
998 void parseTextStyle( QFont &labelFont, Qgis::RenderUnit fontunits, QgsRenderContext &context );
999
1000 void parseTextBuffer( QgsRenderContext &context );
1001
1002 void parseTextMask( QgsRenderContext &context );
1003
1004 void parseTextFormatting( QgsRenderContext &context );
1005
1006 void parseShapeBackground( QgsRenderContext &context );
1007
1008 void parseDropShadow( QgsRenderContext &context );
1009
1014 bool checkMinimumSizeMM( const QgsRenderContext &ct, const QgsGeometry &geom, double minSize ) const;
1015
1021 bool isLabelVisible( QgsRenderContext &context ) const;
1022
1029 QgsTextFormat evaluateTextFormat( QgsRenderContext &context, bool &labelIsHidden );
1030
1036 bool evaluateLabelContent( const QgsFeature &feature, QgsRenderContext &context, bool allowMultipleLines, QString &labelText, QgsTextDocument &document, const QgsTextFormat &format ) const;
1037
1041 QgsGeometry evaluateLabelGeometry( const QgsFeature &feature, QgsRenderContext &context, const QgsLabelLineSettings &lineSettings ) const;
1042
1043 std::unique_ptr< QgsTextLabelFeature> generateLabelFeature(
1044 QgsRenderContext &context,
1045 const QgsFeature &feature,
1046 int subPartId,
1047 QgsGeometry geom,
1048 const QgsGeometry &obstacleGeometry,
1049 QgsTextDocument doc,
1050 const QString &labelText,
1051 const QgsTextFormat &evaluatedFormat,
1052 const QgsSymbol *symbol,
1053 const QgsLabelLineSettings &lineSettings,
1054 const QgsLabelPointSettings &pointSettings,
1055 const QgsLabelPlacementSettings &placementSettings,
1056 bool isObstacle,
1057 bool doClip
1058 ) const;
1059
1063 std::unique_ptr< QgsLabelFeature > registerObstacleFeature( const QgsFeature &f, QgsRenderContext &context, const QgsGeometry &obstacleGeometry = QgsGeometry() );
1064
1065 QMap<Property, QVariant> dataDefinedValues;
1066
1068 QgsPropertyCollection mDataDefinedProperties;
1069
1070 mutable std::unique_ptr<QgsExpression> expression;
1071
1072 std::unique_ptr< QFontDatabase > mFontDB;
1073
1074 QgsTextFormat mFormat;
1075
1076 std::unique_ptr< QgsCallout > mCallout;
1077
1078 QgsLabelPlacementSettings mPlacementSettings;
1079 QgsLabelLineSettings mLineSettings;
1080 QgsLabelPointSettings mPointSettings;
1081 QgsLabelObstacleSettings mObstacleSettings;
1082 QgsLabelThinningSettings mThinningSettings;
1083
1085
1086 QgsExpression mGeometryGeneratorExpression;
1087
1088 bool mRenderStarted = false;
1089
1090 QString mLegendString = QObject::tr( "Aa" );
1091
1093
1096
1097 static void initPropertyDefinitions();
1098};
1099
1100
1106class CORE_EXPORT QgsPalLabeling
1107{
1108 public:
1112 static bool staticWillUseLayer( const QgsMapLayer *layer );
1113
1114 // clang-format off
1124 static QgsGeometry prepareGeometry( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry = QgsGeometry(), bool mergeLines = false ) SIP_FACTORY;
1125 // clang-format on
1126
1136 static bool geometryRequiresPreparation(
1137 const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry = QgsGeometry(), bool mergeLines = false
1138 );
1139
1151 static QStringList splitToLines( const QString &text, const QString &wrapCharacter, int autoWrapLength = 0, bool useMaxLineLengthWhenAutoWrapping = true );
1152
1160 static QStringList splitToGraphemes( const QString &text );
1161
1162 private:
1164 static void dataDefinedTextStyle( QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1165
1167 static void dataDefinedTextFormatting( QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1168
1170 static void dataDefinedTextBuffer( QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1171
1173 static void dataDefinedTextMask( QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1174
1176 static void dataDefinedShapeBackground( QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1177
1179 static void dataDefinedDropShadow( QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1180
1181 friend class QgsVectorLayerLabelProvider; // to allow calling the static methods above
1182 friend class QgsDxfExport; // to allow calling the static methods above
1183
1191 static bool checkMinimumSizeMM( const QgsRenderContext &context, const QgsGeometry &geom, double minSize );
1192
1194};
1195
1196
1197#endif // QGSPALLABELING_H
AngleUnit
Units of angles.
Definition qgis.h:5673
@ Degrees
Degrees.
Definition qgis.h:5674
LabelOffsetType
Behavior modifier for label offset and distance, only applies in some label placement modes.
Definition qgis.h:1361
@ FromPoint
Offset distance applies from point geometry.
Definition qgis.h:1362
LabelPlacement
Placement modes which determine how label candidates are generated for a feature.
Definition qgis.h:1287
@ AroundPoint
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
Definition qgis.h:1288
@ AllowPlacementInsideOfPolygon
Labels can be placed inside a polygon feature.
Definition qgis.h:1422
QFlags< LabelPolygonPlacementFlag > LabelPolygonPlacementFlags
Polygon placement flags, which control how candidates are generated for a polygon feature.
Definition qgis.h:1432
UnplacedLabelVisibility
Unplaced label visibility.
Definition qgis.h:1236
@ FollowEngineSetting
Respect the label engine setting.
Definition qgis.h:1237
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:379
@ Point
Points.
Definition qgis.h:380
@ Unknown
Unknown types.
Definition qgis.h:383
LabelMultiLineAlignment
Text alignment for multi-line labels.
Definition qgis.h:1458
@ FollowPlacement
Alignment follows placement of label, e.g., labels to the left of a feature will be drawn with right ...
Definition qgis.h:1462
RenderUnit
Rendering size units.
Definition qgis.h:5738
@ Millimeters
Millimeters.
Definition qgis.h:5739
UpsideDownLabelHandling
Handling techniques for upside down labels.
Definition qgis.h:1443
@ FlipUpsideDownLabels
Upside-down labels (90 <= angle < 270) are shown upright.
Definition qgis.h:1444
Abstract base class for callout renderers.
Definition qgscallout.h:55
Represents a coordinate reference system (CRS).
Handles coordinate transforms between two coordinate systems.
Stores the settings for rendering of all diagrams for a layer.
Exports QGIS layers to the DXF format.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Handles parsing and evaluation of expressions (formerly called "search strings").
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:60
Container of fields for a vector layer.
Definition qgsfields.h:45
A geometry is the spatial representation of a feature.
Encapsulates details for an individual feature to label.
Describes a feature that should be used within the labeling engine.
Contains settings related to how the label engine places and formats labels for line features (or pol...
Contains settings related to how the label engine treats features as obstacles.
Contains general settings related to how labels are placed.
Contains settings related to how the label engine places and formats labels for point-like features.
Queries the labeling structure at a given point.
Contains settings related to how the label engine removes candidate label positions and reduces the n...
Provides map labeling functionality.
Base class for all map layer types.
Definition qgsmaplayer.h:83
Contains configuration for rendering maps.
Perform transforms between map coordinates and device coordinates.
Struct for storing maximum and minimum scales for measurements in map units.
PAL labeling utilities.
friend class QgsVectorLayerLabelProvider
friend class QgsDxfExport
static QStringList splitToLines(const QString &text, const QString &wrapCharacter, int autoWrapLength=0, bool useMaxLineLengthWhenAutoWrapping=true)
Splits a text string to a list of separate lines, using a specified wrap character (wrapCharacter).
static QgsGeometry prepareGeometry(const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry=QgsGeometry(), bool mergeLines=false)
Prepares a geometry for registration with PAL.
static bool geometryRequiresPreparation(const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry=QgsGeometry(), bool mergeLines=false)
Checks whether a geometry requires preparation before registration with PAL.
friend class QgsPalLayerSettings
static bool staticWillUseLayer(const QgsMapLayer *layer)
Called to find out whether a specified layer is used for labeling.
static QStringList splitToGraphemes(const QString &text)
Splits a text string to a list of graphemes, which are the smallest allowable character divisions in ...
Contains settings for how a map layer will be labeled.
bool fitInPolygonOnly
true if only labels which completely fit within a polygon are allowed.
double yOffset
Vertical offset of label.
QgsMapUnitScale labelOffsetMapUnitScale
Map unit scale for label offset.
const QgsLabelObstacleSettings & obstacleSettings() const
Returns the label obstacle settings.
int fontMaxPixelSize
Maximum pixel size for showing rendered map unit labels (1 - 10000).
void setObstacleSettings(const QgsLabelObstacleSettings &settings)
Sets the label obstacle settings.
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the label's property collection, used for data defined overrides.
const QgsLabelPlacementSettings & placementSettings() const
Returns the label placement settings.
double maxCurvedCharAngleIn
Maximum angle between inside curved label characters (valid range 20.0 to 60.0).
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
double zIndex
Z-Index of label, where labels with a higher z-index are rendered on top of labels with a lower z-ind...
const QgsMapToPixel * xform
void setPolygonPlacementFlags(Qgis::LabelPolygonPlacementFlags flags)
Sets the polygon placement flags, which dictate how polygon labels can be placed.
QString wrapChar
Wrapping character string.
Qgis::LabelOffsetType offsetType
Offset type for layer (only applies in certain placement modes).
double xOffset
Horizontal offset of label.
Qgis::LabelPlacement placement
Label placement mode.
QgsCoordinateTransform ct
bool drawLabels
Whether to draw labels for this layer.
bool fontLimitPixelSize
true if label sizes should be limited by pixel size.
QString legendString() const
legendString
friend class QgsVectorLayer
double minimumScale
The minimum map scale (i.e.
QgsLabelPointSettings & pointSettings()
Returns the label point settings, which contain settings related to how the label engine places and f...
QgsPalLayerSettings & operator=(const QgsPalLayerSettings &s)
copy operator - only copies the permanent members
void setLineSettings(const QgsLabelLineSettings &settings)
Sets the label line settings, which contain settings related to how the label engine places and forma...
bool scaleVisibility
Set to true to limit label visibility to a range of scales.
double repeatDistance
Distance for repeating labels for a single feature.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the label's property collection, used for data defined overrides.
QgsLabelLineSettings & lineSettings()
Returns the label line settings, which contain settings related to how the label engine places and fo...
QgsExpression * getLabelExpression() const
Returns the QgsExpression for this label settings.
bool geometryGeneratorEnabled
Defines if the geometry generator is enabled or not. If disabled, the standard geometry will be taken...
Qgis::LabelMultiLineAlignment multilineAlign
Horizontal alignment of multi-line labels.
bool centroidInside
true if centroid positioned labels must be placed inside their corresponding feature polygon,...
int priority
Label priority.
Qgis::GeometryType geometryGeneratorType
The type of the result geometry of the geometry generator.
QgsCallout * callout() const
Returns the label callout renderer, responsible for drawing label callouts.
int fontMinPixelSize
Minimum pixel size for showing rendered map unit labels (1 - 1000).
double angleOffset
Label rotation, in degrees clockwise.
double maxCurvedCharAngleOut
Maximum angle between outside curved label characters (valid range -20.0 to -95.0).
const QgsLabelThinningSettings & thinningSettings() const
Returns the label thinning settings.
Qgis::AngleUnit rotationUnit() const
Unit for rotation of labels.
Qgis::GeometryType layerType
Geometry type of layers associated with these settings.
void setLegendString(const QString &legendString)
setLegendString
void setThinningSettings(const QgsLabelThinningSettings &settings)
Sets the label thinning settings.
Qgis::RenderUnit offsetUnits
Units for offsets of label.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the label's property collection, used for data defined overrides.
bool isExpression
true if this label is made from a expression string, e.g., FieldName || 'mm'
bool preserveRotation
True if label rotation should be preserved during label pin/unpin operations.
void setPlacementSettings(const QgsLabelPlacementSettings &settings)
Sets the label placement settings.
bool plusSign
Whether '+' signs should be prepended to positive numeric labels.
QgsLabelThinningSettings & thinningSettings()
Returns the label thinning settings.
QString geometryGenerator
The geometry generator expression. Null if disabled.
const QgsLabelLineSettings & lineSettings() const
Returns the label line settings, which contain settings related to how the label engine places and fo...
QgsMapUnitScale distMapUnitScale
Map unit scale for label feature distance.
QgsStringReplacementCollection substitutions
Substitution collection for automatic text substitution with labels.
Q_DECL_DEPRECATED QColor previewBkgrdColor
const QgsFeature * mCurFeat
int decimals
Number of decimal places to show for numeric labels.
double dist
Distance from feature to the label.
void setRotationUnit(Qgis::AngleUnit angleUnit)
Set unit for rotation of labels.
QgsMapUnitScale repeatDistanceMapUnitScale
Map unit scale for repeating labels for a single feature.
Qgis::RenderUnit distUnits
Units the distance from feature to the label.
bool centroidWhole
true if feature centroid should be calculated from the whole feature, or false if only the visible pa...
Property
Data definable properties.
Qgis::RenderUnit repeatDistanceUnit
Units for repeating labels for a single feature.
Qgis::UpsideDownLabelHandling upsidedownLabels
Controls whether upside down labels are displayed and how they are handled.
QString fieldName
Name of field (or an expression) to use for label text.
void setPointSettings(const QgsLabelPointSettings &settings)
Sets the label point settings, which contain settings related to how the label engine places and form...
bool formatNumbers
Set to true to format numeric label text as numbers (e.g.
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc.
QgsLabelPlacementSettings & placementSettings()
Returns the label placement settings.
double maximumScale
The maximum map scale (i.e.
int autoWrapLength
If non-zero, indicates that label text should be automatically wrapped to (ideally) the specified num...
bool useMaxLineLengthForAutoWrap
If true, indicates that when auto wrapping label text the autoWrapLength length indicates the maximum...
const QgsLabelPointSettings & pointSettings() const
Returns the label point settings, which contain settings related to how the label engine places and f...
Qgis::LabelPolygonPlacementFlags polygonPlacementFlags() const
Returns the polygon placement flags, which dictate how polygon labels can be placed.
QgsLabelObstacleSettings & obstacleSettings()
Returns the label obstacle settings.
bool useSubstitutions
True if substitutions should be applied.
Represents a 2D point.
Definition qgspointxy.h:62
A grouped map of multiple QgsProperty objects, each referenced by an integer key value.
A container for the context for various read/write operations on objects.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
Stores properties relating to a screen.
A collection of string replacements (specified using QgsStringReplacement objects).
Abstract base class for all rendered symbols.
Definition qgssymbol.h:227
Contains pre-calculated metrics of a QgsTextDocument.
Represents a document consisting of one or more QgsTextBlock objects.
Container for all settings relating to text rendering.
Adds extra information to QgsLabelFeature for text labels.
Implements support for diagrams within the labeling engine.
Implements a label provider for vector layers.
Represents a vector layer which manages a vector based dataset.
LabelPosition is a candidate feature label position.
A set of features which influence the labeling process.
Definition layer.h:63
Main Pal labeling class.
Definition pal.h:87
#define SIP_DEPRECATED
Definition qgis_sip.h:113
#define SIP_SKIP
Definition qgis_sip.h:138
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition qgis_sip.h:270
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_OUT
Definition qgis_sip.h:57
#define SIP_FACTORY
Definition qgis_sip.h:83
#define SIP_INOUT
Definition qgis_sip.h:78
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.