QGIS API Documentation  2.17.0-Master (bf77d09)
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,
92  };
93 
95  //TODO QGIS 3.0 - move to QgsLabelingEngineV2
97  {
110  };
111 
114  //TODO QGIS 3.0 - move to QgsLabelingEngineV2
116  {
119  };
120 
123  //TODO QGIS 3.0 - move to QgsLabelingEngineV2, rename to LinePlacementFlag, use Q_DECLARE_FLAGS to make
124  //LinePlacementFlags type, and replace use of pal::LineArrangementFlag
126  {
127  OnLine = 1,
128  AboveLine = 2,
131  BelowLine = 4,
134  MapOrientation = 8,
137  };
138 
140  {
149  QuadrantBelowRight
150  };
151 
153  {
156  ShowAll
157  };
158 
160  {
163  SymbolBelow
164  };
165 
167  {
168  MultiLeft = 0,
171  MultiFollowPlacement
173  };
174 
178  //TODO QGIS 3.0 - Move to QgsLabelingEngineV2
180  {
181  PolygonInterior,
183  PolygonBoundary,
185  PolygonWhole
189  };
190 
192  {
193  ShapeRectangle = 0,
197  ShapeSVG
198  };
199 
200  enum SizeType
201  {
202  SizeBuffer = 0,
204  SizePercent
205  };
206 
208  {
209  RotationSync = 0,
211  RotationFixed
212  };
213 
215  enum SizeUnit
216  {
217  Points = 0,
218  MM,
220  Percent
221  };
222 
224  {
225  ShadowLowest = 0,
228  ShadowShape
229  };
230 
231  // update mDataDefinedNames QMap in constructor when adding/deleting enum value
233  {
234  // text style
235  Size = 0,
236  Bold = 1,
237  Italic = 2,
238  Underline = 3,
239  Color = 4,
240  Strikeout = 5,
241  Family = 6,
242  FontStyle = 21,
243  FontSizeUnit = 22,
244  FontTransp = 18,
245  FontCase = 27,
246  FontLetterSpacing = 28,
247  FontWordSpacing = 29,
248  FontBlendMode = 30,
249 
250  // text formatting
251  MultiLineWrapChar = 31,
252  MultiLineHeight = 32,
253  MultiLineAlignment = 33,
254  DirSymbDraw = 34,
255  DirSymbLeft = 35,
256  DirSymbRight = 36,
257  DirSymbPlacement = 37,
258  DirSymbReverse = 38,
259  NumFormat = 39,
260  NumDecimals = 40,
261  NumPlusSign = 41,
262 
263  // text buffer
264  BufferDraw = 42,
265  BufferSize = 7,
266  BufferUnit = 43,
267  BufferColor = 8,
268  BufferTransp = 19,
269  BufferJoinStyle = 44,
270  BufferBlendMode = 45,
271 
272  // background
273  ShapeDraw = 46,
274  ShapeKind = 47,
275  ShapeSVGFile = 48,
276  ShapeSizeType = 49,
277  ShapeSizeX = 50,
278  ShapeSizeY = 85,
279  ShapeSizeUnits = 51,
280  ShapeRotationType = 52,
281  ShapeRotation = 53,
282  ShapeOffset = 54,
283  ShapeOffsetUnits = 55,
284  ShapeRadii = 56,
285  ShapeRadiiUnits = 57,
286  ShapeTransparency = 63,
287  ShapeBlendMode = 64,
288  ShapeFillColor = 58,
289  ShapeBorderColor = 59,
290  ShapeBorderWidth = 60,
291  ShapeBorderWidthUnits = 61,
292  ShapeJoinStyle = 62,
293 
294  // drop shadow
295  ShadowDraw = 65,
296  ShadowUnder = 66,
297  ShadowOffsetAngle = 67,
298  ShadowOffsetDist = 68,
299  ShadowOffsetUnits = 69,
300  ShadowRadius = 70,
301  ShadowRadiusUnits = 71,
302  ShadowTransparency = 72,
303  ShadowScale = 73,
304  ShadowColor = 74,
305  ShadowBlendMode = 75,
306 
307  // placement
308  CentroidWhole = 76,
309  OffsetQuad = 77,
310  OffsetXY = 78,
311  OffsetUnits = 80,
312  LabelDistance = 13,
313  DistanceUnits = 81,
314  OffsetRotation = 82,
315  CurvedCharAngleInOut = 83,
316  // (data defined only)
317  PositionX = 9, //x-coordinate data defined label position
318  PositionY = 10, //y-coordinate data defined label position
319  Hali = 11, //horizontal alignment for data defined label position (Left, Center, Right)
320  Vali = 12, //vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top)
321  Rotation = 14, //data defined rotation
322  RepeatDistance = 84,
323  RepeatDistanceUnit = 86,
324  Priority = 87,
325  PredefinedPositionOrder = 91,
326 
327  // rendering
328  ScaleVisibility = 23,
329  MinScale = 16,
330  MaxScale = 17,
331  FontLimitPixel = 24,
332  FontMinPixel = 25,
333  FontMaxPixel = 26,
334  IsObstacle = 88,
335  ObstacleFactor = 89,
336  ZIndex = 90,
337 
338  // (data defined only)
339  Show = 15,
340  AlwaysShow = 20
341  };
342 
343  // whether to label this layer
344  bool enabled;
345 
354 
355  //-- text style
356 
358 
362 
365  QgsExpression* getLabelExpression();
366 
369  bool fontSizeInMapUnits; //true if font size is in map units (otherwise in points)
370  QgsMapUnitScale fontSizeMapUnitScale; // scale range for map units for font size
373  QPainter::CompositionMode blendMode;
375 
376  //-- text formatting
377 
379  double multilineHeight; //0.0 to 10.0, leading between lines as multiplyer of line height
380  MultiLineAlign multilineAlign; // horizontal alignment of multi-line labels
381 
382  // Adds '<' or '>', or user-defined symbol to the label string pointing to the
383  // direction of the line / polygon ring
384  // Works only if Placement == Line
388  DirectionSymbols placeDirectionSymbol; // whether to place left/right, above or below label
390 
392  int decimals;
393  bool plusSign;
394 
395  //-- text buffer
396 
398  double bufferSize; // buffer size
399  bool bufferSizeInMapUnits; //true if buffer is in map units (otherwise in mm)
400  QgsMapUnitScale bufferSizeMapUnitScale; // scale range for map units for buffer size
402  bool bufferNoFill; //set interior of buffer to 100% transparent
404  Qt::PenJoinStyle bufferJoinStyle;
405  QPainter::CompositionMode bufferBlendMode;
406 
407  //-- shape background
408 
409  bool shapeDraw;
425  QPainter::CompositionMode shapeBlendMode;
431  Qt::PenJoinStyle shapeJoinStyle;
432 
433  //-- drop shadow
434 
442  double shadowRadius;
449  QPainter::CompositionMode shadowBlendMode;
450 
451  //-- placement
452 
454  unsigned int placementFlags;
455 
456  bool centroidWhole; // whether centroid calculated from whole or visible polygon
457  bool centroidInside; // whether centroid-point calculated must be inside polygon
458 
465 
469  double dist; // distance from the feature (in mm)
470  bool distInMapUnits; //true if distance is in map units (otherwise in mm)
474 
478 
479  // offset labels of point/centroid features default to center
480  // move label to quadrant: left/down, don't move, right/up (-1, 0, 1)
482 
483  double xOffset; // offset from point in mm or map units
484  double yOffset; // offset from point in mm or map units
485  bool labelOffsetInMapUnits; //true if label offset is in map units (otherwise in mm)
487  double angleOffset; // rotation applied to offset labels
488  bool preserveRotation; // preserve predefined rotation data during label pin/unpin operations
489 
490  double maxCurvedCharAngleIn; // maximum angle between inside curved label characters (defaults to 20.0, range 20.0 to 60.0)
491  double maxCurvedCharAngleOut; // maximum angle between outside curved label characters (defaults to -20.0, range -20.0 to -95.0)
492 
493  int priority; // 0 = low, 10 = high
494 
495  //-- rendering
496 
498  int scaleMin;
499  int scaleMax;
500 
501  bool fontLimitPixelSize; // true is label should be limited by fontMinPixelSize/fontMaxPixelSize
502  int fontMinPixelSize; // minimum pixel size for showing rendered map unit labels (1 - 1000)
503  int fontMaxPixelSize; // maximum pixel size for showing rendered map unit labels (1 - 10000)
504 
505  bool displayAll; // if true, all features will be labelled even though overlaps occur
506  UpsideDownLabels upsidedownLabels; // whether, or how, to show upsidedown labels
507 
508  bool labelPerPart; // whether to label every feature's part or only the biggest one
510 
511  bool limitNumLabels; // whether to limit the number of labels to be drawn
512  int maxNumLabels; // maximum number of labels to be drawn
513 
514  double minFeatureSize; // minimum feature size to be labelled (in mm)
515  bool obstacle; // whether features for layer are obstacles to labels of other layers
516 
521 
525 
527  double zIndex;
528 
529  //-- scale factors
530  double vectorScaleFactor; //scale factor painter units->pixels
531  double rasterCompressFactor; //pixel resolution scale factor
532 
533  // called from register feature hook
534  void calculateLabelSize( const QFontMetricsF* fm, QString text, double& labelX, double& labelY, QgsFeature* f = nullptr, QgsRenderContext* context = nullptr );
535 
548  void registerFeature( QgsFeature& f, QgsRenderContext& context, QgsLabelFeature** labelFeature = nullptr, QgsGeometry* obstacleGeometry = nullptr );
549 
550  void readFromLayer( QgsVectorLayer* layer );
551  void writeToLayer( QgsVectorLayer* layer );
552 
556  void readXml( QDomElement& elem );
557 
561  QDomElement writeXml( QDomDocument& doc );
562 
567 
571  void setDataDefinedProperty( QgsPalLayerSettings::DataDefinedProperties p,
572  bool active, bool useExpr, const QString& expr, const QString& field );
573 
575  void removeDataDefinedProperty( QgsPalLayerSettings::DataDefinedProperties p );
576 
580  void removeAllDataDefinedProperties();
581 
585  QString updateDataDefinedString( const QString& value );
586 
591 
596  QVariant dataDefinedValue( QgsPalLayerSettings::DataDefinedProperties p, QgsFeature& f, const QgsFields& fields,
597  const QgsExpressionContext* context = nullptr ) const;
598 
603  bool dataDefinedEvaluate( QgsPalLayerSettings::DataDefinedProperties p, QVariant& exprVal, QgsExpressionContext* context = nullptr, const QVariant& originalValue = QVariant() ) const;
604 
607  bool dataDefinedIsActive( QgsPalLayerSettings::DataDefinedProperties p ) const;
608 
611  bool dataDefinedUseExpression( QgsPalLayerSettings::DataDefinedProperties p ) const;
612 
618 
619 
628  int sizeToPixel( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
629 
638  double scaleToPixelContext( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
639 
645 
646  // temporary stuff: set when layer gets prepared or labeled
652 
656  int mFeaturesToLabel; // total features that will probably be labeled, may be less (figured before PAL)
657  int mFeatsSendingToPal; // total features tested for sending into PAL (relative to maxNumLabels)
658  int mFeatsRegPal; // number of features registered in PAL, when using limitNumLabels
659 
662 
663  bool showingShadowRects; // whether to show debug rectangles for drop shadows
664 
665  private:
666 
667  void readDataDefinedPropertyMap( QgsVectorLayer* layer, QDomElement* parentElem,
669  QgsDataDefined* > & propertyMap );
670  void writeDataDefinedPropertyMap( QgsVectorLayer* layer, QDomElement* parentElem,
672  QgsDataDefined* > & propertyMap );
673  void readDataDefinedProperty( QgsVectorLayer* layer,
676  QgsDataDefined* > & propertyMap );
677 
678  enum DataDefinedValueType
679  {
680  DDBool,
681  DDInt,
682  DDIntPos,
683  DDDouble,
684  DDDoublePos,
685  DDRotation180,
686  DDTransparency,
687  DDString,
688  DDUnits,
689  DDColor,
690  DDJoinStyle,
691  DDBlendMode,
692  DDPointF
693  };
694 
695  // convenience data defined evaluation function
696  bool dataDefinedValEval( DataDefinedValueType valType,
698  QVariant& exprVal, QgsExpressionContext &context, const QVariant& originalValue = QVariant() );
699 
700  void parseTextStyle( QFont& labelFont,
702  QgsRenderContext& context );
703 
704  void parseTextBuffer( QgsRenderContext& context );
705 
706  void parseTextFormatting( QgsRenderContext& context );
707 
708  void parseShapeBackground( QgsRenderContext& context );
709 
710  void parseDropShadow( QgsRenderContext& context );
711 
714  bool checkMinimumSizeMM( const QgsRenderContext& ct, const QgsGeometry* geom, double minSize ) const;
715 
718  void registerObstacleFeature( QgsFeature &f, QgsRenderContext &context, QgsLabelFeature** obstacleFeature, QgsGeometry* obstacleGeometry = nullptr );
719 
720  QMap<DataDefinedProperties, QVariant> dataDefinedValues;
721  QgsExpression* expression;
723 
724  QFontDatabase mFontDB;
725 
726  static QVector< PredefinedPointPosition > DEFAULT_PLACEMENT_ORDER;
727 };
728 
731 class CORE_EXPORT QgsLabelCandidate
732 {
733  public:
734  QgsLabelCandidate( const QRectF& r, double c ): rect( r ), cost( c ) {}
735 
737  double cost;
738 };
739 
744 class CORE_EXPORT QgsLabelComponent
745 {
746  public:
748  : mText( QString() )
749  , mOrigin( QgsPoint() )
750  , mUseOrigin( false )
751  , mRotation( 0.0 )
752  , mRotationOffset( 0.0 )
753  , mUseRotation( false )
754  , mCenter( QgsPoint() )
755  , mUseCenter( false )
756  , mSize( QgsPoint() )
757  , mOffset( QgsPoint() )
758  , mPicture( nullptr )
759  , mPictureBuffer( 0.0 )
760  , mDpiRatio( 1.0 )
761  {}
762 
763  // methods
764 
765  QString text() const { return mText; }
766  void setText( const QString& text ) { mText = text; }
767 
768  const QgsPoint& origin() const { return mOrigin; }
769  void setOrigin( const QgsPoint& point ) { mOrigin = point; }
770 
771  bool useOrigin() const { return mUseOrigin; }
772  void setUseOrigin( const bool use ) { mUseOrigin = use; }
773 
774  double rotation() const { return mRotation; }
775  void setRotation( const double rotation ) { mRotation = rotation; }
776 
777  double rotationOffset() const { return mRotationOffset; }
778  void setRotationOffset( const double rotation ) { mRotationOffset = rotation; }
779 
780  bool useRotation() const { return mUseRotation; }
781  void setUseRotation( const bool use ) { mUseRotation = use; }
782 
783  const QgsPoint& center() const { return mCenter; }
784  void setCenter( const QgsPoint& point ) { mCenter = point; }
785 
786  bool useCenter() const { return mUseCenter; }
787  void setUseCenter( const bool use ) { mUseCenter = use; }
788 
789  const QgsPoint& size() const { return mSize; }
790  void setSize( const QgsPoint& point ) { mSize = point; }
791 
792  const QgsPoint& offset() const { return mOffset; }
793  void setOffset( const QgsPoint& point ) { mOffset = point; }
794 
795  const QPicture* picture() const { return mPicture; }
796  void setPicture( QPicture* picture ) { mPicture = picture; }
797 
798  double pictureBuffer() const { return mPictureBuffer; }
799  void setPictureBuffer( const double buffer ) { mPictureBuffer = buffer; }
800 
801  double dpiRatio() const { return mDpiRatio; }
802  void setDpiRatio( const double ratio ) { mDpiRatio = ratio; }
803 
804  private:
805  // current label component text,
806  // e.g. single line in a multi-line label or charcater in curved labeling
807  QString mText;
808  // current origin point for painting (generally current painter rotation point)
809  QgsPoint mOrigin;
810  // whether to translate the painter to supplied origin
811  bool mUseOrigin;
812  // any rotation to be applied to painter (in radians)
813  double mRotation;
814  // any rotation to be applied to painter (in radians) after initial rotation
815  double mRotationOffset;
816  // whether to use the rotation to rotate the painter
817  bool mUseRotation;
818  // current center point of label compnent, after rotation
819  QgsPoint mCenter;
820  // whether to translate the painter to supplied origin based upon center
821  bool mUseCenter;
822  // width and height of label component, transformed and ready for painting
823  QgsPoint mSize;
824  // any translation offsets to be applied before painting, transformed and ready for painting
825  QgsPoint mOffset;
826 
827  // a stored QPicture of painting for the component
828  QPicture* mPicture;
829  // buffer for component to accommodate graphic items ignored by QPicture,
830  // e.g. half-width of an applied QPen, which would extend beyond boundingRect() of QPicture
831  double mPictureBuffer;
832 
833  // a ratio of native painter dpi and that of rendering context's painter
834  double mDpiRatio;
835 };
836 
837 
842 class CORE_EXPORT QgsLabelingResults
843 {
844  public:
847 
849  QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) const;
851  QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) const;
852 
853  private:
854  QgsLabelingResults( const QgsLabelingResults& ); // no copying allowed
855  QgsLabelingResults& operator=( const QgsLabelingResults& rh );
856 
857  QgsLabelSearchTree* mLabelSearchTree;
858 
859  friend class QgsPalLabeling;
862 };
863 
868 class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface
869 {
870  public:
872  {
873  LabelText = 0,
877  LabelShadow
878  };
879 
880  QgsPalLabeling();
881  ~QgsPalLabeling();
882 
884  Q_DECL_DEPRECATED QgsPalLayerSettings& layer( const QString& layerName ) override;
885 
886  void numCandidatePositions( int& candPoint, int& candLine, int& candPolygon );
887  void setNumCandidatePositions( int candPoint, int candLine, int candPolygon );
888 
889  enum Search { Chain, Popmusic_Tabu, Popmusic_Chain, Popmusic_Tabu_Chain, Falp };
890 
891  void setSearchMethod( Search s );
892  Search searchMethod() const;
893 
894  bool isShowingCandidates() const;
895  void setShowingCandidates( bool showing );
897  Q_DECL_DEPRECATED const QList<QgsLabelCandidate>& candidates() { return mCandidates; }
898 
899  bool isShowingShadowRectangles() const;
900  void setShowingShadowRectangles( bool showing );
901 
902  bool isShowingAllLabels() const;
903  void setShowingAllLabels( bool showing );
904 
905  bool isShowingPartialsLabels() const;
906  void setShowingPartialsLabels( bool showing );
907 
909  bool isDrawingOutlineLabels() const;
910  void setDrawingOutlineLabels( bool outline );
911 
917  bool drawLabelRectOnly() const;
918 
925  void setDrawLabelRectOnly( bool drawRect );
926 
927  // implemented methods from labeling engine interface
928 
931  Q_DECL_DEPRECATED virtual void init( QgsMapRenderer* mr ) override;
933  virtual void init( const QgsMapSettings& mapSettings ) override;
935  virtual bool willUseLayer( QgsVectorLayer* layer ) override;
936 
939  static bool staticWillUseLayer( QgsVectorLayer* layer );
940  static bool staticWillUseLayer( const QString& layerID );
941 
943  virtual void clearActiveLayers() override;
945  virtual void clearActiveLayer( const QString& layerID ) override;
947  virtual int prepareLayer( QgsVectorLayer* layer, QStringList &attrNames, QgsRenderContext& ctx ) override;
950  virtual int prepareDiagramLayer( QgsVectorLayer* layer, QStringList& attrNames, QgsRenderContext& ctx ) override;
953  Q_DECL_DEPRECATED virtual int addDiagramLayer( QgsVectorLayer* layer, const QgsDiagramLayerSettings *s ) override;
954 
961  virtual void registerFeature( const QString& layerID, QgsFeature& feat, QgsRenderContext& context ) override;
962 
963  virtual void registerDiagramFeature( const QString& layerID, QgsFeature& feat, QgsRenderContext& context ) override;
965  virtual void drawLabeling( QgsRenderContext& context ) override;
967  virtual void exit() override;
968 
971  Q_DECL_DEPRECATED virtual QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) override;
974  Q_DECL_DEPRECATED virtual QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) override;
975 
978  QgsLabelingResults* takeResults();
979 
981  virtual QgsPalLabeling* clone() override;
982 
984  static void drawLabelCandidateRect( pal::LabelPosition* lp, QPainter* painter, const QgsMapToPixel* xform, QList<QgsLabelCandidate>* candidates = nullptr );
985 
986  static void drawLabelBuffer( QgsRenderContext& context,
987  const QgsLabelComponent &component,
988  const QgsPalLayerSettings& tmpLyr );
989 
990  static void drawLabelBackground( QgsRenderContext& context,
991  QgsLabelComponent component,
992  const QgsPalLayerSettings& tmpLyr );
993 
994  static void drawLabelShadow( QgsRenderContext &context,
995  const QgsLabelComponent &component,
996  const QgsPalLayerSettings& tmpLyr );
997 
999  void loadEngineSettings();
1000  void saveEngineSettings();
1001  void clearEngineSettings();
1003  Q_DECL_DEPRECATED bool isStoredWithProject() const { return true; }
1005  Q_DECL_DEPRECATED void setStoredWithProject( bool store ) { Q_UNUSED( store ); }
1006 
1015  static QgsGeometry* prepareGeometry( const QgsGeometry *geometry, QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry = nullptr );
1016 
1025  static bool geometryRequiresPreparation( const QgsGeometry *geometry, QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry = nullptr );
1026 
1034  static QStringList splitToLines( const QString& text, const QString& wrapCharacter );
1035 
1043  static QStringList splitToGraphemes( const QString& text );
1044 
1045  protected:
1046  // update temporary QgsPalLayerSettings with any data defined text style values
1047  static void dataDefinedTextStyle( QgsPalLayerSettings& tmpLyr,
1049 
1050  // update temporary QgsPalLayerSettings with any data defined text formatting values
1051  static void dataDefinedTextFormatting( QgsPalLayerSettings& tmpLyr,
1053 
1054  // update temporary QgsPalLayerSettings with any data defined text buffer values
1055  static void dataDefinedTextBuffer( QgsPalLayerSettings& tmpLyr,
1057 
1058  // update temporary QgsPalLayerSettings with any data defined shape background values
1059  static void dataDefinedShapeBackground( QgsPalLayerSettings& tmpLyr,
1061 
1062  // update temporary QgsPalLayerSettings with any data defined drop shadow values
1063  static void dataDefinedDropShadow( QgsPalLayerSettings& tmpLyr,
1065 
1066  friend class QgsVectorLayerLabelProvider; // to allow calling the static methods above
1067  friend class QgsDxfExport; // to allow calling the static methods above
1068 
1069  void deleteTemporaryData();
1070 
1078  static bool checkMinimumSizeMM( const QgsRenderContext &context, const QgsGeometry *geom, double minSize );
1079 
1085 
1088 
1089  // list of candidates from last labeling
1091 
1092  friend class QgsPalLayerSettings;
1093 };
1095 
1096 
1097 #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:193
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.