QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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 //Note: although this file is in the core library, it is not part of the stable API
19 //and might change at any time!
20 
21 #ifndef QGSPALLABELING_H
22 #define QGSPALLABELING_H
23 
24 #include "qgis_core.h"
25 #include "qgis_sip.h"
26 #include <QString>
27 #include <QFont>
28 #include <QFontDatabase>
29 #include <QColor>
30 #include <QHash>
31 #include <QList>
32 #include <QPainter>
33 #include <QRectF>
34 #include <QMap>
35 #include "qgsfeature.h"
36 #include "qgsgeometry.h"
37 #include "qgsfields.h"
39 #include "qgspointxy.h"
40 #include "qgsmapunitscale.h"
41 #include "qgsstringutils.h"
42 #include "qgssymbol.h"
43 #include "qgstextrenderer.h"
44 #include "qgspropertycollection.h"
45 
46 namespace pal SIP_SKIP
47 {
48  class Pal;
49  class Layer;
50  class LabelPosition;
51 }
52 
54 class QgsRectangle;
55 class QgsMapToPixel;
56 class QgsFeature;
58 class QgsVectorLayer;
59 class QgsExpression;
60 class QFontMetricsF;
61 class QPainter;
62 class QPicture;
63 class QgsGeometry;
65 class QgsLabelSearchTree;
66 class QgsMapSettings;
67 class QgsLabelFeature;
68 class QgsLabelingEngine;
71 class QgsDxfExport;
74 class QgsCallout;
75 
80 class CORE_EXPORT QgsLabelPosition
81 {
82  public:
83 
102  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(),
103  const QgsGeometry &labelGeometry = QgsGeometry(), bool isUnplaced = false )
104  : featureId( id )
105  , rotation( r )
106  , cornerPoints( corners )
107  , labelRect( rect )
108  , labelGeometry( labelGeometry )
109  , width( w )
110  , height( h )
111  , layerID( layer )
112  , labelText( labeltext )
113  , labelFont( labelfont )
114  , upsideDown( upside_down )
115  , isDiagram( diagram )
116  , isPinned( pinned )
117  , providerID( providerId )
118  , isUnplaced( isUnplaced )
119  {}
120 
122  QgsLabelPosition() = default;
123 
127  QgsFeatureId featureId = FID_NULL;
128 
132  double rotation = 0;
133 
134  QVector< QgsPointXY > cornerPoints;
136 
142 
146  double width = 0;
147 
151  double height = 0;
152 
156  QString layerID;
157 
161  QString labelText;
162 
166  QFont labelFont;
167 
171  bool upsideDown = false;
172 
176  bool isDiagram = false;
177 
181  bool isPinned = false;
182 
187  QString providerID;
188 
193  bool isUnplaced = false;
194 };
195 
196 
201 class CORE_EXPORT QgsPalLayerSettings
202 {
203  public:
207 
209  QgsPalLayerSettings &operator=( const QgsPalLayerSettings &s );
210 
211  //TODO QGIS 4.0 - move to QgsLabelingEngine
212 
217  {
226  };
227 
228  //TODO QGIS 4.0 - move to QgsLabelingEngine
231  {
244  };
245 
246  //TODO QGIS 4.0 - move to QgsLabelingEngine
247 
253  {
256  };
257 
258  //TODO QGIS 4.0 - move to QgsLabelingEngine, rename to LinePlacementFlag, use Q_DECLARE_FLAGS to make
259  //LinePlacementFlags type, and replace use of pal::LineArrangementFlag
260 
265  {
266  OnLine = 1,
267  AboveLine = 2,
270  BelowLine = 4,
273  MapOrientation = 8,
276  };
277 
279  {
289  };
290 
292  {
295  ShowAll
296  };
297 
299  {
302  SymbolBelow
303  };
304 
306  {
307  MultiLeft = 0,
310  MultiFollowPlacement
312  };
313 
314  //TODO QGIS 4.0 - Move to QgsLabelingEngine
315 
321  {
322  PolygonInterior,
324  PolygonBoundary,
326  PolygonWhole
330  };
331 
333  enum Property
334  {
335  // text style
336  Size = 0,
337  Bold = 1,
338  Italic = 2,
339  Underline = 3,
340  Color = 4,
341  Strikeout = 5,
342  Family = 6,
343  FontStyle = 21,
344  FontSizeUnit = 22,
345  FontTransp = 18,
346  FontOpacity = 92,
347  FontCase = 27,
348  FontLetterSpacing = 28,
349  FontWordSpacing = 29,
350  FontBlendMode = 30,
351 
352  // text formatting
353  MultiLineWrapChar = 31,
354  AutoWrapLength = 101,
355  MultiLineHeight = 32,
356  MultiLineAlignment = 33,
357  TextOrientation = 104,
358  DirSymbDraw = 34,
359  DirSymbLeft = 35,
360  DirSymbRight = 36,
361  DirSymbPlacement = 37,
362  DirSymbReverse = 38,
363  NumFormat = 39,
364  NumDecimals = 40,
365  NumPlusSign = 41,
366 
367  // text buffer
368  BufferDraw = 42,
369  BufferSize = 7,
370  BufferUnit = 43,
371  BufferColor = 8,
372  BufferTransp = 19,
373  BufferOpacity = 94,
374  BufferJoinStyle = 44,
375  BufferBlendMode = 45,
376 
377  // background
378  ShapeDraw = 46,
379  ShapeKind = 47,
380  ShapeSVGFile = 48,
381  ShapeSizeType = 49,
382  ShapeSizeX = 50,
383  ShapeSizeY = 85,
384  ShapeSizeUnits = 51,
385  ShapeRotationType = 52,
386  ShapeRotation = 53,
387  ShapeOffset = 54,
388  ShapeOffsetUnits = 55,
389  ShapeRadii = 56,
390  ShapeRadiiUnits = 57,
391  ShapeTransparency = 63,
392  ShapeOpacity = 93,
393  ShapeBlendMode = 64,
394  ShapeFillColor = 58,
395  ShapeStrokeColor = 59,
396  ShapeStrokeWidth = 60,
397  ShapeStrokeWidthUnits = 61,
398  ShapeJoinStyle = 62,
399 
400  // drop shadow
401  ShadowDraw = 65,
402  ShadowUnder = 66,
403  ShadowOffsetAngle = 67,
404  ShadowOffsetDist = 68,
405  ShadowOffsetUnits = 69,
406  ShadowRadius = 70,
407  ShadowRadiusUnits = 71,
408  ShadowTransparency = 72,
409  ShadowOpacity = 95,
410  ShadowScale = 73,
411  ShadowColor = 74,
412  ShadowBlendMode = 75,
413 
414  // placement
415  CentroidWhole = 76,
416  OffsetQuad = 77,
417  OffsetXY = 78,
418  OffsetUnits = 80,
419  LabelDistance = 13,
420  DistanceUnits = 81,
421  OffsetRotation = 82,
422  CurvedCharAngleInOut = 83,
423  // (data defined only)
424  PositionX = 9,
425  PositionY = 10,
426  Hali = 11,
427  Vali = 12,
428  Rotation = 14,
429  LabelRotation = 96,
430  RepeatDistance = 84,
431  RepeatDistanceUnit = 86,
432  Priority = 87,
433  PredefinedPositionOrder = 91,
434  LinePlacementOptions = 99,
435  OverrunDistance = 102,
436  LabelAllParts = 103,
437 
438  // rendering
439  ScaleVisibility = 23,
440  MinScale = 16,
441  MinimumScale = 97,
442  MaxScale = 17,
443  MaximumScale = 98,
444  FontLimitPixel = 24,
445  FontMinPixel = 25,
446  FontMaxPixel = 26,
447  IsObstacle = 88,
448  ObstacleFactor = 89,
449  ZIndex = 90,
450  CalloutDraw = 100,
451 
452  // (data defined only)
453  Show = 15,
454  AlwaysShow = 20
455  };
456 
457 
469  bool prepare( QgsRenderContext &context, QSet<QString> &attributeNames SIP_INOUT, const QgsFields &fields, const QgsMapSettings &mapSettings, const QgsCoordinateReferenceSystem &crs );
470 
479  void startRender( QgsRenderContext &context );
480 
488  void stopRender( QgsRenderContext &context );
489 
494  static const QgsPropertiesDefinition &propertyDefinitions();
495 
505 
506  //-- text style
507 
513  QString fieldName;
514 
520 
524  QgsExpression *getLabelExpression();
525 
529  Q_DECL_DEPRECATED QColor previewBkgrdColor = Qt::white;
530 
535 
536  //-- text formatting
537 
542  QString wrapChar;
543 
551  int autoWrapLength = 0;
552 
563  bool useMaxLineLengthForAutoWrap = true;
564 
567 
579 
586 
593 
599 
602 
610 
616  int decimals;
617 
623  bool plusSign;
624 
625  //-- placement
626 
628  unsigned int placementFlags;
629 
635 
642 
649  QVector< PredefinedPointPosition > predefinedPositionOrder SIP_SKIP;
650 
655 
661  double dist;
662 
669 
676 
679 
686 
693 
700 
707  double overrunDistance = 0;
708 
716 
724 
729 
736  double xOffset;
737 
744  double yOffset;
745 
753 
761 
763  double angleOffset;
764 
767 
773 
779 
784  int priority;
785 
786  //-- rendering
787 
794 
805  double maximumScale;
806 
817  double minimumScale;
818 
825 
832 
839 
842 
844  UpsideDownLabels upsidedownLabels = Upright;
845 
851 
857 
863 
870 
875 
881  bool obstacle;
882 
890 
897 
899  double zIndex;
900 
903 
905  QgsWkbTypes::GeometryType geometryGeneratorType = QgsWkbTypes::GeometryType::PointGeometry;
906 
908  bool geometryGeneratorEnabled = false;
909 
915 
922  void calculateLabelSize( const QFontMetricsF *fm, const QString &text, double &labelX, double &labelY, const QgsFeature *f = nullptr, QgsRenderContext *context = nullptr, double *rotatedLabelX SIP_OUT = nullptr, double *rotatedLabelY SIP_OUT = nullptr );
923 
938  void registerFeature( const QgsFeature &f, QgsRenderContext &context,
939  QgsLabelFeature **labelFeature SIP_PYARGREMOVE = nullptr,
940  QgsGeometry obstacleGeometry SIP_PYARGREMOVE = QgsGeometry(), const QgsSymbol *symbol SIP_PYARGREMOVE = nullptr );
941 
946  void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
947 
952  QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
953 
959  QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
960 
968  const QgsPropertyCollection &dataDefinedProperties() const SIP_SKIP { return mDataDefinedProperties; }
969 
977  void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
978 
984  const QgsTextFormat &format() const { return mFormat; }
985 
992  void setFormat( const QgsTextFormat &format ) { mFormat = format; }
993 
1002  QgsCallout *callout() const { return mCallout.get(); }
1003 
1012  void setCallout( QgsCallout *callout SIP_TRANSFER );
1013 
1022  static QPixmap labelSettingsPreviewPixmap( const QgsPalLayerSettings &settings, QSize size, const QString &previewText = QString(), int padding = 0 );
1023 
1024  // temporary stuff: set when layer gets prepared or labeled
1025  const QgsFeature *mCurFeat = nullptr;
1028  const QgsMapToPixel *xform = nullptr;
1030 
1034  int mFeaturesToLabel = 0; // total features that will probably be labeled, may be less (figured before PAL)
1035  int mFeatsSendingToPal = 0; // total features tested for sending into PAL (relative to maxNumLabels)
1036  int mFeatsRegPal = 0; // number of features registered in PAL, when using limitNumLabels
1037  private:
1038 
1039  friend class QgsVectorLayer; // to allow calling readFromLayerCustomProperties()
1040 
1045  void readFromLayerCustomProperties( QgsVectorLayer *layer );
1046 
1050  void readOldDataDefinedPropertyMap( QgsVectorLayer *layer, QDomElement *parentElem );
1051 
1055  void readOldDataDefinedProperty( QgsVectorLayer *layer, QgsPalLayerSettings::Property p );
1056 
1057  enum DataDefinedValueType
1058  {
1059  DDBool,
1060  DDInt,
1061  DDIntPos,
1062  DDDouble,
1063  DDDoublePos,
1064  DDRotation180,
1065  DDOpacity,
1066  DDString,
1067  DDUnits,
1068  DDColor,
1069  DDJoinStyle,
1070  DDBlendMode,
1071  DDPointF,
1072  DDSizeF,
1073  };
1074 
1075  // convenience data defined evaluation function
1076  bool dataDefinedValEval( DataDefinedValueType valType,
1078  QVariant &exprVal, QgsExpressionContext &context, const QVariant &originalValue = QVariant() );
1079 
1080  void parseTextStyle( QFont &labelFont,
1081  QgsUnitTypes::RenderUnit fontunits,
1082  QgsRenderContext &context );
1083 
1084  void parseTextBuffer( QgsRenderContext &context );
1085 
1086  void parseTextFormatting( QgsRenderContext &context );
1087 
1088  void parseShapeBackground( QgsRenderContext &context );
1089 
1090  void parseDropShadow( QgsRenderContext &context );
1091 
1095  bool checkMinimumSizeMM( const QgsRenderContext &ct, const QgsGeometry &geom, double minSize ) const;
1096 
1100  void registerObstacleFeature( const QgsFeature &f, QgsRenderContext &context, QgsLabelFeature **obstacleFeature, const QgsGeometry &obstacleGeometry = QgsGeometry() );
1101 
1102  QMap<Property, QVariant> dataDefinedValues;
1103 
1105  QgsPropertyCollection mDataDefinedProperties;
1106 
1107  QgsExpression *expression = nullptr;
1108 
1109  QFontDatabase mFontDB;
1110 
1111  QgsTextFormat mFormat;
1112 
1113  std::unique_ptr< QgsCallout > mCallout;
1114 
1115  QgsExpression mGeometryGeneratorExpression;
1116 
1117  bool mRenderStarted = false;
1118 
1119  static const QVector< PredefinedPointPosition > DEFAULT_PLACEMENT_ORDER;
1120 
1121  static void initPropertyDefinitions();
1122 
1124  static QgsPropertiesDefinition sPropertyDefinitions;
1125 
1126 };
1127 
1131 class CORE_EXPORT QgsLabelCandidate
1132 {
1133  public:
1134  QgsLabelCandidate( const QRectF &r, double c ): rect( r ), cost( c ) {}
1135 
1136  QRectF rect;
1137  double cost;
1138 };
1139 
1140 
1141 
1142 
1148 class CORE_EXPORT QgsLabelingResults
1149 {
1150  public:
1152  ~QgsLabelingResults();
1153 
1155  QgsLabelingResults( const QgsLabelingResults & ) = delete;
1157  QgsLabelingResults &operator=( const QgsLabelingResults &rh ) = delete;
1158 
1160  QList<QgsLabelPosition> labelsAtPosition( const QgsPointXY &p ) const;
1162  QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle &r ) const;
1163 
1168  void setMapSettings( const QgsMapSettings &settings );
1169 
1170  private:
1171 #ifdef SIP_RUN
1173 #endif
1174 
1175  std::unique_ptr< QgsLabelSearchTree > mLabelSearchTree;
1176 
1177  friend class QgsPalLabeling;
1180 };
1181 
1186 class CORE_EXPORT QgsPalLabeling
1187 {
1188  public:
1189 
1194  static bool staticWillUseLayer( QgsVectorLayer *layer );
1195 
1197  static void drawLabelCandidateRect( pal::LabelPosition *lp, QPainter *painter, const QgsMapToPixel *xform, QList<QgsLabelCandidate> *candidates = nullptr ) SIP_SKIP;
1198 
1209  static QgsGeometry prepareGeometry( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry = QgsGeometry(), bool mergeLines = false ) SIP_FACTORY;
1210 
1221  static bool geometryRequiresPreparation( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry = QgsGeometry(), bool mergeLines = false );
1222 
1235  static QStringList splitToLines( const QString &text, const QString &wrapCharacter, int autoWrapLength = 0, bool useMaxLineLengthWhenAutoWrapping = true );
1236 
1245  static QStringList splitToGraphemes( const QString &text );
1246 
1247  private:
1249  static void dataDefinedTextStyle( QgsPalLayerSettings &tmpLyr,
1250  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1251 
1253  static void dataDefinedTextFormatting( QgsPalLayerSettings &tmpLyr,
1254  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1255 
1257  static void dataDefinedTextBuffer( QgsPalLayerSettings &tmpLyr,
1258  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1259 
1261  static void dataDefinedShapeBackground( QgsPalLayerSettings &tmpLyr,
1262  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1263 
1265  static void dataDefinedDropShadow( QgsPalLayerSettings &tmpLyr,
1266  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1267 
1268  friend class QgsVectorLayerLabelProvider; // to allow calling the static methods above
1269  friend class QgsDxfExport; // to allow calling the static methods above
1270 
1279  static bool checkMinimumSizeMM( const QgsRenderContext &context, const QgsGeometry &geom, double minSize );
1280 
1281  friend class QgsPalLayerSettings;
1282 };
1283 
1284 #endif // QGSPALLABELING_H
Label on bottom right of point.
QgsRectangle labelRect
Class for parsing and evaluation of expressions (formerly called "search strings").
double xOffset
Horizontal offset of label.
The class is used as a container of context for various read/write operations on other objects...
QString geometryGenerator
The geometry generator expression. Null if disabled.
QString labelText
String shown in label.
A rectangle specified with double values.
Definition: qgsrectangle.h:41
Label on bottom-left of point.
double maxCurvedCharAngleOut
Maximum angle between outside curved label characters (valid range -20.0 to -95.0) ...
double maximumScale
The maximum map scale (i.e.
Abstract base class for callout renderers.
Definition: qgscallout.h:46
QString leftDirectionSymbol
String to use for left direction arrows.
Label on top of point, slightly left of center.
QgsUnitTypes::RenderUnit repeatDistanceUnit
Units for repeating labels for a single feature.
QgsMapUnitScale overrunDistanceMapUnitScale
Map unit scale for label overrun distance.
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:61
double angleOffset
Label rotation, in degrees clockwise.
bool formatNumbers
Set to true to format numeric label text as numbers (e.g.
A class to query the labeling structure at a given point (small wrapper around pal RTree class) ...
double obstacleFactor
Obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels, 1.0 less likely to be covered
Label on top-left of point.
QgsLabelCandidate(const QRectF &r, double c)
#define FID_NULL
Definition: qgsfeatureid.h:26
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point...
Arranges candidates following the curvature of a line feature. Applies to line layers only...
PredefinedPointPosition
Positions for labels when using the QgsPalLabeling::OrderedPositionsAroundPoint placement mode...
A class to represent a 2D point.
Definition: qgspointxy.h:43
QString layerID
ID of associated map layer.
bool obstacle
true if features for layer are obstacles to labels of other layers.
int decimals
Number of decimal places to show for numeric labels.
double repeatDistance
Distance for repeating labels for a single feature.
Candidates are placed in predefined positions around a point. Preference is given to positions with g...
qint64 QgsFeatureId
Definition: qgsfeatureid.h:25
QuadrantPosition quadOffset
Sets the quadrant in which to offset labels from feature.
QgsUnitTypes::RenderUnit offsetUnits
Units for offsets of label.
double yOffset
Vertical offset of label.
Class that adds extra information to QgsLabelFeature for text labels.
Container of fields for a vector layer.
Definition: qgsfields.h:42
Label on top-right of point.
bool addDirectionSymbol
If true, &#39;<&#39; or &#39;>&#39; (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) will be ...
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:122
bool drawLabels
Whether to draw labels for this layer.
bool mergeLines
true if connected line features with identical label text should be merged prior to generating label ...
#define SIP_INOUT
Definition: qgis_sip.h:71
QgsMapUnitScale repeatDistanceMapUnitScale
Map unit scale for repeating labels for a single feature.
MultiLineAlign multilineAlign
Horizontal alignment of multi-line labels.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:55
const QgsCoordinateReferenceSystem & crs
QgsGeometry labelGeometry
A polygon geometry representing the label&#39;s bounds in map coordinates.
double maxCurvedCharAngleIn
Maximum angle between inside curved label characters (valid range 20.0 to 60.0).
QgsCoordinateTransform ct
bool reverseDirectionSymbol
True if direction symbols should be reversed.
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...
QgsStringReplacementCollection substitutions
Substitution collection for automatic text substitution with labels.
Arranges horizontal candidates scattered throughout a polygon feature. Applies to polygon layers only...
The QgsMapSettings class contains configuration for rendering of the map.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
Place direction symbols on left/right of label.
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:37
Property
Data definable properties.
ObstacleType obstacleType
Controls how features act as obstacles for labels.
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the label&#39;s property collection, used for data defined overrides.
bool displayAll
If true, all features will be labelled even when overlaps occur.
Label on left of point.
Offset distance applies from point geometry.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the label&#39;s property collection, used for data defined overrides.
int fontMaxPixelSize
Maximum pixel size for showing rendered map unit labels (1 - 10000).
#define SIP_SKIP
Definition: qgis_sip.h:126
The QgsVectorLayerDiagramProvider class implements support for diagrams within the labeling engine...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QVector< QgsPointXY > cornerPoints
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
#define SIP_TRANSFER
Definition: qgis_sip.h:36
Upside-down labels (90 <= angle < 270) are shown upright.
OffsetType
Behavior modifier for label offset and distance, only applies in some label placement modes...
#define SIP_FACTORY
Definition: qgis_sip.h:76
Label below point, slightly right of center.
Offset distance applies from rendered symbol bounds.
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc...
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
int maxNumLabels
The maximum number of labels which should be drawn for this layer.
Place direction symbols on above label.
Stores the settings for rendering of all diagrams for a layer.
bool plusSign
Whether &#39;+&#39; signs should be prepended to positive numeric labels.
unsigned int placementFlags
QString wrapChar
Wrapping character string.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:139
Placement
Placement modes which determine how label candidates are generated for a feature. ...
#define SIP_PYARGREMOVE
Definition: qgis_sip.h:146
QString rightDirectionSymbol
String to use for right direction arrows.
The QgsLabelingEngine class provides map labeling functionality.
bool preserveRotation
True if label rotation should be preserved during label pin/unpin operations.
Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon&#39;...
Contains information about the context of a rendering operation.
bool centroidWhole
true if feature centroid should be calculated from the whole feature, or false if only the visible pa...
bool scaleVisibility
Set to true to limit label visibility to a range of scales.
The QgsLabelFeature class describes a feature that should be used within the labeling engine...
Label below point, slightly left of center.
QgsMapUnitScale distMapUnitScale
Map unit scale for label feature distance.
Struct for storing maximum and minimum scales for measurements in map units.
bool fitInPolygonOnly
true if only labels which completely fit within a polygon are allowed.
A collection of string replacements (specified using QgsStringReplacement objects).
#define SIP_OUT
Definition: qgis_sip.h:58
OffsetType offsetType
Offset type for layer (only applies in certain placement modes)
double dist
Distance from feature to the label.
Label on top of point, slightly right of center.
bool useSubstitutions
True if substitutions should be applied.
This class represents a coordinate reference system (CRS).
Label directly below point.
QFont labelFont
Font which the label is rendered using.
Class for doing transforms between two map coordinate systems.
LabelPosition is a candidate feature label position.
Definition: labelposition.h:55
Label directly above point.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
Label on right of point.
bool limitNumLabels
true if the number of labels drawn should be limited.
QgsCallout * callout() const
Returns the label callout renderer, responsible for drawing label callouts.
bool isExpression
true if this label is made from a expression string, e.g., FieldName || &#39;mm&#39;
Class that stores computed placement from labeling engine.
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.
LinePlacementFlags
Line placement flags, which control how candidates are generated for a linear feature.
Show upside down when rotation is layer- or data-defined.
QString providerID
ID of the associated label provider.
Container for all settings relating to text rendering.
bool centroidInside
true if centroid positioned labels must be placed inside their corresponding feature polygon...
Represents a vector layer which manages a vector based data sets.
Arranges candidates following the curvature of a polygon&#39;s boundary. Applies to polygon layers only...
double minFeatureSize
Minimum feature size (in millimeters) for a feature to be labelled.
int fontMinPixelSize
Minimum pixel size for showing rendered map unit labels (1 - 1000).
int priority
Label priority.
bool labelPerPart
true if every part of a multi-part feature should be labeled.
QgsUnitTypes::RenderUnit distUnits
Units the distance from feature to the label.
QgsMapUnitScale labelOffsetMapUnitScale
Map unit scale for label offset.
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:145
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the label&#39;s property collection, used for data defined overrides.
double minimumScale
The minimum map scale (i.e.
QString fieldName
Name of field (or an expression) to use for label text.
bool fontLimitPixelSize
true if label sizes should be limited by pixel size.
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels...
DirectionSymbols placeDirectionSymbol
Placement option for direction symbols.
Arranges candidates scattered throughout a polygon feature. Candidates are rotated to respect the pol...