QGIS API Documentation  2.11.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;
46 class QgsPalGeometry;
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 
59 class CORE_EXPORT QgsPalLayerSettings
60 {
61  public:
65 
67  static QgsPalLayerSettings fromLayer( QgsVectorLayer* layer );
68 
69  enum Placement
70  {
71  AroundPoint, // Point / Polygon
72  OverPoint, // Point / Polygon
73  Line, // Line / Polygon
74  Curved, // Line
75  Horizontal, // Polygon
76  Free // Polygon
77  };
78 
80  {
81  OnLine = 1,
82  AboveLine = 2,
83  BelowLine = 4,
84  MapOrientation = 8
85  };
86 
88  {
97  QuadrantBelowRight
98  };
99 
101  {
104  ShowAll
105  };
106 
108  {
111  SymbolBelow
112  };
113 
115  {
116  MultiLeft = 0,
119  MultiFollowPlacement
121  };
122 
127  {
132  };
133 
135  {
136  ShapeRectangle = 0,
140  ShapeSVG
141  };
142 
143  enum SizeType
144  {
145  SizeBuffer = 0,
147  SizePercent
148  };
149 
151  {
152  RotationSync = 0,
154  RotationFixed
155  };
156 
158  enum SizeUnit
159  {
160  Points = 0,
161  MM,
163  Percent
164  };
165 
167  {
168  ShadowLowest = 0,
171  ShadowShape
172  };
173 
174  // update mDataDefinedNames QMap in constructor when adding/deleting enum value
176  {
177  // text style
178  Size = 0,
179  Bold = 1,
180  Italic = 2,
181  Underline = 3,
182  Color = 4,
183  Strikeout = 5,
184  Family = 6,
185  FontStyle = 21,
186  FontSizeUnit = 22,
187  FontTransp = 18,
188  FontCase = 27,
189  FontLetterSpacing = 28,
190  FontWordSpacing = 29,
191  FontBlendMode = 30,
192 
193  // text formatting
194  MultiLineWrapChar = 31,
195  MultiLineHeight = 32,
196  MultiLineAlignment = 33,
197  DirSymbDraw = 34,
198  DirSymbLeft = 35,
199  DirSymbRight = 36,
200  DirSymbPlacement = 37,
201  DirSymbReverse = 38,
202  NumFormat = 39,
203  NumDecimals = 40,
204  NumPlusSign = 41,
205 
206  // text buffer
207  BufferDraw = 42,
208  BufferSize = 7,
209  BufferUnit = 43,
210  BufferColor = 8,
211  BufferTransp = 19,
212  BufferJoinStyle = 44,
213  BufferBlendMode = 45,
214 
215  // background
216  ShapeDraw = 46,
217  ShapeKind = 47,
218  ShapeSVGFile = 48,
219  ShapeSizeType = 49,
220  ShapeSizeX = 50,
221  ShapeSizeY = 85,
222  ShapeSizeUnits = 51,
223  ShapeRotationType = 52,
224  ShapeRotation = 53,
225  ShapeOffset = 54,
226  ShapeOffsetUnits = 55,
227  ShapeRadii = 56,
228  ShapeRadiiUnits = 57,
229  ShapeTransparency = 63,
230  ShapeBlendMode = 64,
231  ShapeFillColor = 58,
232  ShapeBorderColor = 59,
233  ShapeBorderWidth = 60,
234  ShapeBorderWidthUnits = 61,
235  ShapeJoinStyle = 62,
236 
237  // drop shadow
238  ShadowDraw = 65,
239  ShadowUnder = 66,
240  ShadowOffsetAngle = 67,
241  ShadowOffsetDist = 68,
242  ShadowOffsetUnits = 69,
243  ShadowRadius = 70,
244  ShadowRadiusUnits = 71,
245  ShadowTransparency = 72,
246  ShadowScale = 73,
247  ShadowColor = 74,
248  ShadowBlendMode = 75,
249 
250  // placement
251  CentroidWhole = 76,
252  OffsetQuad = 77,
253  OffsetXY = 78,
254  OffsetUnits = 80,
255  LabelDistance = 13,
256  DistanceUnits = 81,
257  OffsetRotation = 82,
258  CurvedCharAngleInOut = 83,
259  // (data defined only)
260  PositionX = 9, //x-coordinate data defined label position
261  PositionY = 10, //y-coordinate data defined label position
262  Hali = 11, //horizontal alignment for data defined label position (Left, Center, Right)
263  Vali = 12, //vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top)
264  Rotation = 14, //data defined rotation
265  RepeatDistance = 84,
266  RepeatDistanceUnit = 86,
267  Priority = 87,
268 
269  // rendering
270  ScaleVisibility = 23,
271  MinScale = 16,
272  MaxScale = 17,
273  FontLimitPixel = 24,
274  FontMinPixel = 25,
275  FontMaxPixel = 26,
276  IsObstacle = 88,
277  ObstacleFactor = 89,
278 
279  // (data defined only)
280  Show = 15,
281  AlwaysShow = 20
282  };
283 
284  // whether to label this layer
285  bool enabled;
286 
295 
296  //-- text style
297 
299 
303 
306  QgsExpression* getLabelExpression();
307 
310  bool fontSizeInMapUnits; //true if font size is in map units (otherwise in points)
311  QgsMapUnitScale fontSizeMapUnitScale; // scale range for map units for font size
314  QPainter::CompositionMode blendMode;
316 
317  //-- text formatting
318 
320  double multilineHeight; //0.0 to 10.0, leading between lines as multiplyer of line height
321  MultiLineAlign multilineAlign; // horizontal alignment of multi-line labels
322 
323  // Adds '<' or '>', or user-defined symbol to the label string pointing to the
324  // direction of the line / polygon ring
325  // Works only if Placement == Line
329  DirectionSymbols placeDirectionSymbol; // whether to place left/right, above or below label
331 
333  int decimals;
334  bool plusSign;
335 
336  //-- text buffer
337 
339  double bufferSize; // buffer size
340  bool bufferSizeInMapUnits; //true if buffer is in map units (otherwise in mm)
341  QgsMapUnitScale bufferSizeMapUnitScale; // scale range for map units for buffer size
343  bool bufferNoFill; //set interior of buffer to 100% transparent
345  Qt::PenJoinStyle bufferJoinStyle;
346  QPainter::CompositionMode bufferBlendMode;
347 
348  //-- shape background
349 
350  bool shapeDraw;
366  QPainter::CompositionMode shapeBlendMode;
372  Qt::PenJoinStyle shapeJoinStyle;
373 
374  //-- drop shadow
375 
383  double shadowRadius;
390  QPainter::CompositionMode shadowBlendMode;
391 
392  //-- placement
393 
395  unsigned int placementFlags;
396 
397  bool centroidWhole; // whether centroid calculated from whole or visible polygon
398  bool centroidInside; // whether centroid-point calculated must be inside polygon
399 
403  double dist; // distance from the feature (in mm)
404  bool distInMapUnits; //true if distance is in map units (otherwise in mm)
406 
410 
411  // offset labels of point/centroid features default to center
412  // move label to quadrant: left/down, don't move, right/up (-1, 0, 1)
414 
415  double xOffset; // offset from point in mm or map units
416  double yOffset; // offset from point in mm or map units
417  bool labelOffsetInMapUnits; //true if label offset is in map units (otherwise in mm)
419  double angleOffset; // rotation applied to offset labels
420  bool preserveRotation; // preserve predefined rotation data during label pin/unpin operations
421 
422  double maxCurvedCharAngleIn; // maximum angle between inside curved label characters (defaults to 20.0, range 20.0 to 60.0)
423  double maxCurvedCharAngleOut; // maximum angle between outside curved label characters (defaults to -20.0, range -20.0 to -95.0)
424 
425  int priority; // 0 = low, 10 = high
426 
427  //-- rendering
428 
430  int scaleMin;
431  int scaleMax;
432 
433  bool fontLimitPixelSize; // true is label should be limited by fontMinPixelSize/fontMaxPixelSize
434  int fontMinPixelSize; // minimum pixel size for showing rendered map unit labels (1 - 1000)
435  int fontMaxPixelSize; // maximum pixel size for showing rendered map unit labels (1 - 10000)
436 
437  bool displayAll; // if true, all features will be labelled even though overlaps occur
438  unsigned int upsidedownLabels; // whether, or how, to show upsidedown labels
439 
440  bool labelPerPart; // whether to label every feature's part or only the biggest one
442 
443  bool limitNumLabels; // whether to limit the number of labels to be drawn
444  int maxNumLabels; // maximum number of labels to be drawn
445 
446  double minFeatureSize; // minimum feature size to be labelled (in mm)
447  bool obstacle; // whether features for layer are obstacles to labels of other layers
448 
453 
457 
458  //-- scale factors
459  double vectorScaleFactor; //scale factor painter units->pixels
460  double rasterCompressFactor; //pixel resolution scale factor
461 
462  // called from register feature hook
463  void calculateLabelSize( const QFontMetricsF* fm, QString text, double& labelX, double& labelY, QgsFeature* f = 0 );
464 
465  // implementation of register feature hook
466  void registerFeature( QgsFeature& f, const QgsRenderContext& context, QString dxfLayer );
467 
468  void readFromLayer( QgsVectorLayer* layer );
469  void writeToLayer( QgsVectorLayer* layer );
470 
475 
479  void setDataDefinedProperty( QgsPalLayerSettings::DataDefinedProperties p,
480  bool active, bool useExpr, const QString& expr, const QString& field );
481 
483  void removeDataDefinedProperty( QgsPalLayerSettings::DataDefinedProperties p );
484 
488  QString updateDataDefinedString( const QString& value );
489 
494 
499  QVariant dataDefinedValue( QgsPalLayerSettings::DataDefinedProperties p, QgsFeature& f, const QgsFields& fields ) const;
500 
505  bool dataDefinedEvaluate( QgsPalLayerSettings::DataDefinedProperties p, QVariant& exprVal ) const;
506 
509  bool dataDefinedIsActive( QgsPalLayerSettings::DataDefinedProperties p ) const;
510 
513  bool dataDefinedUseExpression( QgsPalLayerSettings::DataDefinedProperties p ) const;
514 
518 
519 
528  int sizeToPixel( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
529 
538  double scaleToPixelContext( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
539 
545 
546  // temporary stuff: set when layer gets prepared or labeled
547  // NOTE: not in Python binding
554  QgsPoint ptZero, ptOne;
557  int mFeaturesToLabel; // total features that will probably be labeled, may be less (figured before PAL)
558  int mFeatsSendingToPal; // total features tested for sending into PAL (relative to maxNumLabels)
559  int mFeatsRegPal; // number of features registered in PAL, when using limitNumLabels
560 
563 
564  bool showingShadowRects; // whether to show debug rectangles for drop shadows
565 
566  private:
567 
568  void readDataDefinedPropertyMap( QgsVectorLayer* layer,
570  QgsDataDefined* > & propertyMap );
571  void writeDataDefinedPropertyMap( QgsVectorLayer* layer,
573  QgsDataDefined* > & propertyMap );
574  void readDataDefinedProperty( QgsVectorLayer* layer,
577  QgsDataDefined* > & propertyMap );
578 
579  // convenience data defined evaluation function
580  bool dataDefinedValEval( const QString& valType,
582  QVariant& exprVal );
583 
584  void parseTextStyle( QFont& labelFont,
586  const QgsRenderContext& context );
587 
588  void parseTextBuffer();
589 
590  void parseTextFormatting();
591 
592  void parseShapeBackground();
593 
594  void parseDropShadow();
595 
598  bool checkMinimumSizeMM( const QgsRenderContext& ct, const QgsGeometry* geom, double minSize ) const;
599 
602  void registerObstacleFeature( QgsFeature &f, const QgsRenderContext &context, QString dxfLayer );
603 
604  QMap<DataDefinedProperties, QVariant> dataDefinedValues;
605  QgsExpression* expression;
607 
608  QFontDatabase mFontDB;
609 };
610 
611 class CORE_EXPORT QgsLabelCandidate
612 {
613  public:
614  QgsLabelCandidate( QRectF r, double c ): rect( r ), cost( c ) {}
615 
617  double cost;
618 };
619 
624 class CORE_EXPORT QgsLabelComponent
625 {
626  public:
628  : mText( QString() )
629  , mOrigin( QgsPoint() )
630  , mUseOrigin( false )
631  , mRotation( 0.0 )
632  , mRotationOffset( 0.0 )
633  , mUseRotation( false )
634  , mCenter( QgsPoint() )
635  , mUseCenter( false )
636  , mSize( QgsPoint() )
637  , mOffset( QgsPoint() )
638  , mPicture( 0 )
639  , mPictureBuffer( 0.0 )
640  , mDpiRatio( 1.0 )
641  {}
642 
643  // methods
644 
645  const QString& text() const { return mText; }
646  void setText( const QString& text ) { mText = text; }
647 
648  const QgsPoint& origin() const { return mOrigin; }
649  void setOrigin( const QgsPoint& point ) { mOrigin = point; }
650 
651  bool useOrigin() const { return mUseOrigin; }
652  void setUseOrigin( const bool use ) { mUseOrigin = use; }
653 
654  double rotation() const { return mRotation; }
655  void setRotation( const double rotation ) { mRotation = rotation; }
656 
657  double rotationOffset() const { return mRotationOffset; }
658  void setRotationOffset( const double rotation ) { mRotationOffset = rotation; }
659 
660  bool useRotation() const { return mUseRotation; }
661  void setUseRotation( const bool use ) { mUseRotation = use; }
662 
663  const QgsPoint& center() const { return mCenter; }
664  void setCenter( const QgsPoint& point ) { mCenter = point; }
665 
666  bool useCenter() const { return mUseCenter; }
667  void setUseCenter( const bool use ) { mUseCenter = use; }
668 
669  const QgsPoint& size() const { return mSize; }
670  void setSize( const QgsPoint& point ) { mSize = point; }
671 
672  const QgsPoint& offset() const { return mOffset; }
673  void setOffset( const QgsPoint& point ) { mOffset = point; }
674 
675  const QPicture* picture() const { return mPicture; }
676  void setPicture( QPicture* picture ) { mPicture = picture; }
677 
678  double pictureBuffer() const { return mPictureBuffer; }
679  void setPictureBuffer( const double buffer ) { mPictureBuffer = buffer; }
680 
681  double dpiRatio() const { return mDpiRatio; }
682  void setDpiRatio( const double ratio ) { mDpiRatio = ratio; }
683 
684  private:
685  // current label component text,
686  // e.g. single line in a multi-line label or charcater in curved labeling
687  QString mText;
688  // current origin point for painting (generally current painter rotation point)
689  QgsPoint mOrigin;
690  // whether to translate the painter to supplied origin
691  bool mUseOrigin;
692  // any rotation to be applied to painter (in radians)
693  double mRotation;
694  // any rotation to be applied to painter (in radians) after initial rotation
695  double mRotationOffset;
696  // whether to use the rotation to rotate the painter
697  bool mUseRotation;
698  // current center point of label compnent, after rotation
699  QgsPoint mCenter;
700  // whether to translate the painter to supplied origin based upon center
701  bool mUseCenter;
702  // width and height of label component, transformed and ready for painting
703  QgsPoint mSize;
704  // any translation offsets to be applied before painting, transformed and ready for painting
705  QgsPoint mOffset;
706 
707  // a stored QPicture of painting for the component
708  QPicture* mPicture;
709  // buffer for component to accommodate graphic items ignored by QPicture,
710  // e.g. half-width of an applied QPen, which would extend beyond boundingRect() of QPicture
711  double mPictureBuffer;
712 
713  // a ratio of native painter dpi and that of rendering context's painter
714  double mDpiRatio;
715 };
716 
717 
722 class CORE_EXPORT QgsLabelingResults
723 {
724  public:
727 
729  QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) const;
731  QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) const;
732 
733  private:
734  QgsLabelingResults( const QgsLabelingResults& ) {} // no copying allowed
735 
736  QgsLabelSearchTree* mLabelSearchTree;
737 
738  friend class QgsPalLabeling;
739 };
740 
742 class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface
743 {
744  public:
746  {
747  LabelText = 0,
751  LabelShadow
752  };
753 
754  QgsPalLabeling();
755  ~QgsPalLabeling();
756 
757  QgsPalLayerSettings& layer( const QString& layerName ) override;
758 
759  void numCandidatePositions( int& candPoint, int& candLine, int& candPolygon );
760  void setNumCandidatePositions( int candPoint, int candLine, int candPolygon );
761 
762  enum Search { Chain, Popmusic_Tabu, Popmusic_Chain, Popmusic_Tabu_Chain, Falp };
763 
764  void setSearchMethod( Search s );
765  Search searchMethod() const;
766 
767  bool isShowingCandidates() const { return mShowingCandidates; }
768  void setShowingCandidates( bool showing ) { mShowingCandidates = showing; }
769  const QList<QgsLabelCandidate>& candidates() { return mCandidates; }
770 
771  bool isShowingShadowRectangles() const { return mShowingShadowRects; }
772  void setShowingShadowRectangles( bool showing ) { mShowingShadowRects = showing; }
773 
774  bool isShowingAllLabels() const { return mShowingAllLabels; }
775  void setShowingAllLabels( bool showing ) { mShowingAllLabels = showing; }
776 
777  bool isShowingPartialsLabels() const { return mShowingPartialsLabels; }
778  void setShowingPartialsLabels( bool showing ) { mShowingPartialsLabels = showing; }
779 
781  bool isDrawingOutlineLabels() const { return mDrawOutlineLabels; }
782  void setDrawingOutlineLabels( bool outline ) { mDrawOutlineLabels = outline; }
783 
784  // implemented methods from labeling engine interface
785 
788  Q_DECL_DEPRECATED virtual void init( QgsMapRenderer* mr ) override;
790  virtual void init( const QgsMapSettings& mapSettings ) override;
792  virtual bool willUseLayer( QgsVectorLayer* layer ) override;
793 
796  static bool staticWillUseLayer( QgsVectorLayer* layer );
797  static bool staticWillUseLayer( const QString& layerID );
798 
800  virtual void clearActiveLayers() override;
802  virtual void clearActiveLayer( const QString& layerID ) override;
804  virtual int prepareLayer( QgsVectorLayer* layer, QStringList &attrNames, QgsRenderContext& ctx ) override;
806  virtual int addDiagramLayer( QgsVectorLayer* layer, const QgsDiagramLayerSettings *s ) override;
808  virtual void registerFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext(), QString dxfLayer = QString::null ) override;
809  virtual void registerDiagramFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() ) override;
811  virtual void drawLabeling( QgsRenderContext& context ) override;
813  virtual void exit() override;
814 
817  Q_DECL_DEPRECATED virtual QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) override;
820  Q_DECL_DEPRECATED virtual QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) override;
821 
824  QgsLabelingResults* takeResults();
825 
827  virtual QgsLabelingEngineInterface* clone() override;
828 
830  void drawLabelCandidateRect( pal::LabelPosition* lp, QPainter* painter, const QgsMapToPixel* xform );
833  virtual void drawLabel( pal::LabelPosition* label, QgsRenderContext& context, QgsPalLayerSettings& tmpLyr, DrawLabelType drawType, double dpiRatio = 1.0 );
834 
835  static void drawLabelBuffer( QgsRenderContext& context,
836  const QgsLabelComponent &component,
837  const QgsPalLayerSettings& tmpLyr );
838 
839  static void drawLabelBackground( QgsRenderContext& context,
840  QgsLabelComponent component,
841  const QgsPalLayerSettings& tmpLyr );
842 
843  static void drawLabelShadow( QgsRenderContext &context,
844  const QgsLabelComponent &component,
845  const QgsPalLayerSettings& tmpLyr );
846 
848  void loadEngineSettings();
849  void saveEngineSettings();
850  void clearEngineSettings();
852  Q_DECL_DEPRECATED bool isStoredWithProject() const { return true; }
854  Q_DECL_DEPRECATED void setStoredWithProject( bool store ) { Q_UNUSED( store ); }
855 
864  static QgsGeometry* prepareGeometry( const QgsGeometry *geometry, const QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry = 0 );
865 
874  static bool geometryRequiresPreparation( const QgsGeometry *geometry, const QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry = 0 );
875 
883  static QStringList splitToLines( const QString& text, const QString& wrapCharacter );
884 
892  static QStringList splitToGraphemes( const QString& text );
893 
894  protected:
895  // update temporary QgsPalLayerSettings with any data defined text style values
896  void dataDefinedTextStyle( QgsPalLayerSettings& tmpLyr,
898 
899  // update temporary QgsPalLayerSettings with any data defined text formatting values
900  void dataDefinedTextFormatting( QgsPalLayerSettings& tmpLyr,
902 
903  // update temporary QgsPalLayerSettings with any data defined text buffer values
904  void dataDefinedTextBuffer( QgsPalLayerSettings& tmpLyr,
906 
907  // update temporary QgsPalLayerSettings with any data defined shape background values
908  void dataDefinedShapeBackground( QgsPalLayerSettings& tmpLyr,
910 
911  // update temporary QgsPalLayerSettings with any data defined drop shadow values
912  void dataDefinedDropShadow( QgsPalLayerSettings& tmpLyr,
914 
915  void deleteTemporaryData();
916 
924  static bool checkMinimumSizeMM( const QgsRenderContext &context, const QgsGeometry *geom, double minSize );
925 
926  // hashtable of layer settings, being filled during labeling (key = layer ID)
928  // hashtable of active diagram layers (key = layer ID)
931 
933  int mCandPoint, mCandLine, mCandPolygon;
935 
937 
938  // list of candidates from last labeling
941  bool mShowingAllLabels; // whether to avoid collisions or not
942  bool mShowingShadowRects; // whether to show debugging rectangles for drop shadows
943  bool mShowingPartialsLabels; // whether to avoid partials labels or not
944  bool mDrawOutlineLabels; // whether to draw labels as text or outlines
945 
947 
948  friend class QgsPalLayerSettings;
949 };
951 
952 
953 #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:86
void setShowingCandidates(bool showing)
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
QgsMapUnitScale shapeSizeMapUnitScale
A container class for data source field mapping or expression.
QgsMapUnitScale shadowRadiusMapUnitScale
pal::Layer * palLayer
virtual int prepareLayer(QgsVectorLayer *layer, QStringList &attrNames, QgsRenderContext &ctx)=0
called when starting rendering of a layer
void setOrigin(const QgsPoint &point)
const QgsMapSettings * mMapSettings
pal::Pal * mPal
const QString & text() const
virtual void clearActiveLayer(const QString &layerID)=0
clears data defined objects from PAL layer settings for a registered layer
virtual QgsPalLayerSettings & layer(const QString &layerName)=0
returns PAL layer settings for a registered layer
A class to query the labeling structure at a given point (small wraper around pal RTree class) ...
double obstacleFactor
Obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels, 1.0 less likely to be covered
void setShowingPartialsLabels(bool showing)
QPainter::CompositionMode bufferBlendMode
A layer of spacial entites.
Definition: layer.h:57
double rotationOffset() const
QgsMapUnitScale shadowOffsetMapUnitScale
const QgsPoint & size() const
bool mShowingPartialsLabels
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:464
QuadrantPosition quadOffset
bool useRotation() const
void setUseOrigin(const bool use)
Pal main class.
Definition: pal.h:109
Container of fields for a vector layer.
Definition: qgsfield.h:173
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:75
bool drawLabels
Whether to draw labels for this layer.
void setUseCenter(const bool use)
QgsMapUnitScale repeatDistanceMapUnitScale
MultiLineAlign multilineAlign
virtual int addDiagramLayer(QgsVectorLayer *layer, const QgsDiagramLayerSettings *s)
adds a diagram layer to the labeling engine
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:162
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)
QList< QgsPalGeometry * > geometries
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
QHash< QString, QgsDiagramLayerSettings > mActiveDiagramLayers
Q_DECL_DEPRECATED bool isStoredWithProject() const
struct pal::_chain Chain
void setCenter(const QgsPoint &point)
const QgsMapToPixel * xform
QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined * > dataDefinedProperties
Map of current data defined properties.
bool isShowingPartialsLabels() const
void setText(const QString &text)
QgsMapUnitScale bufferSizeMapUnitScale
QgsFeature * mCurFeat
QPainter::CompositionMode shapeBlendMode
SizeUnit
Units used for option sizes, before being converted to rendered sizes.
const QList< QgsLabelCandidate > & candidates()
A class to represent a point.
Definition: qgspoint.h:63
QHash< QString, QgsPalLayerSettings > mActiveLayers
Qt::PenJoinStyle shapeJoinStyle
unsigned int upsidedownLabels
void setDpiRatio(const double ratio)
unsigned int placementFlags
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:465
bool isShowingCandidates() const
void setDrawingOutlineLabels(bool outline)
Contains information about the context of a rendering operation.
void setShowingShadowRectangles(bool showing)
void setPicture(QPicture *picture)
void setOffset(const QgsPoint &point)
virtual void registerFeature(const QString &layerID, QgsFeature &feat, const QgsRenderContext &context=QgsRenderContext(), QString dxfLayer=QString::null)=0
called for every feature
QgsMapUnitScale distMapUnitScale
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.
QgsLabelCandidate(QRectF r, double c)
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
bool isShowingAllLabels() const
void setShowingAllLabels(bool showing)
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...
bool isShowingShadowRectangles() const
QgsMapUnitScale shapeOffsetMapUnitScale
QList< QgsLabelCandidate > mCandidates
Labeling engine interface.
void setPictureBuffer(const double buffer)
bool isDrawingOutlineLabels() const
void setUseRotation(const bool use)
virtual void registerDiagramFeature(const QString &layerID, QgsFeature &feat, const QgsRenderContext &context=QgsRenderContext())
called for every diagram feature
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
QgsLabelingResults * mResults
const QgsFields * mCurFields
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels...
DirectionSymbols placeDirectionSymbol