QGIS API Documentation  2.13.0-Master
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;
62 
63 class CORE_EXPORT QgsPalLayerSettings
64 {
65  public:
69 
71  QgsPalLayerSettings &operator=( const QgsPalLayerSettings & s );
72 
74  static QgsPalLayerSettings fromLayer( QgsVectorLayer* layer );
75 
76 
79  //TODO QGIS 3.0 - move to QgsLabelingEngineV2
80  enum Placement
81  {
84  Line,
87  Free,
89  };
90 
92  //TODO QGIS 3.0 - move to QgsLabelingEngineV2
94  {
107  };
108 
111  //TODO QGIS 3.0 - move to QgsLabelingEngineV2
113  {
116  };
117 
120  //TODO QGIS 3.0 - move to QgsLabelingEngineV2, rename to LinePlacementFlag, use Q_DECLARE_FLAGS to make
121  //LinePlacementFlags type, and replace use of pal::LineArrangementFlag
123  {
124  OnLine = 1,
125  AboveLine = 2,
128  BelowLine = 4,
131  MapOrientation = 8,
134  };
135 
137  {
146  QuadrantBelowRight
147  };
148 
150  {
153  ShowAll
154  };
155 
157  {
160  SymbolBelow
161  };
162 
164  {
165  MultiLeft = 0,
168  MultiFollowPlacement
170  };
171 
175  //TODO QGIS 3.0 - Move to QgsLabelingEngineV2
177  {
178  PolygonInterior,
180  PolygonBoundary,
182  PolygonWhole
186  };
187 
189  {
190  ShapeRectangle = 0,
194  ShapeSVG
195  };
196 
197  enum SizeType
198  {
199  SizeBuffer = 0,
201  SizePercent
202  };
203 
205  {
206  RotationSync = 0,
208  RotationFixed
209  };
210 
212  enum SizeUnit
213  {
214  Points = 0,
215  MM,
217  Percent
218  };
219 
221  {
222  ShadowLowest = 0,
225  ShadowShape
226  };
227 
228  // update mDataDefinedNames QMap in constructor when adding/deleting enum value
230  {
231  // text style
232  Size = 0,
233  Bold = 1,
234  Italic = 2,
235  Underline = 3,
236  Color = 4,
237  Strikeout = 5,
238  Family = 6,
239  FontStyle = 21,
240  FontSizeUnit = 22,
241  FontTransp = 18,
242  FontCase = 27,
243  FontLetterSpacing = 28,
244  FontWordSpacing = 29,
245  FontBlendMode = 30,
246 
247  // text formatting
248  MultiLineWrapChar = 31,
249  MultiLineHeight = 32,
250  MultiLineAlignment = 33,
251  DirSymbDraw = 34,
252  DirSymbLeft = 35,
253  DirSymbRight = 36,
254  DirSymbPlacement = 37,
255  DirSymbReverse = 38,
256  NumFormat = 39,
257  NumDecimals = 40,
258  NumPlusSign = 41,
259 
260  // text buffer
261  BufferDraw = 42,
262  BufferSize = 7,
263  BufferUnit = 43,
264  BufferColor = 8,
265  BufferTransp = 19,
266  BufferJoinStyle = 44,
267  BufferBlendMode = 45,
268 
269  // background
270  ShapeDraw = 46,
271  ShapeKind = 47,
272  ShapeSVGFile = 48,
273  ShapeSizeType = 49,
274  ShapeSizeX = 50,
275  ShapeSizeY = 85,
276  ShapeSizeUnits = 51,
277  ShapeRotationType = 52,
278  ShapeRotation = 53,
279  ShapeOffset = 54,
280  ShapeOffsetUnits = 55,
281  ShapeRadii = 56,
282  ShapeRadiiUnits = 57,
283  ShapeTransparency = 63,
284  ShapeBlendMode = 64,
285  ShapeFillColor = 58,
286  ShapeBorderColor = 59,
287  ShapeBorderWidth = 60,
288  ShapeBorderWidthUnits = 61,
289  ShapeJoinStyle = 62,
290 
291  // drop shadow
292  ShadowDraw = 65,
293  ShadowUnder = 66,
294  ShadowOffsetAngle = 67,
295  ShadowOffsetDist = 68,
296  ShadowOffsetUnits = 69,
297  ShadowRadius = 70,
298  ShadowRadiusUnits = 71,
299  ShadowTransparency = 72,
300  ShadowScale = 73,
301  ShadowColor = 74,
302  ShadowBlendMode = 75,
303 
304  // placement
305  CentroidWhole = 76,
306  OffsetQuad = 77,
307  OffsetXY = 78,
308  OffsetUnits = 80,
309  LabelDistance = 13,
310  DistanceUnits = 81,
311  OffsetRotation = 82,
312  CurvedCharAngleInOut = 83,
313  // (data defined only)
314  PositionX = 9, //x-coordinate data defined label position
315  PositionY = 10, //y-coordinate data defined label position
316  Hali = 11, //horizontal alignment for data defined label position (Left, Center, Right)
317  Vali = 12, //vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top)
318  Rotation = 14, //data defined rotation
319  RepeatDistance = 84,
320  RepeatDistanceUnit = 86,
321  Priority = 87,
322  PredefinedPositionOrder = 91,
323 
324  // rendering
325  ScaleVisibility = 23,
326  MinScale = 16,
327  MaxScale = 17,
328  FontLimitPixel = 24,
329  FontMinPixel = 25,
330  FontMaxPixel = 26,
331  IsObstacle = 88,
332  ObstacleFactor = 89,
333  ZIndex = 90,
334 
335  // (data defined only)
336  Show = 15,
337  AlwaysShow = 20
338  };
339 
340  // whether to label this layer
341  bool enabled;
342 
351 
352  //-- text style
353 
355 
359 
362  QgsExpression* getLabelExpression();
363 
366  bool fontSizeInMapUnits; //true if font size is in map units (otherwise in points)
367  QgsMapUnitScale fontSizeMapUnitScale; // scale range for map units for font size
370  QPainter::CompositionMode blendMode;
372 
373  //-- text formatting
374 
376  double multilineHeight; //0.0 to 10.0, leading between lines as multiplyer of line height
377  MultiLineAlign multilineAlign; // horizontal alignment of multi-line labels
378 
379  // Adds '<' or '>', or user-defined symbol to the label string pointing to the
380  // direction of the line / polygon ring
381  // Works only if Placement == Line
385  DirectionSymbols placeDirectionSymbol; // whether to place left/right, above or below label
387 
389  int decimals;
390  bool plusSign;
391 
392  //-- text buffer
393 
395  double bufferSize; // buffer size
396  bool bufferSizeInMapUnits; //true if buffer is in map units (otherwise in mm)
397  QgsMapUnitScale bufferSizeMapUnitScale; // scale range for map units for buffer size
399  bool bufferNoFill; //set interior of buffer to 100% transparent
401  Qt::PenJoinStyle bufferJoinStyle;
402  QPainter::CompositionMode bufferBlendMode;
403 
404  //-- shape background
405 
406  bool shapeDraw;
422  QPainter::CompositionMode shapeBlendMode;
428  Qt::PenJoinStyle shapeJoinStyle;
429 
430  //-- drop shadow
431 
439  double shadowRadius;
446  QPainter::CompositionMode shadowBlendMode;
447 
448  //-- placement
449 
451  unsigned int placementFlags;
452 
453  bool centroidWhole; // whether centroid calculated from whole or visible polygon
454  bool centroidInside; // whether centroid-point calculated must be inside polygon
455 
462 
466  double dist; // distance from the feature (in mm)
467  bool distInMapUnits; //true if distance is in map units (otherwise in mm)
471 
475 
476  // offset labels of point/centroid features default to center
477  // move label to quadrant: left/down, don't move, right/up (-1, 0, 1)
479 
480  double xOffset; // offset from point in mm or map units
481  double yOffset; // offset from point in mm or map units
482  bool labelOffsetInMapUnits; //true if label offset is in map units (otherwise in mm)
484  double angleOffset; // rotation applied to offset labels
485  bool preserveRotation; // preserve predefined rotation data during label pin/unpin operations
486 
487  double maxCurvedCharAngleIn; // maximum angle between inside curved label characters (defaults to 20.0, range 20.0 to 60.0)
488  double maxCurvedCharAngleOut; // maximum angle between outside curved label characters (defaults to -20.0, range -20.0 to -95.0)
489 
490  int priority; // 0 = low, 10 = high
491 
492  //-- rendering
493 
495  int scaleMin;
496  int scaleMax;
497 
498  bool fontLimitPixelSize; // true is label should be limited by fontMinPixelSize/fontMaxPixelSize
499  int fontMinPixelSize; // minimum pixel size for showing rendered map unit labels (1 - 1000)
500  int fontMaxPixelSize; // maximum pixel size for showing rendered map unit labels (1 - 10000)
501 
502  bool displayAll; // if true, all features will be labelled even though overlaps occur
503  UpsideDownLabels upsidedownLabels; // whether, or how, to show upsidedown labels
504 
505  bool labelPerPart; // whether to label every feature's part or only the biggest one
507 
508  bool limitNumLabels; // whether to limit the number of labels to be drawn
509  int maxNumLabels; // maximum number of labels to be drawn
510 
511  double minFeatureSize; // minimum feature size to be labelled (in mm)
512  bool obstacle; // whether features for layer are obstacles to labels of other layers
513 
518 
522 
524  double zIndex;
525 
526  //-- scale factors
527  double vectorScaleFactor; //scale factor painter units->pixels
528  double rasterCompressFactor; //pixel resolution scale factor
529 
530  // called from register feature hook
531  void calculateLabelSize( const QFontMetricsF* fm, QString text, double& labelX, double& labelY, QgsFeature* f = nullptr, QgsRenderContext* context = nullptr );
532 
546  void registerFeature( QgsFeature& f, QgsRenderContext& context, const QString& dxfLayer, QgsLabelFeature** labelFeature = nullptr, QgsGeometry* obstacleGeometry = nullptr );
547 
548  void readFromLayer( QgsVectorLayer* layer );
549  void writeToLayer( QgsVectorLayer* layer );
550 
554  void readXml( QDomElement& elem );
555 
559  QDomElement writeXml( QDomDocument& doc );
560 
565 
569  void setDataDefinedProperty( QgsPalLayerSettings::DataDefinedProperties p,
570  bool active, bool useExpr, const QString& expr, const QString& field );
571 
573  void removeDataDefinedProperty( QgsPalLayerSettings::DataDefinedProperties p );
574 
578  void removeAllDataDefinedProperties();
579 
583  QString updateDataDefinedString( const QString& value );
584 
589 
594  QVariant dataDefinedValue( QgsPalLayerSettings::DataDefinedProperties p, QgsFeature& f, const QgsFields& fields,
595  const QgsExpressionContext* context = nullptr ) const;
596 
601  bool dataDefinedEvaluate( QgsPalLayerSettings::DataDefinedProperties p, QVariant& exprVal, QgsExpressionContext* context = nullptr, const QVariant& originalValue = QVariant() ) const;
602 
605  bool dataDefinedIsActive( QgsPalLayerSettings::DataDefinedProperties p ) const;
606 
609  bool dataDefinedUseExpression( QgsPalLayerSettings::DataDefinedProperties p ) const;
610 
616 
617 
626  int sizeToPixel( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
627 
636  double scaleToPixelContext( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
637 
643 
644  // temporary stuff: set when layer gets prepared or labeled
650  QgsPoint ptZero, ptOne;
652  int mFeaturesToLabel; // total features that will probably be labeled, may be less (figured before PAL)
653  int mFeatsSendingToPal; // total features tested for sending into PAL (relative to maxNumLabels)
654  int mFeatsRegPal; // number of features registered in PAL, when using limitNumLabels
655 
658 
659  bool showingShadowRects; // whether to show debug rectangles for drop shadows
660 
661  private:
662 
663  void readDataDefinedPropertyMap( QgsVectorLayer* layer, QDomElement* parentElem,
665  QgsDataDefined* > & propertyMap );
666  void writeDataDefinedPropertyMap( QgsVectorLayer* layer, QDomElement* parentElem,
668  QgsDataDefined* > & propertyMap );
669  void readDataDefinedProperty( QgsVectorLayer* layer,
672  QgsDataDefined* > & propertyMap );
673 
674  enum DataDefinedValueType
675  {
676  DDBool,
677  DDInt,
678  DDIntPos,
679  DDDouble,
680  DDDoublePos,
681  DDRotation180,
682  DDTransparency,
683  DDString,
684  DDUnits,
685  DDColor,
686  DDJoinStyle,
687  DDBlendMode,
688  DDPointF
689  };
690 
691  // convenience data defined evaluation function
692  bool dataDefinedValEval( DataDefinedValueType valType,
694  QVariant& exprVal, QgsExpressionContext &context, const QVariant& originalValue = QVariant() );
695 
696  void parseTextStyle( QFont& labelFont,
698  QgsRenderContext& context );
699 
700  void parseTextBuffer( QgsRenderContext& context );
701 
702  void parseTextFormatting( QgsRenderContext& context );
703 
704  void parseShapeBackground( QgsRenderContext& context );
705 
706  void parseDropShadow( QgsRenderContext& context );
707 
710  bool checkMinimumSizeMM( const QgsRenderContext& ct, const QgsGeometry* geom, double minSize ) const;
711 
714  void registerObstacleFeature( QgsFeature &f, QgsRenderContext &context, const QString& dxfLayer, QgsLabelFeature** obstacleFeature, QgsGeometry* obstacleGeometry = nullptr );
715 
716  QMap<DataDefinedProperties, QVariant> dataDefinedValues;
717  QgsExpression* expression;
719 
720  QFontDatabase mFontDB;
721 
722  static QVector< PredefinedPointPosition > DEFAULT_PLACEMENT_ORDER;
723 };
724 
725 class CORE_EXPORT QgsLabelCandidate
726 {
727  public:
728  QgsLabelCandidate( const QRectF& r, double c ): rect( r ), cost( c ) {}
729 
731  double cost;
732 };
733 
738 class CORE_EXPORT QgsLabelComponent
739 {
740  public:
742  : mText( QString() )
743  , mOrigin( QgsPoint() )
744  , mUseOrigin( false )
745  , mRotation( 0.0 )
746  , mRotationOffset( 0.0 )
747  , mUseRotation( false )
748  , mCenter( QgsPoint() )
749  , mUseCenter( false )
750  , mSize( QgsPoint() )
751  , mOffset( QgsPoint() )
752  , mPicture( nullptr )
753  , mPictureBuffer( 0.0 )
754  , mDpiRatio( 1.0 )
755  {}
756 
757  // methods
758 
759  QString text() const { return mText; }
760  void setText( const QString& text ) { mText = text; }
761 
762  const QgsPoint& origin() const { return mOrigin; }
763  void setOrigin( const QgsPoint& point ) { mOrigin = point; }
764 
765  bool useOrigin() const { return mUseOrigin; }
766  void setUseOrigin( const bool use ) { mUseOrigin = use; }
767 
768  double rotation() const { return mRotation; }
769  void setRotation( const double rotation ) { mRotation = rotation; }
770 
771  double rotationOffset() const { return mRotationOffset; }
772  void setRotationOffset( const double rotation ) { mRotationOffset = rotation; }
773 
774  bool useRotation() const { return mUseRotation; }
775  void setUseRotation( const bool use ) { mUseRotation = use; }
776 
777  const QgsPoint& center() const { return mCenter; }
778  void setCenter( const QgsPoint& point ) { mCenter = point; }
779 
780  bool useCenter() const { return mUseCenter; }
781  void setUseCenter( const bool use ) { mUseCenter = use; }
782 
783  const QgsPoint& size() const { return mSize; }
784  void setSize( const QgsPoint& point ) { mSize = point; }
785 
786  const QgsPoint& offset() const { return mOffset; }
787  void setOffset( const QgsPoint& point ) { mOffset = point; }
788 
789  const QPicture* picture() const { return mPicture; }
790  void setPicture( QPicture* picture ) { mPicture = picture; }
791 
792  double pictureBuffer() const { return mPictureBuffer; }
793  void setPictureBuffer( const double buffer ) { mPictureBuffer = buffer; }
794 
795  double dpiRatio() const { return mDpiRatio; }
796  void setDpiRatio( const double ratio ) { mDpiRatio = ratio; }
797 
798  private:
799  // current label component text,
800  // e.g. single line in a multi-line label or charcater in curved labeling
801  QString mText;
802  // current origin point for painting (generally current painter rotation point)
803  QgsPoint mOrigin;
804  // whether to translate the painter to supplied origin
805  bool mUseOrigin;
806  // any rotation to be applied to painter (in radians)
807  double mRotation;
808  // any rotation to be applied to painter (in radians) after initial rotation
809  double mRotationOffset;
810  // whether to use the rotation to rotate the painter
811  bool mUseRotation;
812  // current center point of label compnent, after rotation
813  QgsPoint mCenter;
814  // whether to translate the painter to supplied origin based upon center
815  bool mUseCenter;
816  // width and height of label component, transformed and ready for painting
817  QgsPoint mSize;
818  // any translation offsets to be applied before painting, transformed and ready for painting
819  QgsPoint mOffset;
820 
821  // a stored QPicture of painting for the component
822  QPicture* mPicture;
823  // buffer for component to accommodate graphic items ignored by QPicture,
824  // e.g. half-width of an applied QPen, which would extend beyond boundingRect() of QPicture
825  double mPictureBuffer;
826 
827  // a ratio of native painter dpi and that of rendering context's painter
828  double mDpiRatio;
829 };
830 
831 
836 class CORE_EXPORT QgsLabelingResults
837 {
838  public:
841 
843  QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) const;
845  QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) const;
846 
847  private:
848  QgsLabelingResults( const QgsLabelingResults& ); // no copying allowed
849  QgsLabelingResults& operator=( const QgsLabelingResults& rh );
850 
851  QgsLabelSearchTree* mLabelSearchTree;
852 
853  friend class QgsPalLabeling;
856 };
857 
859 class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface
860 {
861  public:
863  {
864  LabelText = 0,
868  LabelShadow
869  };
870 
871  QgsPalLabeling();
872  ~QgsPalLabeling();
873 
875  Q_DECL_DEPRECATED QgsPalLayerSettings& layer( const QString& layerName ) override;
876 
877  void numCandidatePositions( int& candPoint, int& candLine, int& candPolygon );
878  void setNumCandidatePositions( int candPoint, int candLine, int candPolygon );
879 
880  enum Search { Chain, Popmusic_Tabu, Popmusic_Chain, Popmusic_Tabu_Chain, Falp };
881 
882  void setSearchMethod( Search s );
883  Search searchMethod() const;
884 
885  bool isShowingCandidates() const;
886  void setShowingCandidates( bool showing );
888  Q_DECL_DEPRECATED const QList<QgsLabelCandidate>& candidates() { return mCandidates; }
889 
890  bool isShowingShadowRectangles() const;
891  void setShowingShadowRectangles( bool showing );
892 
893  bool isShowingAllLabels() const;
894  void setShowingAllLabels( bool showing );
895 
896  bool isShowingPartialsLabels() const;
897  void setShowingPartialsLabels( bool showing );
898 
900  bool isDrawingOutlineLabels() const;
901  void setDrawingOutlineLabels( bool outline );
902 
908  bool drawLabelRectOnly() const;
909 
916  void setDrawLabelRectOnly( bool drawRect );
917 
918  // implemented methods from labeling engine interface
919 
922  Q_DECL_DEPRECATED virtual void init( QgsMapRenderer* mr ) override;
924  virtual void init( const QgsMapSettings& mapSettings ) override;
926  virtual bool willUseLayer( QgsVectorLayer* layer ) override;
927 
930  static bool staticWillUseLayer( QgsVectorLayer* layer );
931  static bool staticWillUseLayer( const QString& layerID );
932 
934  virtual void clearActiveLayers() override;
936  virtual void clearActiveLayer( const QString& layerID ) override;
938  virtual int prepareLayer( QgsVectorLayer* layer, QStringList &attrNames, QgsRenderContext& ctx ) override;
941  virtual int prepareDiagramLayer( QgsVectorLayer* layer, QStringList& attrNames, QgsRenderContext& ctx ) override;
944  Q_DECL_DEPRECATED virtual int addDiagramLayer( QgsVectorLayer* layer, const QgsDiagramLayerSettings *s ) override;
945 
953  virtual void registerFeature( const QString& layerID, QgsFeature& feat, QgsRenderContext& context, const QString& dxfLayer = QString::null ) override;
954 
955  virtual void registerDiagramFeature( const QString& layerID, QgsFeature& feat, QgsRenderContext& context ) override;
957  virtual void drawLabeling( QgsRenderContext& context ) override;
959  virtual void exit() override;
960 
963  Q_DECL_DEPRECATED virtual QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) override;
966  Q_DECL_DEPRECATED virtual QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) override;
967 
970  QgsLabelingResults* takeResults();
971 
973  virtual QgsPalLabeling* clone() override;
974 
976  static void drawLabelCandidateRect( pal::LabelPosition* lp, QPainter* painter, const QgsMapToPixel* xform, QList<QgsLabelCandidate>* candidates = nullptr );
977 
978  static void drawLabelBuffer( QgsRenderContext& context,
979  const QgsLabelComponent &component,
980  const QgsPalLayerSettings& tmpLyr );
981 
982  static void drawLabelBackground( QgsRenderContext& context,
983  QgsLabelComponent component,
984  const QgsPalLayerSettings& tmpLyr );
985 
986  static void drawLabelShadow( QgsRenderContext &context,
987  const QgsLabelComponent &component,
988  const QgsPalLayerSettings& tmpLyr );
989 
991  void loadEngineSettings();
992  void saveEngineSettings();
993  void clearEngineSettings();
995  Q_DECL_DEPRECATED bool isStoredWithProject() const { return true; }
997  Q_DECL_DEPRECATED void setStoredWithProject( bool store ) { Q_UNUSED( store ); }
998 
1007  static QgsGeometry* prepareGeometry( const QgsGeometry *geometry, QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry = nullptr );
1008 
1017  static bool geometryRequiresPreparation( const QgsGeometry *geometry, QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry = nullptr );
1018 
1026  static QStringList splitToLines( const QString& text, const QString& wrapCharacter );
1027 
1035  static QStringList splitToGraphemes( const QString& text );
1036 
1037  protected:
1038  // update temporary QgsPalLayerSettings with any data defined text style values
1039  static void dataDefinedTextStyle( QgsPalLayerSettings& tmpLyr,
1041 
1042  // update temporary QgsPalLayerSettings with any data defined text formatting values
1043  static void dataDefinedTextFormatting( QgsPalLayerSettings& tmpLyr,
1045 
1046  // update temporary QgsPalLayerSettings with any data defined text buffer values
1047  static void dataDefinedTextBuffer( QgsPalLayerSettings& tmpLyr,
1049 
1050  // update temporary QgsPalLayerSettings with any data defined shape background values
1051  static void dataDefinedShapeBackground( QgsPalLayerSettings& tmpLyr,
1053 
1054  // update temporary QgsPalLayerSettings with any data defined drop shadow values
1055  static void dataDefinedDropShadow( QgsPalLayerSettings& tmpLyr,
1057 
1058  friend class QgsVectorLayerLabelProvider; // to allow calling the static methods above
1059 
1060  void deleteTemporaryData();
1061 
1069  static bool checkMinimumSizeMM( const QgsRenderContext &context, const QgsGeometry *geom, double minSize );
1070 
1076 
1079 
1080  // list of candidates from last labeling
1082 
1083  friend class QgsPalLayerSettings;
1084 };
1086 
1087 
1088 #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:407
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:189
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:65
Qt::PenJoinStyle shapeJoinStyle
Offset distance applies from rendered symbol bounds.
void setDpiRatio(const double ratio)
unsigned int placementFlags
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:408
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:50
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.