QGIS API Documentation  3.20.0-Odense (decaadbb31)
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 "qgstextformat.h"
43 #include "qgspropertycollection.h"
46 #include "qgslabellinesettings.h"
47 #include "qgslabeling.h"
48 #include "qgslabelposition.h"
49 
50 class QgsTextDocument;
51 
52 namespace pal SIP_SKIP
53 {
54  class Pal;
55  class Layer;
56  class LabelPosition;
57 }
58 
60 class QgsRectangle;
61 class QgsMapToPixel;
62 class QgsFeature;
64 class QgsVectorLayer;
65 class QgsExpression;
66 class QFontMetricsF;
67 class QPainter;
68 class QPicture;
69 class QgsGeometry;
71 class QgsLabelSearchTree;
72 class QgsMapSettings;
73 class QgsLabelFeature;
74 class QgsLabelingEngine;
77 class QgsDxfExport;
80 class QgsCallout;
81 
87 class CORE_EXPORT QgsPalLayerSettings
88 {
89  public:
93 
95  QgsPalLayerSettings &operator=( const QgsPalLayerSettings &s );
96 
97  //TODO QGIS 4.0 - move to QgsLabelingEngine
98 
103  {
113  };
114 
115  //TODO QGIS 4.0 - move to QgsLabelingEngine
118  {
131  };
132 
133  //TODO QGIS 4.0 - move to QgsLabelingEngine
134 
140  {
143  };
144 
145  //TODO QGIS 4.0 - remove, replaced by QgsLabeling::LinePlacementFlags
146 
153  {
154  OnLine = 1,
155  AboveLine = 2,
158  BelowLine = 4,
161  MapOrientation = 8,
164  };
165 
167  {
177  };
178 
180  {
183  ShowAll
184  };
185 
186  //TODO QGIS 4.0 - Remove -- moved to QgsLabelEngineObstacleSettings
187 
190  {
193  SymbolBelow
194  };
195 
197  {
198  MultiLeft = 0,
201  MultiFollowPlacement,
204  };
205 
206  //TODO QGIS 4.0 - Remove -- moved to QgsLabelEngineObstacleSettings
207 
213  {
214  PolygonInterior,
216  PolygonBoundary,
218  PolygonWhole
222  };
223 
225  enum Property
226  {
227  // text style
228  Size = 0,
229  Bold = 1,
230  Italic = 2,
231  Underline = 3,
232  Color = 4,
233  Strikeout = 5,
234  Family = 6,
235  FontStyle = 21,
236  FontSizeUnit = 22,
237  FontTransp = 18,
238  FontOpacity = 92,
239  FontCase = 27,
240  FontLetterSpacing = 28,
241  FontWordSpacing = 29,
242  FontBlendMode = 30,
243 
244  // text formatting
245  MultiLineWrapChar = 31,
246  AutoWrapLength = 101,
247  MultiLineHeight = 32,
248  MultiLineAlignment = 33,
249  TextOrientation = 110,
250  DirSymbDraw = 34,
251  DirSymbLeft = 35,
252  DirSymbRight = 36,
253  DirSymbPlacement = 37,
254  DirSymbReverse = 38,
255  NumFormat = 39,
256  NumDecimals = 40,
257  NumPlusSign = 41,
258 
259  // text buffer
260  BufferDraw = 42,
261  BufferSize = 7,
262  BufferUnit = 43,
263  BufferColor = 8,
264  BufferTransp = 19,
265  BufferOpacity = 94,
266  BufferJoinStyle = 44,
267  BufferBlendMode = 45,
268 
269  // mask buffer
270  MaskEnabled = 104,
271  MaskBufferSize = 105,
272  MaskBufferUnit = 106,
273  MaskOpacity = 107,
274  MaskJoinStyle = 108,
275 
276  // background
277  ShapeDraw = 46,
278  ShapeKind = 47,
279  ShapeSVGFile = 48,
280  ShapeSizeType = 49,
281  ShapeSizeX = 50,
282  ShapeSizeY = 85,
283  ShapeSizeUnits = 51,
284  ShapeRotationType = 52,
285  ShapeRotation = 53,
286  ShapeOffset = 54,
287  ShapeOffsetUnits = 55,
288  ShapeRadii = 56,
289  ShapeRadiiUnits = 57,
290  ShapeTransparency = 63,
291  ShapeOpacity = 93,
292  ShapeBlendMode = 64,
293  ShapeFillColor = 58,
294  ShapeStrokeColor = 59,
295  ShapeStrokeWidth = 60,
296  ShapeStrokeWidthUnits = 61,
297  ShapeJoinStyle = 62,
298 
299  // drop shadow
300  ShadowDraw = 65,
301  ShadowUnder = 66,
302  ShadowOffsetAngle = 67,
303  ShadowOffsetDist = 68,
304  ShadowOffsetUnits = 69,
305  ShadowRadius = 70,
306  ShadowRadiusUnits = 71,
307  ShadowTransparency = 72,
308  ShadowOpacity = 95,
309  ShadowScale = 73,
310  ShadowColor = 74,
311  ShadowBlendMode = 75,
312 
313  // placement
314  CentroidWhole = 76,
315  OffsetQuad = 77,
316  OffsetXY = 78,
317  OffsetUnits = 80,
318  LabelDistance = 13,
319  DistanceUnits = 81,
320  OffsetRotation = 82,
321  CurvedCharAngleInOut = 83,
322  // (data defined only)
323  PositionX = 9,
324  PositionY = 10,
325  Hali = 11,
326  Vali = 12,
327  Rotation = 14,
328  LabelRotation = 96,
329  RepeatDistance = 84,
330  RepeatDistanceUnit = 86,
331  Priority = 87,
332  PredefinedPositionOrder = 91,
333  LinePlacementOptions = 99,
334  OverrunDistance = 102,
335  LabelAllParts = 103,
336  PolygonLabelOutside = 109,
337  LineAnchorPercent = 111,
338  LineAnchorClipping = 112,
339 
340  // rendering
341  ScaleVisibility = 23,
342  MinScale = 16,
343  MinimumScale = 97,
344  MaxScale = 17,
345  MaximumScale = 98,
346  FontLimitPixel = 24,
347  FontMinPixel = 25,
348  FontMaxPixel = 26,
349  IsObstacle = 88,
350  ObstacleFactor = 89,
351  ZIndex = 90,
352  CalloutDraw = 100,
353 
354  // (data defined only)
355  Show = 15,
356  AlwaysShow = 20
357  };
358 
359 
371  bool prepare( QgsRenderContext &context, QSet<QString> &attributeNames SIP_INOUT, const QgsFields &fields, const QgsMapSettings &mapSettings, const QgsCoordinateReferenceSystem &crs );
372 
377  QSet<QString> referencedFields( const QgsRenderContext &context ) const;
378 
387  void startRender( QgsRenderContext &context );
388 
396  void stopRender( QgsRenderContext &context );
397 
403  bool containsAdvancedEffects() const;
404 
409  static const QgsPropertiesDefinition &propertyDefinitions();
410 
419  bool drawLabels = true;
420 
421  //-- text style
422 
428  QString fieldName;
429 
434  bool isExpression = false;
435 
439  QgsExpression *getLabelExpression();
440 
444  Q_DECL_DEPRECATED QColor previewBkgrdColor = Qt::white;
445 
449  bool useSubstitutions = false;
450 
451  //-- text formatting
452 
457  QString wrapChar;
458 
466  int autoWrapLength = 0;
467 
478  bool useMaxLineLengthForAutoWrap = true;
479 
481  MultiLineAlign multilineAlign = MultiFollowPlacement;
482 
489  bool formatNumbers = false;
490 
496  int decimals = 3;
497 
503  bool plusSign = false;
504 
505  //-- placement
506 
507  Placement placement = AroundPoint;
508 
515  QgsLabeling::PolygonPlacementFlags polygonPlacementFlags() const { return mPolygonPlacementFlags; }
516 
523  void setPolygonPlacementFlags( QgsLabeling::PolygonPlacementFlags flags ) { mPolygonPlacementFlags = flags; }
524 
529  bool centroidWhole = false;
530 
536  bool centroidInside = false;
537 
544  QVector< PredefinedPointPosition > predefinedPositionOrder SIP_SKIP;
545 
549  bool fitInPolygonOnly = false;
550 
556  double dist = 0;
557 
564 
571 
573  OffsetType offsetType = FromPoint;
574 
580  double repeatDistance = 0;
581 
588 
595 
599  QuadrantPosition quadOffset = QuadrantOver;
600 
607  double xOffset = 0;
608 
615  double yOffset = 0;
616 
624 
632 
634  double angleOffset = 0;
635 
637  bool preserveRotation = true;
638 
643  double maxCurvedCharAngleIn = 25.0;
644 
649  double maxCurvedCharAngleOut = -25.0;
650 
655  int priority = 5;
656 
657  //-- rendering
658 
664  bool scaleVisibility = false;
665 
676  double maximumScale = 0;
677 
688  double minimumScale = 0;
689 
695  bool fontLimitPixelSize = false;
696 
702  int fontMinPixelSize = 0;
703 
709  int fontMaxPixelSize = 10000;
710 
712  bool displayAll = false;
713 
715  UpsideDownLabels upsidedownLabels = Upright;
716 
721  bool labelPerPart = false;
722 
723  // TODO QGIS 4.0 - remove this junk
724 
725 #ifdef SIP_RUN
726  SIP_PROPERTY( name = limitNumLabels, get = _limitNumLabels, set = _setLimitNumLabels )
727  SIP_PROPERTY( name = maxNumLabels, get = _maxNumLabels, set = _setMaxNumLabels )
728  SIP_PROPERTY( name = minFeatureSize, get = _minFeatureSize, set = _setMinFeatureSize )
729  SIP_PROPERTY( name = obstacle, get = _getIsObstacle, set = _setIsObstacle )
730  SIP_PROPERTY( name = obstacleFactor, get = _getObstacleFactor, set = _setObstacleFactor )
731  SIP_PROPERTY( name = obstacleType, get = _getObstacleType, set = _setObstacleType )
732  SIP_PROPERTY( name = placementFlags, get = _getLinePlacementFlags, set = _setLinePlacementFlags )
733  SIP_PROPERTY( name = mergeLines, get = _getMergeLines, set = _setMergeLines )
734  SIP_PROPERTY( name = addDirectionSymbol, get = _getAddDirectionSymbol, set = _setAddDirectionSymbol )
735  SIP_PROPERTY( name = leftDirectionSymbol, get = _getLeftDirectionSymbol, set = _setLeftDirectionSymbol )
736  SIP_PROPERTY( name = rightDirectionSymbol, get = _getRightDirectionSymbol, set = _setRightDirectionSymbol )
737  SIP_PROPERTY( name = reverseDirectionSymbol, get = _getReverseDirectionSymbol, set = _setReverseDirectionSymbol )
738  SIP_PROPERTY( name = placeDirectionSymbol, get = _getPlaceDirectionSymbol, set = _setPlaceDirectionSymbol )
739 
740  SIP_PROPERTY( name = overrunDistance, get = _getOverrunDistance, set = _setOverrunDistance )
741  SIP_PROPERTY( name = overrunDistanceUnit, get = _getOverrunDistanceUnit, set = _setOverrunDistanceUnit )
742  SIP_PROPERTY( name = overrunDistanceMapUnitScale, get = _getOverrunDistanceMapUnitScale, set = _setOverrunDistanceMapUnitScale )
743 #endif
744 
746  bool _limitNumLabels() const { return mThinningSettings.limitNumberOfLabelsEnabled(); }
747  void _setLimitNumLabels( bool limit ) { mThinningSettings.setLimitNumberLabelsEnabled( limit ); }
748  int _maxNumLabels() const { return mThinningSettings.maximumNumberLabels(); }
749  void _setMaxNumLabels( int max ) { mThinningSettings.setMaximumNumberLabels( max ); }
750  double _minFeatureSize() const { return mThinningSettings.minimumFeatureSize(); }
751  void _setMinFeatureSize( double size ) { mThinningSettings.setMinimumFeatureSize( size ); }
752  bool _getIsObstacle() const { return mObstacleSettings.isObstacle(); }
753  void _setIsObstacle( bool obstacle ) { mObstacleSettings.setIsObstacle( obstacle ); }
754  double _getObstacleFactor() const { return mObstacleSettings.factor(); }
755  void _setObstacleFactor( double factor ) { mObstacleSettings.setFactor( factor ); }
756  ObstacleType _getObstacleType() const { return static_cast< ObstacleType>( mObstacleSettings.type() ); }
757  void _setObstacleType( ObstacleType type ) { mObstacleSettings.setType( static_cast< QgsLabelObstacleSettings::ObstacleType>( type ) ); }
758  unsigned int _getLinePlacementFlags() const { return static_cast< unsigned int >( mLineSettings.placementFlags() ); }
759  void _setLinePlacementFlags( unsigned int flags ) { mLineSettings.setPlacementFlags( static_cast< QgsLabeling::LinePlacementFlags >( flags ) ); }
760  bool _getMergeLines() const { return mLineSettings.mergeLines(); }
761  void _setMergeLines( bool merge ) { mLineSettings.setMergeLines( merge ); }
762  bool _getAddDirectionSymbol() const { return mLineSettings.addDirectionSymbol(); }
763  void _setAddDirectionSymbol( bool add ) { mLineSettings.setAddDirectionSymbol( add ); }
764  QString _getLeftDirectionSymbol() const { return mLineSettings.leftDirectionSymbol(); }
765  void _setLeftDirectionSymbol( const QString &symbol ) { mLineSettings.setLeftDirectionSymbol( symbol ); }
766  QString _getRightDirectionSymbol() const { return mLineSettings.rightDirectionSymbol(); }
767  void _setRightDirectionSymbol( const QString &symbol ) { mLineSettings.setRightDirectionSymbol( symbol ); }
768  bool _getReverseDirectionSymbol() const { return mLineSettings.reverseDirectionSymbol(); }
769  void _setReverseDirectionSymbol( bool reverse ) { mLineSettings.setReverseDirectionSymbol( reverse ); }
771  DirectionSymbols _getPlaceDirectionSymbol() const { return static_cast< DirectionSymbols>( mLineSettings.directionSymbolPlacement() ); }
772  void _setPlaceDirectionSymbol( DirectionSymbols placement ) { mLineSettings.setDirectionSymbolPlacement( static_cast< QgsLabelLineSettings::DirectionSymbolPlacement>( placement ) ); }
774  double _getOverrunDistance() const { return mLineSettings.overrunDistance(); }
775  void _setOverrunDistance( double distance ) { mLineSettings.setOverrunDistance( distance ); }
776  QgsUnitTypes::RenderUnit _getOverrunDistanceUnit() const { return mLineSettings.overrunDistanceUnit(); }
777  void _setOverrunDistanceUnit( QgsUnitTypes::RenderUnit unit ) { mLineSettings.setOverrunDistanceUnit( unit ); }
778  QgsMapUnitScale _getOverrunDistanceMapUnitScale() const { return mLineSettings.overrunDistanceMapUnitScale(); }
779  void _setOverrunDistanceMapUnitScale( const QgsMapUnitScale &scale ) { mLineSettings.setOverrunDistanceMapUnitScale( scale ); }
781 
783  double zIndex = 0;
784 
787 
789  QgsWkbTypes::GeometryType geometryGeneratorType = QgsWkbTypes::GeometryType::PointGeometry;
790 
792  bool geometryGeneratorEnabled = false;
793 
799 
804  void setLegendString( const QString &legendString ) { mLegendString = legendString; }
805 
810  QString legendString() const { return mLegendString; }
811 
818 #ifndef SIP_RUN
819  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,
820  QgsTextDocument *document = nullptr );
821 #else
822  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 );
823 #endif
824 
839  void registerFeature( const QgsFeature &f, QgsRenderContext &context,
840  QgsLabelFeature **labelFeature SIP_PYARGREMOVE = nullptr,
841  QgsGeometry obstacleGeometry SIP_PYARGREMOVE = QgsGeometry(), const QgsSymbol *symbol SIP_PYARGREMOVE = nullptr );
842 
847  void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
848 
853  QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
854 
860  QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
861 
869  const QgsPropertyCollection &dataDefinedProperties() const SIP_SKIP { return mDataDefinedProperties; }
870 
878  void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
879 
885  const QgsTextFormat &format() const { return mFormat; }
886 
893  void setFormat( const QgsTextFormat &format ) { mFormat = format; }
894 
903  QgsCallout *callout() const { return mCallout.get(); }
904 
913  void setCallout( QgsCallout *callout SIP_TRANSFER );
914 
923  const QgsLabelLineSettings &lineSettings() const { return mLineSettings; } SIP_SKIP
924 
932  QgsLabelLineSettings &lineSettings() { return mLineSettings; }
933 
941  void setLineSettings( const QgsLabelLineSettings &settings ) { mLineSettings = settings; }
942 
949  const QgsLabelObstacleSettings &obstacleSettings() const { return mObstacleSettings; } SIP_SKIP
950 
956  QgsLabelObstacleSettings &obstacleSettings() { return mObstacleSettings; }
957 
963  void setObstacleSettings( const QgsLabelObstacleSettings &settings ) { mObstacleSettings = settings; }
964 
971  const QgsLabelThinningSettings &thinningSettings() const { return mThinningSettings; } SIP_SKIP
972 
978  QgsLabelThinningSettings &thinningSettings() { return mThinningSettings; }
979 
985  void setThinningSettings( const QgsLabelThinningSettings &settings ) { mThinningSettings = settings; }
986 
995  static QPixmap labelSettingsPreviewPixmap( const QgsPalLayerSettings &settings, QSize size, const QString &previewText = QString(), int padding = 0 );
996 
1003  Qgis::UnplacedLabelVisibility unplacedVisibility() const;
1004 
1011  void setUnplacedVisibility( Qgis::UnplacedLabelVisibility visibility );
1012 
1013  // temporary stuff: set when layer gets prepared or labeled
1014  const QgsFeature *mCurFeat = nullptr;
1016  int fieldIndex = 0;
1017  const QgsMapToPixel *xform = nullptr;
1019 
1023  int mFeaturesToLabel = 0; // total features that will probably be labeled, may be less (figured before PAL)
1024  int mFeatsSendingToPal = 0; // total features tested for sending into PAL (relative to maxNumLabels)
1025  int mFeatsRegPal = 0; // number of features registered in PAL, when using limitNumLabels
1026 
1027  private:
1028 
1029  friend class QgsVectorLayer; // to allow calling readFromLayerCustomProperties()
1030 
1035  void readFromLayerCustomProperties( QgsVectorLayer *layer );
1036 
1040  void readOldDataDefinedPropertyMap( QgsVectorLayer *layer, QDomElement *parentElem );
1041 
1045  void readOldDataDefinedProperty( QgsVectorLayer *layer, QgsPalLayerSettings::Property p );
1046 
1047  enum DataDefinedValueType
1048  {
1049  DDBool,
1050  DDInt,
1051  DDIntPos,
1052  DDDouble,
1053  DDDoublePos,
1054  DDRotation180,
1055  DDOpacity,
1056  DDString,
1057  DDUnits,
1058  DDColor,
1059  DDJoinStyle,
1060  DDBlendMode,
1061  DDPointF,
1062  DDSizeF,
1063  };
1064 
1065  // convenience data defined evaluation function
1066  bool dataDefinedValEval( DataDefinedValueType valType,
1068  QVariant &exprVal, QgsExpressionContext &context, const QVariant &originalValue = QVariant() );
1069 
1070  void parseTextStyle( QFont &labelFont,
1071  QgsUnitTypes::RenderUnit fontunits,
1072  QgsRenderContext &context );
1073 
1074  void parseTextBuffer( QgsRenderContext &context );
1075 
1076  void parseTextMask( QgsRenderContext &context );
1077 
1078  void parseTextFormatting( QgsRenderContext &context );
1079 
1080  void parseShapeBackground( QgsRenderContext &context );
1081 
1082  void parseDropShadow( QgsRenderContext &context );
1083 
1088  bool checkMinimumSizeMM( const QgsRenderContext &ct, const QgsGeometry &geom, double minSize ) const;
1089 
1093  void registerObstacleFeature( const QgsFeature &f, QgsRenderContext &context, QgsLabelFeature **obstacleFeature, const QgsGeometry &obstacleGeometry = QgsGeometry() );
1094 
1095  QMap<Property, QVariant> dataDefinedValues;
1096 
1098  QgsPropertyCollection mDataDefinedProperties;
1099 
1100  QgsExpression *expression = nullptr;
1101 
1102  std::unique_ptr< QFontDatabase > mFontDB;
1103 
1104  QgsTextFormat mFormat;
1105 
1106  std::unique_ptr< QgsCallout > mCallout;
1107 
1108  QgsLabelLineSettings mLineSettings;
1109  QgsLabelObstacleSettings mObstacleSettings;
1110  QgsLabelThinningSettings mThinningSettings;
1111 
1112  QgsLabeling::PolygonPlacementFlags mPolygonPlacementFlags = QgsLabeling::PolygonPlacementFlag::AllowPlacementInsideOfPolygon;
1113 
1114  QgsExpression mGeometryGeneratorExpression;
1115 
1116  bool mRenderStarted = false;
1117 
1118  QString mLegendString = QObject::tr( "Aa" );
1119 
1121 
1122  static void initPropertyDefinitions();
1123 };
1124 
1129 class CORE_EXPORT QgsLabelCandidate
1130 {
1131  public:
1132  QgsLabelCandidate( const QRectF &r, double c ): rect( r ), cost( c ) {}
1133 
1134  QRectF rect;
1135  double cost;
1136 };
1137 
1143 class CORE_EXPORT QgsPalLabeling
1144 {
1145  public:
1146 
1151  static bool staticWillUseLayer( const QgsMapLayer *layer );
1152 
1154  static void drawLabelCandidateRect( pal::LabelPosition *lp, QPainter *painter, const QgsMapToPixel *xform, QList<QgsLabelCandidate> *candidates = nullptr ) SIP_SKIP;
1155 
1166  static QgsGeometry prepareGeometry( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry = QgsGeometry(), bool mergeLines = false ) SIP_FACTORY;
1167 
1178  static bool geometryRequiresPreparation( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry = QgsGeometry(), bool mergeLines = false );
1179 
1192  static QStringList splitToLines( const QString &text, const QString &wrapCharacter, int autoWrapLength = 0, bool useMaxLineLengthWhenAutoWrapping = true );
1193 
1202  static QStringList splitToGraphemes( const QString &text );
1203 
1204  private:
1206  static void dataDefinedTextStyle( QgsPalLayerSettings &tmpLyr,
1207  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1208 
1210  static void dataDefinedTextFormatting( QgsPalLayerSettings &tmpLyr,
1211  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1212 
1214  static void dataDefinedTextBuffer( QgsPalLayerSettings &tmpLyr,
1215  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1216 
1218  static void dataDefinedTextMask( QgsPalLayerSettings &tmpLyr,
1219  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1220 
1222  static void dataDefinedShapeBackground( QgsPalLayerSettings &tmpLyr,
1223  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1224 
1226  static void dataDefinedDropShadow( QgsPalLayerSettings &tmpLyr,
1227  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1228 
1229  friend class QgsVectorLayerLabelProvider; // to allow calling the static methods above
1230  friend class QgsDxfExport; // to allow calling the static methods above
1231 
1240  static bool checkMinimumSizeMM( const QgsRenderContext &context, const QgsGeometry &geom, double minSize );
1241 
1242  friend class QgsPalLayerSettings;
1243 };
1244 
1245 
1246 #endif // QGSPALLABELING_H
UnplacedLabelVisibility
Unplaced label visibility.
Definition: qgis.h:354
@ FollowEngineSetting
Respect the label engine setting.
Abstract base class for callout renderers.
Definition: qgscallout.h:52
This class represents a coordinate reference system (CRS).
Class for doing transforms between two map coordinate systems.
Stores the settings for rendering of all diagrams for a layer.
Exports QGIS layers to the DXF format.
Definition: qgsdxfexport.h:64
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Class for parsing and evaluation of expressions (formerly called "search strings").
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
Container of fields for a vector layer.
Definition: qgsfields.h:45
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
Represents a label candidate.
QgsLabelCandidate(const QRectF &r, double c)
The QgsLabelFeature class describes a feature that should be used within the labeling engine.
Contains settings related to how the label engine places and formats labels for line features (or pol...
DirectionSymbolPlacement
Placement options for direction symbols.
Contains settings related to how the label engine treats features as obstacles.
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels.
A class to query the labeling structure at a given point (small wrapper around pal RTree class)
Contains settings related to how the label engine removes candidate label positions and reduces the n...
The QgsLabelingEngine class provides map labeling functionality.
Base class for all map layer types.
Definition: qgsmaplayer.h:70
The QgsMapSettings class contains configuration for rendering of the map.
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:39
Struct for storing maximum and minimum scales for measurements in map units.
PAL labeling utilities.
Contains settings for how a map layer will be labeled.
QgsMapUnitScale labelOffsetMapUnitScale
Map unit scale for label offset.
void setObstacleSettings(const QgsLabelObstacleSettings &settings)
Sets the label obstacle settings.
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
QString wrapChar
Wrapping character string.
@ SymbolAbove
Place direction symbols on above label.
@ SymbolLeftRight
Place direction symbols on left/right of label.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the label's property collection, used for data defined overrides.
QgsCoordinateTransform ct
QString legendString() const
legendString
@ ShowDefined
Show upside down when rotation is layer- or data-defined.
@ Upright
Upside-down labels (90 <= angle < 270) are shown upright.
void setLineSettings(const QgsLabelLineSettings &settings)
Sets the label line settings, which contain settings related to how the label engine places and forma...
QgsCallout * callout() const
Returns the label callout renderer, responsible for drawing label callouts.
Placement
Placement modes which determine how label candidates are generated for a feature.
@ PerimeterCurved
Arranges candidates following the curvature of a polygon's boundary. Applies to polygon layers only.
@ Curved
Arranges candidates following the curvature of a line feature. Applies to line layers only.
@ Horizontal
Arranges horizontal candidates scattered throughout a polygon feature. Applies to polygon layers only...
@ Free
Arranges candidates scattered throughout a polygon feature. Candidates are rotated to respect the pol...
@ OverPoint
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point....
@ AroundPoint
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
@ Line
Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon'...
@ OrderedPositionsAroundPoint
Candidates are placed in predefined positions around a point. Preference is given to positions with g...
@ OutsidePolygons
Candidates are placed outside of polygon boundaries. Applies to polygon layers only....
@ MultiJustify
Justified.
PredefinedPointPosition
Positions for labels when using the QgsPalLabeling::OrderedPositionsAroundPoint placement mode.
@ BottomSlightlyLeft
Label below point, slightly left of center.
@ BottomMiddle
Label directly below point.
@ BottomSlightlyRight
Label below point, slightly right of center.
@ MiddleLeft
Label on left of point.
@ TopSlightlyRight
Label on top of point, slightly right of center.
@ TopSlightlyLeft
Label on top of point, slightly left of center.
@ MiddleRight
Label on right of point.
@ TopMiddle
Label directly above point.
@ BottomRight
Label on bottom right of point.
@ BottomLeft
Label on bottom-left of point.
@ TopRight
Label on top-right of point.
@ TopLeft
Label on top-left of point.
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the label's property collection, used for data defined overrides.
Property
Data definable properties.
const QgsLabelLineSettings & lineSettings() const
Returns the label line settings, which contain settings related to how the label engine places and fo...
void setPolygonPlacementFlags(QgsLabeling::PolygonPlacementFlags flags)
Sets the polygon placement flags, which dictate how polygon labels can be placed.
const QgsLabelObstacleSettings & obstacleSettings() const
Returns the label obstacle settings.
OffsetType
Behavior modifier for label offset and distance, only applies in some label placement modes.
@ FromPoint
Offset distance applies from point geometry.
@ FromSymbolBounds
Offset distance applies from rendered symbol bounds.
void setLegendString(const QString &legendString)
setLegendString
void setThinningSettings(const QgsLabelThinningSettings &settings)
Sets the label thinning settings.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the label's property collection, used for data defined overrides.
QgsLabeling::PolygonPlacementFlags polygonPlacementFlags() const
Returns the polygon placement flags, which dictate how polygon labels can be placed.
QString geometryGenerator
The geometry generator expression. Null if disabled.
QgsMapUnitScale distMapUnitScale
Map unit scale for label feature distance.
QgsStringReplacementCollection substitutions
Substitution collection for automatic text substitution with labels.
LinePlacementFlags
Line placement flags, which control how candidates are generated for a linear feature.
QgsMapUnitScale repeatDistanceMapUnitScale
Map unit scale for repeating labels for a single feature.
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc.
QString fieldName
Name of field (or an expression) to use for label text.
QgsLabelLineSettings & lineSettings()
Returns the label line settings, which contain settings related to how the label engine places and fo...
QgsLabelObstacleSettings & obstacleSettings()
Returns the label obstacle settings.
const QgsLabelThinningSettings & thinningSettings() const
Returns the label thinning settings.
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels.
QgsLabelThinningSettings & thinningSettings()
Returns the label thinning settings.
A class to represent a 2D point.
Definition: qgspointxy.h:59
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
The class is used as a container of context for various read/write operations on other objects.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
Contains information about the context of a rendering operation.
A collection of string replacements (specified using QgsStringReplacement objects).
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:38
Represents a document consisting of one or more QgsTextBlock objects.
Container for all settings relating to text rendering.
Definition: qgstextformat.h:41
Class that adds extra information to QgsLabelFeature for text labels.
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:168
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
The QgsVectorLayerDiagramProvider class implements support for diagrams within the labeling engine.
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
Represents a vector layer which manages a vector based data sets.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:141
LabelPosition is a candidate feature label position.
Definition: labelposition.h:56
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
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:1080
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:1079
#define SIP_PROPERTY(name, getter, setter)
Definition: qgis_sip.h:263
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_PYARGREMOVE
Definition: qgis_sip.h:146
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_OUT
Definition: qgis_sip.h:58
#define SIP_FACTORY
Definition: qgis_sip.h:76
#define SIP_INOUT
Definition: qgis_sip.h:71
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
const QgsCoordinateReferenceSystem & crs