QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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, QString dxfLayer );
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 
504  double scaleToPixelContext( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
505 
510  QMap<QgsPalLayerSettings::DataDefinedProperties, QPair<QString, int> > dataDefinedNames() const { return mDataDefinedNames; }
511 
512  // temporary stuff: set when layer gets prepared or labeled
513  // NOTE: not in Python binding
520  QgsPoint ptZero, ptOne;
521  QList<QgsPalGeometry*> geometries;
523  int mFeaturesToLabel; // total features that will probably be labeled, may be less (figured before PAL)
524  int mFeatsSendingToPal; // total features tested for sending into PAL (relative to maxNumLabels)
525  int mFeatsRegPal; // number of features registered in PAL, when using limitNumLabels
526 
529 
530  bool showingShadowRects; // whether to show debug rectangles for drop shadows
531 
532  private:
533  void readDataDefinedPropertyMap( QgsVectorLayer* layer,
535  QgsDataDefined* > & propertyMap );
536  void writeDataDefinedPropertyMap( QgsVectorLayer* layer,
538  QgsDataDefined* > & propertyMap );
539  void readDataDefinedProperty( QgsVectorLayer* layer,
542  QgsDataDefined* > & propertyMap );
543 
544  // convenience data defined evaluation function
545  bool dataDefinedValEval( const QString& valType,
547  QVariant& exprVal );
548 
549  void parseTextStyle( QFont& labelFont,
551  const QgsRenderContext& context );
552 
553  void parseTextBuffer();
554 
555  void parseTextFormatting();
556 
557  void parseShapeBackground();
558 
559  void parseDropShadow();
560 
563  bool checkMinimumSizeMM( const QgsRenderContext& ct, QgsGeometry* geom, double minSize ) const;
564 
565 
566  QMap<DataDefinedProperties, QVariant> dataDefinedValues;
567  QgsExpression* expression;
568  QMap<QgsPalLayerSettings::DataDefinedProperties, QPair<QString, int> > mDataDefinedNames;
569 
570  QFontDatabase mFontDB;
571 };
572 
573 class CORE_EXPORT QgsLabelCandidate
574 {
575  public:
576  QgsLabelCandidate( QRectF r, double c ): rect( r ), cost( c ) {}
577 
578  QRectF rect;
579  double cost;
580 };
581 
586 class CORE_EXPORT QgsLabelComponent
587 {
588  public:
590  : mText( QString() )
591  , mOrigin( QgsPoint() )
592  , mUseOrigin( false )
593  , mRotation( 0.0 )
594  , mRotationOffset( 0.0 )
595  , mUseRotation( false )
596  , mCenter( QgsPoint() )
597  , mUseCenter( false )
598  , mSize( QgsPoint() )
599  , mOffset( QgsPoint() )
600  , mPicture( 0 )
601  , mPictureBuffer( 0.0 )
602  , mDpiRatio( 1.0 )
603  {}
604 
605  // methods
606 
607  const QString& text() { return mText; }
608  void setText( const QString& text ) { mText = text; }
609 
610  const QgsPoint& origin() { return mOrigin; }
611  void setOrigin( QgsPoint point ) { mOrigin = point; }
612 
613  bool useOrigin() const { return mUseOrigin; }
614  void setUseOrigin( bool use ) { mUseOrigin = use; }
615 
616  double rotation() const { return mRotation; }
617  void setRotation( double rotation ) { mRotation = rotation; }
618 
619  double rotationOffset() const { return mRotationOffset; }
620  void setRotationOffset( double rotation ) { mRotationOffset = rotation; }
621 
622  bool useRotation() const { return mUseRotation; }
623  void setUseRotation( bool use ) { mUseRotation = use; }
624 
625  const QgsPoint& center() { return mCenter; }
626  void setCenter( QgsPoint point ) { mCenter = point; }
627 
628  bool useCenter() const { return mUseCenter; }
629  void setUseCenter( bool use ) { mUseCenter = use; }
630 
631  const QgsPoint& size() { return mSize; }
632  void setSize( QgsPoint point ) { mSize = point; }
633 
634  const QgsPoint& offset() { return mOffset; }
635  void setOffset( QgsPoint point ) { mOffset = point; }
636 
637  const QPicture* picture() { return mPicture; }
638  void setPicture( QPicture* picture ) { mPicture = picture; }
639 
640  double pictureBuffer() const { return mPictureBuffer; }
641  void setPictureBuffer( double buffer ) { mPictureBuffer = buffer; }
642 
643  double dpiRatio() const { return mDpiRatio; }
644  void setDpiRatio( double ratio ) { mDpiRatio = ratio; }
645 
646  private:
647  // current label component text,
648  // e.g. single line in a multi-line label or charcater in curved labeling
649  QString mText;
650  // current origin point for painting (generally current painter rotation point)
651  QgsPoint mOrigin;
652  // whether to translate the painter to supplied origin
653  bool mUseOrigin;
654  // any rotation to be applied to painter (in radians)
655  double mRotation;
656  // any rotation to be applied to painter (in radians) after initial rotation
657  double mRotationOffset;
658  // whether to use the rotation to rotate the painter
659  bool mUseRotation;
660  // current center point of label compnent, after rotation
661  QgsPoint mCenter;
662  // whether to translate the painter to supplied origin based upon center
663  bool mUseCenter;
664  // width and height of label component, transformed and ready for painting
665  QgsPoint mSize;
666  // any translation offsets to be applied before painting, transformed and ready for painting
667  QgsPoint mOffset;
668 
669  // a stored QPicture of painting for the component
670  QPicture* mPicture;
671  // buffer for component to accommodate graphic items ignored by QPicture,
672  // e.g. half-width of an applied QPen, which would extend beyond boundingRect() of QPicture
673  double mPictureBuffer;
674 
675  // a ratio of native painter dpi and that of rendering context's painter
676  double mDpiRatio;
677 };
678 
679 
684 class CORE_EXPORT QgsLabelingResults
685 {
686  public:
689 
691  QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) const;
693  QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) const;
694 
695  private:
696  QgsLabelingResults( const QgsLabelingResults& ) {} // no copying allowed
697 
698  QgsLabelSearchTree* mLabelSearchTree;
699 
700  friend class QgsPalLabeling;
701 };
702 
704 class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface
705 {
706  public:
708  {
709  LabelText = 0,
713  LabelShadow
714  };
715 
716  QgsPalLabeling();
717  ~QgsPalLabeling();
718 
719  QgsPalLayerSettings& layer( const QString& layerName );
720 
721  void numCandidatePositions( int& candPoint, int& candLine, int& candPolygon );
722  void setNumCandidatePositions( int candPoint, int candLine, int candPolygon );
723 
724  enum Search { Chain, Popmusic_Tabu, Popmusic_Chain, Popmusic_Tabu_Chain, Falp };
725 
726  void setSearchMethod( Search s );
727  Search searchMethod() const;
728 
729  bool isShowingCandidates() const { return mShowingCandidates; }
730  void setShowingCandidates( bool showing ) { mShowingCandidates = showing; }
731  const QList<QgsLabelCandidate>& candidates() { return mCandidates; }
732 
733  bool isShowingShadowRectangles() const { return mShowingShadowRects; }
734  void setShowingShadowRectangles( bool showing ) { mShowingShadowRects = showing; }
735 
736  bool isShowingAllLabels() const { return mShowingAllLabels; }
737  void setShowingAllLabels( bool showing ) { mShowingAllLabels = showing; }
738 
739  bool isShowingPartialsLabels() const { return mShowingPartialsLabels; }
740  void setShowingPartialsLabels( bool showing ) { mShowingPartialsLabels = showing; }
741 
743  bool isDrawingOutlineLabels() const { return mDrawOutlineLabels; }
744  void setDrawingOutlineLabels( bool outline ) { mDrawOutlineLabels = outline; }
745 
746  // implemented methods from labeling engine interface
747 
750  Q_DECL_DEPRECATED virtual void init( QgsMapRenderer* mr );
752  virtual void init( const QgsMapSettings& mapSettings );
754  virtual bool willUseLayer( QgsVectorLayer* layer );
755 
758  static bool staticWillUseLayer( QgsVectorLayer* layer );
759  static bool staticWillUseLayer( const QString& layerID );
760 
762  virtual void clearActiveLayers();
764  virtual void clearActiveLayer( const QString& layerID );
766  virtual int prepareLayer( QgsVectorLayer* layer, QStringList &attrNames, QgsRenderContext& ctx );
768  virtual int addDiagramLayer( QgsVectorLayer* layer, const QgsDiagramLayerSettings *s );
770  virtual void registerFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext(), QString dxfLayer = QString::null );
771  virtual void registerDiagramFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() );
773  virtual void drawLabeling( QgsRenderContext& context );
775  virtual void exit();
776 
779  Q_DECL_DEPRECATED virtual QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p );
782  Q_DECL_DEPRECATED virtual QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r );
783 
786  QgsLabelingResults* takeResults();
787 
790 
792  void drawLabelCandidateRect( pal::LabelPosition* lp, QPainter* painter, const QgsMapToPixel* xform );
795  virtual void drawLabel( pal::LabelPosition* label, QgsRenderContext& context, QgsPalLayerSettings& tmpLyr, DrawLabelType drawType, double dpiRatio = 1.0 );
796 
797  static void drawLabelBuffer( QgsRenderContext& context,
798  QgsLabelComponent component,
799  const QgsPalLayerSettings& tmpLyr );
800 
801  static void drawLabelBackground( QgsRenderContext& context,
802  QgsLabelComponent component,
803  const QgsPalLayerSettings& tmpLyr );
804 
805  static void drawLabelShadow( QgsRenderContext& context,
806  QgsLabelComponent component,
807  const QgsPalLayerSettings& tmpLyr );
808 
810  void loadEngineSettings();
811  void saveEngineSettings();
812  void clearEngineSettings();
814  Q_DECL_DEPRECATED bool isStoredWithProject() const { return true; }
816  Q_DECL_DEPRECATED void setStoredWithProject( bool store ) { Q_UNUSED( store ); }
817 
818  protected:
819  // update temporary QgsPalLayerSettings with any data defined text style values
820  void dataDefinedTextStyle( QgsPalLayerSettings& tmpLyr,
821  const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues );
822 
823  // update temporary QgsPalLayerSettings with any data defined text formatting values
824  void dataDefinedTextFormatting( QgsPalLayerSettings& tmpLyr,
825  const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues );
826 
827  // update temporary QgsPalLayerSettings with any data defined text buffer values
828  void dataDefinedTextBuffer( QgsPalLayerSettings& tmpLyr,
829  const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues );
830 
831  // update temporary QgsPalLayerSettings with any data defined shape background values
832  void dataDefinedShapeBackground( QgsPalLayerSettings& tmpLyr,
833  const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues );
834 
835  // update temporary QgsPalLayerSettings with any data defined drop shadow values
836  void dataDefinedDropShadow( QgsPalLayerSettings& tmpLyr,
837  const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues );
838 
839  void deleteTemporaryData();
840 
841  // hashtable of layer settings, being filled during labeling (key = layer ID)
842  QHash<QString, QgsPalLayerSettings> mActiveLayers;
843  // hashtable of active diagram layers (key = layer ID)
844  QHash<QString, QgsDiagramLayerSettings> mActiveDiagramLayers;
846 
848  int mCandPoint, mCandLine, mCandPolygon;
850 
852 
853  // list of candidates from last labeling
854  QList<QgsLabelCandidate> mCandidates;
856  bool mShowingAllLabels; // whether to avoid collisions or not
857  bool mShowingShadowRects; // whether to show debugging rectangles for drop shadows
858  bool mShowingPartialsLabels; // whether to avoid partials labels or not
859  bool mDrawOutlineLabels; // whether to draw labels as text or outlines
860 
862 };
864 
865 
866 #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:87
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
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
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
A layer of spacial entites.
Definition: layer.h:65
double rotationOffset() const
QgsMapUnitScale shadowOffsetMapUnitScale
bool mShowingPartialsLabels
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:439
QuadrantPosition quadOffset
bool useRotation() const
Pal main class.
Definition: pal.h:126
Container of fields for a vector layer.
Definition: qgsfield.h:172
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:34
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()
QPainter::CompositionMode blendMode
const QgsPoint & center()
QHash< QString, QgsDiagramLayerSettings > mActiveDiagramLayers
Q_DECL_DEPRECATED bool isStoredWithProject() const
struct pal::_chain Chain
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.
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
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)
virtual void registerFeature(const QString &layerID, QgsFeature &feat, const QgsRenderContext &context=QgsRenderContext(), QString dxfLayer=QString::null)=0
called for every feature
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)
LabelPositon is a candidate feature label position.
Definition: labelposition.h:53
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
QgsLabelingResults * mResults
const QgsFields * mCurFields
void setOrigin(QgsPoint point)
DirectionSymbols placeDirectionSymbol