QGIS API Documentation  2.99.0-Master (6a61179)
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 <QString>
25 #include <QFont>
26 #include <QFontDatabase>
27 #include <QColor>
28 #include <QHash>
29 #include <QList>
30 #include <QPainter>
31 #include <QRectF>
32 #include "qgsfeature.h"
33 #include "qgsgeometry.h"
34 #include "qgsfields.h"
35 #include "qgspoint.h"
36 #include "qgsmapunitscale.h"
37 #include "qgsstringutils.h"
38 #include "qgstextrenderer.h"
39 
40 namespace pal
41 {
42  class Pal;
43  class Layer;
44  class LabelPosition;
45 }
46 
48 class QgsRectangle;
49 class QgsMapToPixel;
50 class QgsFeature;
52 class QgsVectorLayer;
53 class QgsDataDefined;
54 class QgsExpression;
55 class QFontMetricsF;
56 class QPainter;
57 class QPicture;
58 class QgsGeometry;
60 class QgsLabelSearchTree;
61 class QgsMapSettings;
62 class QgsLabelFeature;
63 class QgsLabelingEngine;
66 class QgsDxfExport;
68 
69 
70 
74 class CORE_EXPORT QgsLabelPosition
75 {
76  public:
77  QgsLabelPosition( int id, double r, const QVector< QgsPoint >& 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() )
78  : featureId( id )
79  , rotation( r )
80  , cornerPoints( corners )
81  , labelRect( rect )
82  , width( w )
83  , height( h )
84  , layerID( layer )
85  , labelText( labeltext )
86  , labelFont( labelfont )
87  , upsideDown( upside_down )
88  , isDiagram( diagram )
89  , isPinned( pinned )
90  , providerID( providerId )
91  {}
93  : featureId( -1 )
94  , rotation( 0 )
95  , labelRect( QgsRectangle() )
96  , width( 0 )
97  , height( 0 )
98  , layerID( QLatin1String( "" ) )
99  , labelText( QLatin1String( "" ) )
100  , labelFont( QFont() )
101  , upsideDown( false )
102  , isDiagram( false )
103  , isPinned( false )
104  {}
106  double rotation;
107  QVector< QgsPoint > cornerPoints;
109  double width;
110  double height;
111  QString layerID;
112  QString labelText;
113  QFont labelFont;
115  bool isDiagram;
116  bool isPinned;
118  QString providerID;
119 };
120 
124 class CORE_EXPORT QgsLabelingEngineInterface
125 {
126  public:
127 
129 
131  virtual void init( const QgsMapSettings& mapSettings ) = 0;
133  virtual bool willUseLayer( QgsVectorLayer* layer ) = 0;
135  virtual void clearActiveLayers() = 0;
137  virtual void clearActiveLayer( const QString& layerID ) = 0;
139  virtual int prepareLayer( QgsVectorLayer* layer, QSet<QString>& attrNames, QgsRenderContext& ctx ) = 0;
140 
143  virtual int prepareDiagramLayer( QgsVectorLayer *layer, QSet<QString>& attrNames, QgsRenderContext &ctx )
144  { Q_UNUSED( layer ); Q_UNUSED( attrNames ); Q_UNUSED( ctx ); return 0; }
145 
147  virtual void registerFeature( const QString &layerID, QgsFeature &feat, QgsRenderContext &context ) = 0;
149  virtual void registerDiagramFeature( const QString &layerID, QgsFeature &feat, QgsRenderContext &context )
150  { Q_UNUSED( layerID ); Q_UNUSED( feat ); Q_UNUSED( context ); }
152  virtual void drawLabeling( QgsRenderContext& context ) = 0;
154  virtual void exit() = 0;
155 
157  virtual QgsLabelingEngineInterface* clone() = 0;
158 };
159 
160 
164 class CORE_EXPORT QgsPalLayerSettings
165 {
166  public:
170 
172  QgsPalLayerSettings &operator=( const QgsPalLayerSettings & s );
173 
175  static QgsPalLayerSettings fromLayer( QgsVectorLayer* layer );
176 
179  //TODO QGIS 3.0 - move to QgsLabelingEngine
181  {
190  };
191 
193  //TODO QGIS 3.0 - move to QgsLabelingEngine
195  {
208  };
209 
212  //TODO QGIS 3.0 - move to QgsLabelingEngine
214  {
217  };
218 
221  //TODO QGIS 3.0 - move to QgsLabelingEngine, rename to LinePlacementFlag, use Q_DECLARE_FLAGS to make
222  //LinePlacementFlags type, and replace use of pal::LineArrangementFlag
224  {
225  OnLine = 1,
226  AboveLine = 2,
229  BelowLine = 4,
232  MapOrientation = 8,
235  };
236 
238  {
247  QuadrantBelowRight
248  };
249 
251  {
254  ShowAll
255  };
256 
258  {
261  SymbolBelow
262  };
263 
265  {
266  MultiLeft = 0,
269  MultiFollowPlacement
271  };
272 
276  //TODO QGIS 3.0 - Move to QgsLabelingEngine
278  {
279  PolygonInterior,
281  PolygonBoundary,
283  PolygonWhole
287  };
288 
289 
291  enum SizeUnit
292  {
293  Points = 0,
294  MM,
296  Percent
297  };
298 
299  // update mDataDefinedNames QMap in constructor when adding/deleting enum value
301  {
302  // text style
303  Size = 0,
304  Bold = 1,
305  Italic = 2,
306  Underline = 3,
307  Color = 4,
308  Strikeout = 5,
309  Family = 6,
310  FontStyle = 21,
311  FontSizeUnit = 22,
312  FontTransp = 18,
313  FontCase = 27,
314  FontLetterSpacing = 28,
315  FontWordSpacing = 29,
316  FontBlendMode = 30,
317 
318  // text formatting
319  MultiLineWrapChar = 31,
320  MultiLineHeight = 32,
321  MultiLineAlignment = 33,
322  DirSymbDraw = 34,
323  DirSymbLeft = 35,
324  DirSymbRight = 36,
325  DirSymbPlacement = 37,
326  DirSymbReverse = 38,
327  NumFormat = 39,
328  NumDecimals = 40,
329  NumPlusSign = 41,
330 
331  // text buffer
332  BufferDraw = 42,
333  BufferSize = 7,
334  BufferUnit = 43,
335  BufferColor = 8,
336  BufferTransp = 19,
337  BufferJoinStyle = 44,
338  BufferBlendMode = 45,
339 
340  // background
341  ShapeDraw = 46,
342  ShapeKind = 47,
343  ShapeSVGFile = 48,
344  ShapeSizeType = 49,
345  ShapeSizeX = 50,
346  ShapeSizeY = 85,
347  ShapeSizeUnits = 51,
348  ShapeRotationType = 52,
349  ShapeRotation = 53,
350  ShapeOffset = 54,
351  ShapeOffsetUnits = 55,
352  ShapeRadii = 56,
353  ShapeRadiiUnits = 57,
354  ShapeTransparency = 63,
355  ShapeBlendMode = 64,
356  ShapeFillColor = 58,
357  ShapeBorderColor = 59,
358  ShapeBorderWidth = 60,
359  ShapeBorderWidthUnits = 61,
360  ShapeJoinStyle = 62,
361 
362  // drop shadow
363  ShadowDraw = 65,
364  ShadowUnder = 66,
365  ShadowOffsetAngle = 67,
366  ShadowOffsetDist = 68,
367  ShadowOffsetUnits = 69,
368  ShadowRadius = 70,
369  ShadowRadiusUnits = 71,
370  ShadowTransparency = 72,
371  ShadowScale = 73,
372  ShadowColor = 74,
373  ShadowBlendMode = 75,
374 
375  // placement
376  CentroidWhole = 76,
377  OffsetQuad = 77,
378  OffsetXY = 78,
379  OffsetUnits = 80,
380  LabelDistance = 13,
381  DistanceUnits = 81,
382  OffsetRotation = 82,
383  CurvedCharAngleInOut = 83,
384  // (data defined only)
385  PositionX = 9, //x-coordinate data defined label position
386  PositionY = 10, //y-coordinate data defined label position
387  Hali = 11, //horizontal alignment for data defined label position (Left, Center, Right)
388  Vali = 12, //vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top)
389  Rotation = 14, //data defined rotation
390  RepeatDistance = 84,
391  RepeatDistanceUnit = 86,
392  Priority = 87,
393  PredefinedPositionOrder = 91,
394 
395  // rendering
396  ScaleVisibility = 23,
397  MinScale = 16,
398  MaxScale = 17,
399  FontLimitPixel = 24,
400  FontMinPixel = 25,
401  FontMaxPixel = 26,
402  IsObstacle = 88,
403  ObstacleFactor = 89,
404  ZIndex = 90,
405 
406  // (data defined only)
407  Show = 15,
408  AlwaysShow = 20
409  };
410 
411  // whether to label this layer
412  bool enabled;
413 
422 
423  //-- text style
424 
425  QString fieldName;
426 
430 
433  QgsExpression* getLabelExpression();
434 
436 
441 
442  //-- text formatting
443 
444  QString wrapChar;
445  MultiLineAlign multilineAlign; // horizontal alignment of multi-line labels
446 
447  // Adds '<' or '>', or user-defined symbol to the label string pointing to the
448  // direction of the line / polygon ring
449  // Works only if Placement == Line
453  DirectionSymbols placeDirectionSymbol; // whether to place left/right, above or below label
455 
457  int decimals;
458  bool plusSign;
459 
460  //-- placement
461 
463  unsigned int placementFlags;
464 
465  bool centroidWhole; // whether centroid calculated from whole or visible polygon
466  bool centroidInside; // whether centroid-point calculated must be inside polygon
467 
473  QVector< PredefinedPointPosition > predefinedPositionOrder;
474 
478  double dist; // distance from the feature (in mm)
479  bool distInMapUnits; //true if distance is in map units (otherwise in mm)
483 
487 
488  // offset labels of point/centroid features default to center
489  // move label to quadrant: left/down, don't move, right/up (-1, 0, 1)
491 
492  double xOffset; // offset from point in mm or map units
493  double yOffset; // offset from point in mm or map units
494  bool labelOffsetInMapUnits; //true if label offset is in map units (otherwise in mm)
496  double angleOffset; // rotation applied to offset labels
497  bool preserveRotation; // preserve predefined rotation data during label pin/unpin operations
498 
499  double maxCurvedCharAngleIn; // maximum angle between inside curved label characters (defaults to 20.0, range 20.0 to 60.0)
500  double maxCurvedCharAngleOut; // maximum angle between outside curved label characters (defaults to -20.0, range -20.0 to -95.0)
501 
502  int priority; // 0 = low, 10 = high
503 
504  //-- rendering
505 
507  int scaleMin;
508  int scaleMax;
509 
510  bool fontLimitPixelSize; // true is label should be limited by fontMinPixelSize/fontMaxPixelSize
511  int fontMinPixelSize; // minimum pixel size for showing rendered map unit labels (1 - 1000)
512  int fontMaxPixelSize; // maximum pixel size for showing rendered map unit labels (1 - 10000)
513 
514  bool displayAll; // if true, all features will be labelled even though overlaps occur
515  UpsideDownLabels upsidedownLabels; // whether, or how, to show upsidedown labels
516 
517  bool labelPerPart; // whether to label every feature's part or only the biggest one
519 
520  bool limitNumLabels; // whether to limit the number of labels to be drawn
521  int maxNumLabels; // maximum number of labels to be drawn
522 
523  double minFeatureSize; // minimum feature size to be labelled (in mm)
524  bool obstacle; // whether features for layer are obstacles to labels of other layers
525 
530 
534 
536  double zIndex;
537 
538  // called from register feature hook
539  void calculateLabelSize( const QFontMetricsF* fm, QString text, double& labelX, double& labelY, QgsFeature* f = nullptr, QgsRenderContext* context = nullptr );
540 
553  void registerFeature( QgsFeature& f, QgsRenderContext& context, QgsLabelFeature** labelFeature = nullptr, QgsGeometry* obstacleGeometry = nullptr );
554 
555  void readFromLayer( QgsVectorLayer* layer );
556  void writeToLayer( QgsVectorLayer* layer );
557 
561  void readXml( QDomElement& elem );
562 
566  QDomElement writeXml( QDomDocument& doc );
567 
572 
576  void setDataDefinedProperty( QgsPalLayerSettings::DataDefinedProperties p,
577  bool active, bool useExpr, const QString& expr, const QString& field );
578 
580  void removeDataDefinedProperty( QgsPalLayerSettings::DataDefinedProperties p );
581 
585  void removeAllDataDefinedProperties();
586 
590  QString updateDataDefinedString( const QString& value );
591 
595  QMap<QString, QString> dataDefinedMap( QgsPalLayerSettings::DataDefinedProperties p ) const;
596 
601  QVariant dataDefinedValue( QgsPalLayerSettings::DataDefinedProperties p, QgsFeature& f, const QgsFields& fields,
602  const QgsExpressionContext* context = nullptr ) const;
603 
608  bool dataDefinedEvaluate( QgsPalLayerSettings::DataDefinedProperties p, QVariant& exprVal, QgsExpressionContext* context = nullptr, const QVariant& originalValue = QVariant() ) const;
609 
612  bool dataDefinedIsActive( QgsPalLayerSettings::DataDefinedProperties p ) const;
613 
616  bool dataDefinedUseExpression( QgsPalLayerSettings::DataDefinedProperties p ) const;
617 
622  QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined* > dataDefinedProperties;
623 
628  QMap<QgsPalLayerSettings::DataDefinedProperties, QPair<QString, int> > dataDefinedNames() const { return mDataDefinedNames; }
629 
634  const QgsTextFormat& format() const { return mFormat; }
635 
641  void setFormat( const QgsTextFormat& format ) { mFormat = format; }
642 
643  // temporary stuff: set when layer gets prepared or labeled
649 
653  int mFeaturesToLabel; // total features that will probably be labeled, may be less (figured before PAL)
654  int mFeatsSendingToPal; // total features tested for sending into PAL (relative to maxNumLabels)
655  int mFeatsRegPal; // number of features registered in PAL, when using limitNumLabels
656 
657  private:
658 
659  void readDataDefinedPropertyMap( QgsVectorLayer* layer, QDomElement* parentElem,
661  QgsDataDefined* > & propertyMap );
662  void writeDataDefinedPropertyMap( QgsVectorLayer* layer, QDomElement* parentElem,
664  QgsDataDefined* > & propertyMap );
665  void readDataDefinedProperty( QgsVectorLayer* layer,
668  QgsDataDefined* > & propertyMap );
669 
670  enum DataDefinedValueType
671  {
672  DDBool,
673  DDInt,
674  DDIntPos,
675  DDDouble,
676  DDDoublePos,
677  DDRotation180,
678  DDTransparency,
679  DDString,
680  DDUnits,
681  DDColor,
682  DDJoinStyle,
683  DDBlendMode,
684  DDPointF
685  };
686 
687  // convenience data defined evaluation function
688  bool dataDefinedValEval( DataDefinedValueType valType,
690  QVariant& exprVal, QgsExpressionContext &context, const QVariant& originalValue = QVariant() );
691 
692  void parseTextStyle( QFont& labelFont,
693  QgsUnitTypes::RenderUnit fontunits,
694  QgsRenderContext& context );
695 
696  void parseTextBuffer( QgsRenderContext& context );
697 
698  void parseTextFormatting( QgsRenderContext& context );
699 
700  void parseShapeBackground( QgsRenderContext& context );
701 
702  void parseDropShadow( QgsRenderContext& context );
703 
706  bool checkMinimumSizeMM( const QgsRenderContext& ct, const QgsGeometry& geom, double minSize ) const;
707 
710  void registerObstacleFeature( QgsFeature &f, QgsRenderContext &context, QgsLabelFeature** obstacleFeature, QgsGeometry* obstacleGeometry = nullptr );
711 
712  QMap<DataDefinedProperties, QVariant> dataDefinedValues;
713  QgsExpression* expression;
714  QMap<QgsPalLayerSettings::DataDefinedProperties, QPair<QString, int> > mDataDefinedNames;
715 
716  QFontDatabase mFontDB;
717 
718  QgsTextFormat mFormat;
719 
720  static QVector< PredefinedPointPosition > DEFAULT_PLACEMENT_ORDER;
721 };
722 
725 class CORE_EXPORT QgsLabelCandidate
726 {
727  public:
728  QgsLabelCandidate( const QRectF& r, double c ): rect( r ), cost( c ) {}
729 
730  QRectF rect;
731  double cost;
732 };
733 
734 
735 
736 
741 class CORE_EXPORT QgsLabelingResults
742 {
743  public:
746 
748  QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) const;
750  QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) const;
751 
752  private:
753  QgsLabelingResults( const QgsLabelingResults& ); // no copying allowed
754  QgsLabelingResults& operator=( const QgsLabelingResults& rh );
755 
756  QgsLabelSearchTree* mLabelSearchTree;
757 
758  friend class QgsPalLabeling;
761 };
762 
766 class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface
767 {
768  public:
769 
770  QgsPalLabeling();
771  ~QgsPalLabeling();
772 
773  void numCandidatePositions( int& candPoint, int& candLine, int& candPolygon );
774  void setNumCandidatePositions( int candPoint, int candLine, int candPolygon );
775 
776  enum Search { Chain, Popmusic_Tabu, Popmusic_Chain, Popmusic_Tabu_Chain, Falp };
777 
778  void setSearchMethod( Search s );
779  Search searchMethod() const;
780 
781  bool isShowingCandidates() const;
782  void setShowingCandidates( bool showing );
783 
784  bool isShowingAllLabels() const;
785  void setShowingAllLabels( bool showing );
786 
787  bool isShowingPartialsLabels() const;
788  void setShowingPartialsLabels( bool showing );
789 
791  bool isDrawingOutlineLabels() const;
792  void setDrawingOutlineLabels( bool outline );
793 
799  bool drawLabelRectOnly() const;
800 
807  void setDrawLabelRectOnly( bool drawRect );
808 
809  // implemented methods from labeling engine interface
810 
812  virtual void init( const QgsMapSettings& mapSettings ) override;
814  virtual bool willUseLayer( QgsVectorLayer* layer ) override;
815 
818  static bool staticWillUseLayer( QgsVectorLayer* layer );
819  static bool staticWillUseLayer( const QString& layerID );
820 
822  virtual void clearActiveLayers() override;
824  virtual void clearActiveLayer( const QString& layerID ) override;
826  virtual int prepareLayer( QgsVectorLayer* layer, QSet<QString>& attrNames, QgsRenderContext& ctx ) override;
829  virtual int prepareDiagramLayer( QgsVectorLayer* layer, QSet<QString>& attrNames, QgsRenderContext& ctx ) override;
830 
837  virtual void registerFeature( const QString& layerID, QgsFeature& feat, QgsRenderContext& context ) override;
838 
839  virtual void registerDiagramFeature( const QString& layerID, QgsFeature& feat, QgsRenderContext& context ) override;
841  virtual void drawLabeling( QgsRenderContext& context ) override;
843  virtual void exit() override;
844 
847  QgsLabelingResults* takeResults();
848 
850  virtual QgsPalLabeling* clone() override;
851 
853  static void drawLabelCandidateRect( pal::LabelPosition* lp, QPainter* painter, const QgsMapToPixel* xform, QList<QgsLabelCandidate>* candidates = nullptr );
854 
856  void loadEngineSettings();
857  void saveEngineSettings();
858  void clearEngineSettings();
859 
868  static QgsGeometry prepareGeometry( const QgsGeometry& geometry, QgsRenderContext &context, const QgsCoordinateTransform& ct, QgsGeometry *clipGeometry = nullptr );
869 
878  static bool geometryRequiresPreparation( const QgsGeometry& geometry, QgsRenderContext &context, const QgsCoordinateTransform& ct, QgsGeometry *clipGeometry = nullptr );
879 
887  static QStringList splitToLines( const QString& text, const QString& wrapCharacter );
888 
896  static QStringList splitToGraphemes( const QString& text );
897 
898  protected:
899  // update temporary QgsPalLayerSettings with any data defined text style values
900  static void dataDefinedTextStyle( QgsPalLayerSettings& tmpLyr,
901  const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues );
902 
903  // update temporary QgsPalLayerSettings with any data defined text formatting values
904  static void dataDefinedTextFormatting( QgsPalLayerSettings& tmpLyr,
905  const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues );
906 
907  // update temporary QgsPalLayerSettings with any data defined text buffer values
908  static void dataDefinedTextBuffer( QgsPalLayerSettings& tmpLyr,
909  const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues );
910 
911  // update temporary QgsPalLayerSettings with any data defined shape background values
912  static void dataDefinedShapeBackground( QgsPalLayerSettings& tmpLyr,
913  const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues );
914 
915  // update temporary QgsPalLayerSettings with any data defined drop shadow values
916  static void dataDefinedDropShadow( QgsPalLayerSettings& tmpLyr,
917  const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues );
918 
919  friend class QgsVectorLayerLabelProvider; // to allow calling the static methods above
920  friend class QgsDxfExport; // to allow calling the static methods above
921 
922  void deleteTemporaryData();
923 
931  static bool checkMinimumSizeMM( const QgsRenderContext &context, const QgsGeometry *geom, double minSize );
932 
934  QHash<QString, QgsVectorLayerLabelProvider*> mLabelProviders;
936  QHash<QString, QgsVectorLayerDiagramProvider*> mDiagramProviders;
938 
941 
942  // list of candidates from last labeling
943  QList<QgsLabelCandidate> mCandidates;
944 
945  friend class QgsPalLayerSettings;
946 };
947 
948 #endif // QGSPALLABELING_H
Label below point, slightly right of center.
QgsRectangle labelRect
Class for parsing and evaluation of expressions (formerly called "search strings").
A rectangle specified with double values.
Definition: qgsrectangle.h:35
Label on bottom-left of point.
QHash< QString, QgsVectorLayerLabelProvider * > mLabelProviders
hashtable of label providers, being filled during labeling (key = layer ID)
A container class for data source field mapping or expression.
A class to query the labeling structure at a given point (small wraper around pal RTree class) ...
UpsideDownLabels upsidedownLabels
double obstacleFactor
Obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels, 1.0 less likely to be covered
Label on top-left of point.
QgsLabelCandidate(const QRectF &r, double c)
PredefinedPointPosition
Positions for labels when using the QgsPalLabeling::OrderedPositionsAroundPoint placement mode...
Candidates are placed in predefined positions around a point. Peference is given to positions with gr...
QuadrantPosition quadOffset
Class that adds extra information to QgsLabelFeature for text labels.
Container of fields for a vector layer.
Definition: qgsfields.h:36
Label on top of point, slightly right of center.
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:78
bool drawLabels
Whether to draw labels for this layer.
QHash< QString, QgsVectorLayerDiagramProvider * > mDiagramProviders
hashtable of diagram providers (key = layer ID)
QgsMapUnitScale repeatDistanceMapUnitScale
MultiLineAlign multilineAlign
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:135
QMap< QgsPalLayerSettings::DataDefinedProperties, QPair< QString, int > > dataDefinedNames() const
Map of data defined enum to names and old-style indecies The QPair contains a new string for layer pr...
QVector< PredefinedPointPosition > predefinedPositionOrder
Ordered list of predefined label positions for points.
QVector< QgsPoint > cornerPoints
QgsCoordinateTransform ct
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, eg font settings, buffer settings, etc.
double zIndex
Z-Index of label, where labels with a higher z-index are rendered on top of labels with a lower z-ind...
QgsStringReplacementCollection substitutions
Substitution collection for automatic text substitution with labels.
Arranges candidates following the curvature of a line feature. Applies to line layers only...
The QgsMapSettings class contains configuration for rendering of the map.
Place direction symbols on left/right of label.
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:33
ObstacleType obstacleType
Controls how features act as obstacles for labels.
Label on left of point.
Offset distance applies from point geometry.
QgsPalLayerSettings mInvalidLayerSettings
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...
struct pal::_chain Chain
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
const QgsMapToPixel * xform
QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined *> dataDefinedProperties
Map of current data defined properties.
Upside-down labels (90 <= angle < 270) are shown upright.
OffsetType
Behaviour modifier for label offset and distance, only applies in some label placement modes...
QgsFeature * mCurFeat
SizeUnit
Units used for option sizes, before being converted to rendered sizes.
A class to represent a point.
Definition: qgspoint.h:111
Offset distance applies from rendered symbol bounds.
const QgsTextFormat & format() const
Returns the label text formatting settings, eg font settings, buffer settings, etc.
Place direction symbols on above label.
Stores the settings for rendering of all diagrams for a layer.
unsigned int placementFlags
Placement
Placement modes which determine how label candidates are generated for a feature. ...
The QgsLabelingEngine class provides map labeling functionality.
virtual void registerDiagramFeature(const QString &layerID, QgsFeature &feat, QgsRenderContext &context)
called for every diagram feature
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point...
Contains information about the context of a rendering operation.
The QgsLabelFeature class describes a feature that should be used within the labeling engine...
QgsGeometry extentGeom
QgsLabelPosition(int id, double r, const QVector< QgsPoint > &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())
QgsMapUnitScale distMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
bool fitInPolygonOnly
True if only labels which completely fit within a polygon are allowed.
A collection of string replacements (specified using QgsStringReplacement objects).
QgsLabelingEngine * mEngine
New labeling engine to interface with PAL.
OffsetType offsetType
Offset type for layer (only applies in certain placement modes)
bool useSubstitutions
True if substitutions should be applied.
Label below point, slightly left of center.
Class for doing transforms between two map coordinate systems.
LabelPosition is a candidate feature label position.
Definition: labelposition.h:51
Label on top of point, slightly left of center.
Label on right of point.
bool isExpression
Is this label made from a expression string eg FieldName || &#39;mm&#39;.
Class that stores computed placement from labeling engine.
LinePlacementFlags
Line placement flags, which control how candidates are generated for a linear feature.
QList< QgsLabelCandidate > mCandidates
Labeling engine interface.
Show upside down when rotation is layer- or data-defined.
Container for all settings relating to text rendering.
Represents a vector layer which manages a vector based data sets.
QgsMapUnitScale labelOffsetMapUnitScale
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:91
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels...
DirectionSymbols placeDirectionSymbol
virtual int prepareDiagramLayer(QgsVectorLayer *layer, QSet< QString > &attrNames, QgsRenderContext &ctx)
adds a diagram layer to the labeling engine
Arranges candidates scattered throughout a polygon feature. Candidates are rotated to respect the pol...