QGIS API Documentation  2.99.0-Master (23ddace)
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 
41 {
42  public:
43 
49 
53  QgsInvertedPolygonRenderer &operator=( const QgsInvertedPolygonRenderer & ) = delete;
54 
55  virtual QgsInvertedPolygonRenderer *clone() const override SIP_FACTORY;
56  virtual void startRender( QgsRenderContext &context, const QgsFields &fields ) override;
57 
67  virtual bool renderFeature( QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) override;
68 
73  virtual void stopRender( QgsRenderContext &context ) override;
74 
75  virtual QString dump() const override;
76 
78  virtual QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
80  virtual QgsFeatureRenderer::Capabilities capabilities() override;
81 
84  virtual QgsSymbolList symbols( QgsRenderContext &context ) override;
85 
88  virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
89 
92  virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feat, QgsRenderContext &context ) override;
93 
96  virtual QgsSymbolList symbolsForFeature( QgsFeature &feat, QgsRenderContext &context ) override;
97 
100  virtual QgsSymbolList originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context ) override;
101 
104  virtual QgsLegendSymbolList legendSymbolItems() const override;
105 
108  virtual bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context ) override;
109 
111  static QgsFeatureRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
112 
113  virtual QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) override;
114 
115  void setEmbeddedRenderer( QgsFeatureRenderer *subRenderer SIP_TRANSFER ) override;
116  const QgsFeatureRenderer *embeddedRenderer() const override;
117 
118  virtual void setLegendSymbolItem( const QString &key, QgsSymbol *symbol ) override;
119 
120  virtual bool legendSymbolItemsCheckable() const override;
121  virtual bool legendSymbolItemChecked( const QString &key ) override;
122  virtual void checkLegendSymbolItem( const QString &key, bool state = true ) override;
123 
125  bool preprocessingEnabled() const { return mPreprocessingEnabled; }
126 
133  void setPreprocessingEnabled( bool enabled ) { mPreprocessingEnabled = enabled; }
134 
139  static QgsInvertedPolygonRenderer *convertFromRenderer( const QgsFeatureRenderer *renderer ) SIP_FACTORY;
140 
141  private:
142 
144  std::unique_ptr<QgsFeatureRenderer> mSubRenderer;
145 
147  struct CombinedFeature
148  {
149  QList<QgsGeometry> geometries; //< list of geometries
150  QgsFeature feature; //< one feature (for attriute-based rendering)
151  };
152  typedef QVector<CombinedFeature> FeatureCategoryVector;
154  FeatureCategoryVector mFeaturesCategories;
155 
157  QMap<QByteArray, int> mSymbolCategories;
158 
160  QgsPolygon mExtentPolygon;
161 
163  QgsRenderContext mContext;
164 
166  QgsFields mFields;
167 
171  struct FeatureDecoration
172  {
173  QgsFeature feature;
174  bool selected;
175  bool drawMarkers;
176  int layer;
177  FeatureDecoration( QgsFeature &a_feature, bool a_selected, bool a_drawMarkers, int a_layer )
178  : feature( a_feature )
179  , selected( a_selected )
180  , drawMarkers( a_drawMarkers )
181  , layer( a_layer )
182  {}
183  };
184  QList<FeatureDecoration> mFeatureDecorations;
185 
187  bool mPreprocessingEnabled;
188 };
189 
190 
191 #endif // QGSMASKRENDERERV2_H
virtual bool willRenderFeature(QgsFeature &feat, QgsRenderContext &context)
Returns whether the renderer will render a feature or not.
The class is used as a container of context for various read/write operations on other objects...
virtual QgsSymbolList originalSymbolsForFeature(QgsFeature &feat, QgsRenderContext &context)
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
virtual QgsLegendSymbolList legendSymbolItems() const
Returns a list of symbology items for the legend.
QList< QgsLegendSymbolItem > QgsLegendSymbolList
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context)
store renderer info to XML element
virtual QgsSymbol * originalSymbolForFeature(QgsFeature &feature, QgsRenderContext &context)
Return symbol for feature.
Definition: qgsrenderer.cpp:81
Container of fields for a vector layer.
Definition: qgsfields.h:41
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:61
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started.
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const =0
Return a list of attributes required by this renderer.
QList< QgsSymbol * > QgsSymbolList
Definition: qgsrenderer.h:43
virtual QgsSymbolList symbolsForFeature(QgsFeature &feat, QgsRenderContext &context)
Returns list of symbols used for rendering the feature.
QgsInvertedPolygonRenderer is a polygon-only feature renderer used to display features inverted...
#define SIP_TRANSFER
Definition: qgis_sip.h:24
virtual bool legendSymbolItemChecked(const QString &key)
items of symbology items in legend is checked
#define SIP_FACTORY
Definition: qgis_sip.h:57
QVector< QgsPolyline > QgsPolygon
Polygon: first item of the list is outer ring, inner rings (if any) start from second item...
Definition: qgsgeometry.h:55
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.
virtual void setEmbeddedRenderer(QgsFeatureRenderer *subRenderer)
Sets an embedded renderer (subrenderer) for this feature renderer.
Definition: qgsrenderer.h:407
virtual QgsSymbolList symbols(QgsRenderContext &context)
Returns list of symbols used by the renderer.
Definition: qgsrenderer.h:247
virtual const QgsFeatureRenderer * embeddedRenderer() const
Returns the current embedded renderer (subrenderer) for this feature renderer.
Definition: qgsrenderer.h:414
virtual QgsSymbol * symbolForFeature(QgsFeature &feature, QgsRenderContext &context)=0
To be overridden.
Contains information about the context of a rendering operation.
virtual void stopRender(QgsRenderContext &context)=0
Needs to be called when a render cycle has finished to clean up.
virtual bool legendSymbolItemsCheckable() const
items of symbology items in legend should be checkable
virtual QgsFeatureRenderer::Capabilities capabilities()
Returns details about internals of this renderer.
Definition: qgsrenderer.h:241
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
virtual bool renderFeature(QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
Render a feature using this renderer in the given context.
Definition: qgsrenderer.cpp:98
virtual QString dump() const
Returns debug information about this renderer.