QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 #define SIP_NO_FILE
20 
21 #include "qgis_core.h"
22 #include "qgslabelingengine.h"
23 #include "qgslabelfeature.h"
24 #include "qgsdiagramrenderer.h"
25 
34 {
35  public:
38  : QgsLabelFeature( id, std::move( geometry ), size ) {}
39 
41  void setAttributes( const QgsAttributes &attrs ) { mAttributes = attrs; }
43  const QgsAttributes &attributes() { return mAttributes; }
44 
45  protected:
48 };
49 
50 
52 
63 {
64  public:
65 
67  explicit QgsVectorLayerDiagramProvider( QgsVectorLayer *layer, bool ownFeatureLoop = true );
68 
71 
72  QList<QgsLabelFeature *> labelFeatures( QgsRenderContext &context ) override;
73 
74  void drawLabel( QgsRenderContext &context, pal::LabelPosition *label ) const override;
75 
76  // new virtual methods
77 
84  virtual bool prepare( const QgsRenderContext &context, QSet<QString> &attributeNames );
85 
98  virtual void registerFeature( QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry = QgsGeometry() );
99 
105  void setClipFeatureGeometry( const QgsGeometry &geometry );
106 
107  protected:
109  void init();
111  QgsLabelFeature *registerDiagram( QgsFeature &feat, QgsRenderContext &context, const QgsGeometry &obstacleGeometry = QgsGeometry() );
112 
113  protected:
114 
118  QgsDiagramRenderer *mDiagRenderer = nullptr;
119 
120  // these are needed only if using own renderer loop
121 
127  QgsAbstractFeatureSource *mSource = nullptr;
130 
132  QList<QgsLabelFeature *> mFeatures;
133 
135 };
136 
137 #endif // QGSVECTORLAYERDIAGRAMPROVIDER_H
QgsLabelFeature::id
QgsFeatureId id() const
Identifier of the label (unique within the parent label provider)
Definition: qgslabelfeature.h:66
QgsAbstractLabelProvider::drawLabel
virtual void drawLabel(QgsRenderContext &context, pal::LabelPosition *label) const =0
Draw this label at the position determined by the labeling engine.
QgsVectorLayerDiagramProvider::mSettings
QgsDiagramLayerSettings mSettings
Diagram layer settings.
Definition: qgsvectorlayerdiagramprovider.h:116
pal::LabelPosition
LabelPosition is a candidate feature label position.
Definition: labelposition.h:56
QgsVectorLayerDiagramProvider
The QgsVectorLayerDiagramProvider class implements support for diagrams within the labeling engine.
Definition: qgsvectorlayerdiagramprovider.h:63
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:45
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:58
QgsDiagramLabelFeature
Class that adds extra information to QgsLabelFeature for labeling of diagrams.
Definition: qgsvectorlayerdiagramprovider.h:34
qgslabelfeature.h
geos::unique_ptr
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:79
QgsAbstractLabelProvider
The QgsAbstractLabelProvider class is an interface class.
Definition: qgslabelingengine.h:48
QgsVectorLayerDiagramProvider::mOwnsSource
bool mOwnsSource
Whether layer's feature source is owned.
Definition: qgsvectorlayerdiagramprovider.h:129
QgsAbstractLabelProvider::labelFeatures
virtual QList< QgsLabelFeature * > labelFeatures(QgsRenderContext &context)=0
Returns list of label features (they are owned by the provider and thus deleted on its destruction)
QgsVectorLayerDiagramProvider::mFeatures
QList< QgsLabelFeature * > mFeatures
List of generated label features (owned by the provider)
Definition: qgsvectorlayerdiagramprovider.h:132
QgsAbstractFeatureSource
Base class that can be used for any class that is capable of returning features.
Definition: qgsfeaturerequest.h:743
QgsVectorLayerDiagramProvider::mFields
QgsFields mFields
Layer's fields.
Definition: qgsvectorlayerdiagramprovider.h:123
QgsDiagramLayerSettings
Stores the settings for rendering of all diagrams for a layer.
Definition: qgsdiagramrenderer.h:61
QgsVectorLayerDiagramProvider::mLayerCrs
QgsCoordinateReferenceSystem mLayerCrs
Layer's CRS.
Definition: qgsvectorlayerdiagramprovider.h:125
QgsDiagramRenderer
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
Definition: qgsdiagramrenderer.h:684
qgsdiagramrenderer.h
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:206
QgsDiagramLabelFeature::QgsDiagramLabelFeature
QgsDiagramLabelFeature(QgsFeatureId id, geos::unique_ptr geometry, QSizeF size)
Create label feature, takes ownership of the geometry instance.
Definition: qgsvectorlayerdiagramprovider.h:37
QgsLabelFeature::size
QSizeF size(double angle=0.0) const
Size of the label (in map units)
Definition: qgslabelfeature.cpp:64
QgsLabelFeature::geometry
GEOSGeometry * geometry() const
Gets access to the associated geometry.
Definition: qgslabelfeature.h:69
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsDiagramLabelFeature::attributes
const QgsAttributes & attributes()
Gets feature's attributes - used for rendering of diagrams.
Definition: qgsvectorlayerdiagramprovider.h:43
QgsDiagramLabelFeature::setAttributes
void setAttributes(const QgsAttributes &attrs)
Store feature's attributes - used for rendering of diagrams.
Definition: qgsvectorlayerdiagramprovider.h:41
QgsVectorLayerDiagramProvider::mLabelClipFeatureGeom
QgsGeometry mLabelClipFeatureGeom
Definition: qgsvectorlayerdiagramprovider.h:134
QgsAttributes
A vector of attributes.
Definition: qgsattributes.h:58
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
QgsLabelFeature
The QgsLabelFeature class describes a feature that should be used within the labeling engine.
Definition: qgslabelfeature.h:57
QgsDiagramLabelFeature::mAttributes
QgsAttributes mAttributes
Stores attribute values for diagram rendering.
Definition: qgsvectorlayerdiagramprovider.h:47
qgslabelingengine.h
QgsFeatureId
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28