QGIS API Documentation  2.12.0-Lyon
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  enum Placement
77  {
78  AroundPoint, // Point / Polygon
79  OverPoint, // Point / Polygon
80  Line, // Line / Polygon
81  Curved, // Line
82  Horizontal, // Polygon
83  Free // Polygon
84  };
85 
87  {
88  OnLine = 1,
89  AboveLine = 2,
90  BelowLine = 4,
91  MapOrientation = 8
92  };
93 
95  {
104  QuadrantBelowRight
105  };
106 
108  {
111  ShowAll
112  };
113 
115  {
118  SymbolBelow
119  };
120 
122  {
123  MultiLeft = 0,
126  MultiFollowPlacement
128  };
129 
134  {
139  };
140 
142  {
143  ShapeRectangle = 0,
147  ShapeSVG
148  };
149 
150  enum SizeType
151  {
152  SizeBuffer = 0,
154  SizePercent
155  };
156 
158  {
159  RotationSync = 0,
161  RotationFixed
162  };
163 
165  enum SizeUnit
166  {
167  Points = 0,
168  MM,
170  Percent
171  };
172 
174  {
175  ShadowLowest = 0,
178  ShadowShape
179  };
180 
181  // update mDataDefinedNames QMap in constructor when adding/deleting enum value
183  {
184  // text style
185  Size = 0,
186  Bold = 1,
187  Italic = 2,
188  Underline = 3,
189  Color = 4,
190  Strikeout = 5,
191  Family = 6,
192  FontStyle = 21,
193  FontSizeUnit = 22,
194  FontTransp = 18,
195  FontCase = 27,
196  FontLetterSpacing = 28,
197  FontWordSpacing = 29,
198  FontBlendMode = 30,
199 
200  // text formatting
201  MultiLineWrapChar = 31,
202  MultiLineHeight = 32,
203  MultiLineAlignment = 33,
204  DirSymbDraw = 34,
205  DirSymbLeft = 35,
206  DirSymbRight = 36,
207  DirSymbPlacement = 37,
208  DirSymbReverse = 38,
209  NumFormat = 39,
210  NumDecimals = 40,
211  NumPlusSign = 41,
212 
213  // text buffer
214  BufferDraw = 42,
215  BufferSize = 7,
216  BufferUnit = 43,
217  BufferColor = 8,
218  BufferTransp = 19,
219  BufferJoinStyle = 44,
220  BufferBlendMode = 45,
221 
222  // background
223  ShapeDraw = 46,
224  ShapeKind = 47,
225  ShapeSVGFile = 48,
226  ShapeSizeType = 49,
227  ShapeSizeX = 50,
228  ShapeSizeY = 85,
229  ShapeSizeUnits = 51,
230  ShapeRotationType = 52,
231  ShapeRotation = 53,
232  ShapeOffset = 54,
233  ShapeOffsetUnits = 55,
234  ShapeRadii = 56,
235  ShapeRadiiUnits = 57,
236  ShapeTransparency = 63,
237  ShapeBlendMode = 64,
238  ShapeFillColor = 58,
239  ShapeBorderColor = 59,
240  ShapeBorderWidth = 60,
241  ShapeBorderWidthUnits = 61,
242  ShapeJoinStyle = 62,
243 
244  // drop shadow
245  ShadowDraw = 65,
246  ShadowUnder = 66,
247  ShadowOffsetAngle = 67,
248  ShadowOffsetDist = 68,
249  ShadowOffsetUnits = 69,
250  ShadowRadius = 70,
251  ShadowRadiusUnits = 71,
252  ShadowTransparency = 72,
253  ShadowScale = 73,
254  ShadowColor = 74,
255  ShadowBlendMode = 75,
256 
257  // placement
258  CentroidWhole = 76,
259  OffsetQuad = 77,
260  OffsetXY = 78,
261  OffsetUnits = 80,
262  LabelDistance = 13,
263  DistanceUnits = 81,
264  OffsetRotation = 82,
265  CurvedCharAngleInOut = 83,
266  // (data defined only)
267  PositionX = 9, //x-coordinate data defined label position
268  PositionY = 10, //y-coordinate data defined label position
269  Hali = 11, //horizontal alignment for data defined label position (Left, Center, Right)
270  Vali = 12, //vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top)
271  Rotation = 14, //data defined rotation
272  RepeatDistance = 84,
273  RepeatDistanceUnit = 86,
274  Priority = 87,
275 
276  // rendering
277  ScaleVisibility = 23,
278  MinScale = 16,
279  MaxScale = 17,
280  FontLimitPixel = 24,
281  FontMinPixel = 25,
282  FontMaxPixel = 26,
283  IsObstacle = 88,
284  ObstacleFactor = 89,
285 
286  // (data defined only)
287  Show = 15,
288  AlwaysShow = 20
289  };
290 
291  // whether to label this layer
292  bool enabled;
293 
302 
303  //-- text style
304 
306 
310 
313  QgsExpression* getLabelExpression();
314 
317  bool fontSizeInMapUnits; //true if font size is in map units (otherwise in points)
318  QgsMapUnitScale fontSizeMapUnitScale; // scale range for map units for font size
321  QPainter::CompositionMode blendMode;
323 
324  //-- text formatting
325 
327  double multilineHeight; //0.0 to 10.0, leading between lines as multiplyer of line height
328  MultiLineAlign multilineAlign; // horizontal alignment of multi-line labels
329 
330  // Adds '<' or '>', or user-defined symbol to the label string pointing to the
331  // direction of the line / polygon ring
332  // Works only if Placement == Line
336  DirectionSymbols placeDirectionSymbol; // whether to place left/right, above or below label
338 
340  int decimals;
341  bool plusSign;
342 
343  //-- text buffer
344 
346  double bufferSize; // buffer size
347  bool bufferSizeInMapUnits; //true if buffer is in map units (otherwise in mm)
348  QgsMapUnitScale bufferSizeMapUnitScale; // scale range for map units for buffer size
350  bool bufferNoFill; //set interior of buffer to 100% transparent
352  Qt::PenJoinStyle bufferJoinStyle;
353  QPainter::CompositionMode bufferBlendMode;
354 
355  //-- shape background
356 
357  bool shapeDraw;
373  QPainter::CompositionMode shapeBlendMode;
379  Qt::PenJoinStyle shapeJoinStyle;
380 
381  //-- drop shadow
382 
390  double shadowRadius;
397  QPainter::CompositionMode shadowBlendMode;
398 
399  //-- placement
400 
402  unsigned int placementFlags;
403 
404  bool centroidWhole; // whether centroid calculated from whole or visible polygon
405  bool centroidInside; // whether centroid-point calculated must be inside polygon
406 
410  double dist; // distance from the feature (in mm)
411  bool distInMapUnits; //true if distance is in map units (otherwise in mm)
413 
417 
418  // offset labels of point/centroid features default to center
419  // move label to quadrant: left/down, don't move, right/up (-1, 0, 1)
421 
422  double xOffset; // offset from point in mm or map units
423  double yOffset; // offset from point in mm or map units
424  bool labelOffsetInMapUnits; //true if label offset is in map units (otherwise in mm)
426  double angleOffset; // rotation applied to offset labels
427  bool preserveRotation; // preserve predefined rotation data during label pin/unpin operations
428 
429  double maxCurvedCharAngleIn; // maximum angle between inside curved label characters (defaults to 20.0, range 20.0 to 60.0)
430  double maxCurvedCharAngleOut; // maximum angle between outside curved label characters (defaults to -20.0, range -20.0 to -95.0)
431 
432  int priority; // 0 = low, 10 = high
433 
434  //-- rendering
435 
437  int scaleMin;
438  int scaleMax;
439 
440  bool fontLimitPixelSize; // true is label should be limited by fontMinPixelSize/fontMaxPixelSize
441  int fontMinPixelSize; // minimum pixel size for showing rendered map unit labels (1 - 1000)
442  int fontMaxPixelSize; // maximum pixel size for showing rendered map unit labels (1 - 10000)
443 
444  bool displayAll; // if true, all features will be labelled even though overlaps occur
445  UpsideDownLabels upsidedownLabels; // whether, or how, to show upsidedown labels
446 
447  bool labelPerPart; // whether to label every feature's part or only the biggest one
449 
450  bool limitNumLabels; // whether to limit the number of labels to be drawn
451  int maxNumLabels; // maximum number of labels to be drawn
452 
453  double minFeatureSize; // minimum feature size to be labelled (in mm)
454  bool obstacle; // whether features for layer are obstacles to labels of other layers
455 
460 
464 
465  //-- scale factors
466  double vectorScaleFactor; //scale factor painter units->pixels
467  double rasterCompressFactor; //pixel resolution scale factor
468 
469  // called from register feature hook
470  void calculateLabelSize( const QFontMetricsF* fm, QString text, double& labelX, double& labelY, QgsFeature* f = 0, QgsRenderContext* context = 0 );
471 
479  void registerFeature( QgsFeature& f, QgsRenderContext& context, const QString& dxfLayer, QgsLabelFeature** labelFeature = 0 );
480 
481  void readFromLayer( QgsVectorLayer* layer );
482  void writeToLayer( QgsVectorLayer* layer );
483 
487  void readXml( QDomElement& elem );
488 
492  QDomElement writeXml( QDomDocument& doc );
493 
498 
502  void setDataDefinedProperty( QgsPalLayerSettings::DataDefinedProperties p,
503  bool active, bool useExpr, const QString& expr, const QString& field );
504 
506  void removeDataDefinedProperty( QgsPalLayerSettings::DataDefinedProperties p );
507 
511  void removeAllDataDefinedProperties();
512 
516  QString updateDataDefinedString( const QString& value );
517 
522 
527  QVariant dataDefinedValue( QgsPalLayerSettings::DataDefinedProperties p, QgsFeature& f, const QgsFields& fields,
528  const QgsExpressionContext* context = 0 ) const;
529 
534  bool dataDefinedEvaluate( QgsPalLayerSettings::DataDefinedProperties p, QVariant& exprVal, QgsExpressionContext* context = 0, const QVariant& originalValue = QVariant() ) const;
535 
538  bool dataDefinedIsActive( QgsPalLayerSettings::DataDefinedProperties p ) const;
539 
542  bool dataDefinedUseExpression( QgsPalLayerSettings::DataDefinedProperties p ) const;
543 
549 
550 
559  int sizeToPixel( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
560 
569  double scaleToPixelContext( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
570 
576 
577  // temporary stuff: set when layer gets prepared or labeled
583  QgsPoint ptZero, ptOne;
585  int mFeaturesToLabel; // total features that will probably be labeled, may be less (figured before PAL)
586  int mFeatsSendingToPal; // total features tested for sending into PAL (relative to maxNumLabels)
587  int mFeatsRegPal; // number of features registered in PAL, when using limitNumLabels
588 
591 
592  bool showingShadowRects; // whether to show debug rectangles for drop shadows
593 
594  private:
595 
596  void readDataDefinedPropertyMap( QgsVectorLayer* layer, QDomElement* parentElem,
598  QgsDataDefined* > & propertyMap );
599  void writeDataDefinedPropertyMap( QgsVectorLayer* layer, QDomElement* parentElem,
601  QgsDataDefined* > & propertyMap );
602  void readDataDefinedProperty( QgsVectorLayer* layer,
605  QgsDataDefined* > & propertyMap );
606 
607  enum DataDefinedValueType
608  {
609  DDBool,
610  DDInt,
611  DDIntPos,
612  DDDouble,
613  DDDoublePos,
614  DDRotation180,
615  DDTransparency,
616  DDString,
617  DDUnits,
618  DDColor,
619  DDJoinStyle,
620  DDBlendMode,
621  DDPointF
622  };
623 
624  // convenience data defined evaluation function
625  bool dataDefinedValEval( DataDefinedValueType valType,
627  QVariant& exprVal, QgsExpressionContext &context, const QVariant& originalValue = QVariant() );
628 
629  void parseTextStyle( QFont& labelFont,
631  QgsRenderContext& context );
632 
633  void parseTextBuffer( QgsRenderContext& context );
634 
635  void parseTextFormatting( QgsRenderContext& context );
636 
637  void parseShapeBackground( QgsRenderContext& context );
638 
639  void parseDropShadow( QgsRenderContext& context );
640 
643  bool checkMinimumSizeMM( const QgsRenderContext& ct, const QgsGeometry* geom, double minSize ) const;
644 
647  void registerObstacleFeature( QgsFeature &f, QgsRenderContext &context, const QString& dxfLayer, QgsLabelFeature** obstacleFeature );
648 
649  QMap<DataDefinedProperties, QVariant> dataDefinedValues;
650  QgsExpression* expression;
652 
653  QFontDatabase mFontDB;
654 };
655 
656 class CORE_EXPORT QgsLabelCandidate
657 {
658  public:
659  QgsLabelCandidate( const QRectF& r, double c ): rect( r ), cost( c ) {}
660 
662  double cost;
663 };
664 
669 class CORE_EXPORT QgsLabelComponent
670 {
671  public:
673  : mText( QString() )
674  , mOrigin( QgsPoint() )
675  , mUseOrigin( false )
676  , mRotation( 0.0 )
677  , mRotationOffset( 0.0 )
678  , mUseRotation( false )
679  , mCenter( QgsPoint() )
680  , mUseCenter( false )
681  , mSize( QgsPoint() )
682  , mOffset( QgsPoint() )
683  , mPicture( 0 )
684  , mPictureBuffer( 0.0 )
685  , mDpiRatio( 1.0 )
686  {}
687 
688  // methods
689 
690  const QString& text() const { return mText; }
691  void setText( const QString& text ) { mText = text; }
692 
693  const QgsPoint& origin() const { return mOrigin; }
694  void setOrigin( const QgsPoint& point ) { mOrigin = point; }
695 
696  bool useOrigin() const { return mUseOrigin; }
697  void setUseOrigin( const bool use ) { mUseOrigin = use; }
698 
699  double rotation() const { return mRotation; }
700  void setRotation( const double rotation ) { mRotation = rotation; }
701 
702  double rotationOffset() const { return mRotationOffset; }
703  void setRotationOffset( const double rotation ) { mRotationOffset = rotation; }
704 
705  bool useRotation() const { return mUseRotation; }
706  void setUseRotation( const bool use ) { mUseRotation = use; }
707 
708  const QgsPoint& center() const { return mCenter; }
709  void setCenter( const QgsPoint& point ) { mCenter = point; }
710 
711  bool useCenter() const { return mUseCenter; }
712  void setUseCenter( const bool use ) { mUseCenter = use; }
713 
714  const QgsPoint& size() const { return mSize; }
715  void setSize( const QgsPoint& point ) { mSize = point; }
716 
717  const QgsPoint& offset() const { return mOffset; }
718  void setOffset( const QgsPoint& point ) { mOffset = point; }
719 
720  const QPicture* picture() const { return mPicture; }
721  void setPicture( QPicture* picture ) { mPicture = picture; }
722 
723  double pictureBuffer() const { return mPictureBuffer; }
724  void setPictureBuffer( const double buffer ) { mPictureBuffer = buffer; }
725 
726  double dpiRatio() const { return mDpiRatio; }
727  void setDpiRatio( const double ratio ) { mDpiRatio = ratio; }
728 
729  private:
730  // current label component text,
731  // e.g. single line in a multi-line label or charcater in curved labeling
732  QString mText;
733  // current origin point for painting (generally current painter rotation point)
734  QgsPoint mOrigin;
735  // whether to translate the painter to supplied origin
736  bool mUseOrigin;
737  // any rotation to be applied to painter (in radians)
738  double mRotation;
739  // any rotation to be applied to painter (in radians) after initial rotation
740  double mRotationOffset;
741  // whether to use the rotation to rotate the painter
742  bool mUseRotation;
743  // current center point of label compnent, after rotation
744  QgsPoint mCenter;
745  // whether to translate the painter to supplied origin based upon center
746  bool mUseCenter;
747  // width and height of label component, transformed and ready for painting
748  QgsPoint mSize;
749  // any translation offsets to be applied before painting, transformed and ready for painting
750  QgsPoint mOffset;
751 
752  // a stored QPicture of painting for the component
753  QPicture* mPicture;
754  // buffer for component to accommodate graphic items ignored by QPicture,
755  // e.g. half-width of an applied QPen, which would extend beyond boundingRect() of QPicture
756  double mPictureBuffer;
757 
758  // a ratio of native painter dpi and that of rendering context's painter
759  double mDpiRatio;
760 };
761 
762 
767 class CORE_EXPORT QgsLabelingResults
768 {
769  public:
772 
774  QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) const;
776  QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) const;
777 
778  private:
779  QgsLabelingResults( const QgsLabelingResults& ) {} // no copying allowed
780 
781  QgsLabelSearchTree* mLabelSearchTree;
782 
783  friend class QgsPalLabeling;
786 };
787 
789 class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface
790 {
791  public:
793  {
794  LabelText = 0,
798  LabelShadow
799  };
800 
801  QgsPalLabeling();
802  ~QgsPalLabeling();
803 
805  Q_DECL_DEPRECATED QgsPalLayerSettings& layer( const QString& layerName ) override;
806 
807  void numCandidatePositions( int& candPoint, int& candLine, int& candPolygon );
808  void setNumCandidatePositions( int candPoint, int candLine, int candPolygon );
809 
810  enum Search { Chain, Popmusic_Tabu, Popmusic_Chain, Popmusic_Tabu_Chain, Falp };
811 
812  void setSearchMethod( Search s );
813  Search searchMethod() const;
814 
815  bool isShowingCandidates() const;
816  void setShowingCandidates( bool showing );
818  Q_DECL_DEPRECATED const QList<QgsLabelCandidate>& candidates() { return mCandidates; }
819 
820  bool isShowingShadowRectangles() const;
821  void setShowingShadowRectangles( bool showing );
822 
823  bool isShowingAllLabels() const;
824  void setShowingAllLabels( bool showing );
825 
826  bool isShowingPartialsLabels() const;
827  void setShowingPartialsLabels( bool showing );
828 
830  bool isDrawingOutlineLabels() const;
831  void setDrawingOutlineLabels( bool outline );
832 
838  bool drawLabelRectOnly() const;
839 
846  void setDrawLabelRectOnly( bool drawRect );
847 
848  // implemented methods from labeling engine interface
849 
852  Q_DECL_DEPRECATED virtual void init( QgsMapRenderer* mr ) override;
854  virtual void init( const QgsMapSettings& mapSettings ) override;
856  virtual bool willUseLayer( QgsVectorLayer* layer ) override;
857 
860  static bool staticWillUseLayer( QgsVectorLayer* layer );
861  static bool staticWillUseLayer( const QString& layerID );
862 
864  virtual void clearActiveLayers() override;
866  virtual void clearActiveLayer( const QString& layerID ) override;
868  virtual int prepareLayer( QgsVectorLayer* layer, QStringList &attrNames, QgsRenderContext& ctx ) override;
871  virtual int prepareDiagramLayer( QgsVectorLayer* layer, QStringList& attrNames, QgsRenderContext& ctx ) override;
874  Q_DECL_DEPRECATED virtual int addDiagramLayer( QgsVectorLayer* layer, const QgsDiagramLayerSettings *s ) override;
875 
883  virtual void registerFeature( const QString& layerID, QgsFeature& feat, QgsRenderContext& context, const QString& dxfLayer = QString::null ) override;
884 
885  virtual void registerDiagramFeature( const QString& layerID, QgsFeature& feat, QgsRenderContext& context ) override;
887  virtual void drawLabeling( QgsRenderContext& context ) override;
889  virtual void exit() override;
890 
893  Q_DECL_DEPRECATED virtual QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) override;
896  Q_DECL_DEPRECATED virtual QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) override;
897 
900  QgsLabelingResults* takeResults();
901 
903  virtual QgsLabelingEngineInterface* clone() override;
904 
906  static void drawLabelCandidateRect( pal::LabelPosition* lp, QPainter* painter, const QgsMapToPixel* xform, QList<QgsLabelCandidate>* candidates = 0 );
907 
908  static void drawLabelBuffer( QgsRenderContext& context,
909  const QgsLabelComponent &component,
910  const QgsPalLayerSettings& tmpLyr );
911 
912  static void drawLabelBackground( QgsRenderContext& context,
913  QgsLabelComponent component,
914  const QgsPalLayerSettings& tmpLyr );
915 
916  static void drawLabelShadow( QgsRenderContext &context,
917  const QgsLabelComponent &component,
918  const QgsPalLayerSettings& tmpLyr );
919 
921  void loadEngineSettings();
922  void saveEngineSettings();
923  void clearEngineSettings();
925  Q_DECL_DEPRECATED bool isStoredWithProject() const { return true; }
927  Q_DECL_DEPRECATED void setStoredWithProject( bool store ) { Q_UNUSED( store ); }
928 
937  static QgsGeometry* prepareGeometry( const QgsGeometry *geometry, QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry = 0 );
938 
947  static bool geometryRequiresPreparation( const QgsGeometry *geometry, QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry = 0 );
948 
956  static QStringList splitToLines( const QString& text, const QString& wrapCharacter );
957 
965  static QStringList splitToGraphemes( const QString& text );
966 
967  protected:
968  // update temporary QgsPalLayerSettings with any data defined text style values
969  static void dataDefinedTextStyle( QgsPalLayerSettings& tmpLyr,
971 
972  // update temporary QgsPalLayerSettings with any data defined text formatting values
973  static void dataDefinedTextFormatting( QgsPalLayerSettings& tmpLyr,
975 
976  // update temporary QgsPalLayerSettings with any data defined text buffer values
977  static void dataDefinedTextBuffer( QgsPalLayerSettings& tmpLyr,
979 
980  // update temporary QgsPalLayerSettings with any data defined shape background values
981  static void dataDefinedShapeBackground( QgsPalLayerSettings& tmpLyr,
983 
984  // update temporary QgsPalLayerSettings with any data defined drop shadow values
985  static void dataDefinedDropShadow( QgsPalLayerSettings& tmpLyr,
987 
988  friend class QgsVectorLayerLabelProvider; // to allow calling the static methods above
989 
990  void deleteTemporaryData();
991 
999  static bool checkMinimumSizeMM( const QgsRenderContext &context, const QgsGeometry *geom, double minSize );
1000 
1006 
1009 
1010  // list of candidates from last labeling
1012 
1013  friend class QgsPalLayerSettings;
1014 };
1016 
1017 
1018 #endif // QGSPALLABELING_H
virtual void exit()=0
called when we're done with rendering
Class for parsing and evaluation of expressions (formerly called "search strings").
Definition: qgsexpression.h:92
virtual void clearActiveLayers()=0
clears all PAL layer settings for registered layers
virtual Q_DECL_DEPRECATED void init(QgsMapRenderer *mp)=0
called when we're going to start with rendering
A rectangle specified with double values.
Definition: qgsrectangle.h:35
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
virtual int prepareLayer(QgsVectorLayer *layer, QStringList &attrNames, QgsRenderContext &ctx)=0
called when starting rendering of a layer
void setOrigin(const QgsPoint &point)
const QString & text() const
virtual void clearActiveLayer(const QString &layerID)=0
clears data defined objects from PAL layer settings for a registered layer
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
QgsLabelCandidate(const QRectF &r, double c)
QPainter::CompositionMode bufferBlendMode
virtual void registerFeature(const QString &layerID, QgsFeature &feat, QgsRenderContext &context, const QString &dxfLayer=QString::null)=0
called for every feature
virtual Q_DECL_DEPRECATED QgsPalLayerSettings & layer(const QString &layerName)=0
returns PAL layer settings for a registered layer
double rotationOffset() const
virtual int prepareDiagramLayer(QgsVectorLayer *layer, QStringList &attrNames, QgsRenderContext &ctx)
adds a diagram layer to the labeling engine
QgsMapUnitScale shadowOffsetMapUnitScale
const QgsPoint & size() const
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:390
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:177
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:176
bool useCenter() const
const QgsPoint & origin() const
double dpiRatio() const
A non GUI class for rendering a map layer set onto a QPainter.
virtual Q_DECL_DEPRECATED QList< QgsLabelPosition > labelsWithinRect(const QgsRectangle &r)=0
return infos about labels within a given (map) rectangle
const QgsPoint & center() const
void setRotationOffset(const double rotation)
Qt::PenJoinStyle bufferJoinStyle
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)
const QgsCoordinateTransform * ct
bool useOrigin() const
QgsMapUnitScale shapeRadiiMapUnitScale
virtual Q_DECL_DEPRECATED QList< QgsLabelPosition > labelsAtPosition(const QgsPoint &p)=0
return infos about labels at a given (map) position
const QPicture * picture() const
QgsPalLayerSettings mInvalidLayerSettings
virtual QgsLabelingEngineInterface * clone()=0
called when passing engine among map renderers
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)
const QgsMapToPixel * xform
QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined * > dataDefinedProperties
Map of current data defined properties.
virtual Q_DECL_DEPRECATED int addDiagramLayer(QgsVectorLayer *layer, const QgsDiagramLayerSettings *s)
adds a diagram layer to the labeling engine
void setText(const QString &text)
QgsMapUnitScale bufferSizeMapUnitScale
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:63
Qt::PenJoinStyle shapeJoinStyle
void setDpiRatio(const double ratio)
unsigned int placementFlags
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:391
virtual void registerDiagramFeature(const QString &layerID, QgsFeature &feat, QgsRenderContext &context)
called for every diagram feature
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.
virtual void drawLabeling(QgsRenderContext &context)=0
called when the map is drawn and labels should be placed
Class for doing transforms between two map coordinate systems.
LabelPosition is a candidate feature label position.
Definition: labelposition.h:48
double pictureBuffer() const
QPainter::CompositionMode shadowBlendMode
bool isExpression
Is this label made from a expression string eg FieldName || 'mm'.
void setSize(const QgsPoint &point)
Class that stores computed placement from labeling engine.
virtual bool willUseLayer(QgsVectorLayer *layer)=0
called to find out whether the layer is used for labeling
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
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.
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
QgsLabelingEngineV2 * mEngine
New labeling engine to interface with PAL.