QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 <QRectF>
31 #include "qgspoint.h"
32 #include "qgsmaprenderer.h" // definition of QgsLabelingEngineInterface
33 #include "qgsdiagramrendererv2.h"
34 #include "qgsmapunitscale.h"
35 #include "qgsstringutils.h"
36 
37 namespace pal
38 {
39  class Pal;
40  class Layer;
41  class LabelPosition;
42 }
43 
44 class QgsRectangle;
45 class QgsMapToPixel;
46 class QgsFeature;
48 class QgsVectorLayer;
49 class QgsDataDefined;
50 class QgsExpression;
51 class QFontMetricsF;
52 class QPainter;
53 class QPicture;
54 class QgsGeometry;
55 class QgsMapRenderer;
57 class QgsLabelSearchTree;
58 class QgsMapSettings;
59 class QgsLabelFeature;
62 class QgsDxfExport;
64 
68 class CORE_EXPORT QgsPalLayerSettings
69 {
70  public:
74 
76  QgsPalLayerSettings &operator=( const QgsPalLayerSettings & s );
77 
79  static QgsPalLayerSettings fromLayer( QgsVectorLayer* layer );
80 
83  //TODO QGIS 3.0 - move to QgsLabelingEngineV2
84  enum Placement
85  {
88  Line,
91  Free,
94  };
95 
97  //TODO QGIS 3.0 - move to QgsLabelingEngineV2
99  {
112  };
113 
116  //TODO QGIS 3.0 - move to QgsLabelingEngineV2
118  {
121  };
122 
125  //TODO QGIS 3.0 - move to QgsLabelingEngineV2, rename to LinePlacementFlag, use Q_DECLARE_FLAGS to make
126  //LinePlacementFlags type, and replace use of pal::LineArrangementFlag
128  {
129  OnLine = 1,
130  AboveLine = 2,
133  BelowLine = 4,
136  MapOrientation = 8,
139  };
140 
142  {
151  QuadrantBelowRight
152  };
153 
155  {
158  ShowAll
159  };
160 
162  {
165  SymbolBelow
166  };
167 
169  {
170  MultiLeft = 0,
173  MultiFollowPlacement
175  };
176 
180  //TODO QGIS 3.0 - Move to QgsLabelingEngineV2
182  {
183  PolygonInterior,
185  PolygonBoundary,
187  PolygonWhole
191  };
192 
194  {
195  ShapeRectangle = 0,
199  ShapeSVG
200  };
201 
202  enum SizeType
203  {
204  SizeBuffer = 0,
206  SizePercent
207  };
208 
210  {
211  RotationSync = 0,
213  RotationFixed
214  };
215 
217  enum SizeUnit
218  {
219  Points = 0,
220  MM,
222  Percent
223  };
224 
226  {
227  ShadowLowest = 0,
230  ShadowShape
231  };
232 
233  // update mDataDefinedNames QMap in constructor when adding/deleting enum value
235  {
236  // text style
237  Size = 0,
238  Bold = 1,
239  Italic = 2,
240  Underline = 3,
241  Color = 4,
242  Strikeout = 5,
243  Family = 6,
244  FontStyle = 21,
245  FontSizeUnit = 22,
246  FontTransp = 18,
247  FontCase = 27,
248  FontLetterSpacing = 28,
249  FontWordSpacing = 29,
250  FontBlendMode = 30,
251 
252  // text formatting
253  MultiLineWrapChar = 31,
254  MultiLineHeight = 32,
255  MultiLineAlignment = 33,
256  DirSymbDraw = 34,
257  DirSymbLeft = 35,
258  DirSymbRight = 36,
259  DirSymbPlacement = 37,
260  DirSymbReverse = 38,
261  NumFormat = 39,
262  NumDecimals = 40,
263  NumPlusSign = 41,
264 
265  // text buffer
266  BufferDraw = 42,
267  BufferSize = 7,
268  BufferUnit = 43,
269  BufferColor = 8,
270  BufferTransp = 19,
271  BufferJoinStyle = 44,
272  BufferBlendMode = 45,
273 
274  // background
275  ShapeDraw = 46,
276  ShapeKind = 47,
277  ShapeSVGFile = 48,
278  ShapeSizeType = 49,
279  ShapeSizeX = 50,
280  ShapeSizeY = 85,
281  ShapeSizeUnits = 51,
282  ShapeRotationType = 52,
283  ShapeRotation = 53,
284  ShapeOffset = 54,
285  ShapeOffsetUnits = 55,
286  ShapeRadii = 56,
287  ShapeRadiiUnits = 57,
288  ShapeTransparency = 63,
289  ShapeBlendMode = 64,
290  ShapeFillColor = 58,
291  ShapeBorderColor = 59,
292  ShapeBorderWidth = 60,
293  ShapeBorderWidthUnits = 61,
294  ShapeJoinStyle = 62,
295 
296  // drop shadow
297  ShadowDraw = 65,
298  ShadowUnder = 66,
299  ShadowOffsetAngle = 67,
300  ShadowOffsetDist = 68,
301  ShadowOffsetUnits = 69,
302  ShadowRadius = 70,
303  ShadowRadiusUnits = 71,
304  ShadowTransparency = 72,
305  ShadowScale = 73,
306  ShadowColor = 74,
307  ShadowBlendMode = 75,
308 
309  // placement
310  CentroidWhole = 76,
311  OffsetQuad = 77,
312  OffsetXY = 78,
313  OffsetUnits = 80,
314  LabelDistance = 13,
315  DistanceUnits = 81,
316  OffsetRotation = 82,
317  CurvedCharAngleInOut = 83,
318  // (data defined only)
319  PositionX = 9, //x-coordinate data defined label position
320  PositionY = 10, //y-coordinate data defined label position
321  Hali = 11, //horizontal alignment for data defined label position (Left, Center, Right)
322  Vali = 12, //vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top)
323  Rotation = 14, //data defined rotation
324  RepeatDistance = 84,
325  RepeatDistanceUnit = 86,
326  Priority = 87,
327  PredefinedPositionOrder = 91,
328 
329  // rendering
330  ScaleVisibility = 23,
331  MinScale = 16,
332  MaxScale = 17,
333  FontLimitPixel = 24,
334  FontMinPixel = 25,
335  FontMaxPixel = 26,
336  IsObstacle = 88,
337  ObstacleFactor = 89,
338  ZIndex = 90,
339 
340  // (data defined only)
341  Show = 15,
342  AlwaysShow = 20
343  };
344 
345  // whether to label this layer
346  bool enabled;
347 
356 
357  //-- text style
358 
360 
364 
367  QgsExpression* getLabelExpression();
368 
371  bool fontSizeInMapUnits; //true if font size is in map units (otherwise in points)
372  QgsMapUnitScale fontSizeMapUnitScale; // scale range for map units for font size
375  QPainter::CompositionMode blendMode;
377 
382 
383  //-- text formatting
384 
386  double multilineHeight; //0.0 to 10.0, leading between lines as multiplyer of line height
387  MultiLineAlign multilineAlign; // horizontal alignment of multi-line labels
388 
389  // Adds '<' or '>', or user-defined symbol to the label string pointing to the
390  // direction of the line / polygon ring
391  // Works only if Placement == Line
395  DirectionSymbols placeDirectionSymbol; // whether to place left/right, above or below label
397 
399  int decimals;
400  bool plusSign;
401 
402  //-- text buffer
403 
405  double bufferSize; // buffer size
406  bool bufferSizeInMapUnits; //true if buffer is in map units (otherwise in mm)
407  QgsMapUnitScale bufferSizeMapUnitScale; // scale range for map units for buffer size
409  bool bufferNoFill; //set interior of buffer to 100% transparent
411  Qt::PenJoinStyle bufferJoinStyle;
412  QPainter::CompositionMode bufferBlendMode;
413 
414  //-- shape background
415 
416  bool shapeDraw;
432  QPainter::CompositionMode shapeBlendMode;
438  Qt::PenJoinStyle shapeJoinStyle;
439 
440  //-- drop shadow
441 
449  double shadowRadius;
456  QPainter::CompositionMode shadowBlendMode;
457 
458  //-- placement
459 
461  unsigned int placementFlags;
462 
463  bool centroidWhole; // whether centroid calculated from whole or visible polygon
464  bool centroidInside; // whether centroid-point calculated must be inside polygon
465 
472 
476  double dist; // distance from the feature (in mm)
477  bool distInMapUnits; //true if distance is in map units (otherwise in mm)
481 
485 
486  // offset labels of point/centroid features default to center
487  // move label to quadrant: left/down, don't move, right/up (-1, 0, 1)
489 
490  double xOffset; // offset from point in mm or map units
491  double yOffset; // offset from point in mm or map units
492  bool labelOffsetInMapUnits; //true if label offset is in map units (otherwise in mm)
494  double angleOffset; // rotation applied to offset labels
495  bool preserveRotation; // preserve predefined rotation data during label pin/unpin operations
496 
497  double maxCurvedCharAngleIn; // maximum angle between inside curved label characters (defaults to 20.0, range 20.0 to 60.0)
498  double maxCurvedCharAngleOut; // maximum angle between outside curved label characters (defaults to -20.0, range -20.0 to -95.0)
499 
500  int priority; // 0 = low, 10 = high
501 
502  //-- rendering
503 
505  int scaleMin;
506  int scaleMax;
507 
508  bool fontLimitPixelSize; // true is label should be limited by fontMinPixelSize/fontMaxPixelSize
509  int fontMinPixelSize; // minimum pixel size for showing rendered map unit labels (1 - 1000)
510  int fontMaxPixelSize; // maximum pixel size for showing rendered map unit labels (1 - 10000)
511 
512  bool displayAll; // if true, all features will be labelled even though overlaps occur
513  UpsideDownLabels upsidedownLabels; // whether, or how, to show upsidedown labels
514 
515  bool labelPerPart; // whether to label every feature's part or only the biggest one
517 
518  bool limitNumLabels; // whether to limit the number of labels to be drawn
519  int maxNumLabels; // maximum number of labels to be drawn
520 
521  double minFeatureSize; // minimum feature size to be labelled (in mm)
522  bool obstacle; // whether features for layer are obstacles to labels of other layers
523 
528 
532 
534  double zIndex;
535 
536  //-- scale factors
537  double vectorScaleFactor; //scale factor painter units->pixels
538  double rasterCompressFactor; //pixel resolution scale factor
539 
540  // called from register feature hook
541  void calculateLabelSize( const QFontMetricsF* fm, QString text, double& labelX, double& labelY, QgsFeature* f = nullptr, QgsRenderContext* context = nullptr );
542 
555  void registerFeature( QgsFeature& f, QgsRenderContext& context, QgsLabelFeature** labelFeature = nullptr, QgsGeometry* obstacleGeometry = nullptr );
556 
557  void readFromLayer( QgsVectorLayer* layer );
558  void writeToLayer( QgsVectorLayer* layer );
559 
563  void readXml( QDomElement& elem );
564 
568  QDomElement writeXml( QDomDocument& doc );
569 
574 
578  void setDataDefinedProperty( QgsPalLayerSettings::DataDefinedProperties p,
579  bool active, bool useExpr, const QString& expr, const QString& field );
580 
582  void removeDataDefinedProperty( QgsPalLayerSettings::DataDefinedProperties p );
583 
587  void removeAllDataDefinedProperties();
588 
592  QString updateDataDefinedString( const QString& value );
593 
598 
603  QVariant dataDefinedValue( QgsPalLayerSettings::DataDefinedProperties p, QgsFeature& f, const QgsFields& fields,
604  const QgsExpressionContext* context = nullptr ) const;
605 
610  bool dataDefinedEvaluate( QgsPalLayerSettings::DataDefinedProperties p, QVariant& exprVal, QgsExpressionContext* context = nullptr, const QVariant& originalValue = QVariant() ) const;
611 
614  bool dataDefinedIsActive( QgsPalLayerSettings::DataDefinedProperties p ) const;
615 
618  bool dataDefinedUseExpression( QgsPalLayerSettings::DataDefinedProperties p ) const;
619 
625 
626 
635  int sizeToPixel( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
636 
645  double scaleToPixelContext( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
646 
652 
653  // temporary stuff: set when layer gets prepared or labeled
659 
663  int mFeaturesToLabel; // total features that will probably be labeled, may be less (figured before PAL)
664  int mFeatsSendingToPal; // total features tested for sending into PAL (relative to maxNumLabels)
665  int mFeatsRegPal; // number of features registered in PAL, when using limitNumLabels
666 
669 
670  bool showingShadowRects; // whether to show debug rectangles for drop shadows
671 
672  private:
673 
674  void readDataDefinedPropertyMap( QgsVectorLayer* layer, QDomElement* parentElem,
676  QgsDataDefined* > & propertyMap );
677  void writeDataDefinedPropertyMap( QgsVectorLayer* layer, QDomElement* parentElem,
679  QgsDataDefined* > & propertyMap );
680  void readDataDefinedProperty( QgsVectorLayer* layer,
683  QgsDataDefined* > & propertyMap );
684 
685  enum DataDefinedValueType
686  {
687  DDBool,
688  DDInt,
689  DDIntPos,
690  DDDouble,
691  DDDoublePos,
692  DDRotation180,
693  DDTransparency,
694  DDString,
695  DDUnits,
696  DDColor,
697  DDJoinStyle,
698  DDBlendMode,
699  DDPointF
700  };
701 
702  // convenience data defined evaluation function
703  bool dataDefinedValEval( DataDefinedValueType valType,
705  QVariant& exprVal, QgsExpressionContext &context, const QVariant& originalValue = QVariant() );
706 
707  void parseTextStyle( QFont& labelFont,
709  QgsRenderContext& context );
710 
711  void parseTextBuffer( QgsRenderContext& context );
712 
713  void parseTextFormatting( QgsRenderContext& context );
714 
715  void parseShapeBackground( QgsRenderContext& context );
716 
717  void parseDropShadow( QgsRenderContext& context );
718 
721  bool checkMinimumSizeMM( const QgsRenderContext& ct, const QgsGeometry* geom, double minSize ) const;
722 
725  void registerObstacleFeature( QgsFeature &f, QgsRenderContext &context, QgsLabelFeature** obstacleFeature, QgsGeometry* obstacleGeometry = nullptr );
726 
727  QMap<DataDefinedProperties, QVariant> dataDefinedValues;
728  QgsExpression* expression;
730 
731  QFontDatabase mFontDB;
732 
733  static QVector< PredefinedPointPosition > DEFAULT_PLACEMENT_ORDER;
734 };
735 
738 class CORE_EXPORT QgsLabelCandidate
739 {
740  public:
741  QgsLabelCandidate( const QRectF& r, double c ): rect( r ), cost( c ) {}
742 
744  double cost;
745 };
746 
751 class CORE_EXPORT QgsLabelComponent
752 {
753  public:
755  : mText( QString() )
756  , mOrigin( QgsPoint() )
757  , mUseOrigin( false )
758  , mRotation( 0.0 )
759  , mRotationOffset( 0.0 )
760  , mUseRotation( false )
761  , mCenter( QgsPoint() )
762  , mUseCenter( false )
763  , mSize( QgsPoint() )
764  , mOffset( QgsPoint() )
765  , mPicture( nullptr )
766  , mPictureBuffer( 0.0 )
767  , mDpiRatio( 1.0 )
768  {}
769 
770  // methods
771 
772  QString text() const { return mText; }
773  void setText( const QString& text ) { mText = text; }
774 
775  const QgsPoint& origin() const { return mOrigin; }
776  void setOrigin( const QgsPoint& point ) { mOrigin = point; }
777 
778  bool useOrigin() const { return mUseOrigin; }
779  void setUseOrigin( const bool use ) { mUseOrigin = use; }
780 
781  double rotation() const { return mRotation; }
782  void setRotation( const double rotation ) { mRotation = rotation; }
783 
784  double rotationOffset() const { return mRotationOffset; }
785  void setRotationOffset( const double rotation ) { mRotationOffset = rotation; }
786 
787  bool useRotation() const { return mUseRotation; }
788  void setUseRotation( const bool use ) { mUseRotation = use; }
789 
790  const QgsPoint& center() const { return mCenter; }
791  void setCenter( const QgsPoint& point ) { mCenter = point; }
792 
793  bool useCenter() const { return mUseCenter; }
794  void setUseCenter( const bool use ) { mUseCenter = use; }
795 
796  const QgsPoint& size() const { return mSize; }
797  void setSize( const QgsPoint& point ) { mSize = point; }
798 
799  const QgsPoint& offset() const { return mOffset; }
800  void setOffset( const QgsPoint& point ) { mOffset = point; }
801 
802  const QPicture* picture() const { return mPicture; }
803  void setPicture( QPicture* picture ) { mPicture = picture; }
804 
805  double pictureBuffer() const { return mPictureBuffer; }
806  void setPictureBuffer( const double buffer ) { mPictureBuffer = buffer; }
807 
808  double dpiRatio() const { return mDpiRatio; }
809  void setDpiRatio( const double ratio ) { mDpiRatio = ratio; }
810 
811  private:
812  // current label component text,
813  // e.g. single line in a multi-line label or charcater in curved labeling
814  QString mText;
815  // current origin point for painting (generally current painter rotation point)
816  QgsPoint mOrigin;
817  // whether to translate the painter to supplied origin
818  bool mUseOrigin;
819  // any rotation to be applied to painter (in radians)
820  double mRotation;
821  // any rotation to be applied to painter (in radians) after initial rotation
822  double mRotationOffset;
823  // whether to use the rotation to rotate the painter
824  bool mUseRotation;
825  // current center point of label compnent, after rotation
826  QgsPoint mCenter;
827  // whether to translate the painter to supplied origin based upon center
828  bool mUseCenter;
829  // width and height of label component, transformed and ready for painting
830  QgsPoint mSize;
831  // any translation offsets to be applied before painting, transformed and ready for painting
832  QgsPoint mOffset;
833 
834  // a stored QPicture of painting for the component
835  QPicture* mPicture;
836  // buffer for component to accommodate graphic items ignored by QPicture,
837  // e.g. half-width of an applied QPen, which would extend beyond boundingRect() of QPicture
838  double mPictureBuffer;
839 
840  // a ratio of native painter dpi and that of rendering context's painter
841  double mDpiRatio;
842 };
843 
844 
849 class CORE_EXPORT QgsLabelingResults
850 {
851  public:
854 
856  QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) const;
858  QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) const;
859 
860  private:
861  QgsLabelingResults( const QgsLabelingResults& ); // no copying allowed
862  QgsLabelingResults& operator=( const QgsLabelingResults& rh );
863 
864  QgsLabelSearchTree* mLabelSearchTree;
865 
866  friend class QgsPalLabeling;
869 };
870 
875 class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface
876 {
877  public:
879  {
880  LabelText = 0,
884  LabelShadow
885  };
886 
887  QgsPalLabeling();
888  ~QgsPalLabeling();
889 
891  Q_DECL_DEPRECATED QgsPalLayerSettings& layer( const QString& layerName ) override;
892 
893  void numCandidatePositions( int& candPoint, int& candLine, int& candPolygon );
894  void setNumCandidatePositions( int candPoint, int candLine, int candPolygon );
895 
896  enum Search { Chain, Popmusic_Tabu, Popmusic_Chain, Popmusic_Tabu_Chain, Falp };
897 
898  void setSearchMethod( Search s );
899  Search searchMethod() const;
900 
901  bool isShowingCandidates() const;
902  void setShowingCandidates( bool showing );
904  Q_DECL_DEPRECATED const QList<QgsLabelCandidate>& candidates() { return mCandidates; }
905 
906  bool isShowingShadowRectangles() const;
907  void setShowingShadowRectangles( bool showing );
908 
909  bool isShowingAllLabels() const;
910  void setShowingAllLabels( bool showing );
911 
912  bool isShowingPartialsLabels() const;
913  void setShowingPartialsLabels( bool showing );
914 
916  bool isDrawingOutlineLabels() const;
917  void setDrawingOutlineLabels( bool outline );
918 
924  bool drawLabelRectOnly() const;
925 
932  void setDrawLabelRectOnly( bool drawRect );
933 
934  // implemented methods from labeling engine interface
935 
938  Q_DECL_DEPRECATED virtual void init( QgsMapRenderer* mr ) override;
940  virtual void init( const QgsMapSettings& mapSettings ) override;
942  virtual bool willUseLayer( QgsVectorLayer* layer ) override;
943 
946  static bool staticWillUseLayer( QgsVectorLayer* layer );
947  static bool staticWillUseLayer( const QString& layerID );
948 
950  virtual void clearActiveLayers() override;
952  virtual void clearActiveLayer( const QString& layerID ) override;
954  virtual int prepareLayer( QgsVectorLayer* layer, QStringList &attrNames, QgsRenderContext& ctx ) override;
957  virtual int prepareDiagramLayer( QgsVectorLayer* layer, QStringList& attrNames, QgsRenderContext& ctx ) override;
960  Q_DECL_DEPRECATED virtual int addDiagramLayer( QgsVectorLayer* layer, const QgsDiagramLayerSettings *s ) override;
961 
968  virtual void registerFeature( const QString& layerID, QgsFeature& feat, QgsRenderContext& context ) override;
969 
970  virtual void registerDiagramFeature( const QString& layerID, QgsFeature& feat, QgsRenderContext& context ) override;
972  virtual void drawLabeling( QgsRenderContext& context ) override;
974  virtual void exit() override;
975 
978  Q_DECL_DEPRECATED virtual QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) override;
981  Q_DECL_DEPRECATED virtual QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) override;
982 
985  QgsLabelingResults* takeResults();
986 
988  virtual QgsPalLabeling* clone() override;
989 
991  static void drawLabelCandidateRect( pal::LabelPosition* lp, QPainter* painter, const QgsMapToPixel* xform, QList<QgsLabelCandidate>* candidates = nullptr );
992 
993  static void drawLabelBuffer( QgsRenderContext& context,
994  const QgsLabelComponent &component,
995  const QgsPalLayerSettings& tmpLyr );
996 
997  static void drawLabelBackground( QgsRenderContext& context,
998  QgsLabelComponent component,
999  const QgsPalLayerSettings& tmpLyr );
1000 
1001  static void drawLabelShadow( QgsRenderContext &context,
1002  const QgsLabelComponent &component,
1003  const QgsPalLayerSettings& tmpLyr );
1004 
1006  void loadEngineSettings();
1007  void saveEngineSettings();
1008  void clearEngineSettings();
1010  Q_DECL_DEPRECATED bool isStoredWithProject() const { return true; }
1012  Q_DECL_DEPRECATED void setStoredWithProject( bool store ) { Q_UNUSED( store ); }
1013 
1022  static QgsGeometry* prepareGeometry( const QgsGeometry *geometry, QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry = nullptr );
1023 
1032  static bool geometryRequiresPreparation( const QgsGeometry *geometry, QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry = nullptr );
1033 
1041  static QStringList splitToLines( const QString& text, const QString& wrapCharacter );
1042 
1050  static QStringList splitToGraphemes( const QString& text );
1051 
1052  protected:
1053  // update temporary QgsPalLayerSettings with any data defined text style values
1054  static void dataDefinedTextStyle( QgsPalLayerSettings& tmpLyr,
1056 
1057  // update temporary QgsPalLayerSettings with any data defined text formatting values
1058  static void dataDefinedTextFormatting( QgsPalLayerSettings& tmpLyr,
1060 
1061  // update temporary QgsPalLayerSettings with any data defined text buffer values
1062  static void dataDefinedTextBuffer( QgsPalLayerSettings& tmpLyr,
1064 
1065  // update temporary QgsPalLayerSettings with any data defined shape background values
1066  static void dataDefinedShapeBackground( QgsPalLayerSettings& tmpLyr,
1068 
1069  // update temporary QgsPalLayerSettings with any data defined drop shadow values
1070  static void dataDefinedDropShadow( QgsPalLayerSettings& tmpLyr,
1072 
1073  friend class QgsVectorLayerLabelProvider; // to allow calling the static methods above
1074  friend class QgsDxfExport; // to allow calling the static methods above
1075 
1076  void deleteTemporaryData();
1077 
1085  static bool checkMinimumSizeMM( const QgsRenderContext &context, const QgsGeometry *geom, double minSize );
1086 
1092 
1095 
1096  // list of candidates from last labeling
1098 
1099  friend class QgsPalLayerSettings;
1100 };
1102 
1103 
1104 #endif // QGSPALLABELING_H
Label below point, slightly right of center.
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)
double dpiRatio() const
QgsMapUnitScale shapeSizeMapUnitScale
A container class for data source field mapping or expression.
QgsMapUnitScale shadowRadiusMapUnitScale
double rotationOffset() const
void setOrigin(const QgsPoint &point)
double rotation() const
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)
QPainter::CompositionMode bufferBlendMode
PredefinedPointPosition
Positions for labels when using the QgsPalLabeling::OrderedPositionsAroundPoint placement mode...
QgsMapUnitScale shadowOffsetMapUnitScale
Candidates are placed in predefined positions around a point.
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:515
QuadrantPosition quadOffset
void setUseOrigin(const bool use)
Class that adds extra information to QgsLabelFeature for text labels.
The QgsLabelingEngineV2 class provides map labeling functionality.
Container of fields for a vector layer.
Definition: qgsfield.h:252
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:76
bool drawLabels
Whether to draw labels for this layer.
QHash< QString, QgsVectorLayerDiagramProvider * > mDiagramProviders
hashtable of diagram providers (key = layer ID)
void setUseCenter(const bool use)
QgsMapUnitScale repeatDistanceMapUnitScale
MultiLineAlign multilineAlign
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:187
A non GUI class for rendering a map layer set onto a QPainter.
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...
bool useCenter() const
bool useOrigin() const
QVector< PredefinedPointPosition > predefinedPositionOrder
Ordered list of predefined label positions for points.
void setRotationOffset(const double rotation)
const QgsPoint & offset() const
Qt::PenJoinStyle bufferJoinStyle
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.
QgsMapUnitScale fontSizeMapUnitScale
The QgsMapSettings class contains configuration for rendering of the map.
QgsMapUnitScale shapeBorderWidthMapUnitScale
QgsGeometry * extentGeom
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:34
Q_DECL_DEPRECATED void setStoredWithProject(bool store)
ObstacleType obstacleType
Controls how features act as obstacles for labels.
void setRotation(const double rotation)
Label on left of point.
const QgsCoordinateTransform * ct
QgsMapUnitScale shapeRadiiMapUnitScale
Offset distance applies from point geometry.
QgsPalLayerSettings mInvalidLayerSettings
SizeUnit shapeBorderWidthUnits
QPainter::CompositionMode blendMode
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
void setCenter(const QgsPoint &point)
Arranges candidates in a circle around a point (or centroid of a polygon).
const QgsMapToPixel * xform
QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined *> dataDefinedProperties
Map of current data defined properties.
void setText(const QString &text)
QgsMapUnitScale bufferSizeMapUnitScale
OffsetType
Behaviour modifier for label offset and distance, only applies in some label placement modes...
QgsFeature * mCurFeat
QPainter::CompositionMode shapeBlendMode
SizeUnit
Units used for option sizes, before being converted to rendered sizes.
const QgsPoint & center() const
A class to represent a point.
Definition: qgspoint.h:117
Qt::PenJoinStyle shapeJoinStyle
Offset distance applies from rendered symbol bounds.
const QgsPoint & origin() const
void setDpiRatio(const double ratio)
bool useRotation() const
double pictureBuffer() const
Stores the settings for rendering of all diagrams for a layer.
unsigned int placementFlags
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:516
Placement
Placement modes which determine how label candidates are generated for a feature. ...
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point...
const QgsPoint & size() const
Contains information about the context of a rendering operation.
void setPicture(QPicture *picture)
The QgsLabelFeature class describes a feature that should be used within the labeling engine...
void setOffset(const QgsPoint &point)
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).
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.
QString text() const
const QPicture * picture() const
QPainter::CompositionMode shadowBlendMode
bool isExpression
Is this label made from a expression string eg FieldName || &#39;mm&#39;.
void setSize(const QgsPoint &point)
Class that stores computed placement from labeling engine.
QgsMapUnitScale shapeOffsetMapUnitScale
LinePlacementFlags
Line placement flags, which control how candidates are generated for a linear feature.
QList< QgsLabelCandidate > mCandidates
Labeling engine interface.
void setPictureBuffer(const double buffer)
Q_DECL_DEPRECATED const QList< QgsLabelCandidate > & candidates()
void setUseRotation(const bool use)
Represents a vector layer which manages a vector based data sets.
Maintains current state of more grainular and temporal values when creating/painting component parts ...
RotationType shapeRotationType
QgsMapUnitScale labelOffsetMapUnitScale
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels...
DirectionSymbols placeDirectionSymbol
Arranges candidates scattered throughout a polygon feature.
QgsLabelingEngineV2 * mEngine
New labeling engine to interface with PAL.
Q_DECL_DEPRECATED bool isStoredWithProject() const