QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
47  QgsInvertedPolygonRenderer( const QgsFeatureRendererV2* embeddedRenderer = 0 );
48  virtual ~QgsInvertedPolygonRenderer();
49 
51  virtual QgsFeatureRendererV2* clone() const;
52 
53  virtual void startRender( QgsRenderContext& context, const QgsFields& fields );
54 
64  virtual bool renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool selected = false, bool drawVertexMarker = false );
65 
70  virtual void stopRender( QgsRenderContext& context );
71 
73  virtual QString dump() const;
74 
76  virtual QList<QString> usedAttributes();
78  virtual int capabilities();
80  virtual QgsSymbolV2List symbols();
82  virtual QgsSymbolV2* symbolForFeature( QgsFeature& feature );
90  virtual QgsLegendSymbologyList legendSymbologyItems( QSize iconSize );
94  virtual QgsLegendSymbolList legendSymbolItems( double scaleDenominator = -1, QString rule = "" );
96  virtual bool willRenderFeature( QgsFeature& feat );
97 
99  static QgsFeatureRendererV2* create( QDomElement& element );
100 
105  virtual QDomElement save( QDomDocument& doc );
106 
110  void setEmbeddedRenderer( const QgsFeatureRendererV2* subRenderer );
113  const QgsFeatureRendererV2* embeddedRenderer() const;
114 
116  bool preprocessingEnabled() const { return mPreprocessingEnabled; }
123  void setPreprocessingEnabled( bool enabled ) { mPreprocessingEnabled = enabled; }
124 
129  static QgsInvertedPolygonRenderer* convertFromRenderer( const QgsFeatureRendererV2* renderer );
130 
131  private:
136 
138  QScopedPointer<QgsFeatureRendererV2> mSubRenderer;
139 
141  struct CombinedFeature
142  {
143  QList<QgsGeometry*> geometries; //< list of geometries
144  QgsFeature feature; //< one feature (for attriute-based rendering)
145  };
146  typedef QVector<CombinedFeature> FeatureCategoryVector;
148  FeatureCategoryVector mFeaturesCategories;
149 
151  QMap<QByteArray, int> mSymbolCategories;
152 
154  QgsPolygon mExtentPolygon;
155 
157  QgsRenderContext mContext;
158 
160  QgsFields mFields;
161 
165  struct FeatureDecoration
166  {
167  QgsFeature feature;
168  bool selected;
169  bool drawMarkers;
170  int layer;
171  FeatureDecoration( QgsFeature& a_feature, bool a_selected, bool a_drawMarkers, int a_layer ) :
172  feature( a_feature ), selected( a_selected ), drawMarkers( a_drawMarkers ), layer( a_layer ) {}
173  };
174  QList<FeatureDecoration> mFeatureDecorations;
175 
177  bool mPreprocessingEnabled;
178 };
179 
180 
181 #endif // QGSMASKRENDERERV2_H
virtual bool willRenderFeature(QgsFeature &feat)
return whether the renderer will render a feature or not.
virtual QgsSymbolV2 * originalSymbolForFeature(QgsFeature &feature)
Return symbol for feature.
Definition: qgsrendererv2.h:95
QList< QgsSymbolV2 * > QgsSymbolV2List
Definition: qgsrendererv2.h:38
virtual QString dump() const
for debugging
virtual QDomElement save(QDomDocument &doc)
store renderer info to XML element
virtual QgsLegendSymbolList legendSymbolItems(double scaleDenominator=-1, QString rule="")
return a list of item text / symbol
Container of fields for a vector layer.
Definition: qgsfield.h:172
virtual QList< QString > usedAttributes()=0
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:113
virtual QgsLegendSymbologyList legendSymbologyItems(QSize iconSize)
return a list of symbology items for the legend
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
virtual void stopRender(QgsRenderContext &context)=0
virtual QgsSymbolV2List symbols()=0
for symbol levels
virtual 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)
virtual QgsFeatureRendererV2 * clone() const =0
QgsInvertedPolygonRenderer is a polygon-only feature renderer used to display features inverted...
QVector< QgsPolyline > QgsPolygon
polygon: first item of the list is outer ring, inner rings (if any) start from second item ...
Definition: qgsgeometry.h:39
QList< QPair< QString, QPixmap > > QgsLegendSymbologyList
Contains information about the context of a rendering operation.
virtual QgsSymbolV2List symbolsForFeature(QgsFeature &feat)
return list of symbols used for rendering the feature.
virtual int capabilities()
returns bitwise OR-ed capabilities of the renderer
QList< QPair< QString, QgsSymbolV2 * > > QgsLegendSymbolList
Definition: qgsrendererv2.h:42
virtual QgsSymbolV2 * symbolForFeature(QgsFeature &feature)=0
to be overridden