QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
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 Qgis::FeatureRendererFlags flags() const override;
61
72 bool renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) override SIP_THROW( QgsCsException );
73
78 void stopRender( QgsRenderContext &context ) override;
79
80 QString dump() const override;
81 QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
82 bool filterNeedsGeometry() const override;
83 QgsFeatureRenderer::Capabilities capabilities() override;
84 QgsSymbolList symbols( QgsRenderContext &context ) const override;
85 QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
86 QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
87 QgsSymbolList symbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
88 QgsSymbolList originalSymbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
89 QSet< QString > legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
90 QString legendKeyToExpression( const QString &key, QgsVectorLayer *layer, bool &ok ) const override;
91 QgsLegendSymbolList legendSymbolItems() const override;
92 bool willRenderFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
93 QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) override;
94 void setEmbeddedRenderer( QgsFeatureRenderer *subRenderer SIP_TRANSFER ) override;
95 const QgsFeatureRenderer *embeddedRenderer() const override;
96 void setLegendSymbolItem( const QString &key, QgsSymbol *symbol ) override;
97 bool legendSymbolItemsCheckable() const override;
98 bool legendSymbolItemChecked( const QString &key ) override;
99 void checkLegendSymbolItem( const QString &key, bool state = true ) override;
100 bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
101
106 static QgsMergedFeatureRenderer *convertFromRenderer( const QgsFeatureRenderer *renderer ) SIP_FACTORY;
107
108 protected:
109
115 QgsMergedFeatureRenderer( const QString &type, QgsFeatureRenderer *embeddedRenderer SIP_TRANSFER );
116
126
128 GeometryOperation mOperation = Merge;
129
131 std::unique_ptr<QgsFeatureRenderer> mSubRenderer;
132
133 private:
134
136 struct CombinedFeature
137 {
138 QVector<QgsGeometry> geometries; //< list of geometries
139 QgsFeature feature; //< one feature (for attriute-based rendering)
140 };
141 typedef QVector<CombinedFeature> FeatureCategoryVector;
143 FeatureCategoryVector mFeaturesCategories;
144
146 QMap<QByteArray, int> mSymbolCategories;
147
149 QgsPolygonXY mExtentPolygon;
150
152 QgsRenderContext mContext;
153
155 QgsFields mFields;
156
161 struct FeatureDecoration
162 {
163 QgsFeature feature;
164 bool selected;
165 bool drawMarkers;
166 int layer;
167 FeatureDecoration( const QgsFeature &a_feature, bool a_selected, bool a_drawMarkers, int a_layer )
168 : feature( a_feature )
169 , selected( a_selected )
170 , drawMarkers( a_drawMarkers )
171 , layer( a_layer )
172 {}
173 };
174 QList<FeatureDecoration> mFeatureDecorations;
175
176};
177
178
179#endif // QGSMERGEDFEATURERENDERER_H
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
Custom exception class for Coordinate Reference System related exceptions.
Abstract base class for all 2D vector feature renderers.
QFlags< Capability > Capabilities
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:58
Container of fields for a vector layer.
Definition qgsfields.h:46
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:231
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:203
QVector< QgsPolylineXY > QgsPolygonXY
Polygon: first item of the list is outer ring, inner rings (if any) start from second item.
Definition qgsgeometry.h:74
QList< QgsLegendSymbolItem > QgsLegendSymbolList
QList< QgsSymbol * > QgsSymbolList
Definition qgsrenderer.h:47