QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsvectorlayerlabelprovider.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorlayerlabelprovider.h
3  --------------------------------------
4  Date : September 2015
5  Copyright : (C) 2015 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSVECTORLAYERLABELPROVIDER_H
17 #define QGSVECTORLAYERLABELPROVIDER_H
18 
19 #include "qgslabelingenginev2.h"
20 #include "qgsrendererv2.h"
21 
24 class QgsSymbolV2;
25 
36 {
37  public:
38 
41  const QString& providerId,
42  bool withFeatureLoop = true,
43  const QgsPalLayerSettings* settings = nullptr,
44  const QString& layerName = QString() );
45 
48  const QString& layerId,
49  const QgsFields& fields,
52  bool ownsSource,
53  QgsFeatureRendererV2* renderer = nullptr );
54 
56 
57  virtual QList<QgsLabelFeature*> labelFeatures( QgsRenderContext& context ) override;
58 
59  virtual void drawLabel( QgsRenderContext& context, pal::LabelPosition* label ) const override;
60 
61  // new virtual methods
62 
69  virtual bool prepare( const QgsRenderContext& context, QStringList& attributeNames );
70 
82  virtual void registerFeature( QgsFeature& feature, QgsRenderContext &context, QgsGeometry* obstacleGeometry = nullptr );
83 
92  static QgsGeometry* getPointObstacleGeometry( QgsFeature& fet, QgsRenderContext& context, const QgsSymbolV2List& symbols );
93 
94  protected:
96  void init();
98  void drawLabelPrivate( pal::LabelPosition* label, QgsRenderContext& context, QgsPalLayerSettings& tmpLyr, QgsPalLabeling::DrawLabelType drawType, double dpiRatio = 1.0 ) const;
99 
100  protected:
105 
107 
108  // these are needed only if using own renderer loop
109 
118 
121 
122  friend class TestQgsLabelingEngineV2;
123 };
124 
125 #endif // QGSVECTORLAYERLABELPROVIDER_H
GeometryType
Definition: qgis.h:115
bool mOwnsSource
Whether layer&#39;s feature source is owned.
Container of fields for a vector layer.
Definition: qgsfield.h:252
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:76
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:187
QList< QgsLabelFeature * > mLabels
List of generated.
virtual QList< QgsLabelFeature * > labelFeatures(QgsRenderContext &context)=0
Return list of label features (they are owned by the provider and thus deleted on its destruction) ...
QgsPalLayerSettings mSettings
Layer&#39;s labeling configuration.
Base class that can be used for any class that is capable of returning features.
The QgsAbstractLabelProvider class is an interface class.
QgsFields mFields
Layer&#39;s fields.
QgsAbstractFeatureSource * mSource
Layer&#39;s feature source.
Contains information about the context of a rendering operation.
QgsCoordinateReferenceSystem mCrs
Layer&#39;s CRS.
Class for storing a coordinate reference system (CRS)
LabelPosition is a candidate feature label position.
Definition: labelposition.h:51
virtual void drawLabel(QgsRenderContext &context, pal::LabelPosition *label) const =0
draw this label at the position determined by the labeling engine
Represents a vector layer which manages a vector based data sets.
QGis::GeometryType mLayerGeometryType
Geometry type of layer.