QGIS API Documentation  2.99.0-Master (e077efd)
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 "qgsrenderer.h"
20 #include "qgsexpression.h"
21 #include "qgsfeature.h"
22 #include "qgsgeometry.h"
23 #include <QScopedPointer>
24 
40 {
41  public:
42 
47  QgsInvertedPolygonRenderer( QgsFeatureRenderer* embeddedRenderer = nullptr );
48 
49  virtual ~QgsInvertedPolygonRenderer();
50 
51  virtual QgsInvertedPolygonRenderer* clone() const override;
52  virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) override;
53 
63  virtual bool renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) override;
64 
69  virtual void stopRender( QgsRenderContext& context ) override;
70 
71  virtual QString dump() const override;
72 
74  virtual QSet<QString> usedAttributes() const override;
76  virtual Capabilities capabilities() override;
77 
80  virtual QgsSymbolList symbols( QgsRenderContext& context ) override;
81 
84  virtual QgsSymbol* symbolForFeature( QgsFeature& feature, QgsRenderContext& context ) override;
85 
88  virtual QgsSymbol* originalSymbolForFeature( QgsFeature& feat, QgsRenderContext& context ) override;
89 
92  virtual QgsSymbolList symbolsForFeature( QgsFeature& feat, QgsRenderContext& context ) override;
93 
96  virtual QgsSymbolList originalSymbolsForFeature( QgsFeature& feat, QgsRenderContext& context ) override;
98  virtual QgsLegendSymbologyList legendSymbologyItems( QSize iconSize ) override;
99 
103  virtual QgsLegendSymbolList legendSymbolItems( double scaleDenominator = -1, const QString& rule = "" ) override;
104 
107  virtual bool willRenderFeature( QgsFeature& feat, QgsRenderContext& context ) override;
108 
110  static QgsFeatureRenderer* create( QDomElement& element );
111 
112  virtual QDomElement save( QDomDocument& doc ) override;
113 
114  void setEmbeddedRenderer( QgsFeatureRenderer* subRenderer ) override;
115  const QgsFeatureRenderer* embeddedRenderer() const override;
116 
117  virtual void setLegendSymbolItem( const QString& key, QgsSymbol* symbol ) override;
118 
119  virtual bool legendSymbolItemsCheckable() const override;
120  virtual bool legendSymbolItemChecked( const QString& key ) override;
121  virtual void checkLegendSymbolItem( const QString& key, bool state = true ) override;
122 
124  bool preprocessingEnabled() const { return mPreprocessingEnabled; }
125 
132  void setPreprocessingEnabled( bool enabled ) { mPreprocessingEnabled = enabled; }
133 
138  static QgsInvertedPolygonRenderer* convertFromRenderer( const QgsFeatureRenderer* renderer );
139 
140  private:
145 
147  QScopedPointer<QgsFeatureRenderer> mSubRenderer;
148 
150  struct CombinedFeature
151  {
152  QList<QgsGeometry> geometries; //< list of geometries
153  QgsFeature feature; //< one feature (for attriute-based rendering)
154  };
155  typedef QVector<CombinedFeature> FeatureCategoryVector;
157  FeatureCategoryVector mFeaturesCategories;
158 
160  QMap<QByteArray, int> mSymbolCategories;
161 
163  QgsPolygon mExtentPolygon;
164 
166  QgsRenderContext mContext;
167 
169  QgsFields mFields;
170 
174  struct FeatureDecoration
175  {
176  QgsFeature feature;
177  bool selected;
178  bool drawMarkers;
179  int layer;
180  FeatureDecoration( QgsFeature& a_feature, bool a_selected, bool a_drawMarkers, int a_layer )
181  : feature( a_feature )
182  , selected( a_selected )
183  , drawMarkers( a_drawMarkers )
184  , layer( a_layer )
185  {}
186  };
187  QList<FeatureDecoration> mFeatureDecorations;
188 
190  bool mPreprocessingEnabled;
191 };
192 
193 
194 #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:36
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:135
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started.
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:52
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:383
virtual QgsSymbolList symbols(QgsRenderContext &context)
Returns list of symbols used by the renderer.
Definition: qgsrenderer.h:215
virtual const QgsFeatureRenderer * embeddedRenderer() const
Returns the current embedded renderer (subrenderer) for this feature renderer.
Definition: qgsrenderer.h:390
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< QgsSymbol * > QgsSymbolList
Definition: qgsrenderer.h:40
virtual QSet< QString > usedAttributes() const =0
Return a list of attributes required by this renderer.
virtual Capabilities capabilities()
Returns details about internals of this renderer.
Definition: qgsrenderer.h:209
virtual bool legendSymbolItemsCheckable() const
items of symbology items in legend should be checkable
QList< QPair< QString, QgsSymbol * > > QgsLegendSymbolList
Definition: qgsrenderer.h:44
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.