QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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