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