QGIS API Documentation  2.9.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,
124  MultiFollowPlacement /*< Alignment follows placement of label, eg labels to the left of a feature
125  will be drawn with right alignment*/
126  };
127 
129  {
130  ShapeRectangle = 0,
134  ShapeSVG
135  };
136 
137  enum SizeType
138  {
139  SizeBuffer = 0,
141  SizePercent
142  };
143 
145  {
146  RotationSync = 0,
148  RotationFixed
149  };
150 
152  enum SizeUnit
153  {
154  Points = 0,
155  MM,
157  Percent
158  };
159 
161  {
162  ShadowLowest = 0,
165  ShadowShape
166  };
167 
168  // update mDataDefinedNames QMap in constructor when adding/deleting enum value
170  {
171  // text style
172  Size = 0,
173  Bold = 1,
174  Italic = 2,
175  Underline = 3,
176  Color = 4,
177  Strikeout = 5,
178  Family = 6,
179  FontStyle = 21,
180  FontSizeUnit = 22,
181  FontTransp = 18,
182  FontCase = 27,
183  FontLetterSpacing = 28,
184  FontWordSpacing = 29,
185  FontBlendMode = 30,
186 
187  // text formatting
188  MultiLineWrapChar = 31,
189  MultiLineHeight = 32,
190  MultiLineAlignment = 33,
191  DirSymbDraw = 34,
192  DirSymbLeft = 35,
193  DirSymbRight = 36,
194  DirSymbPlacement = 37,
195  DirSymbReverse = 38,
196  NumFormat = 39,
197  NumDecimals = 40,
198  NumPlusSign = 41,
199 
200  // text buffer
201  BufferDraw = 42,
202  BufferSize = 7,
203  BufferUnit = 43,
204  BufferColor = 8,
205  BufferTransp = 19,
206  BufferJoinStyle = 44,
207  BufferBlendMode = 45,
208 
209  // background
210  ShapeDraw = 46,
211  ShapeKind = 47,
212  ShapeSVGFile = 48,
213  ShapeSizeType = 49,
214  ShapeSizeX = 50,
215  ShapeSizeY = 85,
216  ShapeSizeUnits = 51,
217  ShapeRotationType = 52,
218  ShapeRotation = 53,
219  ShapeOffset = 54,
220  ShapeOffsetUnits = 55,
221  ShapeRadii = 56,
222  ShapeRadiiUnits = 57,
223  ShapeTransparency = 63,
224  ShapeBlendMode = 64,
225  ShapeFillColor = 58,
226  ShapeBorderColor = 59,
227  ShapeBorderWidth = 60,
228  ShapeBorderWidthUnits = 61,
229  ShapeJoinStyle = 62,
230 
231  // drop shadow
232  ShadowDraw = 65,
233  ShadowUnder = 66,
234  ShadowOffsetAngle = 67,
235  ShadowOffsetDist = 68,
236  ShadowOffsetUnits = 69,
237  ShadowRadius = 70,
238  ShadowRadiusUnits = 71,
239  ShadowTransparency = 72,
240  ShadowScale = 73,
241  ShadowColor = 74,
242  ShadowBlendMode = 75,
243 
244  // placement
245  CentroidWhole = 76,
246  OffsetQuad = 77,
247  OffsetXY = 78,
248  OffsetUnits = 80,
249  LabelDistance = 13,
250  DistanceUnits = 81,
251  OffsetRotation = 82,
252  CurvedCharAngleInOut = 83,
253  // (data defined only)
254  PositionX = 9, //x-coordinate data defined label position
255  PositionY = 10, //y-coordinate data defined label position
256  Hali = 11, //horizontal alignment for data defined label position (Left, Center, Right)
257  Vali = 12, //vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top)
258  Rotation = 14, //data defined rotation
259  RepeatDistance = 84,
260  RepeatDistanceUnit = 86,
261 
262  // rendering
263  ScaleVisibility = 23,
264  MinScale = 16,
265  MaxScale = 17,
266  FontLimitPixel = 24,
267  FontMinPixel = 25,
268  FontMaxPixel = 26,
269  // (data defined only)
270  Show = 15,
271  AlwaysShow = 20
272  };
273 
274  // whether to label this layer
275  bool enabled;
276 
277  //-- text style
278 
279  QString fieldName;
280 
284 
287  QgsExpression* getLabelExpression();
288 
289  QFont textFont;
290  QString textNamedStyle;
291  bool fontSizeInMapUnits; //true if font size is in map units (otherwise in points)
292  QgsMapUnitScale fontSizeMapUnitScale; // scale range for map units for font size
293  QColor textColor;
295  QPainter::CompositionMode blendMode;
297 
298  //-- text formatting
299 
300  QString wrapChar;
301  double multilineHeight; //0.0 to 10.0, leading between lines as multiplyer of line height
302  MultiLineAlign multilineAlign; // horizontal alignment of multi-line labels
303 
304  // Adds '<' or '>', or user-defined symbol to the label string pointing to the
305  // direction of the line / polygon ring
306  // Works only if Placement == Line
310  DirectionSymbols placeDirectionSymbol; // whether to place left/right, above or below label
312 
314  int decimals;
315  bool plusSign;
316 
317  //-- text buffer
318 
320  double bufferSize; // buffer size
321  bool bufferSizeInMapUnits; //true if buffer is in map units (otherwise in mm)
322  QgsMapUnitScale bufferSizeMapUnitScale; // scale range for map units for buffer size
323  QColor bufferColor;
324  bool bufferNoFill; //set interior of buffer to 100% transparent
326  Qt::PenJoinStyle bufferJoinStyle;
327  QPainter::CompositionMode bufferBlendMode;
328 
329  //-- shape background
330 
331  bool shapeDraw;
333  QString shapeSVGFile;
335  QPointF shapeSize;
340  QPointF shapeOffset;
343  QPointF shapeRadii;
347  QPainter::CompositionMode shapeBlendMode;
353  Qt::PenJoinStyle shapeJoinStyle;
354 
355  //-- drop shadow
356 
364  double shadowRadius;
370  QColor shadowColor;
371  QPainter::CompositionMode shadowBlendMode;
372 
373  //-- placement
374 
376  unsigned int placementFlags;
377 
378  bool centroidWhole; // whether centroid calculated from whole or visible polygon
379  bool centroidInside; // whether centroid-point calculated must be inside polygon
380  double dist; // distance from the feature (in mm)
381  bool distInMapUnits; //true if distance is in map units (otherwise in mm)
383 
387 
388  // offset labels of point/centroid features default to center
389  // move label to quadrant: left/down, don't move, right/up (-1, 0, 1)
391 
392  double xOffset; // offset from point in mm or map units
393  double yOffset; // offset from point in mm or map units
394  bool labelOffsetInMapUnits; //true if label offset is in map units (otherwise in mm)
396  double angleOffset; // rotation applied to offset labels
397  bool preserveRotation; // preserve predefined rotation data during label pin/unpin operations
398 
399  double maxCurvedCharAngleIn; // maximum angle between inside curved label characters (defaults to 20.0, range 20.0 to 60.0)
400  double maxCurvedCharAngleOut; // maximum angle between outside curved label characters (defaults to -20.0, range -20.0 to -95.0)
401 
402  int priority; // 0 = low, 10 = high
403 
404  //-- rendering
405 
407  int scaleMin;
408  int scaleMax;
409 
410  bool fontLimitPixelSize; // true is label should be limited by fontMinPixelSize/fontMaxPixelSize
411  int fontMinPixelSize; // minimum pixel size for showing rendered map unit labels (1 - 1000)
412  int fontMaxPixelSize; // maximum pixel size for showing rendered map unit labels (1 - 10000)
413 
414  bool displayAll; // if true, all features will be labelled even though overlaps occur
415  unsigned int upsidedownLabels; // whether, or how, to show upsidedown labels
416 
417  bool labelPerPart; // whether to label every feature's part or only the biggest one
419 
420  bool limitNumLabels; // whether to limit the number of labels to be drawn
421  int maxNumLabels; // maximum number of labels to be drawn
422 
423  double minFeatureSize; // minimum feature size to be labelled (in mm)
424  bool obstacle; // whether features for layer are obstacles to labels of other layers
425 
426  //-- scale factors
427  double vectorScaleFactor; //scale factor painter units->pixels
428  double rasterCompressFactor; //pixel resolution scale factor
429 
430  // called from register feature hook
431  void calculateLabelSize( const QFontMetricsF* fm, QString text, double& labelX, double& labelY, QgsFeature* f = 0 );
432 
433  // implementation of register feature hook
434  void registerFeature( QgsFeature& f, const QgsRenderContext& context, QString dxfLayer );
435 
436  void readFromLayer( QgsVectorLayer* layer );
437  void writeToLayer( QgsVectorLayer* layer );
438 
443 
447  void setDataDefinedProperty( QgsPalLayerSettings::DataDefinedProperties p,
448  bool active, bool useExpr, const QString& expr, const QString& field );
449 
451  void removeDataDefinedProperty( QgsPalLayerSettings::DataDefinedProperties p );
452 
456  QString updateDataDefinedString( const QString& value );
457 
461  QMap<QString, QString> dataDefinedMap( QgsPalLayerSettings::DataDefinedProperties p ) const;
462 
467  QVariant dataDefinedValue( QgsPalLayerSettings::DataDefinedProperties p, QgsFeature& f, const QgsFields& fields ) const;
468 
473  bool dataDefinedEvaluate( QgsPalLayerSettings::DataDefinedProperties p, QVariant& exprVal ) const;
474 
477  bool dataDefinedIsActive( QgsPalLayerSettings::DataDefinedProperties p ) const;
478 
481  bool dataDefinedUseExpression( QgsPalLayerSettings::DataDefinedProperties p ) const;
482 
485  QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined* > dataDefinedProperties;
486 
487 
496  int sizeToPixel( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
497 
506  double scaleToPixelContext( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
507 
512  QMap<QgsPalLayerSettings::DataDefinedProperties, QPair<QString, int> > dataDefinedNames() const { return mDataDefinedNames; }
513 
514  // temporary stuff: set when layer gets prepared or labeled
515  // NOTE: not in Python binding
522  QgsPoint ptZero, ptOne;
523  QList<QgsPalGeometry*> geometries;
525  int mFeaturesToLabel; // total features that will probably be labeled, may be less (figured before PAL)
526  int mFeatsSendingToPal; // total features tested for sending into PAL (relative to maxNumLabels)
527  int mFeatsRegPal; // number of features registered in PAL, when using limitNumLabels
528 
531 
532  bool showingShadowRects; // whether to show debug rectangles for drop shadows
533 
534  private:
535  void readDataDefinedPropertyMap( QgsVectorLayer* layer,
537  QgsDataDefined* > & propertyMap );
538  void writeDataDefinedPropertyMap( QgsVectorLayer* layer,
540  QgsDataDefined* > & propertyMap );
541  void readDataDefinedProperty( QgsVectorLayer* layer,
544  QgsDataDefined* > & propertyMap );
545 
546  // convenience data defined evaluation function
547  bool dataDefinedValEval( const QString& valType,
549  QVariant& exprVal );
550 
551  void parseTextStyle( QFont& labelFont,
553  const QgsRenderContext& context );
554 
555  void parseTextBuffer();
556 
557  void parseTextFormatting();
558 
559  void parseShapeBackground();
560 
561  void parseDropShadow();
562 
565  bool checkMinimumSizeMM( const QgsRenderContext& ct, QgsGeometry* geom, double minSize ) const;
566 
567 
568  QMap<DataDefinedProperties, QVariant> dataDefinedValues;
569  QgsExpression* expression;
570  QMap<QgsPalLayerSettings::DataDefinedProperties, QPair<QString, int> > mDataDefinedNames;
571 
572  QFontDatabase mFontDB;
573 };
574 
575 class CORE_EXPORT QgsLabelCandidate
576 {
577  public:
578  QgsLabelCandidate( QRectF r, double c ): rect( r ), cost( c ) {}
579 
580  QRectF rect;
581  double cost;
582 };
583 
588 class CORE_EXPORT QgsLabelComponent
589 {
590  public:
592  : mText( QString() )
593  , mOrigin( QgsPoint() )
594  , mUseOrigin( false )
595  , mRotation( 0.0 )
596  , mRotationOffset( 0.0 )
597  , mUseRotation( false )
598  , mCenter( QgsPoint() )
599  , mUseCenter( false )
600  , mSize( QgsPoint() )
601  , mOffset( QgsPoint() )
602  , mPicture( 0 )
603  , mPictureBuffer( 0.0 )
604  , mDpiRatio( 1.0 )
605  {}
606 
607  // methods
608 
609  const QString& text() const { return mText; }
610  void setText( const QString& text ) { mText = text; }
611 
612  const QgsPoint& origin() const { return mOrigin; }
613  void setOrigin( const QgsPoint& point ) { mOrigin = point; }
614 
615  bool useOrigin() const { return mUseOrigin; }
616  void setUseOrigin( const bool use ) { mUseOrigin = use; }
617 
618  double rotation() const { return mRotation; }
619  void setRotation( const double rotation ) { mRotation = rotation; }
620 
621  double rotationOffset() const { return mRotationOffset; }
622  void setRotationOffset( const double rotation ) { mRotationOffset = rotation; }
623 
624  bool useRotation() const { return mUseRotation; }
625  void setUseRotation( const bool use ) { mUseRotation = use; }
626 
627  const QgsPoint& center() const { return mCenter; }
628  void setCenter( const QgsPoint& point ) { mCenter = point; }
629 
630  bool useCenter() const { return mUseCenter; }
631  void setUseCenter( const bool use ) { mUseCenter = use; }
632 
633  const QgsPoint& size() const { return mSize; }
634  void setSize( const QgsPoint& point ) { mSize = point; }
635 
636  const QgsPoint& offset() const { return mOffset; }
637  void setOffset( const QgsPoint& point ) { mOffset = point; }
638 
639  const QPicture* picture() const { return mPicture; }
640  void setPicture( QPicture* picture ) { mPicture = picture; }
641 
642  double pictureBuffer() const { return mPictureBuffer; }
643  void setPictureBuffer( const double buffer ) { mPictureBuffer = buffer; }
644 
645  double dpiRatio() const { return mDpiRatio; }
646  void setDpiRatio( const double ratio ) { mDpiRatio = ratio; }
647 
648  private:
649  // current label component text,
650  // e.g. single line in a multi-line label or charcater in curved labeling
651  QString mText;
652  // current origin point for painting (generally current painter rotation point)
653  QgsPoint mOrigin;
654  // whether to translate the painter to supplied origin
655  bool mUseOrigin;
656  // any rotation to be applied to painter (in radians)
657  double mRotation;
658  // any rotation to be applied to painter (in radians) after initial rotation
659  double mRotationOffset;
660  // whether to use the rotation to rotate the painter
661  bool mUseRotation;
662  // current center point of label compnent, after rotation
663  QgsPoint mCenter;
664  // whether to translate the painter to supplied origin based upon center
665  bool mUseCenter;
666  // width and height of label component, transformed and ready for painting
667  QgsPoint mSize;
668  // any translation offsets to be applied before painting, transformed and ready for painting
669  QgsPoint mOffset;
670 
671  // a stored QPicture of painting for the component
672  QPicture* mPicture;
673  // buffer for component to accommodate graphic items ignored by QPicture,
674  // e.g. half-width of an applied QPen, which would extend beyond boundingRect() of QPicture
675  double mPictureBuffer;
676 
677  // a ratio of native painter dpi and that of rendering context's painter
678  double mDpiRatio;
679 };
680 
681 
686 class CORE_EXPORT QgsLabelingResults
687 {
688  public:
691 
693  QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) const;
695  QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) const;
696 
697  private:
698  QgsLabelingResults( const QgsLabelingResults& ) {} // no copying allowed
699 
700  QgsLabelSearchTree* mLabelSearchTree;
701 
702  friend class QgsPalLabeling;
703 };
704 
706 class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface
707 {
708  public:
710  {
711  LabelText = 0,
715  LabelShadow
716  };
717 
718  QgsPalLabeling();
719  ~QgsPalLabeling();
720 
721  QgsPalLayerSettings& layer( const QString& layerName ) override;
722 
723  void numCandidatePositions( int& candPoint, int& candLine, int& candPolygon );
724  void setNumCandidatePositions( int candPoint, int candLine, int candPolygon );
725 
726  enum Search { Chain, Popmusic_Tabu, Popmusic_Chain, Popmusic_Tabu_Chain, Falp };
727 
728  void setSearchMethod( Search s );
729  Search searchMethod() const;
730 
731  bool isShowingCandidates() const { return mShowingCandidates; }
732  void setShowingCandidates( bool showing ) { mShowingCandidates = showing; }
733  const QList<QgsLabelCandidate>& candidates() { return mCandidates; }
734 
735  bool isShowingShadowRectangles() const { return mShowingShadowRects; }
736  void setShowingShadowRectangles( bool showing ) { mShowingShadowRects = showing; }
737 
738  bool isShowingAllLabels() const { return mShowingAllLabels; }
739  void setShowingAllLabels( bool showing ) { mShowingAllLabels = showing; }
740 
741  bool isShowingPartialsLabels() const { return mShowingPartialsLabels; }
742  void setShowingPartialsLabels( bool showing ) { mShowingPartialsLabels = showing; }
743 
745  bool isDrawingOutlineLabels() const { return mDrawOutlineLabels; }
746  void setDrawingOutlineLabels( bool outline ) { mDrawOutlineLabels = outline; }
747 
748  // implemented methods from labeling engine interface
749 
752  Q_DECL_DEPRECATED virtual void init( QgsMapRenderer* mr ) override;
754  virtual void init( const QgsMapSettings& mapSettings ) override;
756  virtual bool willUseLayer( QgsVectorLayer* layer ) override;
757 
760  static bool staticWillUseLayer( QgsVectorLayer* layer );
761  static bool staticWillUseLayer( const QString& layerID );
762 
764  virtual void clearActiveLayers() override;
766  virtual void clearActiveLayer( const QString& layerID ) override;
768  virtual int prepareLayer( QgsVectorLayer* layer, QStringList &attrNames, QgsRenderContext& ctx ) override;
770  virtual int addDiagramLayer( QgsVectorLayer* layer, const QgsDiagramLayerSettings *s ) override;
772  virtual void registerFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext(), QString dxfLayer = QString::null ) override;
773  virtual void registerDiagramFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() ) override;
775  virtual void drawLabeling( QgsRenderContext& context ) override;
777  virtual void exit() override;
778 
781  Q_DECL_DEPRECATED virtual QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) override;
784  Q_DECL_DEPRECATED virtual QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) override;
785 
788  QgsLabelingResults* takeResults();
789 
791  virtual QgsLabelingEngineInterface* clone() override;
792 
794  void drawLabelCandidateRect( pal::LabelPosition* lp, QPainter* painter, const QgsMapToPixel* xform );
797  virtual void drawLabel( pal::LabelPosition* label, QgsRenderContext& context, QgsPalLayerSettings& tmpLyr, DrawLabelType drawType, double dpiRatio = 1.0 );
798 
799  static void drawLabelBuffer( QgsRenderContext& context,
800  const QgsLabelComponent &component,
801  const QgsPalLayerSettings& tmpLyr );
802 
803  static void drawLabelBackground( QgsRenderContext& context,
804  QgsLabelComponent component,
805  const QgsPalLayerSettings& tmpLyr );
806 
807  static void drawLabelShadow( QgsRenderContext &context,
808  const QgsLabelComponent &component,
809  const QgsPalLayerSettings& tmpLyr );
810 
812  void loadEngineSettings();
813  void saveEngineSettings();
814  void clearEngineSettings();
816  Q_DECL_DEPRECATED bool isStoredWithProject() const { return true; }
818  Q_DECL_DEPRECATED void setStoredWithProject( bool store ) { Q_UNUSED( store ); }
819 
820  protected:
821  // update temporary QgsPalLayerSettings with any data defined text style values
822  void dataDefinedTextStyle( QgsPalLayerSettings& tmpLyr,
823  const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues );
824 
825  // update temporary QgsPalLayerSettings with any data defined text formatting values
826  void dataDefinedTextFormatting( QgsPalLayerSettings& tmpLyr,
827  const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues );
828 
829  // update temporary QgsPalLayerSettings with any data defined text buffer values
830  void dataDefinedTextBuffer( QgsPalLayerSettings& tmpLyr,
831  const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues );
832 
833  // update temporary QgsPalLayerSettings with any data defined shape background values
834  void dataDefinedShapeBackground( QgsPalLayerSettings& tmpLyr,
835  const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues );
836 
837  // update temporary QgsPalLayerSettings with any data defined drop shadow values
838  void dataDefinedDropShadow( QgsPalLayerSettings& tmpLyr,
839  const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues );
840 
841  void deleteTemporaryData();
842 
843  // hashtable of layer settings, being filled during labeling (key = layer ID)
844  QHash<QString, QgsPalLayerSettings> mActiveLayers;
845  // hashtable of active diagram layers (key = layer ID)
846  QHash<QString, QgsDiagramLayerSettings> mActiveDiagramLayers;
848 
850  int mCandPoint, mCandLine, mCandPolygon;
852 
854 
855  // list of candidates from last labeling
856  QList<QgsLabelCandidate> mCandidates;
858  bool mShowingAllLabels; // whether to avoid collisions or not
859  bool mShowingShadowRects; // whether to show debugging rectangles for drop shadows
860  bool mShowingPartialsLabels; // whether to avoid partials labels or not
861  bool mDrawOutlineLabels; // whether to draw labels as text or outlines
862 
864 };
866 
867 
868 #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)
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) ...
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
const QgsPoint & size() const
bool mShowingPartialsLabels
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:461
QuadrantPosition quadOffset
bool useRotation() const
void setUseOrigin(const bool use)
Pal main class.
Definition: pal.h:126
Container of fields for a vector layer.
Definition: qgsfield.h:172
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:113
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)
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:462
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
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:53
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.
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
DirectionSymbols placeDirectionSymbol