QGIS API Documentation  2.11.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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 #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, const QgsRenderContext* context = 0 );
464 
471  void registerFeature( QgsFeature& f, const QgsRenderContext& context, QString dxfLayer );
472 
473  void readFromLayer( QgsVectorLayer* layer );
474  void writeToLayer( QgsVectorLayer* layer );
475 
480 
484  void setDataDefinedProperty( QgsPalLayerSettings::DataDefinedProperties p,
485  bool active, bool useExpr, const QString& expr, const QString& field );
486 
488  void removeDataDefinedProperty( QgsPalLayerSettings::DataDefinedProperties p );
489 
493  QString updateDataDefinedString( const QString& value );
494 
499 
504  QVariant dataDefinedValue( QgsPalLayerSettings::DataDefinedProperties p, QgsFeature& f, const QgsFields& fields,
505  const QgsExpressionContext* context = 0 ) const;
506 
511  bool dataDefinedEvaluate( QgsPalLayerSettings::DataDefinedProperties p, QVariant& exprVal, const QgsExpressionContext* context = 0 ) const;
512 
515  bool dataDefinedIsActive( QgsPalLayerSettings::DataDefinedProperties p ) const;
516 
519  bool dataDefinedUseExpression( QgsPalLayerSettings::DataDefinedProperties p ) const;
520 
524 
525 
534  int sizeToPixel( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
535 
544  double scaleToPixelContext( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
545 
551 
552  // temporary stuff: set when layer gets prepared or labeled
553  // NOTE: not in Python binding
560  QgsPoint ptZero, ptOne;
563  int mFeaturesToLabel; // total features that will probably be labeled, may be less (figured before PAL)
564  int mFeatsSendingToPal; // total features tested for sending into PAL (relative to maxNumLabels)
565  int mFeatsRegPal; // number of features registered in PAL, when using limitNumLabels
566 
569 
570  bool showingShadowRects; // whether to show debug rectangles for drop shadows
571 
572  private:
573 
574  void readDataDefinedPropertyMap( QgsVectorLayer* layer,
576  QgsDataDefined* > & propertyMap );
577  void writeDataDefinedPropertyMap( QgsVectorLayer* layer,
579  QgsDataDefined* > & propertyMap );
580  void readDataDefinedProperty( QgsVectorLayer* layer,
583  QgsDataDefined* > & propertyMap );
584 
585  // convenience data defined evaluation function
586  bool dataDefinedValEval( const QString& valType,
588  QVariant& exprVal, const QgsExpressionContext& context );
589 
590  void parseTextStyle( QFont& labelFont,
592  const QgsRenderContext& context );
593 
594  void parseTextBuffer( const QgsRenderContext& context );
595 
596  void parseTextFormatting( const QgsRenderContext& context );
597 
598  void parseShapeBackground( const QgsRenderContext& context );
599 
600  void parseDropShadow( const QgsRenderContext& context );
601 
604  bool checkMinimumSizeMM( const QgsRenderContext& ct, const QgsGeometry* geom, double minSize ) const;
605 
608  void registerObstacleFeature( QgsFeature &f, const QgsRenderContext &context, QString dxfLayer );
609 
610  QMap<DataDefinedProperties, QVariant> dataDefinedValues;
611  QgsExpression* expression;
613 
614  QFontDatabase mFontDB;
615 };
616 
617 class CORE_EXPORT QgsLabelCandidate
618 {
619  public:
620  QgsLabelCandidate( QRectF r, double c ): rect( r ), cost( c ) {}
621 
623  double cost;
624 };
625 
630 class CORE_EXPORT QgsLabelComponent
631 {
632  public:
634  : mText( QString() )
635  , mOrigin( QgsPoint() )
636  , mUseOrigin( false )
637  , mRotation( 0.0 )
638  , mRotationOffset( 0.0 )
639  , mUseRotation( false )
640  , mCenter( QgsPoint() )
641  , mUseCenter( false )
642  , mSize( QgsPoint() )
643  , mOffset( QgsPoint() )
644  , mPicture( 0 )
645  , mPictureBuffer( 0.0 )
646  , mDpiRatio( 1.0 )
647  {}
648 
649  // methods
650 
651  const QString& text() const { return mText; }
652  void setText( const QString& text ) { mText = text; }
653 
654  const QgsPoint& origin() const { return mOrigin; }
655  void setOrigin( const QgsPoint& point ) { mOrigin = point; }
656 
657  bool useOrigin() const { return mUseOrigin; }
658  void setUseOrigin( const bool use ) { mUseOrigin = use; }
659 
660  double rotation() const { return mRotation; }
661  void setRotation( const double rotation ) { mRotation = rotation; }
662 
663  double rotationOffset() const { return mRotationOffset; }
664  void setRotationOffset( const double rotation ) { mRotationOffset = rotation; }
665 
666  bool useRotation() const { return mUseRotation; }
667  void setUseRotation( const bool use ) { mUseRotation = use; }
668 
669  const QgsPoint& center() const { return mCenter; }
670  void setCenter( const QgsPoint& point ) { mCenter = point; }
671 
672  bool useCenter() const { return mUseCenter; }
673  void setUseCenter( const bool use ) { mUseCenter = use; }
674 
675  const QgsPoint& size() const { return mSize; }
676  void setSize( const QgsPoint& point ) { mSize = point; }
677 
678  const QgsPoint& offset() const { return mOffset; }
679  void setOffset( const QgsPoint& point ) { mOffset = point; }
680 
681  const QPicture* picture() const { return mPicture; }
682  void setPicture( QPicture* picture ) { mPicture = picture; }
683 
684  double pictureBuffer() const { return mPictureBuffer; }
685  void setPictureBuffer( const double buffer ) { mPictureBuffer = buffer; }
686 
687  double dpiRatio() const { return mDpiRatio; }
688  void setDpiRatio( const double ratio ) { mDpiRatio = ratio; }
689 
690  private:
691  // current label component text,
692  // e.g. single line in a multi-line label or charcater in curved labeling
693  QString mText;
694  // current origin point for painting (generally current painter rotation point)
695  QgsPoint mOrigin;
696  // whether to translate the painter to supplied origin
697  bool mUseOrigin;
698  // any rotation to be applied to painter (in radians)
699  double mRotation;
700  // any rotation to be applied to painter (in radians) after initial rotation
701  double mRotationOffset;
702  // whether to use the rotation to rotate the painter
703  bool mUseRotation;
704  // current center point of label compnent, after rotation
705  QgsPoint mCenter;
706  // whether to translate the painter to supplied origin based upon center
707  bool mUseCenter;
708  // width and height of label component, transformed and ready for painting
709  QgsPoint mSize;
710  // any translation offsets to be applied before painting, transformed and ready for painting
711  QgsPoint mOffset;
712 
713  // a stored QPicture of painting for the component
714  QPicture* mPicture;
715  // buffer for component to accommodate graphic items ignored by QPicture,
716  // e.g. half-width of an applied QPen, which would extend beyond boundingRect() of QPicture
717  double mPictureBuffer;
718 
719  // a ratio of native painter dpi and that of rendering context's painter
720  double mDpiRatio;
721 };
722 
723 
728 class CORE_EXPORT QgsLabelingResults
729 {
730  public:
733 
735  QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) const;
737  QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) const;
738 
739  private:
740  QgsLabelingResults( const QgsLabelingResults& ) {} // no copying allowed
741 
742  QgsLabelSearchTree* mLabelSearchTree;
743 
744  friend class QgsPalLabeling;
745 };
746 
748 class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface
749 {
750  public:
752  {
753  LabelText = 0,
757  LabelShadow
758  };
759 
760  QgsPalLabeling();
761  ~QgsPalLabeling();
762 
763  QgsPalLayerSettings& layer( const QString& layerName ) override;
764 
765  void numCandidatePositions( int& candPoint, int& candLine, int& candPolygon );
766  void setNumCandidatePositions( int candPoint, int candLine, int candPolygon );
767 
768  enum Search { Chain, Popmusic_Tabu, Popmusic_Chain, Popmusic_Tabu_Chain, Falp };
769 
770  void setSearchMethod( Search s );
771  Search searchMethod() const;
772 
773  bool isShowingCandidates() const { return mShowingCandidates; }
774  void setShowingCandidates( bool showing ) { mShowingCandidates = showing; }
775  const QList<QgsLabelCandidate>& candidates() { return mCandidates; }
776 
777  bool isShowingShadowRectangles() const { return mShowingShadowRects; }
778  void setShowingShadowRectangles( bool showing ) { mShowingShadowRects = showing; }
779 
780  bool isShowingAllLabels() const { return mShowingAllLabels; }
781  void setShowingAllLabels( bool showing ) { mShowingAllLabels = showing; }
782 
783  bool isShowingPartialsLabels() const { return mShowingPartialsLabels; }
784  void setShowingPartialsLabels( bool showing ) { mShowingPartialsLabels = showing; }
785 
787  bool isDrawingOutlineLabels() const { return mDrawOutlineLabels; }
788  void setDrawingOutlineLabels( bool outline ) { mDrawOutlineLabels = outline; }
789 
795  bool drawLabelRectOnly() const { return mDrawLabelRectOnly; }
796 
803  void setDrawLabelRectOnly( bool drawRect ) { mDrawLabelRectOnly = drawRect; }
804 
805  // implemented methods from labeling engine interface
806 
809  Q_DECL_DEPRECATED virtual void init( QgsMapRenderer* mr ) override;
811  virtual void init( const QgsMapSettings& mapSettings ) override;
813  virtual bool willUseLayer( QgsVectorLayer* layer ) override;
814 
817  static bool staticWillUseLayer( QgsVectorLayer* layer );
818  static bool staticWillUseLayer( const QString& layerID );
819 
821  virtual void clearActiveLayers() override;
823  virtual void clearActiveLayer( const QString& layerID ) override;
825  virtual int prepareLayer( QgsVectorLayer* layer, QStringList &attrNames, QgsRenderContext& ctx ) override;
827  virtual int addDiagramLayer( QgsVectorLayer* layer, const QgsDiagramLayerSettings *s ) override;
828 
836  virtual void registerFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext(), QString dxfLayer = QString::null ) override;
837 
838  virtual void registerDiagramFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() ) override;
840  virtual void drawLabeling( QgsRenderContext& context ) override;
842  virtual void exit() override;
843 
846  Q_DECL_DEPRECATED virtual QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) override;
849  Q_DECL_DEPRECATED virtual QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) override;
850 
853  QgsLabelingResults* takeResults();
854 
856  virtual QgsLabelingEngineInterface* clone() override;
857 
859  void drawLabelCandidateRect( pal::LabelPosition* lp, QPainter* painter, const QgsMapToPixel* xform );
860 
863  virtual void drawLabel( pal::LabelPosition* label, QgsRenderContext& context, QgsPalLayerSettings& tmpLyr, DrawLabelType drawType, double dpiRatio = 1.0 );
864 
865  static void drawLabelBuffer( QgsRenderContext& context,
866  const QgsLabelComponent &component,
867  const QgsPalLayerSettings& tmpLyr );
868 
869  static void drawLabelBackground( QgsRenderContext& context,
870  QgsLabelComponent component,
871  const QgsPalLayerSettings& tmpLyr );
872 
873  static void drawLabelShadow( QgsRenderContext &context,
874  const QgsLabelComponent &component,
875  const QgsPalLayerSettings& tmpLyr );
876 
878  void loadEngineSettings();
879  void saveEngineSettings();
880  void clearEngineSettings();
882  Q_DECL_DEPRECATED bool isStoredWithProject() const { return true; }
884  Q_DECL_DEPRECATED void setStoredWithProject( bool store ) { Q_UNUSED( store ); }
885 
894  static QgsGeometry* prepareGeometry( const QgsGeometry *geometry, const QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry = 0 );
895 
904  static bool geometryRequiresPreparation( const QgsGeometry *geometry, const QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry = 0 );
905 
913  static QStringList splitToLines( const QString& text, const QString& wrapCharacter );
914 
922  static QStringList splitToGraphemes( const QString& text );
923 
924  protected:
925  // update temporary QgsPalLayerSettings with any data defined text style values
926  void dataDefinedTextStyle( QgsPalLayerSettings& tmpLyr,
928 
929  // update temporary QgsPalLayerSettings with any data defined text formatting values
930  void dataDefinedTextFormatting( QgsPalLayerSettings& tmpLyr,
932 
933  // update temporary QgsPalLayerSettings with any data defined text buffer values
934  void dataDefinedTextBuffer( QgsPalLayerSettings& tmpLyr,
936 
937  // update temporary QgsPalLayerSettings with any data defined shape background values
938  void dataDefinedShapeBackground( QgsPalLayerSettings& tmpLyr,
940 
941  // update temporary QgsPalLayerSettings with any data defined drop shadow values
942  void dataDefinedDropShadow( QgsPalLayerSettings& tmpLyr,
944 
945  void deleteTemporaryData();
946 
954  static bool checkMinimumSizeMM( const QgsRenderContext &context, const QgsGeometry *geom, double minSize );
955 
956  // hashtable of layer settings, being filled during labeling (key = layer ID)
958  // hashtable of active diagram layers (key = layer ID)
961 
963  int mCandPoint, mCandLine, mCandPolygon;
965 
967 
968  // list of candidates from last labeling
970 
974  bool mShowingAllLabels; // whether to avoid collisions or not
975  bool mShowingShadowRects; // whether to show debugging rectangles for drop shadows
976  bool mShowingPartialsLabels; // whether to avoid partials labels or not
977  bool mDrawOutlineLabels; // whether to draw labels as text or outlines
978 
980 
981  friend class QgsPalLayerSettings;
982 };
984 
985 
986 #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:88
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:177
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
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
struct pal::_chain Chain
void setCenter(const QgsPoint &point)
const QgsMapToPixel * xform
QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined * > dataDefinedProperties
Map of current data defined properties.
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
bool drawLabelRectOnly() const
Returns whether the engine will only draw the outline rectangles of labels, not the label contents th...
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
bool mDrawLabelRectOnly
Whether to only draw the label rect and not the actual label text (used for unit tests) ...
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.
void setDrawLabelRectOnly(bool drawRect)
Sets whether the engine should only draw the outline rectangles of labels, not the label contents the...
Maintains current state of more grainular and temporal values when creating/painting component parts ...
RotationType shapeRotationType
QgsMapUnitScale labelOffsetMapUnitScale
QgsLabelingResults * mResults
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels...
DirectionSymbols placeDirectionSymbol