QGIS API Documentation 3.43.0-Master (c67cf405802)
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:
37 QgsDiagramLabelFeature( const QgsFeature &feature, geos::unique_ptr geometry, QSizeF size )
38 : QgsLabelFeature( feature.id(), std::move( geometry ), size )
39 {
41 }
42
43};
44
45
47
58{
59 public:
60
62 explicit QgsVectorLayerDiagramProvider( QgsVectorLayer *layer, bool ownFeatureLoop = true );
63
66
67 QList<QgsLabelFeature *> labelFeatures( QgsRenderContext &context ) override;
68
69 void drawLabel( QgsRenderContext &context, pal::LabelPosition *label ) const override;
70
71 // new virtual methods
72
79 virtual bool prepare( const QgsRenderContext &context, QSet<QString> &attributeNames );
80
93 virtual void registerFeature( QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry = QgsGeometry() );
94
100 void setClipFeatureGeometry( const QgsGeometry &geometry );
101
102 protected:
104 void init();
106 QgsLabelFeature *registerDiagram( const QgsFeature &feat, QgsRenderContext &context, const QgsGeometry &obstacleGeometry = QgsGeometry() );
107
108 protected:
109
113 QgsDiagramRenderer *mDiagRenderer = nullptr;
114
115 // these are needed only if using own renderer loop
116
122 QgsAbstractFeatureSource *mSource = nullptr;
125
127 QList<QgsLabelFeature *> mFeatures;
128
129 std::unique_ptr< QgsExpressionContextScope > mLayerScope;
130
132};
133
134#endif // QGSVECTORLAYERDIAGRAMPROVIDER_H
Base class that can be used for any class that is capable of returning features.
An abstract interface class for label providers.
virtual QList< QgsLabelFeature * > labelFeatures(QgsRenderContext &context)=0
Returns list of label features (they are owned by the provider and thus deleted on its destruction)
virtual void drawLabel(QgsRenderContext &context, pal::LabelPosition *label) const =0
Draw this label at the position determined by the labeling engine.
Represents a coordinate reference system (CRS).
Adds extra information to QgsLabelFeature for labeling of diagrams.
QgsDiagramLabelFeature(const QgsFeature &feature, geos::unique_ptr geometry, QSizeF size)
Create label feature, takes ownership of the geometry instance.
Stores the settings for rendering of all diagrams for a layer.
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
Container of fields for a vector layer.
Definition qgsfields.h:46
A geometry is the spatial representation of a feature.
Describes a feature that should be used within the labeling engine.
QSizeF size(double angle=0.0) const
Size of the label (in map units).
void setFeature(const QgsFeature &feature)
Sets the original feature associated with this label.
GEOSGeometry * geometry() const
Gets access to the associated geometry.
QgsFeature feature() const
Returns the original feature associated with this label.
QgsFeatureId id() const
Identifier of the label (unique within the parent label provider)
Contains information about the context of a rendering operation.
Implements support for diagrams within the labeling engine.
QgsDiagramLayerSettings mSettings
Diagram layer settings.
bool mOwnsSource
Whether layer's feature source is owned.
QgsCoordinateReferenceSystem mLayerCrs
Layer's CRS.
QList< QgsLabelFeature * > mFeatures
List of generated label features (owned by the provider)
std::unique_ptr< QgsExpressionContextScope > mLayerScope
Represents a vector layer which manages a vector based dataset.
LabelPosition is a candidate feature label position.