QGIS API Documentation  2.4.0-Chugiak
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 class QFontMetricsF;
25 class QPainter;
26 class QPicture;
27 class QgsGeometry;
28 class QgsMapRenderer;
29 class QgsRectangle;
31 class QgsLabelSearchTree;
32 
33 class QgsMapSettings;
34 
35 #include <QString>
36 #include <QFont>
37 #include <QFontDatabase>
38 #include <QColor>
39 #include <QHash>
40 #include <QList>
41 #include <QRectF>
42 
43 namespace pal
44 {
45  class Pal;
46  class Layer;
47  class LabelPosition;
48 }
49 
50 class QgsMapToPixel;
51 class QgsFeature;
52 
53 #include "qgspoint.h"
54 #include "qgsrectangle.h"
55 #include "qgsmaprenderer.h" // definition of QgsLabelingEngineInterface
56 #include "qgsexpression.h"
57 #include "qgsdatadefined.h"
58 #include "qgsdiagramrendererv2.h"
59 #include "qgsmapunitscale.h"
60 
61 class QgsPalGeometry;
62 class QgsVectorLayer;
63 
64 class CORE_EXPORT QgsPalLayerSettings
65 {
66  public:
70 
72  static QgsPalLayerSettings fromLayer( QgsVectorLayer* layer );
73 
74  enum Placement
75  {
76  AroundPoint, // Point / Polygon
77  OverPoint, // Point / Polygon
78  Line, // Line / Polygon
79  Curved, // Line
80  Horizontal, // Polygon
81  Free // Polygon
82  };
83 
85  {
86  OnLine = 1,
87  AboveLine = 2,
88  BelowLine = 4,
89  MapOrientation = 8
90  };
91 
93  {
102  QuadrantBelowRight
103  };
104 
106  {
107  Upright, // upside-down labels (90 <= angle < 270) are shown upright
108  ShowDefined, // show upside down when rotation is layer- or data-defined
109  ShowAll // show upside down for all labels, including dynamic ones
110  };
111 
113  {
114  SymbolLeftRight, // place direction symbols on left/right of label
115  SymbolAbove, // place direction symbols on above label
116  SymbolBelow // place direction symbols on below label
117  };
118 
120  {
121  MultiLeft = 0,
123  MultiRight
124  };
125 
127  {
128  ShapeRectangle = 0,
132  ShapeSVG
133  };
134 
135  enum SizeType
136  {
137  SizeBuffer = 0,
139  SizePercent
140  };
141 
143  {
144  RotationSync = 0,
146  RotationFixed
147  };
148 
150  enum SizeUnit
151  {
152  Points = 0,
153  MM,
155  Percent
156  };
157 
159  {
160  ShadowLowest = 0,
163  ShadowShape
164  };
165 
166  // update mDataDefinedNames QMap in constructor when adding/deleting enum value
168  {
169  // text style
170  Size = 0,
171  Bold = 1,
172  Italic = 2,
173  Underline = 3,
174  Color = 4,
175  Strikeout = 5,
176  Family = 6,
177  FontStyle = 21,
178  FontSizeUnit = 22,
179  FontTransp = 18,
180  FontCase = 27,
181  FontLetterSpacing = 28,
182  FontWordSpacing = 29,
183  FontBlendMode = 30,
184 
185  // text formatting
186  MultiLineWrapChar = 31,
187  MultiLineHeight = 32,
188  MultiLineAlignment = 33,
189  DirSymbDraw = 34,
190  DirSymbLeft = 35,
191  DirSymbRight = 36,
192  DirSymbPlacement = 37,
193  DirSymbReverse = 38,
194  NumFormat = 39,
195  NumDecimals = 40,
196  NumPlusSign = 41,
197 
198  // text buffer
199  BufferDraw = 42,
200  BufferSize = 7,
201  BufferUnit = 43,
202  BufferColor = 8,
203  BufferTransp = 19,
204  BufferJoinStyle = 44,
205  BufferBlendMode = 45,
206 
207  // background
208  ShapeDraw = 46,
209  ShapeKind = 47,
210  ShapeSVGFile = 48,
211  ShapeSizeType = 49,
212  ShapeSizeX = 50,
213  ShapeSizeY = 85,
214  ShapeSizeUnits = 51,
215  ShapeRotationType = 52,
216  ShapeRotation = 53,
217  ShapeOffset = 54,
218  ShapeOffsetUnits = 55,
219  ShapeRadii = 56,
220  ShapeRadiiUnits = 57,
221  ShapeTransparency = 63,
222  ShapeBlendMode = 64,
223  ShapeFillColor = 58,
224  ShapeBorderColor = 59,
225  ShapeBorderWidth = 60,
226  ShapeBorderWidthUnits = 61,
227  ShapeJoinStyle = 62,
228 
229  // drop shadow
230  ShadowDraw = 65,
231  ShadowUnder = 66,
232  ShadowOffsetAngle = 67,
233  ShadowOffsetDist = 68,
234  ShadowOffsetUnits = 69,
235  ShadowRadius = 70,
236  ShadowRadiusUnits = 71,
237  ShadowTransparency = 72,
238  ShadowScale = 73,
239  ShadowColor = 74,
240  ShadowBlendMode = 75,
241 
242  // placement
243  CentroidWhole = 76,
244  OffsetQuad = 77,
245  OffsetXY = 78,
246  OffsetUnits = 80,
247  LabelDistance = 13,
248  DistanceUnits = 81,
249  OffsetRotation = 82,
250  CurvedCharAngleInOut = 83,
251  // (data defined only)
252  PositionX = 9, //x-coordinate data defined label position
253  PositionY = 10, //y-coordinate data defined label position
254  Hali = 11, //horizontal alignment for data defined label position (Left, Center, Right)
255  Vali = 12, //vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top)
256  Rotation = 14, //data defined rotation
257  RepeatDistance = 84,
258  RepeatDistanceUnit = 86,
259 
260  // rendering
261  ScaleVisibility = 23,
262  MinScale = 16,
263  MaxScale = 17,
264  FontLimitPixel = 24,
265  FontMinPixel = 25,
266  FontMaxPixel = 26,
267  // (data defined only)
268  Show = 15,
269  AlwaysShow = 20
270  };
271 
272  // whether to label this layer
273  bool enabled;
274 
275  //-- text style
276 
277  QString fieldName;
278 
282 
285  QgsExpression* getLabelExpression();
286 
287  QFont textFont;
288  QString textNamedStyle;
289  bool fontSizeInMapUnits; //true if font size is in map units (otherwise in points)
290  QgsMapUnitScale fontSizeMapUnitScale; // scale range for map units for font size
291  QColor textColor;
293  QPainter::CompositionMode blendMode;
295 
296  //-- text formatting
297 
298  QString wrapChar;
299  double multilineHeight; //0.0 to 10.0, leading between lines as multiplyer of line height
300  MultiLineAlign multilineAlign; // horizontal alignment of multi-line labels
301 
302  // Adds '<' or '>', or user-defined symbol to the label string pointing to the
303  // direction of the line / polygon ring
304  // Works only if Placement == Line
308  DirectionSymbols placeDirectionSymbol; // whether to place left/right, above or below label
310 
312  int decimals;
313  bool plusSign;
314 
315  //-- text buffer
316 
318  double bufferSize; // buffer size
319  bool bufferSizeInMapUnits; //true if buffer is in map units (otherwise in mm)
320  QgsMapUnitScale bufferSizeMapUnitScale; // scale range for map units for buffer size
321  QColor bufferColor;
322  bool bufferNoFill; //set interior of buffer to 100% transparent
324  Qt::PenJoinStyle bufferJoinStyle;
325  QPainter::CompositionMode bufferBlendMode;
326 
327  //-- shape background
328 
329  bool shapeDraw;
331  QString shapeSVGFile;
333  QPointF shapeSize;
338  QPointF shapeOffset;
341  QPointF shapeRadii;
345  QPainter::CompositionMode shapeBlendMode;
351  Qt::PenJoinStyle shapeJoinStyle;
352 
353  //-- drop shadow
354 
362  double shadowRadius;
368  QColor shadowColor;
369  QPainter::CompositionMode shadowBlendMode;
370 
371  //-- placement
372 
374  unsigned int placementFlags;
375 
376  bool centroidWhole; // whether centroid calculated from whole or visible polygon
377  bool centroidInside; // whether centroid-point calculated must be inside polygon
378  double dist; // distance from the feature (in mm)
379  bool distInMapUnits; //true if distance is in map units (otherwise in mm)
381 
385 
386  // offset labels of point/centroid features default to center
387  // move label to quadrant: left/down, don't move, right/up (-1, 0, 1)
389 
390  double xOffset; // offset from point in mm or map units
391  double yOffset; // offset from point in mm or map units
392  bool labelOffsetInMapUnits; //true if label offset is in map units (otherwise in mm)
394  double angleOffset; // rotation applied to offset labels
395  bool preserveRotation; // preserve predefined rotation data during label pin/unpin operations
396 
397  double maxCurvedCharAngleIn; // maximum angle between inside curved label characters (defaults to 20.0, range 20.0 to 60.0)
398  double maxCurvedCharAngleOut; // maximum angle between outside curved label characters (defaults to -20.0, range -20.0 to -95.0)
399 
400  int priority; // 0 = low, 10 = high
401 
402  //-- rendering
403 
405  int scaleMin;
406  int scaleMax;
407 
408  bool fontLimitPixelSize; // true is label should be limited by fontMinPixelSize/fontMaxPixelSize
409  int fontMinPixelSize; // minimum pixel size for showing rendered map unit labels (1 - 1000)
410  int fontMaxPixelSize; // maximum pixel size for showing rendered map unit labels (1 - 10000)
411 
412  bool displayAll; // if true, all features will be labelled even though overlaps occur
413  unsigned int upsidedownLabels; // whether, or how, to show upsidedown labels
414 
415  bool labelPerPart; // whether to label every feature's part or only the biggest one
417 
418  bool limitNumLabels; // whether to limit the number of labels to be drawn
419  int maxNumLabels; // maximum number of labels to be drawn
420 
421  double minFeatureSize; // minimum feature size to be labelled (in mm)
422  bool obstacle; // whether features for layer are obstacles to labels of other layers
423 
424  //-- scale factors
425  double vectorScaleFactor; //scale factor painter units->pixels
426  double rasterCompressFactor; //pixel resolution scale factor
427 
428  // called from register feature hook
429  void calculateLabelSize( const QFontMetricsF* fm, QString text, double& labelX, double& labelY, QgsFeature* f = 0 );
430 
431  // implementation of register feature hook
432  void registerFeature( QgsFeature& f, const QgsRenderContext& context );
433 
434  void readFromLayer( QgsVectorLayer* layer );
435  void writeToLayer( QgsVectorLayer* layer );
436 
441 
445  void setDataDefinedProperty( QgsPalLayerSettings::DataDefinedProperties p,
446  bool active, bool useExpr, const QString& expr, const QString& field );
447 
449  void removeDataDefinedProperty( QgsPalLayerSettings::DataDefinedProperties p );
450 
454  QString updateDataDefinedString( const QString& value );
455 
459  QMap<QString, QString> dataDefinedMap( QgsPalLayerSettings::DataDefinedProperties p ) const;
460 
465  QVariant dataDefinedValue( QgsPalLayerSettings::DataDefinedProperties p, QgsFeature& f, const QgsFields& fields ) const;
466 
471  bool dataDefinedEvaluate( QgsPalLayerSettings::DataDefinedProperties p, QVariant& exprVal ) const;
472 
475  bool dataDefinedIsActive( QgsPalLayerSettings::DataDefinedProperties p ) const;
476 
479  bool dataDefinedUseExpression( QgsPalLayerSettings::DataDefinedProperties p ) const;
480 
483  QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined* > dataDefinedProperties;
484 
485 
494  int sizeToPixel( double size, const QgsRenderContext& c , SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
495 
505  double scaleToPixelContext( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
506 
511  QMap<QgsPalLayerSettings::DataDefinedProperties, QPair<QString, int> > dataDefinedNames() const { return mDataDefinedNames; }
512 
513  // temporary stuff: set when layer gets prepared or labeled
514  // NOTE: not in Python binding
515  pal::Layer* palLayer;
521  QgsPoint ptZero, ptOne;
522  QList<QgsPalGeometry*> geometries;
524  int mFeaturesToLabel; // total features that will probably be labeled, may be less (figured before PAL)
525  int mFeatsSendingToPal; // total features tested for sending into PAL (relative to maxNumLabels)
526  int mFeatsRegPal; // number of features registered in PAL, when using limitNumLabels
527 
530 
531  bool showingShadowRects; // whether to show debug rectangles for drop shadows
532 
533  private:
534  void readDataDefinedPropertyMap( QgsVectorLayer* layer,
536  QgsDataDefined* > & propertyMap );
537  void writeDataDefinedPropertyMap( QgsVectorLayer* layer,
539  QgsDataDefined* > & propertyMap );
540  void readDataDefinedProperty( QgsVectorLayer* layer,
543  QgsDataDefined* > & propertyMap );
544 
545  // convenience data defined evaluation function
546  bool dataDefinedValEval( const QString& valType,
548  QVariant& exprVal );
549 
550  void parseTextStyle( QFont& labelFont,
552  const QgsRenderContext& context );
553 
554  void parseTextBuffer();
555 
556  void parseTextFormatting();
557 
558  void parseShapeBackground();
559 
560  void parseDropShadow();
561 
564  bool checkMinimumSizeMM( const QgsRenderContext& ct, QgsGeometry* geom, double minSize ) const;
565 
566 
567  QMap<DataDefinedProperties, QVariant> dataDefinedValues;
569  QMap<QgsPalLayerSettings::DataDefinedProperties, QPair<QString, int> > mDataDefinedNames;
570 
571  QFontDatabase mFontDB;
572 };
573 
574 class CORE_EXPORT QgsLabelCandidate
575 {
576  public:
577  QgsLabelCandidate( QRectF r, double c ): rect( r ), cost( c ) {}
578 
579  QRectF rect;
580  double cost;
581 };
582 
587 class CORE_EXPORT QgsLabelComponent
588 {
589  public:
591  : mText( QString() )
592  , mOrigin( QgsPoint() )
593  , mUseOrigin( false )
594  , mRotation( 0.0 )
595  , mRotationOffset( 0.0 )
596  , mUseRotation( false )
597  , mCenter( QgsPoint() )
598  , mUseCenter( false )
599  , mSize( QgsPoint() )
600  , mOffset( QgsPoint() )
601  , mPicture( 0 )
602  , mPictureBuffer( 0.0 )
603  , mDpiRatio( 1.0 )
604  {}
605 
606  // methods
607 
608  const QString& text() { return mText; }
609  void setText( const QString& text ) { mText = text; }
610 
611  const QgsPoint& origin() { return mOrigin; }
612  void setOrigin( QgsPoint point ) { mOrigin = point; }
613 
614  bool useOrigin() const { return mUseOrigin; }
615  void setUseOrigin( bool use ) { mUseOrigin = use; }
616 
617  double rotation() const { return mRotation; }
618  void setRotation( double rotation ) { mRotation = rotation; }
619 
620  double rotationOffset() const { return mRotationOffset; }
621  void setRotationOffset( double rotation ) { mRotationOffset = rotation; }
622 
623  bool useRotation() const { return mUseRotation; }
624  void setUseRotation( bool use ) { mUseRotation = use; }
625 
626  const QgsPoint& center() { return mCenter; }
627  void setCenter( QgsPoint point ) { mCenter = point; }
628 
629  bool useCenter() const { return mUseCenter; }
630  void setUseCenter( bool use ) { mUseCenter = use; }
631 
632  const QgsPoint& size() { return mSize; }
633  void setSize( QgsPoint point ) { mSize = point; }
634 
635  const QgsPoint& offset() { return mOffset; }
636  void setOffset( QgsPoint point ) { mOffset = point; }
637 
638  const QPicture* picture() { return mPicture; }
639  void setPicture( QPicture* picture ) { mPicture = picture; }
640 
641  double pictureBuffer() const { return mPictureBuffer; }
642  void setPictureBuffer( double buffer ) { mPictureBuffer = buffer; }
643 
644  double dpiRatio() const { return mDpiRatio; }
645  void setDpiRatio( double ratio ) { mDpiRatio = ratio; }
646 
647  private:
648  // current label component text,
649  // e.g. single line in a multi-line label or charcater in curved labeling
650  QString mText;
651  // current origin point for painting (generally current painter rotation point)
653  // whether to translate the painter to supplied origin
655  // any rotation to be applied to painter (in radians)
656  double mRotation;
657  // any rotation to be applied to painter (in radians) after initial rotation
659  // whether to use the rotation to rotate the painter
661  // current center point of label compnent, after rotation
663  // whether to translate the painter to supplied origin based upon center
665  // width and height of label component, transformed and ready for painting
667  // any translation offsets to be applied before painting, transformed and ready for painting
669 
670  // a stored QPicture of painting for the component
671  QPicture* mPicture;
672  // buffer for component to accommodate graphic items ignored by QPicture,
673  // e.g. half-width of an applied QPen, which would extend beyond boundingRect() of QPicture
675 
676  // a ratio of native painter dpi and that of rendering context's painter
677  double mDpiRatio;
678 };
679 
680 
685 class CORE_EXPORT QgsLabelingResults
686 {
687  public:
690 
692  QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) const;
694  QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) const;
695 
696  private:
697  QgsLabelingResults( const QgsLabelingResults& ) {} // no copying allowed
698 
700 
701  friend class QgsPalLabeling;
702 };
703 
705 class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface
706 {
707  public:
709  {
710  LabelText = 0,
714  LabelShadow
715  };
716 
717  QgsPalLabeling();
718  ~QgsPalLabeling();
719 
720  QgsPalLayerSettings& layer( const QString& layerName );
721 
722  void numCandidatePositions( int& candPoint, int& candLine, int& candPolygon );
723  void setNumCandidatePositions( int candPoint, int candLine, int candPolygon );
724 
725  enum Search { Chain, Popmusic_Tabu, Popmusic_Chain, Popmusic_Tabu_Chain, Falp };
726 
727  void setSearchMethod( Search s );
728  Search searchMethod() const;
729 
730  bool isShowingCandidates() const { return mShowingCandidates; }
731  void setShowingCandidates( bool showing ) { mShowingCandidates = showing; }
732  const QList<QgsLabelCandidate>& candidates() { return mCandidates; }
733 
734  bool isShowingShadowRectangles() const { return mShowingShadowRects; }
735  void setShowingShadowRectangles( bool showing ) { mShowingShadowRects = showing; }
736 
737  bool isShowingAllLabels() const { return mShowingAllLabels; }
738  void setShowingAllLabels( bool showing ) { mShowingAllLabels = showing; }
739 
740  bool isShowingPartialsLabels() const { return mShowingPartialsLabels; }
741  void setShowingPartialsLabels( bool showing ) { mShowingPartialsLabels = showing; }
742 
744  bool isDrawingOutlineLabels() const { return mDrawOutlineLabels; }
745  void setDrawingOutlineLabels( bool outline ) { mDrawOutlineLabels = outline; }
746 
747  // implemented methods from labeling engine interface
748 
751  Q_DECL_DEPRECATED virtual void init( QgsMapRenderer* mr );
753  virtual void init( const QgsMapSettings& mapSettings );
755  virtual bool willUseLayer( QgsVectorLayer* layer );
756 
759  static bool staticWillUseLayer( QgsVectorLayer* layer );
760  static bool staticWillUseLayer( const QString& layerID );
761 
764  virtual void clearActiveLayers();
767  virtual void clearActiveLayer( const QString& layerID );
769  virtual int prepareLayer( QgsVectorLayer* layer, QStringList &attrNames, QgsRenderContext& ctx );
771  virtual int addDiagramLayer( QgsVectorLayer* layer, const QgsDiagramLayerSettings *s );
773  virtual void registerFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() );
774  virtual void registerDiagramFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() );
776  virtual void drawLabeling( QgsRenderContext& context );
778  virtual void exit();
779 
782  Q_DECL_DEPRECATED virtual QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p );
785  Q_DECL_DEPRECATED virtual QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r );
786 
789  QgsLabelingResults* takeResults();
790 
793 
795  void drawLabelCandidateRect( pal::LabelPosition* lp, QPainter* painter, const QgsMapToPixel* xform );
798  virtual void drawLabel( pal::LabelPosition* label, QgsRenderContext& context, QgsPalLayerSettings& tmpLyr, DrawLabelType drawType, double dpiRatio = 1.0 );
799 
800  static void drawLabelBuffer( QgsRenderContext& context,
801  QgsLabelComponent component,
802  const QgsPalLayerSettings& tmpLyr );
803 
804  static void drawLabelBackground( QgsRenderContext& context,
805  QgsLabelComponent component,
806  const QgsPalLayerSettings& tmpLyr );
807 
808  static void drawLabelShadow( QgsRenderContext& context,
809  QgsLabelComponent component,
810  const QgsPalLayerSettings& tmpLyr );
811 
814  void loadEngineSettings();
815  void saveEngineSettings();
816  void clearEngineSettings();
818  Q_DECL_DEPRECATED bool isStoredWithProject() const { return true; }
820  Q_DECL_DEPRECATED void setStoredWithProject( bool store ) { Q_UNUSED( store ); }
821 
822  protected:
823  // update temporary QgsPalLayerSettings with any data defined text style values
824  void dataDefinedTextStyle( QgsPalLayerSettings& tmpLyr,
825  const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues );
826 
827  // update temporary QgsPalLayerSettings with any data defined text formatting values
828  void dataDefinedTextFormatting( QgsPalLayerSettings& tmpLyr,
829  const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues );
830 
831  // update temporary QgsPalLayerSettings with any data defined text buffer values
832  void dataDefinedTextBuffer( QgsPalLayerSettings& tmpLyr,
833  const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues );
834 
835  // update temporary QgsPalLayerSettings with any data defined shape background values
836  void dataDefinedShapeBackground( QgsPalLayerSettings& tmpLyr,
837  const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues );
838 
839  // update temporary QgsPalLayerSettings with any data defined drop shadow values
840  void dataDefinedDropShadow( QgsPalLayerSettings& tmpLyr,
841  const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues );
842 
843  void deleteTemporaryData();
844 
845  // hashtable of layer settings, being filled during labeling (key = layer ID)
846  QHash<QString, QgsPalLayerSettings> mActiveLayers;
847  // hashtable of active diagram layers (key = layer ID)
848  QHash<QString, QgsDiagramLayerSettings> mActiveDiagramLayers;
850 
852  int mCandPoint, mCandLine, mCandPolygon;
854 
855  pal::Pal* mPal;
856 
857  // list of candidates from last labeling
858  QList<QgsLabelCandidate> mCandidates;
860  bool mShowingAllLabels; // whether to avoid collisions or not
861  bool mShowingShadowRects; // whether to show debugging rectangles for drop shadows
862  bool mShowingPartialsLabels; // whether to avoid partials labels or not
863  bool mDrawOutlineLabels; // whether to draw labels as text or outlines
864 
866 };
868 
869 
870 #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:89
void setShowingCandidates(bool showing)
void setRotationOffset(double rotation)
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
QgsExpression * expression
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
const QgsMapSettings * mMapSettings
pal::Pal * mPal
QFontDatabase mFontDB
virtual void clearActiveLayer(const QString &layerID)=0
clears data defined objects from PAL layer settings for a registered layer
const QgsPoint & offset()
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) ...
QColor outline
Definition: qgssvgcache.cpp:82
void setShowingPartialsLabels(bool showing)
QPainter::CompositionMode bufferBlendMode
double rotationOffset() const
QgsMapUnitScale shadowOffsetMapUnitScale
bool mShowingPartialsLabels
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:439
QuadrantPosition quadOffset
bool useRotation() const
virtual void registerFeature(const QString &layerID, QgsFeature &feat, const QgsRenderContext &context=QgsRenderContext())=0
called for every feature
Container of fields for a vector layer.
Definition: qgsfield.h:161
QgsMapUnitScale repeatDistanceMapUnitScale
MultiLineAlign multilineAlign
void setOffset(QgsPoint point)
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:113
bool useCenter() 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
Qt::PenJoinStyle bufferJoinStyle
void setRotation(double rotation)
QgsMapUnitScale fontSizeMapUnitScale
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:33
double rotation() const
Q_DECL_DEPRECATED void setStoredWithProject(bool store)
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
QgsPalLayerSettings mInvalidLayerSettings
virtual QgsLabelingEngineInterface * clone()=0
called when passing engine among map renderers
SizeUnit shapeBorderWidthUnits
const QgsPoint & size()
QMap< QgsPalLayerSettings::DataDefinedProperties, QPair< QString, int > > mDataDefinedNames
QPainter::CompositionMode blendMode
const QgsPoint & center()
QHash< QString, QgsDiagramLayerSettings > mActiveDiagramLayers
Q_DECL_DEPRECATED bool isStoredWithProject() const
void setUseCenter(bool use)
const QgsMapToPixel * xform
QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined * > dataDefinedProperties
Map of current data defined properties.
void setUseOrigin(bool use)
bool isShowingPartialsLabels() const
void setText(const QString &text)
void setDpiRatio(double ratio)
QgsMapUnitScale bufferSizeMapUnitScale
const QgsPoint & origin()
QgsFeature * mCurFeat
QPainter::CompositionMode shapeBlendMode
void setPictureBuffer(double buffer)
SizeUnit
Units used for option sizes, before being converted to rendered sizes.
const QList< QgsLabelCandidate > & candidates()
A class to represent a point geometry.
Definition: qgspoint.h:63
QHash< QString, QgsPalLayerSettings > mActiveLayers
Qt::PenJoinStyle shapeJoinStyle
unsigned int upsidedownLabels
unsigned int placementFlags
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:440
QgsLabelSearchTree * mLabelSearchTree
void setSize(QgsPoint point)
bool isShowingCandidates() const
void setDrawingOutlineLabels(bool outline)
Contains information about the context of a rendering operation.
const QPicture * picture()
void setShowingShadowRectangles(bool showing)
void setPicture(QPicture *picture)
QgsLabelingResults(const QgsLabelingResults &)
QgsMapUnitScale distMapUnitScale
void setUseRotation(bool use)
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)
double pictureBuffer() const
QPainter::CompositionMode shadowBlendMode
bool isExpression
Is this label made from a expression string eg FieldName || 'mm'.
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 setCenter(QgsPoint point)
bool isDrawingOutlineLabels() const
virtual void registerDiagramFeature(const QString &layerID, QgsFeature &feat, const QgsRenderContext &context=QgsRenderContext())
called for every diagram feature
const QString & text()
Represents a vector layer which manages a vector based data sets.
double size
Definition: qgssvgcache.cpp:77
Maintains current state of more grainular and temporal values when creating/painting component parts ...
RotationType shapeRotationType
QgsMapUnitScale labelOffsetMapUnitScale
QMap< DataDefinedProperties, QVariant > dataDefinedValues
QgsLabelingResults * mResults
const QgsFields * mCurFields
void setOrigin(QgsPoint point)
DirectionSymbols placeDirectionSymbol