QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 #include "qgslabelfeature.h"
21 
29 {
30  public:
33  : QgsLabelFeature( id, geometry, size ) {}
34 
36  void setAttributes( const QgsAttributes& attrs ) { mAttributes = attrs; }
38  const QgsAttributes& attributes() { return mAttributes; }
39 
40  protected:
43 };
44 
45 
47 
48 
58 {
59  public:
60 
62  explicit QgsVectorLayerDiagramProvider( QgsVectorLayer* layer, bool ownFeatureLoop = true );
63 
66  const QgsDiagramRendererV2* diagRenderer,
67  const QString& layerId,
68  const QgsFields& fields,
71  bool ownsSource );
72 
75 
76  virtual QList<QgsLabelFeature*> labelFeatures( QgsRenderContext& context ) override;
77 
78  virtual void drawLabel( QgsRenderContext& context, pal::LabelPosition* label ) const override;
79 
80  // new virtual methods
81 
88  virtual bool prepare( const QgsRenderContext& context, QStringList& attributeNames );
89 
102  virtual void registerFeature( QgsFeature& feature, QgsRenderContext &context, QgsGeometry* obstacleGeometry = nullptr );
103 
104  protected:
106  void init();
108  QgsLabelFeature* registerDiagram( QgsFeature& feat, QgsRenderContext& context, QgsGeometry* obstacleGeometry = nullptr );
109 
110  protected:
111 
116 
117  // these are needed only if using own renderer loop
118 
127 
130 };
131 
132 #endif // QGSVECTORLAYERDIAGRAMPROVIDER_H
QgsDiagramLabelFeature(QgsFeatureId id, GEOSGeometry *geometry, QSizeF size)
Create label feature, takes ownership of the geometry instance.
GEOSGeometry * geometry() const
Get access to the associated geometry.
Container of fields for a vector layer.
Definition: qgsfield.h:252
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:76
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:187
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
bool mOwnsSource
Whether layer&#39;s feature source is owned.
The QgsVectorLayerDiagramProvider class implements support for diagrams within the labeling engine...
pal::Layer * layer() const
Get PAL layer of the label feature. Should be only used internally in PAL.
Base class that can be used for any class that is capable of returning features.
QgsFields mFields
Layer&#39;s fields.
The QgsAbstractLabelProvider class is an interface class.
QgsCoordinateReferenceSystem mLayerCrs
Layer&#39;s CRS.
QSizeF size() const
Size of the label (in map units)
Stores the settings for rendering of all diagrams for a layer.
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.
GEOSGeometry * obstacleGeometry() const
Returns the label&#39;s obstacle geometry, if different to the feature geometry.
void setAttributes(const QgsAttributes &attrs)
Store feature&#39;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:51
qint64 QgsFeatureId
Definition: qgsfeature.h:31
const QgsAttributes & attributes()
Get feature&#39;s attributes - used for rendering of diagrams.
QgsAbstractFeatureSource * mSource
Layer&#39;s feature source.
A vector of attributes.
Definition: qgsfeature.h:115
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)