QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsmergedfeaturerenderer.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmergedfeaturerenderer.h
3 ---------------------
4 begin : December 2020
5 copyright : (C) 2020 by Nyall Dawson
6 email : nyall dot dawson 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#ifndef QGSMERGEDFEATURERENDERER_H
16#define QGSMERGEDFEATURERENDERER_H
17
18#include "qgis_core.h"
19#include "qgis_sip.h"
20#include "qgis.h"
21#include "qgsrenderer.h"
22#include "qgsexpression.h"
23#include "qgsfeature.h"
24#include "qgsgeometry.h"
25#include "qgsrendercontext.h"
26
41{
42 public:
43
49
54
56 static QgsFeatureRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
57
59 void startRender( QgsRenderContext &context, const QgsFields &fields ) override;
60
71 bool renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) override SIP_THROW( QgsCsException );
72
77 void stopRender( QgsRenderContext &context ) override;
78
79 QString dump() const override;
80 QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
81 bool filterNeedsGeometry() const override;
82 QgsFeatureRenderer::Capabilities capabilities() override;
83 QgsSymbolList symbols( QgsRenderContext &context ) const override;
84 QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
85 QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
86 QgsSymbolList symbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
87 QgsSymbolList originalSymbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
88 QSet< QString > legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
89 QString legendKeyToExpression( const QString &key, QgsVectorLayer *layer, bool &ok ) const override;
90 QgsLegendSymbolList legendSymbolItems() const override;
91 bool willRenderFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
92 QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) override;
93 void setEmbeddedRenderer( QgsFeatureRenderer *subRenderer SIP_TRANSFER ) override;
94 const QgsFeatureRenderer *embeddedRenderer() const override;
95 void setLegendSymbolItem( const QString &key, QgsSymbol *symbol ) override;
96 bool legendSymbolItemsCheckable() const override;
97 bool legendSymbolItemChecked( const QString &key ) override;
98 void checkLegendSymbolItem( const QString &key, bool state = true ) override;
99 bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
100
105 static QgsMergedFeatureRenderer *convertFromRenderer( const QgsFeatureRenderer *renderer ) SIP_FACTORY;
106
107 protected:
108
114 QgsMergedFeatureRenderer( const QString &type, QgsFeatureRenderer *embeddedRenderer SIP_TRANSFER );
115
120 {
124 };
125
127 GeometryOperation mOperation = Merge;
128
130 std::unique_ptr<QgsFeatureRenderer> mSubRenderer;
131
132 private:
133
135 struct CombinedFeature
136 {
137 QVector<QgsGeometry> geometries; //< list of geometries
138 QgsFeature feature; //< one feature (for attriute-based rendering)
139 };
140 typedef QVector<CombinedFeature> FeatureCategoryVector;
142 FeatureCategoryVector mFeaturesCategories;
143
145 QMap<QByteArray, int> mSymbolCategories;
146
148 QgsPolygonXY mExtentPolygon;
149
151 QgsRenderContext mContext;
152
154 QgsFields mFields;
155
160 struct FeatureDecoration
161 {
162 QgsFeature feature;
163 bool selected;
164 bool drawMarkers;
165 int layer;
166 FeatureDecoration( const QgsFeature &a_feature, bool a_selected, bool a_drawMarkers, int a_layer )
167 : feature( a_feature )
168 , selected( a_selected )
169 , drawMarkers( a_drawMarkers )
170 , layer( a_layer )
171 {}
172 };
173 QList<FeatureDecoration> mFeatureDecorations;
174
175};
176
177
178#endif // QGSMERGEDFEATURERENDERER_H
Custom exception class for Coordinate Reference System related exceptions.
Definition: qgsexception.h:66
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
Container of fields for a vector layer.
Definition: qgsfields.h:45
QgsMergedFeatureRenderer is a polygon or line-only feature renderer used to renderer a set of feature...
QgsMergedFeatureRenderer & operator=(const QgsMergedFeatureRenderer &)=delete
Direct copies are forbidden. Use clone() instead.
GeometryOperation
Operations to apply to collected geometries prior to rendering.
@ Merge
Merge features (union/dissolve)
@ InvertOnly
Invert features only (polygons only)
@ MergeAndInvert
Merge and invert features (polygons only)
QgsMergedFeatureRenderer(const QgsMergedFeatureRenderer &)=delete
Direct copies are forbidden. Use clone() instead.
std::unique_ptr< QgsFeatureRenderer > mSubRenderer
Embedded renderer.
The class is used as a container of context for various read/write operations on other objects.
Contains information about the context of a rendering operation.
An interface for classes which can visit style entity (e.g.
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:93
Represents a vector layer which manages a vector based data sets.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:76
#define SIP_THROW(name,...)
Definition: qgis_sip.h:198
QVector< QgsPolylineXY > QgsPolygonXY
Polygon: first item of the list is outer ring, inner rings (if any) start from second item.
Definition: qgsgeometry.h:76
QList< QgsLegendSymbolItem > QgsLegendSymbolList
QList< QgsSymbol * > QgsSymbolList
Definition: qgsrenderer.h:44