QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsinvertedpolygonrenderer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsinvertedpolygonrenderer.h
3  ---------------------
4  begin : April 2014
5  copyright : (C) 2014 Hugo Mercier / Oslandia
6  email : hugo dot mercier at oslandia 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 QGSINVERTEDPOLYGONRENDERER_H
16 #define QGSINVERTEDPOLYGONRENDERER_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 
42 {
43  public:
44 
50  QgsInvertedPolygonRenderer( QgsFeatureRenderer *embeddedRenderer SIP_TRANSFER = nullptr );
51 
56 
58  void startRender( QgsRenderContext &context, const QgsFields &fields ) override;
59 
70  bool renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) override SIP_THROW( QgsCsException );
71 
76  void stopRender( QgsRenderContext &context ) override;
77 
78  QString dump() const override;
79  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
80  bool filterNeedsGeometry() const override;
81  QgsFeatureRenderer::Capabilities capabilities() override;
82  QgsSymbolList symbols( QgsRenderContext &context ) const override;
83  QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
84  QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
85  QgsSymbolList symbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
86  QgsSymbolList originalSymbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
87  QSet< QString > legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
88  QgsLegendSymbolList legendSymbolItems() const override;
89  bool willRenderFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
90 
92  static QgsFeatureRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
93 
94  QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) override;
95 
96  void setEmbeddedRenderer( QgsFeatureRenderer *subRenderer SIP_TRANSFER ) override;
97  const QgsFeatureRenderer *embeddedRenderer() const override;
98 
99  void setLegendSymbolItem( const QString &key, QgsSymbol *symbol ) override;
100 
101  bool legendSymbolItemsCheckable() const override;
102  bool legendSymbolItemChecked( const QString &key ) override;
103  void checkLegendSymbolItem( const QString &key, bool state = true ) override;
104  bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
105 
107  bool preprocessingEnabled() const { return mPreprocessingEnabled; }
108 
115  void setPreprocessingEnabled( bool enabled ) { mPreprocessingEnabled = enabled; }
116 
122  static QgsInvertedPolygonRenderer *convertFromRenderer( const QgsFeatureRenderer *renderer ) SIP_FACTORY;
123 
124  private:
125 
127  std::unique_ptr<QgsFeatureRenderer> mSubRenderer;
128 
130  struct CombinedFeature
131  {
132  QVector<QgsGeometry> geometries; //< list of geometries
133  QgsFeature feature; //< one feature (for attriute-based rendering)
134  };
135  typedef QVector<CombinedFeature> FeatureCategoryVector;
137  FeatureCategoryVector mFeaturesCategories;
138 
140  QMap<QByteArray, int> mSymbolCategories;
141 
143  QgsPolygonXY mExtentPolygon;
144 
146  QgsRenderContext mContext;
147 
149  QgsFields mFields;
150 
155  struct FeatureDecoration
156  {
157  QgsFeature feature;
158  bool selected;
159  bool drawMarkers;
160  int layer;
161  FeatureDecoration( const QgsFeature &a_feature, bool a_selected, bool a_drawMarkers, int a_layer )
162  : feature( a_feature )
163  , selected( a_selected )
164  , drawMarkers( a_drawMarkers )
165  , layer( a_layer )
166  {}
167  };
168  QList<FeatureDecoration> mFeatureDecorations;
169 
171  bool mPreprocessingEnabled = false;
172 };
173 
174 
175 #endif // QGSINVERTEDPOLYGONRENDERER_H
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:35
QgsPolygonXY
QVector< QgsPolylineXY > QgsPolygonXY
Polygon: first item of the list is outer ring, inner rings (if any) start from second item.
Definition: qgsgeometry.h:75
qgsexpression.h
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:45
qgsfeature.h
qgis.h
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:58
QgsStyleEntityVisitorInterface
An interface for classes which can visit style entity (e.g.
Definition: qgsstyleentityvisitor.h:34
QgsSymbol
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:64
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsCsException
Custom exception class for Coordinate Reference System related exceptions.
Definition: qgsexception.h:66
SIP_THROW
#define SIP_THROW(name)
Definition: qgis_sip.h:189
QgsSymbolList
QList< QgsSymbol * > QgsSymbolList
Definition: qgsrenderer.h:45
QgsFeatureRenderer::clone
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
qgis_sip.h
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
qgsrenderer.h
qgsgeometry.h
QgsFeatureRenderer
Definition: qgsrenderer.h:103
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
QgsInvertedPolygonRenderer::setPreprocessingEnabled
void setPreprocessingEnabled(bool enabled)
Definition: qgsinvertedpolygonrenderer.h:115
QgsLegendSymbolList
QList< QgsLegendSymbolItem > QgsLegendSymbolList
Definition: qgslegendsymbolitem.h:144
QgsInvertedPolygonRenderer::QgsInvertedPolygonRenderer
QgsInvertedPolygonRenderer(const QgsInvertedPolygonRenderer &)=delete
Direct copies are forbidden. Use clone() instead.
QgsInvertedPolygonRenderer::operator=
QgsInvertedPolygonRenderer & operator=(const QgsInvertedPolygonRenderer &)=delete
Direct copies are forbidden. Use clone() instead.
QgsInvertedPolygonRenderer
QgsInvertedPolygonRenderer is a polygon-only feature renderer used to display features inverted,...
Definition: qgsinvertedpolygonrenderer.h:42