QGIS API Documentation  3.2.0-Bonn (bc43194)
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;
83  QgsFeatureRenderer::Capabilities capabilities() override;
84 
88  QgsSymbolList symbols( QgsRenderContext &context ) const override;
89 
93  QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
94 
98  QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
99 
103  QgsSymbolList symbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
104 
108  QgsSymbolList originalSymbolsForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
109 
113  QgsLegendSymbolList legendSymbolItems() const override;
114 
118  bool willRenderFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
119 
121  static QgsFeatureRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
122 
123  QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) override;
124 
125  void setEmbeddedRenderer( QgsFeatureRenderer *subRenderer SIP_TRANSFER ) override;
126  const QgsFeatureRenderer *embeddedRenderer() const override;
127 
128  void setLegendSymbolItem( const QString &key, QgsSymbol *symbol ) override;
129 
130  bool legendSymbolItemsCheckable() const override;
131  bool legendSymbolItemChecked( const QString &key ) override;
132  void checkLegendSymbolItem( const QString &key, bool state = true ) override;
133 
135  bool preprocessingEnabled() const { return mPreprocessingEnabled; }
136 
143  void setPreprocessingEnabled( bool enabled ) { mPreprocessingEnabled = enabled; }
144 
150  static QgsInvertedPolygonRenderer *convertFromRenderer( const QgsFeatureRenderer *renderer ) SIP_FACTORY;
151 
152  private:
153 
155  std::unique_ptr<QgsFeatureRenderer> mSubRenderer;
156 
158  struct CombinedFeature
159  {
160  QVector<QgsGeometry> geometries; //< list of geometries
161  QgsFeature feature; //< one feature (for attriute-based rendering)
162  };
163  typedef QVector<CombinedFeature> FeatureCategoryVector;
165  FeatureCategoryVector mFeaturesCategories;
166 
168  QMap<QByteArray, int> mSymbolCategories;
169 
171  QgsPolygonXY mExtentPolygon;
172 
174  QgsRenderContext mContext;
175 
177  QgsFields mFields;
178 
183  struct FeatureDecoration
184  {
185  QgsFeature feature;
186  bool selected;
187  bool drawMarkers;
188  int layer;
189  FeatureDecoration( const QgsFeature &a_feature, bool a_selected, bool a_drawMarkers, int a_layer )
190  : feature( a_feature )
191  , selected( a_selected )
192  , drawMarkers( a_drawMarkers )
193  , layer( a_layer )
194  {}
195  };
196  QList<FeatureDecoration> mFeatureDecorations;
197 
199  bool mPreprocessingEnabled = false;
200 };
201 
202 
203 #endif // QGSMASKRENDERERV2_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
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:66
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:62
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:80
#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:92
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 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.