QGIS API Documentation  3.6.0-Noosa (5873452)
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 
55  QgsInvertedPolygonRenderer &operator=( const QgsInvertedPolygonRenderer & ) = delete;
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;
71 
76  void stopRender( QgsRenderContext &context ) override;
77 
78  QString dump() const override;
79 
81  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
82  bool filterNeedsGeometry() const override;
84  QgsFeatureRenderer::Capabilities capabilities() override;
85 
89  QgsSymbolList symbols( QgsRenderContext &context ) const override;
90 
94  QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
95 
99  QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
100 
104  QgsSymbolList symbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
105 
109  QgsSymbolList originalSymbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
110 
114  QgsLegendSymbolList legendSymbolItems() const override;
115 
119  bool willRenderFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
120 
122  static QgsFeatureRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
123 
124  QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) override;
125 
126  void setEmbeddedRenderer( QgsFeatureRenderer *subRenderer SIP_TRANSFER ) override;
127  const QgsFeatureRenderer *embeddedRenderer() const override;
128 
129  void setLegendSymbolItem( const QString &key, QgsSymbol *symbol ) override;
130 
131  bool legendSymbolItemsCheckable() const override;
132  bool legendSymbolItemChecked( const QString &key ) override;
133  void checkLegendSymbolItem( const QString &key, bool state = true ) override;
134 
136  bool preprocessingEnabled() const { return mPreprocessingEnabled; }
137 
144  void setPreprocessingEnabled( bool enabled ) { mPreprocessingEnabled = enabled; }
145 
151  static QgsInvertedPolygonRenderer *convertFromRenderer( const QgsFeatureRenderer *renderer ) SIP_FACTORY;
152 
153  private:
154 
156  std::unique_ptr<QgsFeatureRenderer> mSubRenderer;
157 
159  struct CombinedFeature
160  {
161  QVector<QgsGeometry> geometries; //< list of geometries
162  QgsFeature feature; //< one feature (for attriute-based rendering)
163  };
164  typedef QVector<CombinedFeature> FeatureCategoryVector;
166  FeatureCategoryVector mFeaturesCategories;
167 
169  QMap<QByteArray, int> mSymbolCategories;
170 
172  QgsPolygonXY mExtentPolygon;
173 
175  QgsRenderContext mContext;
176 
178  QgsFields mFields;
179 
184  struct FeatureDecoration
185  {
186  QgsFeature feature;
187  bool selected;
188  bool drawMarkers;
189  int layer;
190  FeatureDecoration( const QgsFeature &a_feature, bool a_selected, bool a_drawMarkers, int a_layer )
191  : feature( a_feature )
192  , selected( a_selected )
193  , drawMarkers( a_drawMarkers )
194  , layer( a_layer )
195  {}
196  };
197  QList<FeatureDecoration> mFeatureDecorations;
198 
200  bool mPreprocessingEnabled = false;
201 };
202 
203 
204 #endif // QGSINVERTEDPOLYGONRENDERER_H
The class is used as a container of context for various read/write operations on other objects...
virtual QgsLegendSymbolList legendSymbolItems() const
Returns a list of symbology items for the legend.
QList< QgsLegendSymbolItem > QgsLegendSymbolList
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:61
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context)
store renderer info to XML element
QVector< QgsPolylineXY > QgsPolygonXY
Polygon: first item of the list is outer ring, inner rings (if any) start from second item...
Definition: qgsgeometry.h:68
Container of fields for a vector layer.
Definition: qgsfields.h:42
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:55
virtual QgsSymbolList originalSymbolsForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
virtual QgsSymbol * symbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const =0
To be overridden.
virtual const QgsFeatureRenderer * embeddedRenderer() const
Returns the current embedded renderer (subrenderer) for this feature renderer.
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const =0
Returns a list of attributes required by this renderer.
QList< QgsSymbol * > QgsSymbolList
Definition: qgsrenderer.h:43
virtual bool renderFeature(const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
Render a feature using this renderer in the given context.
QgsInvertedPolygonRenderer is a polygon-only feature renderer used to display features inverted...
virtual QgsSymbol * originalSymbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns symbol for feature.
Definition: qgsrenderer.cpp:81
#define SIP_TRANSFER
Definition: qgis_sip.h:36
virtual bool legendSymbolItemChecked(const QString &key)
items of symbology items in legend is checked
#define SIP_FACTORY
Definition: qgis_sip.h:69
virtual void checkLegendSymbolItem(const QString &key, bool state=true)
item in symbology was checked
virtual void setLegendSymbolItem(const QString &key, QgsSymbol *symbol)
Sets the symbol to be used for a legend symbol item.
Contains information about the context of a rendering operation.
virtual QgsSymbolList symbolsForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns list of symbols used for rendering the feature.
virtual QgsSymbolList symbols(QgsRenderContext &context) const
Returns list of symbols used by the renderer.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
Definition: qgsrenderer.cpp:93
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
virtual void setEmbeddedRenderer(QgsFeatureRenderer *subRenderer)
Sets an embedded renderer (subrenderer) for this feature renderer.
virtual bool willRenderFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns whether the renderer will render a feature or not.
virtual bool legendSymbolItemsCheckable() const
items of symbology items in legend should be checkable
virtual bool filterNeedsGeometry() const
Returns true if this renderer requires the geometry to apply the filter.
virtual QgsFeatureRenderer::Capabilities capabilities()
Returns details about internals of this renderer.
Definition: qgsrenderer.h:262
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
virtual QString dump() const
Returns debug information about this renderer.