QGIS API Documentation  2.15.0-Master (94d88e6)
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 
64 class CORE_EXPORT QgsPalLayerSettings
65 {
66  public:
70 
72  QgsPalLayerSettings &operator=( const QgsPalLayerSettings & s );
73 
75  static QgsPalLayerSettings fromLayer( QgsVectorLayer* layer );
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 
545  void registerFeature( QgsFeature& f, QgsRenderContext& context, 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, 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 
953  virtual void registerFeature( const QString& layerID, QgsFeature& feat, QgsRenderContext& context ) 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  friend class QgsDxfExport; // 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:504
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:505
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.