QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 "qgstextformat.h"
44 #include "qgspropertycollection.h"
47 #include "qgslabeling.h"
48 
49 class QgsTextDocument;
50 
51 namespace pal SIP_SKIP
52 {
53  class Pal;
54  class Layer;
55  class LabelPosition;
56 }
57 
59 class QgsRectangle;
60 class QgsMapToPixel;
61 class QgsFeature;
63 class QgsVectorLayer;
64 class QgsExpression;
65 class QFontMetricsF;
66 class QPainter;
67 class QPicture;
68 class QgsGeometry;
70 class QgsLabelSearchTree;
71 class QgsMapSettings;
72 class QgsLabelFeature;
73 class QgsLabelingEngine;
76 class QgsDxfExport;
79 class QgsCallout;
80 
85 class CORE_EXPORT QgsLabelPosition
86 {
87  public:
88 
107  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(),
108  const QgsGeometry &labelGeometry = QgsGeometry(), bool isUnplaced = false )
109  : featureId( id )
110  , rotation( r )
111  , cornerPoints( corners )
112  , labelRect( rect )
113  , labelGeometry( labelGeometry )
114  , width( w )
115  , height( h )
116  , layerID( layer )
117  , labelText( labeltext )
118  , labelFont( labelfont )
119  , upsideDown( upside_down )
120  , isDiagram( diagram )
121  , isPinned( pinned )
122  , providerID( providerId )
123  , isUnplaced( isUnplaced )
124  {}
125 
127  QgsLabelPosition() = default;
128 
132  QgsFeatureId featureId = FID_NULL;
133 
137  double rotation = 0;
138 
139  QVector< QgsPointXY > cornerPoints;
141 
147 
151  double width = 0;
152 
156  double height = 0;
157 
161  QString layerID;
162 
166  QString labelText;
167 
171  QFont labelFont;
172 
176  bool upsideDown = false;
177 
181  bool isDiagram = false;
182 
186  bool isPinned = false;
187 
192  QString providerID;
193 
198  bool isUnplaced = false;
199 };
200 
205 class CORE_EXPORT QgsPalLayerSettings
206 {
207  public:
211 
213  QgsPalLayerSettings &operator=( const QgsPalLayerSettings &s );
214 
215  //TODO QGIS 4.0 - move to QgsLabelingEngine
216 
221  {
231  };
232 
233  //TODO QGIS 4.0 - move to QgsLabelingEngine
236  {
249  };
250 
251  //TODO QGIS 4.0 - move to QgsLabelingEngine
252 
258  {
261  };
262 
263  //TODO QGIS 4.0 - remove, replaced by QgsLabeling::LinePlacementFlags
264 
269  {
270  OnLine = 1,
271  AboveLine = 2,
274  BelowLine = 4,
277  MapOrientation = 8,
280  };
281 
283  {
293  };
294 
296  {
299  ShowAll
300  };
301 
303  {
306  SymbolBelow
307  };
308 
310  {
311  MultiLeft = 0,
314  MultiFollowPlacement
316  };
317 
318  //TODO QGIS 4.0 - Remove -- moved to QgsLabelEngineObstacleSettings
319 
325  {
326  PolygonInterior,
328  PolygonBoundary,
330  PolygonWhole
334  };
335 
337  enum Property
338  {
339  // text style
340  Size = 0,
341  Bold = 1,
342  Italic = 2,
343  Underline = 3,
344  Color = 4,
345  Strikeout = 5,
346  Family = 6,
347  FontStyle = 21,
348  FontSizeUnit = 22,
349  FontTransp = 18,
350  FontOpacity = 92,
351  FontCase = 27,
352  FontLetterSpacing = 28,
353  FontWordSpacing = 29,
354  FontBlendMode = 30,
355 
356  // text formatting
357  MultiLineWrapChar = 31,
358  AutoWrapLength = 101,
359  MultiLineHeight = 32,
360  MultiLineAlignment = 33,
361  TextOrientation = 104,
362  DirSymbDraw = 34,
363  DirSymbLeft = 35,
364  DirSymbRight = 36,
365  DirSymbPlacement = 37,
366  DirSymbReverse = 38,
367  NumFormat = 39,
368  NumDecimals = 40,
369  NumPlusSign = 41,
370 
371  // text buffer
372  BufferDraw = 42,
373  BufferSize = 7,
374  BufferUnit = 43,
375  BufferColor = 8,
376  BufferTransp = 19,
377  BufferOpacity = 94,
378  BufferJoinStyle = 44,
379  BufferBlendMode = 45,
380 
381  // mask buffer
382  MaskEnabled = 104,
383  MaskBufferSize = 105,
384  MaskBufferUnit = 106,
385  MaskOpacity = 107,
386  MaskJoinStyle = 108,
387 
388  // background
389  ShapeDraw = 46,
390  ShapeKind = 47,
391  ShapeSVGFile = 48,
392  ShapeSizeType = 49,
393  ShapeSizeX = 50,
394  ShapeSizeY = 85,
395  ShapeSizeUnits = 51,
396  ShapeRotationType = 52,
397  ShapeRotation = 53,
398  ShapeOffset = 54,
399  ShapeOffsetUnits = 55,
400  ShapeRadii = 56,
401  ShapeRadiiUnits = 57,
402  ShapeTransparency = 63,
403  ShapeOpacity = 93,
404  ShapeBlendMode = 64,
405  ShapeFillColor = 58,
406  ShapeStrokeColor = 59,
407  ShapeStrokeWidth = 60,
408  ShapeStrokeWidthUnits = 61,
409  ShapeJoinStyle = 62,
410 
411  // drop shadow
412  ShadowDraw = 65,
413  ShadowUnder = 66,
414  ShadowOffsetAngle = 67,
415  ShadowOffsetDist = 68,
416  ShadowOffsetUnits = 69,
417  ShadowRadius = 70,
418  ShadowRadiusUnits = 71,
419  ShadowTransparency = 72,
420  ShadowOpacity = 95,
421  ShadowScale = 73,
422  ShadowColor = 74,
423  ShadowBlendMode = 75,
424 
425  // placement
426  CentroidWhole = 76,
427  OffsetQuad = 77,
428  OffsetXY = 78,
429  OffsetUnits = 80,
430  LabelDistance = 13,
431  DistanceUnits = 81,
432  OffsetRotation = 82,
433  CurvedCharAngleInOut = 83,
434  // (data defined only)
435  PositionX = 9,
436  PositionY = 10,
437  Hali = 11,
438  Vali = 12,
439  Rotation = 14,
440  LabelRotation = 96,
441  RepeatDistance = 84,
442  RepeatDistanceUnit = 86,
443  Priority = 87,
444  PredefinedPositionOrder = 91,
445  LinePlacementOptions = 99,
446  OverrunDistance = 102,
447  LabelAllParts = 103,
448  PolygonLabelOutside = 109,
449 
450  // rendering
451  ScaleVisibility = 23,
452  MinScale = 16,
453  MinimumScale = 97,
454  MaxScale = 17,
455  MaximumScale = 98,
456  FontLimitPixel = 24,
457  FontMinPixel = 25,
458  FontMaxPixel = 26,
459  IsObstacle = 88,
460  ObstacleFactor = 89,
461  ZIndex = 90,
462  CalloutDraw = 100,
463 
464  // (data defined only)
465  Show = 15,
466  AlwaysShow = 20
467  };
468 
469 
481  bool prepare( QgsRenderContext &context, QSet<QString> &attributeNames SIP_INOUT, const QgsFields &fields, const QgsMapSettings &mapSettings, const QgsCoordinateReferenceSystem &crs );
482 
487  QSet<QString> referencedFields( const QgsRenderContext &context ) const;
488 
497  void startRender( QgsRenderContext &context );
498 
506  void stopRender( QgsRenderContext &context );
507 
512  static const QgsPropertiesDefinition &propertyDefinitions();
513 
522  bool drawLabels = true;
523 
524  //-- text style
525 
531  QString fieldName;
532 
537  bool isExpression = false;
538 
542  QgsExpression *getLabelExpression();
543 
547  Q_DECL_DEPRECATED QColor previewBkgrdColor = Qt::white;
548 
552  bool useSubstitutions = false;
553 
554  //-- text formatting
555 
560  QString wrapChar;
561 
569  int autoWrapLength = 0;
570 
581  bool useMaxLineLengthForAutoWrap = true;
582 
584  MultiLineAlign multilineAlign = MultiFollowPlacement;
585 
596  bool addDirectionSymbol = false;
597 
603  QString leftDirectionSymbol = QString( '<' );
604 
610  QString rightDirectionSymbol = QString( '>' );
611 
616  DirectionSymbols placeDirectionSymbol = SymbolLeftRight;
617 
619  bool reverseDirectionSymbol = false;
620 
627  bool formatNumbers = false;
628 
634  int decimals = 3;
635 
641  bool plusSign = false;
642 
643  //-- placement
644 
645  Placement placement = AroundPoint;
646 
647 #ifndef SIP_RUN
648  unsigned int placementFlags = AboveLine | MapOrientation;
649 #else
650  unsigned int placementFlags;
651 #endif
652 
659  QgsLabeling::PolygonPlacementFlags polygonPlacementFlags() const { return mPolygonPlacementFlags; }
660 
667  void setPolygonPlacementFlags( QgsLabeling::PolygonPlacementFlags flags ) { mPolygonPlacementFlags = flags; }
668 
673  bool centroidWhole = false;
674 
680  bool centroidInside = false;
681 
688  QVector< PredefinedPointPosition > predefinedPositionOrder SIP_SKIP;
689 
693  bool fitInPolygonOnly = false;
694 
700  double dist = 0;
701 
708 
715 
717  OffsetType offsetType = FromPoint;
718 
724  double repeatDistance = 0;
725 
732 
739 
746  double overrunDistance = 0;
747 
755 
763 
767  QuadrantPosition quadOffset = QuadrantOver;
768 
775  double xOffset = 0;
776 
783  double yOffset = 0;
784 
792 
800 
802  double angleOffset = 0;
803 
805  bool preserveRotation = true;
806 
811  double maxCurvedCharAngleIn = 25.0;
812 
817  double maxCurvedCharAngleOut = -25.0;
818 
823  int priority = 5;
824 
825  //-- rendering
826 
832  bool scaleVisibility = false;
833 
844  double maximumScale = 0;
845 
856  double minimumScale = 0;
857 
863  bool fontLimitPixelSize = false;
864 
870  int fontMinPixelSize = 0;
871 
877  int fontMaxPixelSize = 10000;
878 
880  bool displayAll = false;
881 
883  UpsideDownLabels upsidedownLabels = Upright;
884 
889  bool labelPerPart = false;
890 
895  bool mergeLines = false;
896 
897  // TODO QGIS 4.0 - remove this junk
898 
899 #ifdef SIP_RUN
900  SIP_PROPERTY( name = limitNumLabels, get = _limitNumLabels, set = _setLimitNumLabels )
901  SIP_PROPERTY( name = maxNumLabels, get = _maxNumLabels, set = _setMaxNumLabels )
902  SIP_PROPERTY( name = minFeatureSize, get = _minFeatureSize, set = _setMinFeatureSize )
903  SIP_PROPERTY( name = obstacle, get = _getIsObstacle, set = _setIsObstacle )
904  SIP_PROPERTY( name = obstacleFactor, get = _getObstacleFactor, set = _setObstacleFactor )
905  SIP_PROPERTY( name = obstacleType, get = _getObstacleType, set = _setObstacleType )
906 #endif
907 
909  bool _limitNumLabels() const { return mThinningSettings.limitNumberOfLabelsEnabled(); }
910  void _setLimitNumLabels( bool limit ) { mThinningSettings.setLimitNumberLabelsEnabled( limit ); }
911  int _maxNumLabels() const { return mThinningSettings.maximumNumberLabels(); }
912  void _setMaxNumLabels( int max ) { mThinningSettings.setMaximumNumberLabels( max ); }
913  double _minFeatureSize() const { return mThinningSettings.minimumFeatureSize(); }
914  void _setMinFeatureSize( double size ) { mThinningSettings.setMinimumFeatureSize( size ); }
915  bool _getIsObstacle() const { return mObstacleSettings.isObstacle(); }
916  void _setIsObstacle( bool obstacle ) { mObstacleSettings.setIsObstacle( obstacle ); }
917  double _getObstacleFactor() const { return mObstacleSettings.factor(); }
918  void _setObstacleFactor( double factor ) { mObstacleSettings.setFactor( factor ); }
919  ObstacleType _getObstacleType() const { return static_cast< ObstacleType>( mObstacleSettings.type() ); }
920  void _setObstacleType( ObstacleType type ) { mObstacleSettings.setType( static_cast< QgsLabelObstacleSettings::ObstacleType>( type ) ); }
921 
923 
925  double zIndex = 0;
926 
929 
931  QgsWkbTypes::GeometryType geometryGeneratorType = QgsWkbTypes::GeometryType::PointGeometry;
932 
934  bool geometryGeneratorEnabled = false;
935 
941 
948 #ifndef SIP_RUN
949  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,
950  QgsTextDocument *document = nullptr );
951 #else
952  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 );
953 #endif
954 
969  void registerFeature( const QgsFeature &f, QgsRenderContext &context,
970  QgsLabelFeature **labelFeature SIP_PYARGREMOVE = nullptr,
971  QgsGeometry obstacleGeometry SIP_PYARGREMOVE = QgsGeometry(), const QgsSymbol *symbol SIP_PYARGREMOVE = nullptr );
972 
977  void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
978 
983  QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
984 
990  QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
991 
999  const QgsPropertyCollection &dataDefinedProperties() const SIP_SKIP { return mDataDefinedProperties; }
1000 
1008  void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
1009 
1015  const QgsTextFormat &format() const { return mFormat; }
1016 
1023  void setFormat( const QgsTextFormat &format ) { mFormat = format; }
1024 
1033  QgsCallout *callout() const { return mCallout.get(); }
1034 
1043  void setCallout( QgsCallout *callout SIP_TRANSFER );
1044 
1051  const QgsLabelObstacleSettings &obstacleSettings() const { return mObstacleSettings; } SIP_SKIP
1052 
1058  QgsLabelObstacleSettings &obstacleSettings() { return mObstacleSettings; }
1059 
1065  void setObstacleSettings( const QgsLabelObstacleSettings &settings ) { mObstacleSettings = settings; }
1066 
1073  const QgsLabelThinningSettings &thinningSettings() const { return mThinningSettings; } SIP_SKIP
1074 
1080  QgsLabelThinningSettings &thinningSettings() { return mThinningSettings; }
1081 
1087  void setThinningSettings( const QgsLabelThinningSettings &settings ) { mThinningSettings = settings; }
1088 
1097  static QPixmap labelSettingsPreviewPixmap( const QgsPalLayerSettings &settings, QSize size, const QString &previewText = QString(), int padding = 0 );
1098 
1099  // temporary stuff: set when layer gets prepared or labeled
1100  const QgsFeature *mCurFeat = nullptr;
1102  int fieldIndex = 0;
1103  const QgsMapToPixel *xform = nullptr;
1105 
1109  int mFeaturesToLabel = 0; // total features that will probably be labeled, may be less (figured before PAL)
1110  int mFeatsSendingToPal = 0; // total features tested for sending into PAL (relative to maxNumLabels)
1111  int mFeatsRegPal = 0; // number of features registered in PAL, when using limitNumLabels
1112  private:
1113 
1114  friend class QgsVectorLayer; // to allow calling readFromLayerCustomProperties()
1115 
1120  void readFromLayerCustomProperties( QgsVectorLayer *layer );
1121 
1125  void readOldDataDefinedPropertyMap( QgsVectorLayer *layer, QDomElement *parentElem );
1126 
1130  void readOldDataDefinedProperty( QgsVectorLayer *layer, QgsPalLayerSettings::Property p );
1131 
1132  enum DataDefinedValueType
1133  {
1134  DDBool,
1135  DDInt,
1136  DDIntPos,
1137  DDDouble,
1138  DDDoublePos,
1139  DDRotation180,
1140  DDOpacity,
1141  DDString,
1142  DDUnits,
1143  DDColor,
1144  DDJoinStyle,
1145  DDBlendMode,
1146  DDPointF,
1147  DDSizeF,
1148  };
1149 
1150  // convenience data defined evaluation function
1151  bool dataDefinedValEval( DataDefinedValueType valType,
1153  QVariant &exprVal, QgsExpressionContext &context, const QVariant &originalValue = QVariant() );
1154 
1155  void parseTextStyle( QFont &labelFont,
1156  QgsUnitTypes::RenderUnit fontunits,
1157  QgsRenderContext &context );
1158 
1159  void parseTextBuffer( QgsRenderContext &context );
1160 
1161  void parseTextMask( QgsRenderContext &context );
1162 
1163  void parseTextFormatting( QgsRenderContext &context );
1164 
1165  void parseShapeBackground( QgsRenderContext &context );
1166 
1167  void parseDropShadow( QgsRenderContext &context );
1168 
1172  bool checkMinimumSizeMM( const QgsRenderContext &ct, const QgsGeometry &geom, double minSize ) const;
1173 
1177  void registerObstacleFeature( const QgsFeature &f, QgsRenderContext &context, QgsLabelFeature **obstacleFeature, const QgsGeometry &obstacleGeometry = QgsGeometry() );
1178 
1179  QMap<Property, QVariant> dataDefinedValues;
1180 
1182  QgsPropertyCollection mDataDefinedProperties;
1183 
1184  QgsExpression *expression = nullptr;
1185 
1186  QFontDatabase mFontDB;
1187 
1188  QgsTextFormat mFormat;
1189 
1190  std::unique_ptr< QgsCallout > mCallout;
1191 
1192  QgsLabelObstacleSettings mObstacleSettings;
1193  QgsLabelThinningSettings mThinningSettings;
1194 
1195  QgsLabeling::PolygonPlacementFlags mPolygonPlacementFlags = QgsLabeling::PolygonPlacementFlag::AllowPlacementInsideOfPolygon;
1196 
1197  QgsExpression mGeometryGeneratorExpression;
1198 
1199  bool mRenderStarted = false;
1200 
1201  static void initPropertyDefinitions();
1202 };
1203 
1207 class CORE_EXPORT QgsLabelCandidate
1208 {
1209  public:
1210  QgsLabelCandidate( const QRectF &r, double c ): rect( r ), cost( c ) {}
1211 
1212  QRectF rect;
1213  double cost;
1214 };
1215 
1216 
1217 
1218 
1224 class CORE_EXPORT QgsLabelingResults
1225 {
1226  public:
1228  ~QgsLabelingResults();
1229 
1231  QgsLabelingResults( const QgsLabelingResults & ) = delete;
1233  QgsLabelingResults &operator=( const QgsLabelingResults &rh ) = delete;
1234 
1236  QList<QgsLabelPosition> labelsAtPosition( const QgsPointXY &p ) const;
1238  QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle &r ) const;
1239 
1244  void setMapSettings( const QgsMapSettings &settings );
1245 
1246  private:
1247 #ifdef SIP_RUN
1249 #endif
1250 
1251  std::unique_ptr< QgsLabelSearchTree > mLabelSearchTree;
1252 
1253  friend class QgsPalLabeling;
1256 };
1257 
1262 class CORE_EXPORT QgsPalLabeling
1263 {
1264  public:
1265 
1270  static bool staticWillUseLayer( QgsVectorLayer *layer );
1271 
1273  static void drawLabelCandidateRect( pal::LabelPosition *lp, QPainter *painter, const QgsMapToPixel *xform, QList<QgsLabelCandidate> *candidates = nullptr ) SIP_SKIP;
1274 
1285  static QgsGeometry prepareGeometry( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry = QgsGeometry(), bool mergeLines = false ) SIP_FACTORY;
1286 
1297  static bool geometryRequiresPreparation( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry = QgsGeometry(), bool mergeLines = false );
1298 
1311  static QStringList splitToLines( const QString &text, const QString &wrapCharacter, int autoWrapLength = 0, bool useMaxLineLengthWhenAutoWrapping = true );
1312 
1321  static QStringList splitToGraphemes( const QString &text );
1322 
1323  private:
1325  static void dataDefinedTextStyle( QgsPalLayerSettings &tmpLyr,
1326  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1327 
1329  static void dataDefinedTextFormatting( QgsPalLayerSettings &tmpLyr,
1330  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1331 
1333  static void dataDefinedTextBuffer( QgsPalLayerSettings &tmpLyr,
1334  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1335 
1337  static void dataDefinedTextMask( QgsPalLayerSettings &tmpLyr,
1338  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1339 
1341  static void dataDefinedShapeBackground( QgsPalLayerSettings &tmpLyr,
1342  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1343 
1345  static void dataDefinedDropShadow( QgsPalLayerSettings &tmpLyr,
1346  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1347 
1348  friend class QgsVectorLayerLabelProvider; // to allow calling the static methods above
1349  friend class QgsDxfExport; // to allow calling the static methods above
1350 
1359  static bool checkMinimumSizeMM( const QgsRenderContext &context, const QgsGeometry &geom, double minSize );
1360 
1361  friend class QgsPalLayerSettings;
1362 };
1363 
1364 
1365 #endif // QGSPALLABELING_H
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:369
qgsfields.h
QgsPalLayerSettings::ct
QgsCoordinateTransform ct
Definition: qgspallabeling.h:1104
QgsPalLayerSettings::DirectionSymbols
DirectionSymbols
Definition: qgspallabeling.h:302
QgsPalLayerSettings::PerimeterCurved
@ PerimeterCurved
Arranges candidates following the curvature of a polygon's boundary. Applies to polygon layers only.
Definition: qgspallabeling.h:229
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:166
QgsDxfExport
Definition: qgsdxfexport.h:62
QgsPalLayerSettings::AroundPoint
@ AroundPoint
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
Definition: qgspallabeling.h:222
QgsLabelCandidate::QgsLabelCandidate
QgsLabelCandidate(const QRectF &r, double c)
Definition: qgspallabeling.h:1210
QgsReadWriteContext
Definition: qgsreadwritecontext.h:34
QgsPalLayerSettings::FromSymbolBounds
@ FromSymbolBounds
Offset distance applies from rendered symbol bounds.
Definition: qgspallabeling.h:260
QgsCallout
Abstract base class for callout renderers.
Definition: qgscallout.h:46
QgsPalLayerSettings::setPolygonPlacementFlags
void setPolygonPlacementFlags(QgsLabeling::PolygonPlacementFlags flags)
Sets the polygon placement flags, which dictate how polygon labels can be placed.
Definition: qgspallabeling.h:667
QgsPalLayerSettings
Definition: qgspallabeling.h:205
qgslabelingenginesettings.h
SIP_OUT
#define SIP_OUT
Definition: qgis_sip.h:58
qgsstringutils.h
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
qgslabelthinningsettings.h
pal::LabelPosition
LabelPosition is a candidate feature label position.
Definition: labelposition.h:55
QgsPalLayerSettings::obstacleSettings
QgsLabelObstacleSettings & obstacleSettings()
Returns the label obstacle settings.
Definition: qgspallabeling.h:1058
QgsVectorLayerDiagramProvider
The QgsVectorLayerDiagramProvider class implements support for diagrams within the labeling engine....
Definition: qgsvectorlayerdiagramprovider.h:62
QgsPalLayerSettings::FromPoint
@ FromPoint
Offset distance applies from point geometry.
Definition: qgspallabeling.h:259
QgsFields
Definition: qgsfields.h:44
QgsPalLayerSettings::thinningSettings
const QgsLabelThinningSettings & thinningSettings() const
Returns the label thinning settings.
Definition: qgspallabeling.h:1073
QgsPalLayerSettings::obstacleSettings
const QgsLabelObstacleSettings & obstacleSettings() const
Returns the label obstacle settings.
Definition: qgspallabeling.h:1051
qgsfeature.h
QgsLabelingResults
Definition: qgspallabeling.h:1224
QgsPalLayerSettings::MiddleRight
@ MiddleRight
Label on right of point.
Definition: qgspallabeling.h:243
QgsPalLayerSettings::TopRight
@ TopRight
Label on top-right of point.
Definition: qgspallabeling.h:241
QgsPalLayerSettings::OffsetType
OffsetType
Behavior modifier for label offset and distance, only applies in some label placement modes.
Definition: qgspallabeling.h:257
QgsPalLayerSettings::QuadrantPosition
QuadrantPosition
Definition: qgspallabeling.h:282
QgsRenderContext
Definition: qgsrendercontext.h:57
FID_NULL
#define FID_NULL
Definition: qgsfeatureid.h:26
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:168
QgsLabelPosition::labelFont
QFont labelFont
Font which the label is rendered using.
Definition: qgspallabeling.h:171
QgsPalLayerSettings::overrunDistanceMapUnitScale
QgsMapUnitScale overrunDistanceMapUnitScale
Map unit scale for label overrun distance.
Definition: qgspallabeling.h:762
QgsPalLayerSettings::MultiLineAlign
MultiLineAlign
Definition: qgspallabeling.h:309
QgsPalLayerSettings::substitutions
QgsStringReplacementCollection substitutions
Substitution collection for automatic text substitution with labels.
Definition: qgspallabeling.h:550
SIP_PYARGREMOVE
#define SIP_PYARGREMOVE
Definition: qgis_sip.h:146
QgsLabelObstacleSettings
Definition: qgslabelobstaclesettings.h:34
QgsSymbol
Definition: qgssymbol.h:63
QgsPalLayerSettings::Line
@ Line
Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon'...
Definition: qgspallabeling.h:224
QgsTextLabelFeature
Class that adds extra information to QgsLabelFeature for text labels.
Definition: qgspalgeometry.h:30
QgsPalLayerSettings::TopSlightlyRight
@ TopSlightlyRight
Label on top of point, slightly right of center.
Definition: qgspallabeling.h:240
QgsPalLayerSettings::SymbolLeftRight
@ SymbolLeftRight
Place direction symbols on left/right of label.
Definition: qgspallabeling.h:304
QgsVectorLayerLabelProvider
The QgsVectorLayerLabelProvider class implements a label provider for vector layers....
Definition: qgsvectorlayerlabelprovider.h:40
QgsRectangle
Definition: qgsrectangle.h:41
QgsPalLayerSettings::OverPoint
@ OverPoint
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point....
Definition: qgspallabeling.h:223
QgsPalLayerSettings::LinePlacementFlags
LinePlacementFlags
Line placement flags, which control how candidates are generated for a linear feature.
Definition: qgspallabeling.h:268
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: qgspallabeling.h:107
QgsPalLayerSettings::ObstacleType
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels.
Definition: qgspallabeling.h:324
QgsLabelCandidate
Definition: qgspallabeling.h:1207
pal
Definition: qgsdiagramrenderer.h:49
QgsLabelPosition
Definition: qgspallabeling.h:85
QgsPalLayerSettings::QuadrantAboveRight
@ QuadrantAboveRight
Definition: qgspallabeling.h:286
QgsPalLayerSettings::TopMiddle
@ TopMiddle
Label directly above point.
Definition: qgspallabeling.h:239
QgsPalLayerSettings::setThinningSettings
void setThinningSettings(const QgsLabelThinningSettings &settings)
Sets the label thinning settings.
Definition: qgspallabeling.h:1087
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsLabelPosition::providerID
QString providerID
ID of the associated label provider.
Definition: qgspallabeling.h:192
QgsPalLayerSettings::QuadrantBelowLeft
@ QuadrantBelowLeft
Definition: qgspallabeling.h:290
QgsPalLayerSettings::BottomMiddle
@ BottomMiddle
Label directly below point.
Definition: qgspallabeling.h:246
QgsPalLayerSettings::OrderedPositionsAroundPoint
@ OrderedPositionsAroundPoint
Candidates are placed in predefined positions around a point. Preference is given to positions with g...
Definition: qgspallabeling.h:228
QgsTextFormat
Definition: qgstextformat.h:38
QgsPropertiesDefinition
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
Definition: qgspropertycollection.h:29
QgsPalLayerSettings::Placement
Placement
Placement modes which determine how label candidates are generated for a feature.
Definition: qgspallabeling.h:220
QgsPalLayerSettings::Curved
@ Curved
Arranges candidates following the curvature of a line feature. Applies to line layers only.
Definition: qgspallabeling.h:225
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsPalLayerSettings::QuadrantLeft
@ QuadrantLeft
Definition: qgspallabeling.h:287
QgsPalLayerSettings::setDataDefinedProperties
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the label's property collection, used for data defined overrides.
Definition: qgspallabeling.h:1008
QgsPalLayerSettings::SymbolAbove
@ SymbolAbove
Place direction symbols on above label.
Definition: qgspallabeling.h:305
QgsPalLayerSettings::wrapChar
QString wrapChar
Wrapping character string.
Definition: qgspallabeling.h:560
QgsLabelPosition::labelRect
QgsRectangle labelRect
Definition: qgspallabeling.h:140
QgsPalLayerSettings::TopSlightlyLeft
@ TopSlightlyLeft
Label on top of point, slightly left of center.
Definition: qgspallabeling.h:238
QgsPalLayerSettings::BottomSlightlyLeft
@ BottomSlightlyLeft
Label below point, slightly left of center.
Definition: qgspallabeling.h:245
QgsPalLayerSettings::format
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc.
Definition: qgspallabeling.h:1015
QgsLabelCandidate::rect
QRectF rect
Definition: qgspallabeling.h:1212
qgis_sip.h
QgsPalLayerSettings::setFormat
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
Definition: qgspallabeling.h:1023
QgsPalLayerSettings::repeatDistanceMapUnitScale
QgsMapUnitScale repeatDistanceMapUnitScale
Map unit scale for repeating labels for a single feature.
Definition: qgspallabeling.h:738
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsPalLayerSettings::thinningSettings
QgsLabelThinningSettings & thinningSettings()
Returns the label thinning settings.
Definition: qgspallabeling.h:1080
QgsDiagramLayerSettings
Stores the settings for rendering of all diagrams for a layer.
Definition: qgsdiagramrenderer.h:60
QgsPalLayerSettings::Upright
@ Upright
Upside-down labels (90 <= angle < 270) are shown upright.
Definition: qgspallabeling.h:297
QgsPalLayerSettings::MiddleLeft
@ MiddleLeft
Label on left of point.
Definition: qgspallabeling.h:242
QgsPalLabeling
Definition: qgspallabeling.h:1262
QgsPalLayerSettings::PredefinedPointPosition
PredefinedPointPosition
Positions for labels when using the QgsPalLabeling::OrderedPositionsAroundPoint placement mode.
Definition: qgspallabeling.h:235
QgsPalLayerSettings::ShowDefined
@ ShowDefined
Show upside down when rotation is layer- or data-defined.
Definition: qgspallabeling.h:298
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition: qgsmapunitscale.h:37
QgsLabelPosition::labelText
QString labelText
String shown in label.
Definition: qgspallabeling.h:166
QgsPalLayerSettings::dataDefinedProperties
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the label's property collection, used for data defined overrides.
Definition: qgspallabeling.h:999
QgsPalLayerSettings::UpsideDownLabels
UpsideDownLabels
Definition: qgspallabeling.h:295
QgsLabelThinningSettings
Definition: qgslabelthinningsettings.h:34
QgsPalLayerSettings::ptOne
QgsPointXY ptOne
Definition: qgspallabeling.h:1107
QgsStringReplacementCollection
A collection of string replacements (specified using QgsStringReplacement objects).
Definition: qgsstringutils.h:115
QgsLabelPosition::layerID
QString layerID
ID of associated map layer.
Definition: qgspallabeling.h:161
QgsCoordinateReferenceSystem
Definition: qgscoordinatereferencesystem.h:206
QgsPalLayerSettings::BottomSlightlyRight
@ BottomSlightlyRight
Label below point, slightly right of center.
Definition: qgspallabeling.h:247
QgsPalLayerSettings::Horizontal
@ Horizontal
Arranges horizontal candidates scattered throughout a polygon feature. Applies to polygon layers only...
Definition: qgspallabeling.h:226
SIP_INOUT
#define SIP_INOUT
Definition: qgis_sip.h:71
QgsLabelingEngine
The QgsLabelingEngine class provides map labeling functionality. The input for the engine is a list o...
Definition: qgslabelingengine.h:214
QgsPointXY
Definition: qgspointxy.h:43
QgsPalLayerSettings::QuadrantBelowRight
@ QuadrantBelowRight
Definition: qgspallabeling.h:292
QgsPalLayerSettings::QuadrantBelow
@ QuadrantBelow
Definition: qgspallabeling.h:291
QgsPropertyCollection
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
Definition: qgspropertycollection.h:318
qgslabeling.h
QgsPalLayerSettings::TopLeft
@ TopLeft
Label on top-left of point.
Definition: qgspallabeling.h:237
QgsPalLayerSettings::fieldName
QString fieldName
Name of field (or an expression) to use for label text.
Definition: qgspallabeling.h:531
qgsgeometry.h
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:139
c
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
Definition: porting_processing.dox:1
QgsGeometry
Definition: qgsgeometry.h:122
QgsMapToPixel
Definition: qgsmaptopixel.h:37
QgsPalLayerSettings::geometryGenerator
QString geometryGenerator
The geometry generator expression. Null if disabled.
Definition: qgspallabeling.h:928
QgsVectorLayer
Definition: qgsvectorlayer.h:385
QgsPalLayerSettings::OutsidePolygons
@ OutsidePolygons
Candidates are placed outside of polygon boundaries. Applies to polygon layers only....
Definition: qgspallabeling.h:230
QgsPalLayerSettings::QuadrantRight
@ QuadrantRight
Definition: qgspallabeling.h:289
QgsTextDocument
Definition: qgstextdocument.h:37
QgsPalLayerSettings::extentGeom
QgsGeometry extentGeom
Definition: qgspallabeling.h:1108
QgsPalLayerSettings::callout
QgsCallout * callout() const
Returns the label callout renderer, responsible for drawing label callouts.
Definition: qgspallabeling.h:1033
QgsWkbTypes::UnknownGeometry
@ UnknownGeometry
Definition: qgswkbtypes.h:144
qgspropertycollection.h
QgsPalLayerSettings::mCurFields
QgsFields mCurFields
Definition: qgspallabeling.h:1101
QgsPalLayerSettings::QuadrantOver
@ QuadrantOver
Definition: qgspallabeling.h:288
QgsPalLayerSettings::labelOffsetMapUnitScale
QgsMapUnitScale labelOffsetMapUnitScale
Map unit scale for label offset.
Definition: qgspallabeling.h:799
qgsmapunitscale.h
QgsPalLayerSettings::BottomRight
@ BottomRight
Label on bottom right of point.
Definition: qgspallabeling.h:248
QgsPalLayerSettings::ptZero
QgsPointXY ptZero
Definition: qgspallabeling.h:1106
SIP_PROPERTY
#define SIP_PROPERTY(name, getter, setter)
Definition: qgis_sip.h:257
QgsPalLayerSettings::MultiRight
@ MultiRight
Definition: qgspallabeling.h:313
QgsLabelPosition::labelGeometry
QgsGeometry labelGeometry
A polygon geometry representing the label's bounds in map coordinates.
Definition: qgspallabeling.h:146
QgsFeature
Definition: qgsfeature.h:55
QgsPalLayerSettings::Property
Property
Data definable properties.
Definition: qgspallabeling.h:337
QgsLabelObstacleSettings::ObstacleType
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels.
Definition: qgslabelobstaclesettings.h:42
QgsLabelSearchTree
Definition: qgslabelsearchtree.h:45
QgsLabelFeature
The QgsLabelFeature class describes a feature that should be used within the labeling engine....
Definition: qgslabelfeature.h:56
qgstextformat.h
QgsPalLayerSettings::QuadrantAboveLeft
@ QuadrantAboveLeft
Definition: qgspallabeling.h:284
QgsExpression
Definition: qgsexpression.h:113
QgsMapSettings
Definition: qgsmapsettings.h:86
QgsPalLayerSettings::dataDefinedProperties
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the label's property collection, used for data defined overrides.
Definition: qgspallabeling.h:990
QgsCoordinateTransform
Definition: qgscoordinatetransform.h:52
QgsLabelCandidate::cost
double cost
Definition: qgspallabeling.h:1213
QgsPalLayerSettings::Free
@ Free
Arranges candidates scattered throughout a polygon feature. Candidates are rotated to respect the pol...
Definition: qgspallabeling.h:227
qgssymbol.h
QgsPalLayerSettings::polygonPlacementFlags
QgsLabeling::PolygonPlacementFlags polygonPlacementFlags() const
Returns the polygon placement flags, which dictate how polygon labels can be placed.
Definition: qgspallabeling.h:659
QgsLabelPosition::cornerPoints
QVector< QgsPointXY > cornerPoints
Definition: qgspallabeling.h:139
QgsPalLayerSettings::QuadrantAbove
@ QuadrantAbove
Definition: qgspallabeling.h:285
QgsPalLayerSettings::setObstacleSettings
void setObstacleSettings(const QgsLabelObstacleSettings &settings)
Sets the label obstacle settings.
Definition: qgspallabeling.h:1065
qgspointxy.h
QgsPalLayerSettings::MultiCenter
@ MultiCenter
Definition: qgspallabeling.h:312
QgsPalLayerSettings::distMapUnitScale
QgsMapUnitScale distMapUnitScale
Map unit scale for label feature distance.
Definition: qgspallabeling.h:714
QgsPalLayerSettings::BottomLeft
@ BottomLeft
Label on bottom-left of point.
Definition: qgspallabeling.h:244
QgsFeatureId
qint64 QgsFeatureId
Definition: qgsfeatureid.h:25
qgslabelobstaclesettings.h