QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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();
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 
121  private:
126 
128  QScopedPointer<QgsFeatureRendererV2> mSubRenderer;
129 
132  {
133  QList<QgsGeometry*> geometries; //< list of geometries
134  QgsFeature feature; //< one feature (for attriute-based rendering)
135  };
136  typedef QVector<CombinedFeature> FeatureCategoryVector;
138  FeatureCategoryVector mFeaturesCategories;
139 
141  QMap<QByteArray, int> mSymbolCategories;
142 
145 
148 
151 
156  {
158  bool selected;
160  int layer;
161  FeatureDecoration( QgsFeature& a_feature, bool a_selected, bool a_drawMarkers, int a_layer ) :
162  feature( a_feature ), selected( a_selected ), drawMarkers( a_drawMarkers ), layer( a_layer ) {}
163  };
164  QList<FeatureDecoration> mFeatureDecorations;
165 
168 };
169 
170 
171 #endif // QGSMASKRENDERERV2_H
virtual bool willRenderFeature(QgsFeature &feat)
return whether the renderer will render a feature or not.
QList< QgsSymbolV2 * > QgsSymbolV2List
Definition: qgsrendererv2.h:37
virtual QString dump() const
for debugging
virtual QDomElement save(QDomDocument &doc)
store renderer info to XML element
QgsPolygon mExtentPolygon
the polygon used as exterior ring that covers the current extent
bool mPreprocessingEnabled
whether to preprocess (merge) geometries before rendering
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: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
FeatureDecoration(QgsFeature &a_feature, bool a_selected, bool a_drawMarkers, int a_layer)
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 bool renderFeature(QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
virtual QgsFeatureRendererV2 * clone()=0
QgsInvertedPolygonRenderer is a polygon-only feature renderer used to display features inverted...
QgsFields mFields
fields of each feature
QVector< CombinedFeature > FeatureCategoryVector
QVector< QgsPolyline > QgsPolygon
polygon: first item of the list is outer ring, inner rings (if any) start from second item ...
Definition: qgsgeometry.h:44
QList< QPair< QString, QPixmap > > QgsLegendSymbologyList
Class used to represent features that must be rendered with decorations (selection, vertex markers)
Contains information about the context of a rendering operation.
QMap< QByteArray, int > mSymbolCategories
maps a category to an index
FeatureCategoryVector mFeaturesCategories
where features are stored, based on the index of their symbol category
virtual QgsSymbolV2List symbolsForFeature(QgsFeature &feat)
return list of symbols used for rendering the feature.
QgsRenderContext mContext
the context used for rendering
QScopedPointer< QgsFeatureRendererV2 > mSubRenderer
Embedded renderer.
virtual int capabilities()
returns bitwise OR-ed capabilities of the renderer
QList< QPair< QString, QgsSymbolV2 * > > QgsLegendSymbolList
Definition: qgsrendererv2.h:41
virtual QgsSymbolV2 * symbolForFeature(QgsFeature &feature)=0
to be overridden
QList< FeatureDecoration > mFeatureDecorations
Structure where the reversed geometry is built during renderFeature.