QGIS API Documentation  2.17.0-Master (3a3b9ab7)
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 
36 namespace pal
37 {
38  class Pal;
39  class Layer;
40  class LabelPosition;
41 }
42 
43 class QgsRectangle;
44 class QgsMapToPixel;
45 class QgsFeature;
47 class QgsVectorLayer;
48 class QgsDataDefined;
49 class QgsExpression;
50 class QFontMetricsF;
51 class QPainter;
52 class QPicture;
53 class QgsGeometry;
54 class QgsMapRenderer;
56 class QgsLabelSearchTree;
57 class QgsMapSettings;
58 class QgsLabelFeature;
61 class QgsDxfExport;
63 
67 class CORE_EXPORT QgsPalLayerSettings
68 {
69  public:
73 
75  QgsPalLayerSettings &operator=( const QgsPalLayerSettings & s );
76 
78  static QgsPalLayerSettings fromLayer( QgsVectorLayer* layer );
79 
82  //TODO QGIS 3.0 - move to QgsLabelingEngineV2
83  enum Placement
84  {
87  Line,
90  Free,
93  };
94 
96  //TODO QGIS 3.0 - move to QgsLabelingEngineV2
98  {
111  };
112 
115  //TODO QGIS 3.0 - move to QgsLabelingEngineV2
117  {
120  };
121 
124  //TODO QGIS 3.0 - move to QgsLabelingEngineV2, rename to LinePlacementFlag, use Q_DECLARE_FLAGS to make
125  //LinePlacementFlags type, and replace use of pal::LineArrangementFlag
127  {
128  OnLine = 1,
129  AboveLine = 2,
132  BelowLine = 4,
135  MapOrientation = 8,
138  };
139 
141  {
150  QuadrantBelowRight
151  };
152 
154  {
157  ShowAll
158  };
159 
161  {
164  SymbolBelow
165  };
166 
168  {
169  MultiLeft = 0,
172  MultiFollowPlacement
174  };
175 
179  //TODO QGIS 3.0 - Move to QgsLabelingEngineV2
181  {
182  PolygonInterior,
184  PolygonBoundary,
186  PolygonWhole
190  };
191 
193  {
194  ShapeRectangle = 0,
198  ShapeSVG
199  };
200 
201  enum SizeType
202  {
203  SizeBuffer = 0,
205  SizePercent
206  };
207 
209  {
210  RotationSync = 0,
212  RotationFixed
213  };
214 
216  enum SizeUnit
217  {
218  Points = 0,
219  MM,
221  Percent
222  };
223 
225  {
226  ShadowLowest = 0,
229  ShadowShape
230  };
231 
232  // update mDataDefinedNames QMap in constructor when adding/deleting enum value
234  {
235  // text style
236  Size = 0,
237  Bold = 1,
238  Italic = 2,
239  Underline = 3,
240  Color = 4,
241  Strikeout = 5,
242  Family = 6,
243  FontStyle = 21,
244  FontSizeUnit = 22,
245  FontTransp = 18,
246  FontCase = 27,
247  FontLetterSpacing = 28,
248  FontWordSpacing = 29,
249  FontBlendMode = 30,
250 
251  // text formatting
252  MultiLineWrapChar = 31,
253  MultiLineHeight = 32,
254  MultiLineAlignment = 33,
255  DirSymbDraw = 34,
256  DirSymbLeft = 35,
257  DirSymbRight = 36,
258  DirSymbPlacement = 37,
259  DirSymbReverse = 38,
260  NumFormat = 39,
261  NumDecimals = 40,
262  NumPlusSign = 41,
263 
264  // text buffer
265  BufferDraw = 42,
266  BufferSize = 7,
267  BufferUnit = 43,
268  BufferColor = 8,
269  BufferTransp = 19,
270  BufferJoinStyle = 44,
271  BufferBlendMode = 45,
272 
273  // background
274  ShapeDraw = 46,
275  ShapeKind = 47,
276  ShapeSVGFile = 48,
277  ShapeSizeType = 49,
278  ShapeSizeX = 50,
279  ShapeSizeY = 85,
280  ShapeSizeUnits = 51,
281  ShapeRotationType = 52,
282  ShapeRotation = 53,
283  ShapeOffset = 54,
284  ShapeOffsetUnits = 55,
285  ShapeRadii = 56,
286  ShapeRadiiUnits = 57,
287  ShapeTransparency = 63,
288  ShapeBlendMode = 64,
289  ShapeFillColor = 58,
290  ShapeBorderColor = 59,
291  ShapeBorderWidth = 60,
292  ShapeBorderWidthUnits = 61,
293  ShapeJoinStyle = 62,
294 
295  // drop shadow
296  ShadowDraw = 65,
297  ShadowUnder = 66,
298  ShadowOffsetAngle = 67,
299  ShadowOffsetDist = 68,
300  ShadowOffsetUnits = 69,
301  ShadowRadius = 70,
302  ShadowRadiusUnits = 71,
303  ShadowTransparency = 72,
304  ShadowScale = 73,
305  ShadowColor = 74,
306  ShadowBlendMode = 75,
307 
308  // placement
309  CentroidWhole = 76,
310  OffsetQuad = 77,
311  OffsetXY = 78,
312  OffsetUnits = 80,
313  LabelDistance = 13,
314  DistanceUnits = 81,
315  OffsetRotation = 82,
316  CurvedCharAngleInOut = 83,
317  // (data defined only)
318  PositionX = 9, //x-coordinate data defined label position
319  PositionY = 10, //y-coordinate data defined label position
320  Hali = 11, //horizontal alignment for data defined label position (Left, Center, Right)
321  Vali = 12, //vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top)
322  Rotation = 14, //data defined rotation
323  RepeatDistance = 84,
324  RepeatDistanceUnit = 86,
325  Priority = 87,
326  PredefinedPositionOrder = 91,
327 
328  // rendering
329  ScaleVisibility = 23,
330  MinScale = 16,
331  MaxScale = 17,
332  FontLimitPixel = 24,
333  FontMinPixel = 25,
334  FontMaxPixel = 26,
335  IsObstacle = 88,
336  ObstacleFactor = 89,
337  ZIndex = 90,
338 
339  // (data defined only)
340  Show = 15,
341  AlwaysShow = 20
342  };
343 
344  // whether to label this layer
345  bool enabled;
346 
355 
356  //-- text style
357 
359 
363 
366  QgsExpression* getLabelExpression();
367 
370  bool fontSizeInMapUnits; //true if font size is in map units (otherwise in points)
371  QgsMapUnitScale fontSizeMapUnitScale; // scale range for map units for font size
374  QPainter::CompositionMode blendMode;
376 
377  //-- text formatting
378 
380  double multilineHeight; //0.0 to 10.0, leading between lines as multiplyer of line height
381  MultiLineAlign multilineAlign; // horizontal alignment of multi-line labels
382 
383  // Adds '<' or '>', or user-defined symbol to the label string pointing to the
384  // direction of the line / polygon ring
385  // Works only if Placement == Line
389  DirectionSymbols placeDirectionSymbol; // whether to place left/right, above or below label
391 
393  int decimals;
394  bool plusSign;
395 
396  //-- text buffer
397 
399  double bufferSize; // buffer size
400  bool bufferSizeInMapUnits; //true if buffer is in map units (otherwise in mm)
401  QgsMapUnitScale bufferSizeMapUnitScale; // scale range for map units for buffer size
403  bool bufferNoFill; //set interior of buffer to 100% transparent
405  Qt::PenJoinStyle bufferJoinStyle;
406  QPainter::CompositionMode bufferBlendMode;
407 
408  //-- shape background
409 
410  bool shapeDraw;
426  QPainter::CompositionMode shapeBlendMode;
432  Qt::PenJoinStyle shapeJoinStyle;
433 
434  //-- drop shadow
435 
443  double shadowRadius;
450  QPainter::CompositionMode shadowBlendMode;
451 
452  //-- placement
453 
455  unsigned int placementFlags;
456 
457  bool centroidWhole; // whether centroid calculated from whole or visible polygon
458  bool centroidInside; // whether centroid-point calculated must be inside polygon
459 
466 
470  double dist; // distance from the feature (in mm)
471  bool distInMapUnits; //true if distance is in map units (otherwise in mm)
475 
479 
480  // offset labels of point/centroid features default to center
481  // move label to quadrant: left/down, don't move, right/up (-1, 0, 1)
483 
484  double xOffset; // offset from point in mm or map units
485  double yOffset; // offset from point in mm or map units
486  bool labelOffsetInMapUnits; //true if label offset is in map units (otherwise in mm)
488  double angleOffset; // rotation applied to offset labels
489  bool preserveRotation; // preserve predefined rotation data during label pin/unpin operations
490 
491  double maxCurvedCharAngleIn; // maximum angle between inside curved label characters (defaults to 20.0, range 20.0 to 60.0)
492  double maxCurvedCharAngleOut; // maximum angle between outside curved label characters (defaults to -20.0, range -20.0 to -95.0)
493 
494  int priority; // 0 = low, 10 = high
495 
496  //-- rendering
497 
499  int scaleMin;
500  int scaleMax;
501 
502  bool fontLimitPixelSize; // true is label should be limited by fontMinPixelSize/fontMaxPixelSize
503  int fontMinPixelSize; // minimum pixel size for showing rendered map unit labels (1 - 1000)
504  int fontMaxPixelSize; // maximum pixel size for showing rendered map unit labels (1 - 10000)
505 
506  bool displayAll; // if true, all features will be labelled even though overlaps occur
507  UpsideDownLabels upsidedownLabels; // whether, or how, to show upsidedown labels
508 
509  bool labelPerPart; // whether to label every feature's part or only the biggest one
511 
512  bool limitNumLabels; // whether to limit the number of labels to be drawn
513  int maxNumLabels; // maximum number of labels to be drawn
514 
515  double minFeatureSize; // minimum feature size to be labelled (in mm)
516  bool obstacle; // whether features for layer are obstacles to labels of other layers
517 
522 
526 
528  double zIndex;
529 
530  //-- scale factors
531  double vectorScaleFactor; //scale factor painter units->pixels
532  double rasterCompressFactor; //pixel resolution scale factor
533 
534  // called from register feature hook
535  void calculateLabelSize( const QFontMetricsF* fm, QString text, double& labelX, double& labelY, QgsFeature* f = nullptr, QgsRenderContext* context = nullptr );
536 
549  void registerFeature( QgsFeature& f, QgsRenderContext& context, QgsLabelFeature** labelFeature = nullptr, QgsGeometry* obstacleGeometry = nullptr );
550 
551  void readFromLayer( QgsVectorLayer* layer );
552  void writeToLayer( QgsVectorLayer* layer );
553 
557  void readXml( QDomElement& elem );
558 
562  QDomElement writeXml( QDomDocument& doc );
563 
568 
572  void setDataDefinedProperty( QgsPalLayerSettings::DataDefinedProperties p,
573  bool active, bool useExpr, const QString& expr, const QString& field );
574 
576  void removeDataDefinedProperty( QgsPalLayerSettings::DataDefinedProperties p );
577 
581  void removeAllDataDefinedProperties();
582 
586  QString updateDataDefinedString( const QString& value );
587 
592 
597  QVariant dataDefinedValue( QgsPalLayerSettings::DataDefinedProperties p, QgsFeature& f, const QgsFields& fields,
598  const QgsExpressionContext* context = nullptr ) const;
599 
604  bool dataDefinedEvaluate( QgsPalLayerSettings::DataDefinedProperties p, QVariant& exprVal, QgsExpressionContext* context = nullptr, const QVariant& originalValue = QVariant() ) const;
605 
608  bool dataDefinedIsActive( QgsPalLayerSettings::DataDefinedProperties p ) const;
609 
612  bool dataDefinedUseExpression( QgsPalLayerSettings::DataDefinedProperties p ) const;
613 
619 
620 
629  int sizeToPixel( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
630 
639  double scaleToPixelContext( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
640 
646 
647  // temporary stuff: set when layer gets prepared or labeled
653 
657  int mFeaturesToLabel; // total features that will probably be labeled, may be less (figured before PAL)
658  int mFeatsSendingToPal; // total features tested for sending into PAL (relative to maxNumLabels)
659  int mFeatsRegPal; // number of features registered in PAL, when using limitNumLabels
660 
663 
664  bool showingShadowRects; // whether to show debug rectangles for drop shadows
665 
666  private:
667 
668  void readDataDefinedPropertyMap( QgsVectorLayer* layer, QDomElement* parentElem,
670  QgsDataDefined* > & propertyMap );
671  void writeDataDefinedPropertyMap( QgsVectorLayer* layer, QDomElement* parentElem,
673  QgsDataDefined* > & propertyMap );
674  void readDataDefinedProperty( QgsVectorLayer* layer,
677  QgsDataDefined* > & propertyMap );
678 
679  enum DataDefinedValueType
680  {
681  DDBool,
682  DDInt,
683  DDIntPos,
684  DDDouble,
685  DDDoublePos,
686  DDRotation180,
687  DDTransparency,
688  DDString,
689  DDUnits,
690  DDColor,
691  DDJoinStyle,
692  DDBlendMode,
693  DDPointF
694  };
695 
696  // convenience data defined evaluation function
697  bool dataDefinedValEval( DataDefinedValueType valType,
699  QVariant& exprVal, QgsExpressionContext &context, const QVariant& originalValue = QVariant() );
700 
701  void parseTextStyle( QFont& labelFont,
703  QgsRenderContext& context );
704 
705  void parseTextBuffer( QgsRenderContext& context );
706 
707  void parseTextFormatting( QgsRenderContext& context );
708 
709  void parseShapeBackground( QgsRenderContext& context );
710 
711  void parseDropShadow( QgsRenderContext& context );
712 
715  bool checkMinimumSizeMM( const QgsRenderContext& ct, const QgsGeometry* geom, double minSize ) const;
716 
719  void registerObstacleFeature( QgsFeature &f, QgsRenderContext &context, QgsLabelFeature** obstacleFeature, QgsGeometry* obstacleGeometry = nullptr );
720 
721  QMap<DataDefinedProperties, QVariant> dataDefinedValues;
722  QgsExpression* expression;
724 
725  QFontDatabase mFontDB;
726 
727  static QVector< PredefinedPointPosition > DEFAULT_PLACEMENT_ORDER;
728 };
729 
732 class CORE_EXPORT QgsLabelCandidate
733 {
734  public:
735  QgsLabelCandidate( const QRectF& r, double c ): rect( r ), cost( c ) {}
736 
738  double cost;
739 };
740 
745 class CORE_EXPORT QgsLabelComponent
746 {
747  public:
749  : mText( QString() )
750  , mOrigin( QgsPoint() )
751  , mUseOrigin( false )
752  , mRotation( 0.0 )
753  , mRotationOffset( 0.0 )
754  , mUseRotation( false )
755  , mCenter( QgsPoint() )
756  , mUseCenter( false )
757  , mSize( QgsPoint() )
758  , mOffset( QgsPoint() )
759  , mPicture( nullptr )
760  , mPictureBuffer( 0.0 )
761  , mDpiRatio( 1.0 )
762  {}
763 
764  // methods
765 
766  QString text() const { return mText; }
767  void setText( const QString& text ) { mText = text; }
768 
769  const QgsPoint& origin() const { return mOrigin; }
770  void setOrigin( const QgsPoint& point ) { mOrigin = point; }
771 
772  bool useOrigin() const { return mUseOrigin; }
773  void setUseOrigin( const bool use ) { mUseOrigin = use; }
774 
775  double rotation() const { return mRotation; }
776  void setRotation( const double rotation ) { mRotation = rotation; }
777 
778  double rotationOffset() const { return mRotationOffset; }
779  void setRotationOffset( const double rotation ) { mRotationOffset = rotation; }
780 
781  bool useRotation() const { return mUseRotation; }
782  void setUseRotation( const bool use ) { mUseRotation = use; }
783 
784  const QgsPoint& center() const { return mCenter; }
785  void setCenter( const QgsPoint& point ) { mCenter = point; }
786 
787  bool useCenter() const { return mUseCenter; }
788  void setUseCenter( const bool use ) { mUseCenter = use; }
789 
790  const QgsPoint& size() const { return mSize; }
791  void setSize( const QgsPoint& point ) { mSize = point; }
792 
793  const QgsPoint& offset() const { return mOffset; }
794  void setOffset( const QgsPoint& point ) { mOffset = point; }
795 
796  const QPicture* picture() const { return mPicture; }
797  void setPicture( QPicture* picture ) { mPicture = picture; }
798 
799  double pictureBuffer() const { return mPictureBuffer; }
800  void setPictureBuffer( const double buffer ) { mPictureBuffer = buffer; }
801 
802  double dpiRatio() const { return mDpiRatio; }
803  void setDpiRatio( const double ratio ) { mDpiRatio = ratio; }
804 
805  private:
806  // current label component text,
807  // e.g. single line in a multi-line label or charcater in curved labeling
808  QString mText;
809  // current origin point for painting (generally current painter rotation point)
810  QgsPoint mOrigin;
811  // whether to translate the painter to supplied origin
812  bool mUseOrigin;
813  // any rotation to be applied to painter (in radians)
814  double mRotation;
815  // any rotation to be applied to painter (in radians) after initial rotation
816  double mRotationOffset;
817  // whether to use the rotation to rotate the painter
818  bool mUseRotation;
819  // current center point of label compnent, after rotation
820  QgsPoint mCenter;
821  // whether to translate the painter to supplied origin based upon center
822  bool mUseCenter;
823  // width and height of label component, transformed and ready for painting
824  QgsPoint mSize;
825  // any translation offsets to be applied before painting, transformed and ready for painting
826  QgsPoint mOffset;
827 
828  // a stored QPicture of painting for the component
829  QPicture* mPicture;
830  // buffer for component to accommodate graphic items ignored by QPicture,
831  // e.g. half-width of an applied QPen, which would extend beyond boundingRect() of QPicture
832  double mPictureBuffer;
833 
834  // a ratio of native painter dpi and that of rendering context's painter
835  double mDpiRatio;
836 };
837 
838 
843 class CORE_EXPORT QgsLabelingResults
844 {
845  public:
848 
850  QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) const;
852  QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) const;
853 
854  private:
855  QgsLabelingResults( const QgsLabelingResults& ); // no copying allowed
856  QgsLabelingResults& operator=( const QgsLabelingResults& rh );
857 
858  QgsLabelSearchTree* mLabelSearchTree;
859 
860  friend class QgsPalLabeling;
863 };
864 
869 class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface
870 {
871  public:
873  {
874  LabelText = 0,
878  LabelShadow
879  };
880 
881  QgsPalLabeling();
882  ~QgsPalLabeling();
883 
885  Q_DECL_DEPRECATED QgsPalLayerSettings& layer( const QString& layerName ) override;
886 
887  void numCandidatePositions( int& candPoint, int& candLine, int& candPolygon );
888  void setNumCandidatePositions( int candPoint, int candLine, int candPolygon );
889 
890  enum Search { Chain, Popmusic_Tabu, Popmusic_Chain, Popmusic_Tabu_Chain, Falp };
891 
892  void setSearchMethod( Search s );
893  Search searchMethod() const;
894 
895  bool isShowingCandidates() const;
896  void setShowingCandidates( bool showing );
898  Q_DECL_DEPRECATED const QList<QgsLabelCandidate>& candidates() { return mCandidates; }
899 
900  bool isShowingShadowRectangles() const;
901  void setShowingShadowRectangles( bool showing );
902 
903  bool isShowingAllLabels() const;
904  void setShowingAllLabels( bool showing );
905 
906  bool isShowingPartialsLabels() const;
907  void setShowingPartialsLabels( bool showing );
908 
910  bool isDrawingOutlineLabels() const;
911  void setDrawingOutlineLabels( bool outline );
912 
918  bool drawLabelRectOnly() const;
919 
926  void setDrawLabelRectOnly( bool drawRect );
927 
928  // implemented methods from labeling engine interface
929 
932  Q_DECL_DEPRECATED virtual void init( QgsMapRenderer* mr ) override;
934  virtual void init( const QgsMapSettings& mapSettings ) override;
936  virtual bool willUseLayer( QgsVectorLayer* layer ) override;
937 
940  static bool staticWillUseLayer( QgsVectorLayer* layer );
941  static bool staticWillUseLayer( const QString& layerID );
942 
944  virtual void clearActiveLayers() override;
946  virtual void clearActiveLayer( const QString& layerID ) override;
948  virtual int prepareLayer( QgsVectorLayer* layer, QStringList &attrNames, QgsRenderContext& ctx ) override;
951  virtual int prepareDiagramLayer( QgsVectorLayer* layer, QStringList& attrNames, QgsRenderContext& ctx ) override;
954  Q_DECL_DEPRECATED virtual int addDiagramLayer( QgsVectorLayer* layer, const QgsDiagramLayerSettings *s ) override;
955 
962  virtual void registerFeature( const QString& layerID, QgsFeature& feat, QgsRenderContext& context ) override;
963 
964  virtual void registerDiagramFeature( const QString& layerID, QgsFeature& feat, QgsRenderContext& context ) override;
966  virtual void drawLabeling( QgsRenderContext& context ) override;
968  virtual void exit() override;
969 
972  Q_DECL_DEPRECATED virtual QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) override;
975  Q_DECL_DEPRECATED virtual QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) override;
976 
979  QgsLabelingResults* takeResults();
980 
982  virtual QgsPalLabeling* clone() override;
983 
985  static void drawLabelCandidateRect( pal::LabelPosition* lp, QPainter* painter, const QgsMapToPixel* xform, QList<QgsLabelCandidate>* candidates = nullptr );
986 
987  static void drawLabelBuffer( QgsRenderContext& context,
988  const QgsLabelComponent &component,
989  const QgsPalLayerSettings& tmpLyr );
990 
991  static void drawLabelBackground( QgsRenderContext& context,
992  QgsLabelComponent component,
993  const QgsPalLayerSettings& tmpLyr );
994 
995  static void drawLabelShadow( QgsRenderContext &context,
996  const QgsLabelComponent &component,
997  const QgsPalLayerSettings& tmpLyr );
998 
1000  void loadEngineSettings();
1001  void saveEngineSettings();
1002  void clearEngineSettings();
1004  Q_DECL_DEPRECATED bool isStoredWithProject() const { return true; }
1006  Q_DECL_DEPRECATED void setStoredWithProject( bool store ) { Q_UNUSED( store ); }
1007 
1016  static QgsGeometry* prepareGeometry( const QgsGeometry *geometry, QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry = nullptr );
1017 
1026  static bool geometryRequiresPreparation( const QgsGeometry *geometry, QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry = nullptr );
1027 
1035  static QStringList splitToLines( const QString& text, const QString& wrapCharacter );
1036 
1044  static QStringList splitToGraphemes( const QString& text );
1045 
1046  protected:
1047  // update temporary QgsPalLayerSettings with any data defined text style values
1048  static void dataDefinedTextStyle( QgsPalLayerSettings& tmpLyr,
1050 
1051  // update temporary QgsPalLayerSettings with any data defined text formatting values
1052  static void dataDefinedTextFormatting( QgsPalLayerSettings& tmpLyr,
1054 
1055  // update temporary QgsPalLayerSettings with any data defined text buffer values
1056  static void dataDefinedTextBuffer( QgsPalLayerSettings& tmpLyr,
1058 
1059  // update temporary QgsPalLayerSettings with any data defined shape background values
1060  static void dataDefinedShapeBackground( QgsPalLayerSettings& tmpLyr,
1062 
1063  // update temporary QgsPalLayerSettings with any data defined drop shadow values
1064  static void dataDefinedDropShadow( QgsPalLayerSettings& tmpLyr,
1066 
1067  friend class QgsVectorLayerLabelProvider; // to allow calling the static methods above
1068  friend class QgsDxfExport; // to allow calling the static methods above
1069 
1070  void deleteTemporaryData();
1071 
1079  static bool checkMinimumSizeMM( const QgsRenderContext &context, const QgsGeometry *geom, double minSize );
1080 
1086 
1089 
1090  // list of candidates from last labeling
1092 
1093  friend class QgsPalLayerSettings;
1094 };
1096 
1097 
1098 #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)
QgsMapUnitScale shapeSizeMapUnitScale
A container class for data source field mapping or expression.
QgsMapUnitScale shadowRadiusMapUnitScale
void setOrigin(const QgsPoint &point)
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...
double rotationOffset() const
QgsMapUnitScale shadowOffsetMapUnitScale
const QgsPoint & size() const
Candidates are placed in predefined positions around a point.
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:515
QuadrantPosition quadOffset
bool useRotation() const
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:209
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
bool useCenter() const
const QgsPoint & origin() const
double dpiRatio() const
A non GUI class for rendering a map layer set onto a QPainter.
QVector< PredefinedPointPosition > predefinedPositionOrder
Ordered list of predefined label positions for points.
const QgsPoint & center() const
void setRotationOffset(const double rotation)
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...
Arranges candidates following the curvature of a line feature.
QgsMapUnitScale fontSizeMapUnitScale
const QgsPoint & offset() const
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
double rotation() const
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
bool useOrigin() const
QgsMapUnitScale shapeRadiiMapUnitScale
Offset distance applies from point geometry.
const QPicture * picture() const
QgsPalLayerSettings mInvalidLayerSettings
SizeUnit shapeBorderWidthUnits
QPainter::CompositionMode blendMode
The QgsVectorLayerDiagramProvider class implements support for diagrams within the labeling engine...
Q_DECL_DEPRECATED bool isStoredWithProject() const
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.
A class to represent a point.
Definition: qgspoint.h:117
Qt::PenJoinStyle shapeJoinStyle
Offset distance applies from rendered symbol bounds.
void setDpiRatio(const double ratio)
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...
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.
OffsetType offsetType
Offset type for layer (only applies in certain placement modes)
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.
double pictureBuffer() 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.
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...
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.
QString text() const
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.