QGIS API Documentation  3.12.1-BucureČ™ti (121cc00ff0)
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"
47 
48 namespace pal SIP_SKIP
49 {
50  class Pal;
51  class Layer;
52  class LabelPosition;
53 }
54 
56 class QgsRectangle;
57 class QgsMapToPixel;
58 class QgsFeature;
60 class QgsVectorLayer;
61 class QgsExpression;
62 class QFontMetricsF;
63 class QPainter;
64 class QPicture;
65 class QgsGeometry;
67 class QgsLabelSearchTree;
68 class QgsMapSettings;
69 class QgsLabelFeature;
70 class QgsLabelingEngine;
73 class QgsDxfExport;
76 class QgsCallout;
77 
82 class CORE_EXPORT QgsLabelPosition
83 {
84  public:
85 
104  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(),
105  const QgsGeometry &labelGeometry = QgsGeometry(), bool isUnplaced = false )
106  : featureId( id )
107  , rotation( r )
108  , cornerPoints( corners )
109  , labelRect( rect )
110  , labelGeometry( labelGeometry )
111  , width( w )
112  , height( h )
113  , layerID( layer )
114  , labelText( labeltext )
115  , labelFont( labelfont )
116  , upsideDown( upside_down )
117  , isDiagram( diagram )
118  , isPinned( pinned )
119  , providerID( providerId )
120  , isUnplaced( isUnplaced )
121  {}
122 
124  QgsLabelPosition() = default;
125 
129  QgsFeatureId featureId = FID_NULL;
130 
134  double rotation = 0;
135 
136  QVector< QgsPointXY > cornerPoints;
138 
144 
148  double width = 0;
149 
153  double height = 0;
154 
158  QString layerID;
159 
163  QString labelText;
164 
168  QFont labelFont;
169 
173  bool upsideDown = false;
174 
178  bool isDiagram = false;
179 
183  bool isPinned = false;
184 
189  QString providerID;
190 
195  bool isUnplaced = false;
196 };
197 
202 class CORE_EXPORT QgsPalLayerSettings
203 {
204  public:
208 
210  QgsPalLayerSettings &operator=( const QgsPalLayerSettings &s );
211 
212  //TODO QGIS 4.0 - move to QgsLabelingEngine
213 
218  {
227  };
228 
229  //TODO QGIS 4.0 - move to QgsLabelingEngine
232  {
245  };
246 
247  //TODO QGIS 4.0 - move to QgsLabelingEngine
248 
254  {
257  };
258 
259  //TODO QGIS 4.0 - remove, replaced by QgsLabeling::LinePlacementFlags
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 - Remove -- moved to QgsLabelEngineObstacleSettings
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  // mask buffer
378  MaskEnabled = 104,
379  MaskBufferSize = 105,
380  MaskBufferUnit = 106,
381  MaskOpacity = 107,
382  MaskJoinStyle = 108,
383 
384  // background
385  ShapeDraw = 46,
386  ShapeKind = 47,
387  ShapeSVGFile = 48,
388  ShapeSizeType = 49,
389  ShapeSizeX = 50,
390  ShapeSizeY = 85,
391  ShapeSizeUnits = 51,
392  ShapeRotationType = 52,
393  ShapeRotation = 53,
394  ShapeOffset = 54,
395  ShapeOffsetUnits = 55,
396  ShapeRadii = 56,
397  ShapeRadiiUnits = 57,
398  ShapeTransparency = 63,
399  ShapeOpacity = 93,
400  ShapeBlendMode = 64,
401  ShapeFillColor = 58,
402  ShapeStrokeColor = 59,
403  ShapeStrokeWidth = 60,
404  ShapeStrokeWidthUnits = 61,
405  ShapeJoinStyle = 62,
406 
407  // drop shadow
408  ShadowDraw = 65,
409  ShadowUnder = 66,
410  ShadowOffsetAngle = 67,
411  ShadowOffsetDist = 68,
412  ShadowOffsetUnits = 69,
413  ShadowRadius = 70,
414  ShadowRadiusUnits = 71,
415  ShadowTransparency = 72,
416  ShadowOpacity = 95,
417  ShadowScale = 73,
418  ShadowColor = 74,
419  ShadowBlendMode = 75,
420 
421  // placement
422  CentroidWhole = 76,
423  OffsetQuad = 77,
424  OffsetXY = 78,
425  OffsetUnits = 80,
426  LabelDistance = 13,
427  DistanceUnits = 81,
428  OffsetRotation = 82,
429  CurvedCharAngleInOut = 83,
430  // (data defined only)
431  PositionX = 9,
432  PositionY = 10,
433  Hali = 11,
434  Vali = 12,
435  Rotation = 14,
436  LabelRotation = 96,
437  RepeatDistance = 84,
438  RepeatDistanceUnit = 86,
439  Priority = 87,
440  PredefinedPositionOrder = 91,
441  LinePlacementOptions = 99,
442  OverrunDistance = 102,
443  LabelAllParts = 103,
444 
445  // rendering
446  ScaleVisibility = 23,
447  MinScale = 16,
448  MinimumScale = 97,
449  MaxScale = 17,
450  MaximumScale = 98,
451  FontLimitPixel = 24,
452  FontMinPixel = 25,
453  FontMaxPixel = 26,
454  IsObstacle = 88,
455  ObstacleFactor = 89,
456  ZIndex = 90,
457  CalloutDraw = 100,
458 
459  // (data defined only)
460  Show = 15,
461  AlwaysShow = 20
462  };
463 
464 
476  bool prepare( QgsRenderContext &context, QSet<QString> &attributeNames SIP_INOUT, const QgsFields &fields, const QgsMapSettings &mapSettings, const QgsCoordinateReferenceSystem &crs );
477 
486  void startRender( QgsRenderContext &context );
487 
495  void stopRender( QgsRenderContext &context );
496 
501  static const QgsPropertiesDefinition &propertyDefinitions();
502 
511  bool drawLabels = true;
512 
513  //-- text style
514 
520  QString fieldName;
521 
526  bool isExpression = false;
527 
531  QgsExpression *getLabelExpression();
532 
536  Q_DECL_DEPRECATED QColor previewBkgrdColor = Qt::white;
537 
541  bool useSubstitutions = false;
542 
543  //-- text formatting
544 
549  QString wrapChar;
550 
558  int autoWrapLength = 0;
559 
570  bool useMaxLineLengthForAutoWrap = true;
571 
573  MultiLineAlign multilineAlign = MultiFollowPlacement;
574 
585  bool addDirectionSymbol = false;
586 
592  QString leftDirectionSymbol = QString( '<' );
593 
599  QString rightDirectionSymbol = QString( '>' );
600 
605  DirectionSymbols placeDirectionSymbol = SymbolLeftRight;
606 
608  bool reverseDirectionSymbol = false;
609 
616  bool formatNumbers = false;
617 
623  int decimals = 3;
624 
630  bool plusSign = false;
631 
632  //-- placement
633 
634  Placement placement = AroundPoint;
635 
636 #ifndef SIP_RUN
637  unsigned int placementFlags = AboveLine | MapOrientation;
638 #else
639  unsigned int placementFlags;
640 #endif
641 
646  bool centroidWhole = false;
647 
653  bool centroidInside = false;
654 
661  QVector< PredefinedPointPosition > predefinedPositionOrder SIP_SKIP;
662 
666  bool fitInPolygonOnly = false;
667 
673  double dist = 0;
674 
681 
688 
690  OffsetType offsetType = FromPoint;
691 
697  double repeatDistance = 0;
698 
705 
712 
719  double overrunDistance = 0;
720 
728 
736 
740  QuadrantPosition quadOffset = QuadrantOver;
741 
748  double xOffset = 0;
749 
756  double yOffset = 0;
757 
765 
773 
775  double angleOffset = 0;
776 
778  bool preserveRotation = true;
779 
784  double maxCurvedCharAngleIn = 25.0;
785 
790  double maxCurvedCharAngleOut = -25.0;
791 
796  int priority = 5;
797 
798  //-- rendering
799 
805  bool scaleVisibility = false;
806 
817  double maximumScale = 0;
818 
829  double minimumScale = 0;
830 
836  bool fontLimitPixelSize = false;
837 
843  int fontMinPixelSize = 0;
844 
850  int fontMaxPixelSize = 10000;
851 
853  bool displayAll = false;
854 
856  UpsideDownLabels upsidedownLabels = Upright;
857 
862  bool labelPerPart = false;
863 
868  bool mergeLines = false;
869 
870  // TODO QGIS 4.0 - remove this junk
871 
872 #ifdef SIP_RUN
873  SIP_PROPERTY( name = limitNumLabels, get = _limitNumLabels, set = _setLimitNumLabels )
874  SIP_PROPERTY( name = maxNumLabels, get = _maxNumLabels, set = _setMaxNumLabels )
875  SIP_PROPERTY( name = minFeatureSize, get = _minFeatureSize, set = _setMinFeatureSize )
876  SIP_PROPERTY( name = obstacle, get = _getIsObstacle, set = _setIsObstacle )
877  SIP_PROPERTY( name = obstacleFactor, get = _getObstacleFactor, set = _setObstacleFactor )
878  SIP_PROPERTY( name = obstacleType, get = _getObstacleType, set = _setObstacleType )
879 #endif
880 
882  bool _limitNumLabels() const { return mThinningSettings.limitNumberOfLabelsEnabled(); }
883  void _setLimitNumLabels( bool limit ) { mThinningSettings.setLimitNumberLabelsEnabled( limit ); }
884  int _maxNumLabels() const { return mThinningSettings.maximumNumberLabels(); }
885  void _setMaxNumLabels( int max ) { mThinningSettings.setMaximumNumberLabels( max ); }
886  double _minFeatureSize() const { return mThinningSettings.minimumFeatureSize(); }
887  void _setMinFeatureSize( double size ) { mThinningSettings.setMinimumFeatureSize( size ); }
888  bool _getIsObstacle() const { return mObstacleSettings.isObstacle(); }
889  void _setIsObstacle( bool obstacle ) { mObstacleSettings.setIsObstacle( obstacle ); }
890  double _getObstacleFactor() const { return mObstacleSettings.factor(); }
891  void _setObstacleFactor( double factor ) { mObstacleSettings.setFactor( factor ); }
892  ObstacleType _getObstacleType() const { return static_cast< ObstacleType>( mObstacleSettings.type() ); }
893  void _setObstacleType( ObstacleType type ) { mObstacleSettings.setType( static_cast< QgsLabelObstacleSettings::ObstacleType>( type ) ); }
894 
896 
898  double zIndex = 0;
899 
902 
904  QgsWkbTypes::GeometryType geometryGeneratorType = QgsWkbTypes::GeometryType::PointGeometry;
905 
907  bool geometryGeneratorEnabled = false;
908 
914 
921  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 );
922 
937  void registerFeature( const QgsFeature &f, QgsRenderContext &context,
938  QgsLabelFeature **labelFeature SIP_PYARGREMOVE = nullptr,
939  QgsGeometry obstacleGeometry SIP_PYARGREMOVE = QgsGeometry(), const QgsSymbol *symbol SIP_PYARGREMOVE = nullptr );
940 
945  void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
946 
951  QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
952 
958  QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
959 
967  const QgsPropertyCollection &dataDefinedProperties() const SIP_SKIP { return mDataDefinedProperties; }
968 
976  void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
977 
983  const QgsTextFormat &format() const { return mFormat; }
984 
991  void setFormat( const QgsTextFormat &format ) { mFormat = format; }
992 
1001  QgsCallout *callout() const { return mCallout.get(); }
1002 
1011  void setCallout( QgsCallout *callout SIP_TRANSFER );
1012 
1019  const QgsLabelObstacleSettings &obstacleSettings() const { return mObstacleSettings; } SIP_SKIP
1020 
1026  QgsLabelObstacleSettings &obstacleSettings() { return mObstacleSettings; }
1027 
1033  void setObstacleSettings( const QgsLabelObstacleSettings &settings ) { mObstacleSettings = settings; }
1034 
1041  const QgsLabelThinningSettings &thinningSettings() const { return mThinningSettings; } SIP_SKIP
1042 
1048  QgsLabelThinningSettings &thinningSettings() { return mThinningSettings; }
1049 
1055  void setThinningSettings( const QgsLabelThinningSettings &settings ) { mThinningSettings = settings; }
1056 
1065  static QPixmap labelSettingsPreviewPixmap( const QgsPalLayerSettings &settings, QSize size, const QString &previewText = QString(), int padding = 0 );
1066 
1067  // temporary stuff: set when layer gets prepared or labeled
1068  const QgsFeature *mCurFeat = nullptr;
1070  int fieldIndex = 0;
1071  const QgsMapToPixel *xform = nullptr;
1073 
1077  int mFeaturesToLabel = 0; // total features that will probably be labeled, may be less (figured before PAL)
1078  int mFeatsSendingToPal = 0; // total features tested for sending into PAL (relative to maxNumLabels)
1079  int mFeatsRegPal = 0; // number of features registered in PAL, when using limitNumLabels
1080  private:
1081 
1082  friend class QgsVectorLayer; // to allow calling readFromLayerCustomProperties()
1083 
1088  void readFromLayerCustomProperties( QgsVectorLayer *layer );
1089 
1093  void readOldDataDefinedPropertyMap( QgsVectorLayer *layer, QDomElement *parentElem );
1094 
1098  void readOldDataDefinedProperty( QgsVectorLayer *layer, QgsPalLayerSettings::Property p );
1099 
1100  enum DataDefinedValueType
1101  {
1102  DDBool,
1103  DDInt,
1104  DDIntPos,
1105  DDDouble,
1106  DDDoublePos,
1107  DDRotation180,
1108  DDOpacity,
1109  DDString,
1110  DDUnits,
1111  DDColor,
1112  DDJoinStyle,
1113  DDBlendMode,
1114  DDPointF,
1115  DDSizeF,
1116  };
1117 
1118  // convenience data defined evaluation function
1119  bool dataDefinedValEval( DataDefinedValueType valType,
1121  QVariant &exprVal, QgsExpressionContext &context, const QVariant &originalValue = QVariant() );
1122 
1123  void parseTextStyle( QFont &labelFont,
1124  QgsUnitTypes::RenderUnit fontunits,
1125  QgsRenderContext &context );
1126 
1127  void parseTextBuffer( QgsRenderContext &context );
1128 
1129  void parseTextMask( QgsRenderContext &context );
1130 
1131  void parseTextFormatting( QgsRenderContext &context );
1132 
1133  void parseShapeBackground( QgsRenderContext &context );
1134 
1135  void parseDropShadow( QgsRenderContext &context );
1136 
1140  bool checkMinimumSizeMM( const QgsRenderContext &ct, const QgsGeometry &geom, double minSize ) const;
1141 
1145  void registerObstacleFeature( const QgsFeature &f, QgsRenderContext &context, QgsLabelFeature **obstacleFeature, const QgsGeometry &obstacleGeometry = QgsGeometry() );
1146 
1147  QMap<Property, QVariant> dataDefinedValues;
1148 
1150  QgsPropertyCollection mDataDefinedProperties;
1151 
1152  QgsExpression *expression = nullptr;
1153 
1154  QFontDatabase mFontDB;
1155 
1156  QgsTextFormat mFormat;
1157 
1158  std::unique_ptr< QgsCallout > mCallout;
1159 
1160  QgsLabelObstacleSettings mObstacleSettings;
1161  QgsLabelThinningSettings mThinningSettings;
1162 
1163  QgsExpression mGeometryGeneratorExpression;
1164 
1165  bool mRenderStarted = false;
1166 
1167  static void initPropertyDefinitions();
1168 };
1169 
1173 class CORE_EXPORT QgsLabelCandidate
1174 {
1175  public:
1176  QgsLabelCandidate( const QRectF &r, double c ): rect( r ), cost( c ) {}
1177 
1178  QRectF rect;
1179  double cost;
1180 };
1181 
1182 
1183 
1184 
1190 class CORE_EXPORT QgsLabelingResults
1191 {
1192  public:
1194  ~QgsLabelingResults();
1195 
1197  QgsLabelingResults( const QgsLabelingResults & ) = delete;
1199  QgsLabelingResults &operator=( const QgsLabelingResults &rh ) = delete;
1200 
1202  QList<QgsLabelPosition> labelsAtPosition( const QgsPointXY &p ) const;
1204  QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle &r ) const;
1205 
1210  void setMapSettings( const QgsMapSettings &settings );
1211 
1212  private:
1213 #ifdef SIP_RUN
1215 #endif
1216 
1217  std::unique_ptr< QgsLabelSearchTree > mLabelSearchTree;
1218 
1219  friend class QgsPalLabeling;
1222 };
1223 
1228 class CORE_EXPORT QgsPalLabeling
1229 {
1230  public:
1231 
1236  static bool staticWillUseLayer( QgsVectorLayer *layer );
1237 
1239  static void drawLabelCandidateRect( pal::LabelPosition *lp, QPainter *painter, const QgsMapToPixel *xform, QList<QgsLabelCandidate> *candidates = nullptr ) SIP_SKIP;
1240 
1251  static QgsGeometry prepareGeometry( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry = QgsGeometry(), bool mergeLines = false ) SIP_FACTORY;
1252 
1263  static bool geometryRequiresPreparation( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry = QgsGeometry(), bool mergeLines = false );
1264 
1277  static QStringList splitToLines( const QString &text, const QString &wrapCharacter, int autoWrapLength = 0, bool useMaxLineLengthWhenAutoWrapping = true );
1278 
1287  static QStringList splitToGraphemes( const QString &text );
1288 
1289  private:
1291  static void dataDefinedTextStyle( QgsPalLayerSettings &tmpLyr,
1292  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1293 
1295  static void dataDefinedTextFormatting( QgsPalLayerSettings &tmpLyr,
1296  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1297 
1299  static void dataDefinedTextBuffer( QgsPalLayerSettings &tmpLyr,
1300  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1301 
1303  static void dataDefinedTextMask( QgsPalLayerSettings &tmpLyr,
1304  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1305 
1307  static void dataDefinedShapeBackground( QgsPalLayerSettings &tmpLyr,
1308  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1309 
1311  static void dataDefinedDropShadow( QgsPalLayerSettings &tmpLyr,
1312  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1313 
1314  friend class QgsVectorLayerLabelProvider; // to allow calling the static methods above
1315  friend class QgsDxfExport; // to allow calling the static methods above
1316 
1325  static bool checkMinimumSizeMM( const QgsRenderContext &context, const QgsGeometry &geom, double minSize );
1326 
1327  friend class QgsPalLayerSettings;
1328 };
1329 
1330 
1331 #endif // QGSPALLABELING_H
Label on bottom right of point.
QgsRectangle labelRect
Class for parsing and evaluation of expressions (formerly called "search strings").
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.
Abstract base class for callout renderers.
Definition: qgscallout.h:46
#define SIP_PROPERTY(name, getter, setter)
Definition: qgis_sip.h:257
Label on top of point, slightly left of center.
void setThinningSettings(const QgsLabelThinningSettings &settings)
Sets the label thinning settings.
QgsMapUnitScale overrunDistanceMapUnitScale
Map unit scale for label overrun distance.
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:62
A class to query the labeling structure at a given point (small wrapper around pal RTree class) ...
Label on top-left of point.
Contains settings related to how the label engine removes candidate label positions and reduces the n...
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.
Candidates are placed in predefined positions around a point. Preference is given to positions with g...
qint64 QgsFeatureId
Definition: qgsfeatureid.h:25
Class that adds extra information to QgsLabelFeature for text labels.
QgsLabelObstacleSettings & obstacleSettings()
Returns the label obstacle settings.
Container of fields for a vector layer.
Definition: qgsfields.h:42
Label on top-right of point.
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:122
#define SIP_INOUT
Definition: qgis_sip.h:71
QgsMapUnitScale repeatDistanceMapUnitScale
Map unit scale for repeating labels for a single feature.
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.
QgsCoordinateTransform ct
Contains settings related to how the label engine treats features as obstacles.
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
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.
QgsLabelThinningSettings & thinningSettings()
Returns the label thinning settings.
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.
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the label&#39;s property collection, used for data defined overrides.
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.
#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.
void setObstacleSettings(const QgsLabelObstacleSettings &settings)
Sets the label obstacle settings.
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.
Place direction symbols on above label.
Stores the settings for rendering of all diagrams for a layer.
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
The QgsLabelingEngine class provides map labeling functionality.
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.
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.
A collection of string replacements (specified using QgsStringReplacement objects).
const QgsLabelObstacleSettings & obstacleSettings() const
Returns the label obstacle settings.
#define SIP_OUT
Definition: qgis_sip.h:58
Label on top of point, slightly right of center.
const QgsLabelThinningSettings & thinningSettings() const
Returns the label thinning settings.
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.
QgsCallout * callout() const
Returns the label callout renderer, responsible for drawing label callouts.
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.
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...
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.
QString fieldName
Name of field (or an expression) to use for label text.
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels...
Arranges candidates scattered throughout a polygon feature. Candidates are rotated to respect the pol...