QGIS API Documentation  2.17.0-Master (dfeb663)
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.h"
19 #include "qgsrendererv2.h"
20 #include "qgssymbolv2.h"
21 #include "qgsexpression.h"
22 #include "qgsfeature.h"
23 #include "qgsgeometry.h"
24 #include <QScopedPointer>
25 
41 {
42  public:
43 
48  QgsInvertedPolygonRenderer( QgsFeatureRendererV2* embeddedRenderer = nullptr );
49 
50  virtual ~QgsInvertedPolygonRenderer();
51 
53  virtual QgsInvertedPolygonRenderer* clone() const override;
54 
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 
75  virtual QString dump() const override;
76 
78  virtual QList<QString> usedAttributes() override;
80  virtual int capabilities() override;
84  virtual QgsSymbolV2List symbols( QgsRenderContext& context ) override;
88  virtual QgsSymbolV2* symbolForFeature( QgsFeature& feature, QgsRenderContext& context ) override;
92  virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feat, QgsRenderContext& context ) override;
96  virtual QgsSymbolV2List symbolsForFeature( QgsFeature& feat, QgsRenderContext& context ) override;
100  virtual QgsSymbolV2List originalSymbolsForFeature( QgsFeature& feat, QgsRenderContext& context ) override;
102  virtual QgsLegendSymbologyList legendSymbologyItems( QSize iconSize ) override;
106  virtual QgsLegendSymbolList legendSymbolItems( double scaleDenominator = -1, const QString& rule = "" ) override;
110  virtual bool willRenderFeature( QgsFeature& feat, QgsRenderContext& context ) override;
111 
113  static QgsFeatureRendererV2* create( QDomElement& element );
114 
119  virtual QDomElement save( QDomDocument& doc ) override;
120 
121  void setEmbeddedRenderer( QgsFeatureRendererV2* subRenderer ) override;
122  const QgsFeatureRendererV2* embeddedRenderer() const override;
123 
124  virtual void setLegendSymbolItem( const QString& key, QgsSymbolV2* symbol ) override;
125 
126  virtual bool legendSymbolItemsCheckable() const override;
127  virtual bool legendSymbolItemChecked( const QString& key ) override;
128  virtual void checkLegendSymbolItem( const QString& key, bool state = true ) override;
129 
131  bool preprocessingEnabled() const { return mPreprocessingEnabled; }
138  void setPreprocessingEnabled( bool enabled ) { mPreprocessingEnabled = enabled; }
139 
144  static QgsInvertedPolygonRenderer* convertFromRenderer( const QgsFeatureRendererV2* renderer );
145 
146  private:
151 
154 
156  struct CombinedFeature
157  {
158  QList<QgsGeometry*> geometries; //< list of geometries
159  QgsFeature feature; //< one feature (for attriute-based rendering)
160  };
163  FeatureCategoryVector mFeaturesCategories;
164 
166  QMap<QByteArray, int> mSymbolCategories;
167 
169  QgsPolygon mExtentPolygon;
170 
172  QgsRenderContext mContext;
173 
175  QgsFields mFields;
176 
180  struct FeatureDecoration
181  {
182  QgsFeature feature;
183  bool selected;
184  bool drawMarkers;
185  int layer;
186  FeatureDecoration( QgsFeature& a_feature, bool a_selected, bool a_drawMarkers, int a_layer )
187  : feature( a_feature )
188  , selected( a_selected )
189  , drawMarkers( a_drawMarkers )
190  , layer( a_layer )
191  {}
192  };
193  QList<FeatureDecoration> mFeatureDecorations;
194 
196  bool mPreprocessingEnabled;
197 };
198 
199 
200 #endif // QGSMASKRENDERERV2_H
virtual Q_DECL_DEPRECATED QgsSymbolV2 * originalSymbolForFeature(QgsFeature &feature)
Return symbol for feature.
virtual QDomElement save(QDomDocument &doc)
store renderer info to XML element
Container of fields for a vector layer.
Definition: qgsfield.h:252
virtual QList< QString > usedAttributes()=0
Returns a set of attributes required for this renderer.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:187
virtual Q_DECL_DEPRECATED bool willRenderFeature(QgsFeature &feat)
Returns whether the renderer will render a feature or not.
virtual bool legendSymbolItemChecked(const QString &key)
items of symbology items in legend is checked
virtual void checkLegendSymbolItem(const QString &key, bool state=true)
item in symbology was checked
virtual QgsLegendSymbologyList legendSymbologyItems(QSize iconSize)
return a list of symbology items for the legend
virtual const QgsFeatureRendererV2 * embeddedRenderer() const
Returns the current embedded renderer (subrenderer) for this feature renderer.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started.
virtual void stopRender(QgsRenderContext &context)=0
Needs to be called when a render cycle has finished to clean up.
virtual Q_DECL_DEPRECATED QgsSymbolV2List originalSymbolsForFeature(QgsFeature &feat)
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
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.
virtual void setEmbeddedRenderer(QgsFeatureRendererV2 *subRenderer)
Sets an embedded renderer (subrenderer) for this feature renderer.
virtual QgsFeatureRendererV2 * clone() const =0
virtual Q_DECL_DEPRECATED QgsSymbolV2 * symbolForFeature(QgsFeature &feature)
To be overridden.
virtual QString dump() const
for debugging
QgsInvertedPolygonRenderer is a polygon-only feature renderer used to display features inverted...
virtual QgsLegendSymbolList legendSymbolItems(double scaleDenominator=-1, const QString &rule="")
return a list of item text / symbol
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbols()
For symbol levels.
Contains information about the context of a rendering operation.
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbolsForFeature(QgsFeature &feat)
Returns list of symbols used for rendering the feature.
virtual bool legendSymbolItemsCheckable() const
items of symbology items in legend should be checkable
virtual int capabilities()
returns bitwise OR-ed capabilities of the renderer
virtual void setLegendSymbolItem(const QString &key, QgsSymbolV2 *symbol)
Sets the symbol to be used for a legend symbol item.