QGIS API Documentation  2.5.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 );
86  virtual QgsLegendSymbologyList legendSymbologyItems( QSize iconSize );
90  virtual QgsLegendSymbolList legendSymbolItems( double scaleDenominator = -1, QString rule = "" );
92  virtual bool willRenderFeature( QgsFeature& feat );
93 
95  static QgsFeatureRendererV2* create( QDomElement& element );
96 
101  virtual QDomElement save( QDomDocument& doc );
102 
106  void setEmbeddedRenderer( const QgsFeatureRendererV2* subRenderer );
109  const QgsFeatureRendererV2* embeddedRenderer() const;
110 
112  bool preprocessingEnabled() const { return mPreprocessingEnabled; }
119  void setPreprocessingEnabled( bool enabled ) { mPreprocessingEnabled = enabled; }
120 
125  static QgsInvertedPolygonRenderer* convertFromRenderer( const QgsFeatureRendererV2* renderer );
126 
127  private:
132 
134  QScopedPointer<QgsFeatureRendererV2> mSubRenderer;
135 
137  struct CombinedFeature
138  {
139  QList<QgsGeometry*> geometries; //< list of geometries
140  QgsFeature feature; //< one feature (for attriute-based rendering)
141  };
142  typedef QVector<CombinedFeature> FeatureCategoryVector;
144  FeatureCategoryVector mFeaturesCategories;
145 
147  QMap<QByteArray, int> mSymbolCategories;
148 
150  QgsPolygon mExtentPolygon;
151 
153  QgsRenderContext mContext;
154 
156  QgsFields mFields;
157 
161  struct FeatureDecoration
162  {
163  QgsFeature feature;
164  bool selected;
165  bool drawMarkers;
166  int layer;
167  FeatureDecoration( QgsFeature& a_feature, bool a_selected, bool a_drawMarkers, int a_layer ) :
168  feature( a_feature ), selected( a_selected ), drawMarkers( a_drawMarkers ), layer( a_layer ) {}
169  };
170  QList<FeatureDecoration> mFeatureDecorations;
171 
173  bool mPreprocessingEnabled;
174 };
175 
176 
177 #endif // QGSMASKRENDERERV2_H
virtual bool willRenderFeature(QgsFeature &feat)
return whether the renderer will render a feature or not.
Definition: qgsrendererv2.h:196
QList< QgsSymbolV2 * > QgsSymbolV2List
Definition: qgsrendererv2.h:37
virtual QString dump() const
for debugging
Definition: qgsrendererv2.cpp:367
virtual QDomElement save(QDomDocument &doc)
store renderer info to XML element
Definition: qgsrendererv2.cpp:395
virtual QgsLegendSymbolList legendSymbolItems(double scaleDenominator=-1, QString rule="")
return a list of item text / symbol
Definition: qgsrendererv2.cpp:529
Container of fields for a vector layer.
Definition: qgsfield.h:163
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
Definition: qgsrendererv2.cpp:505
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
virtual void stopRender(QgsRenderContext &context)=0
virtual QgsSymbolV2List symbols()=0
for symbol levels
virtual bool renderFeature(QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
Definition: qgsrendererv2.cpp:214
virtual QgsFeatureRendererV2 * clone() const =0
QgsInvertedPolygonRenderer is a polygon-only feature renderer used to display features inverted...
Definition: qgsinvertedpolygonrenderer.h:40
void setPreprocessingEnabled(bool enabled)
Definition: qgsinvertedpolygonrenderer.h:119
bool preprocessingEnabled() const
Definition: qgsinvertedpolygonrenderer.h:112
QVector< QgsPolyline > QgsPolygon
polygon: first item of the list is outer ring, inner rings (if any) start from second item ...
Definition: qgsgeometry.h:39
Definition: qgssymbolv2.h:43
QList< QPair< QString, QPixmap > > QgsLegendSymbologyList
Definition: qgspluginlayer.h:20
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:39
virtual QgsSymbolV2List symbolsForFeature(QgsFeature &feat)
return list of symbols used for rendering the feature.
Definition: qgsrendererv2.cpp:582
Definition: qgsrendererv2.h:72
virtual int capabilities()
returns bitwise OR-ed capabilities of the renderer
Definition: qgsrendererv2.h:117
QList< QPair< QString, QgsSymbolV2 * > > QgsLegendSymbolList
Definition: qgsrendererv2.h:41
virtual QgsSymbolV2 * symbolForFeature(QgsFeature &feature)=0
to be overridden