QGIS API Documentation  2.12.0-Lyon
qgsvectorlayerdiagramprovider.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorlayerdiagramprovider.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 QGSVECTORLAYERDIAGRAMPROVIDER_H
17 #define QGSVECTORLAYERDIAGRAMPROVIDER_H
18 
19 #include "qgslabelingenginev2.h"
20 
21 
28 {
29  public:
32  : QgsLabelFeature( id, geometry, size ) {}
33 
35  void setAttributes( const QgsAttributes& attrs ) { mAttributes = attrs; }
37  const QgsAttributes& attributes() { return mAttributes; }
38 
39  protected:
42 };
43 
44 
46 
47 
55 {
56  public:
57 
59  explicit QgsVectorLayerDiagramProvider( QgsVectorLayer* layer, bool ownFeatureLoop = true );
60 
63  const QgsDiagramRendererV2* diagRenderer,
64  const QString& layerId,
65  const QgsFields& fields,
68  bool ownsSource );
69 
72 
73  virtual QList<QgsLabelFeature*> labelFeatures( QgsRenderContext& context ) override;
74 
75  virtual void drawLabel( QgsRenderContext& context, pal::LabelPosition* label ) const override;
76 
77  // new virtual methods
78 
85  virtual bool prepare( const QgsRenderContext& context, QStringList& attributeNames );
86 
94  virtual void registerFeature( QgsFeature& feature, QgsRenderContext &context );
95 
96  protected:
98  void init();
100  QgsLabelFeature* registerDiagram( QgsFeature& feat, QgsRenderContext& context );
101 
102  protected:
103 
110 
111  // these are needed only if using own renderer loop
112 
121 
124 };
125 
126 #endif // QGSVECTORLAYERDIAGRAMPROVIDER_H
Container of fields for a vector layer.
Definition: qgsfield.h:177
QgsDiagramRendererV2 * mDiagRenderer
Diagram renderer instance (owned by mSettings)
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:176
QgsDiagramLabelFeature(QgsFeatureId id, GEOSGeometry *geometry, const QSizeF &size)
Create label feature, takes ownership of the geometry instance.
Returns diagram settings for a feature.
GEOSGeometry * geometry() const
Get access to the associated geometry.
QSizeF size() const
Size of the label (in map units)
virtual QList< QgsLabelFeature * > labelFeatures(QgsRenderContext &context)=0
Return list of label features (they are owned by the provider and thus deleted on its destruction) ...
bool mOwnsSource
Whether layer's feature source is owned.
The QgsVectorLayerDiagramProvider class implements support for diagrams within the labeling engine...
Base class that can be used for any class that is capable of returning features.
The QgsAbstractLabelProvider class is an interface class.
QgsCoordinateReferenceSystem mLayerCrs
Layer's CRS.
Class that adds extra information to QgsLabelFeature for labeling of diagrams.
Contains information about the context of a rendering operation.
The QgsLabelFeature class describes a feature that should be used within the labeling engine...
QgsAttributes mAttributes
Stores attribute values for diagram rendering.
void setAttributes(const QgsAttributes &attrs)
Store feature's attributes - used for rendering of diagrams.
Class for storing a coordinate reference system (CRS)
LabelPosition is a candidate feature label position.
Definition: labelposition.h:48
qint64 QgsFeatureId
Definition: qgsfeature.h:31
const QgsAttributes & attributes()
Get feature's attributes - used for rendering of diagrams.
QgsAbstractFeatureSource * mSource
Layer's feature source.
virtual void drawLabel(QgsRenderContext &context, pal::LabelPosition *label) const =0
draw this label at the position determined by the labeling engine
A vector of attributes.
Definition: qgsfeature.h:109
Represents a vector layer which manages a vector based data sets.
QgsDiagramLayerSettings mSettings
Diagram layer settings.
QList< QgsLabelFeature * > mFeatures
List of generated label features (owned by the provider)