QGIS API Documentation  2.12.0-Lyon
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 
22 
31 {
32  public:
33 
35  explicit QgsVectorLayerLabelProvider( QgsVectorLayer* layer, bool withFeatureLoop = true, const QgsPalLayerSettings* settings = 0, const QString& layerName = QString() );
36 
39  const QString& layerId,
40  const QgsFields& fields,
43  bool ownsSource );
44 
46 
47  virtual QList<QgsLabelFeature*> labelFeatures( QgsRenderContext& context ) override;
48 
49  virtual void drawLabel( QgsRenderContext& context, pal::LabelPosition* label ) const override;
50 
51  // new virtual methods
52 
59  virtual bool prepare( const QgsRenderContext& context, QStringList& attributeNames );
60 
68  virtual void registerFeature( QgsFeature& feature, QgsRenderContext &context );
69 
70  protected:
72  void init();
74  void drawLabelPrivate( pal::LabelPosition* label, QgsRenderContext& context, QgsPalLayerSettings& tmpLyr, QgsPalLabeling::DrawLabelType drawType, double dpiRatio = 1.0 ) const;
75 
76  protected:
81 
82  // these are needed only if using own renderer loop
83 
92 
95 };
96 
97 
98 #endif // QGSVECTORLAYERLABELPROVIDER_H
bool mOwnsSource
Whether layer's feature source is owned.
Container of fields for a vector layer.
Definition: qgsfield.h:177
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:176
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'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.
QgsAbstractFeatureSource * mSource
Layer's feature source.
Contains information about the context of a rendering operation.
QgsCoordinateReferenceSystem mCrs
Layer's CRS.
Class for storing a coordinate reference system (CRS)
LabelPosition is a candidate feature label position.
Definition: labelposition.h:48
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.