QGIS API Documentation  2.99.0-Master (5169e0d)
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.h"
20 #include "qgsrenderer.h"
21 #include "qgsexpression.h"
22 #include "qgsfeature.h"
23 #include "qgsgeometry.h"
24 
40 {
41  public:
42 
47  QgsInvertedPolygonRenderer( QgsFeatureRenderer *embeddedRenderer = nullptr );
48 
52  QgsInvertedPolygonRenderer &operator=( const QgsInvertedPolygonRenderer & ) = delete;
53 
54  virtual QgsInvertedPolygonRenderer *clone() const override;
55  virtual void startRender( QgsRenderContext &context, const QgsFields &fields ) override;
56 
66  virtual bool renderFeature( QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) override;
67 
72  virtual void stopRender( QgsRenderContext &context ) override;
73 
74  virtual QString dump() const override;
75 
77  virtual QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
79  virtual Capabilities capabilities() override;
80 
83  virtual QgsSymbolList symbols( QgsRenderContext &context ) override;
84 
87  virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
88 
91  virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feat, QgsRenderContext &context ) override;
92 
95  virtual QgsSymbolList symbolsForFeature( QgsFeature &feat, QgsRenderContext &context ) override;
96 
99  virtual QgsSymbolList originalSymbolsForFeature( QgsFeature &feat, QgsRenderContext &context ) override;
101  virtual QgsLegendSymbologyList legendSymbologyItems( QSize iconSize ) override;
102 
106  virtual QgsLegendSymbolList legendSymbolItems( double scaleDenominator = -1, const QString &rule = "" ) override;
107 
110  virtual bool willRenderFeature( QgsFeature &feat, QgsRenderContext &context ) override;
111 
113  static QgsFeatureRenderer *create( QDomElement &element );
114 
115  virtual QDomElement save( QDomDocument &doc ) override;
116 
117  void setEmbeddedRenderer( QgsFeatureRenderer *subRenderer ) override;
118  const QgsFeatureRenderer *embeddedRenderer() const override;
119 
120  virtual void setLegendSymbolItem( const QString &key, QgsSymbol *symbol ) override;
121 
122  virtual bool legendSymbolItemsCheckable() const override;
123  virtual bool legendSymbolItemChecked( const QString &key ) override;
124  virtual void checkLegendSymbolItem( const QString &key, bool state = true ) override;
125 
127  bool preprocessingEnabled() const { return mPreprocessingEnabled; }
128 
135  void setPreprocessingEnabled( bool enabled ) { mPreprocessingEnabled = enabled; }
136 
141  static QgsInvertedPolygonRenderer *convertFromRenderer( const QgsFeatureRenderer *renderer );
142 
143  private:
144 
146  std::unique_ptr<QgsFeatureRenderer> mSubRenderer;
147 
149  struct CombinedFeature
150  {
151  QList<QgsGeometry> geometries; //< list of geometries
152  QgsFeature feature; //< one feature (for attriute-based rendering)
153  };
154  typedef QVector<CombinedFeature> FeatureCategoryVector;
156  FeatureCategoryVector mFeaturesCategories;
157 
159  QMap<QByteArray, int> mSymbolCategories;
160 
162  QgsPolygon mExtentPolygon;
163 
165  QgsRenderContext mContext;
166 
168  QgsFields mFields;
169 
173  struct FeatureDecoration
174  {
175  QgsFeature feature;
176  bool selected;
177  bool drawMarkers;
178  int layer;
179  FeatureDecoration( QgsFeature &a_feature, bool a_selected, bool a_drawMarkers, int a_layer )
180  : feature( a_feature )
181  , selected( a_selected )
182  , drawMarkers( a_drawMarkers )
183  , layer( a_layer )
184  {}
185  };
186  QList<FeatureDecoration> mFeatureDecorations;
187 
189  bool mPreprocessingEnabled;
190 };
191 
192 
193 #endif // QGSMASKRENDERERV2_H
virtual bool willRenderFeature(QgsFeature &feat, QgsRenderContext &context)
Returns whether the renderer will render a feature or not.
virtual QgsSymbolList originalSymbolsForFeature(QgsFeature &feat, QgsRenderContext &context)
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
virtual QgsLegendSymbologyList legendSymbologyItems(QSize iconSize)
return a list of symbology items for the legend
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:39
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:41
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...
virtual QDomElement save(QDomDocument &doc)
store renderer info to XML element
virtual bool legendSymbolItemChecked(const QString &key)
items of symbology items in legend is checked
QVector< QgsPolyline > QgsPolygon
Polygon: first item of the list is outer ring, inner rings (if any) start from second item...
Definition: qgsgeometry.h:53
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.
QList< QPair< QString, QPixmap > > QgsLegendSymbologyList
virtual void setEmbeddedRenderer(QgsFeatureRenderer *subRenderer)
Sets an embedded renderer (subrenderer) for this feature renderer.
Definition: qgsrenderer.h:384
virtual QgsSymbolList symbols(QgsRenderContext &context)
Returns list of symbols used by the renderer.
Definition: qgsrenderer.h:216
virtual const QgsFeatureRenderer * embeddedRenderer() const
Returns the current embedded renderer (subrenderer) for this feature renderer.
Definition: qgsrenderer.h:391
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.
QList< QPair< QString, QgsSymbol * > > QgsLegendSymbolList
Definition: qgsrenderer.h:45
virtual Capabilities capabilities()
Returns details about internals of this renderer.
Definition: qgsrenderer.h:210
virtual bool legendSymbolItemsCheckable() const
items of symbology items in legend should be checkable
virtual QgsLegendSymbolList legendSymbolItems(double scaleDenominator=-1, const QString &rule="")
return a list of item text / symbol
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.