QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgssinglesymbolrendererv2.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssinglesymbolrendererv2.h
3  ---------------------
4  begin : November 2009
5  copyright : (C) 2009 by Martin Dobias
6  email : wonder dot sk at gmail 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 QGSSINGLESYMBOLRENDERERV2_H
16 #define QGSSINGLESYMBOLRENDERERV2_H
17 
18 #include "qgis.h"
19 #include "qgsrendererv2.h"
20 #include "qgssymbolv2.h"
21 #include "qgsexpression.h"
22 #include <QScopedPointer>
23 
25 {
26  public:
27 
29 
30  virtual ~QgsSingleSymbolRendererV2();
31 
32  virtual QgsSymbolV2* symbolForFeature( QgsFeature& feature );
33 
34  virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feature );
35 
36  virtual void startRender( QgsRenderContext& context, const QgsFields& fields );
37 
38  virtual void stopRender( QgsRenderContext& context );
39 
40  virtual QList<QString> usedAttributes();
41 
42  QgsSymbolV2* symbol() const;
43  void setSymbol( QgsSymbolV2* s );
44 
46  void setRotationField( QString fieldOrExpression );
48  QString rotationField() const;
49 
51  void setSizeScaleField( QString fieldOrExpression );
53  QString sizeScaleField() const;
54 
56  void setScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod );
58  QgsSymbolV2::ScaleMethod scaleMethod() const { return mScaleMethod; }
59 
60  virtual QString dump() const;
61 
62  virtual QgsFeatureRendererV2* clone() const ;
63 
64  virtual void toSld( QDomDocument& doc, QDomElement &element ) const;
65  static QgsFeatureRendererV2* createFromSld( QDomElement& element, QGis::GeometryType geomType );
66 
69  virtual int capabilities() { return SymbolLevels | RotationField; }
70 
71  virtual QgsSymbolV2List symbols();
72 
74  static QgsFeatureRendererV2* create( QDomElement& element );
75 
77  virtual QDomElement save( QDomDocument& doc );
78 
80  virtual QgsLegendSymbologyList legendSymbologyItems( QSize iconSize );
81 
85  virtual QgsLegendSymbolList legendSymbolItems( double scaleDenominator = -1, QString rule = QString() );
86 
87 
91 
95  static QgsSingleSymbolRendererV2* convertFromRenderer( const QgsFeatureRendererV2 *renderer );
96 
97 
98  protected:
99  QScopedPointer<QgsSymbolV2> mSymbol;
100  QScopedPointer<QgsExpression> mRotation;
101  QScopedPointer<QgsExpression> mSizeScale;
103 
104  // temporary stuff for rendering
105  QScopedPointer<QgsSymbolV2> mTempSymbol;
106  double mOrigSize;
107 };
108 
109 
110 #endif // QGSSINGLESYMBOLRENDERERV2_H
virtual int capabilities()
returns bitwise OR-ed capabilities of the renderer
Definition: qgssinglesymbolrendererv2.h:69
double mOrigSize
Definition: qgssinglesymbolrendererv2.h:106
virtual QgsSymbolV2 * originalSymbolForFeature(QgsFeature &feature)
Return symbol for feature.
Definition: qgsrendererv2.h:94
virtual void setRotationField(QString fieldName)
sets rotation field of renderer (if supported by the renderer)
Definition: qgsrendererv2.h:198
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
QgsSymbolV2::ScaleMethod scaleMethod() const
Definition: qgssinglesymbolrendererv2.h:58
Container of fields for a vector layer.
Definition: qgsfield.h:172
GeometryType
Definition: qgis.h:155
virtual QList< QString > usedAttributes()=0
QScopedPointer< QgsSymbolV2 > mSymbol
Definition: qgssinglesymbolrendererv2.h:99
Definition: qgssinglesymbolrendererv2.h:24
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:113
QgsSymbolV2::ScaleMethod mScaleMethod
Definition: qgssinglesymbolrendererv2.h:102
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 QString rotationField() const
return rotation field name (or empty string if not set or not supported by renderer) ...
Definition: qgsrendererv2.h:195
virtual QgsSymbolV2List symbols()=0
for symbol levels
virtual QgsFeatureRendererV2 * clone() const =0
QScopedPointer< QgsExpression > mSizeScale
Definition: qgssinglesymbolrendererv2.h:101
Definition: qgssymbolv2.h:43
QList< QPair< QString, QPixmap > > QgsLegendSymbologyList
Definition: qgspluginlayer.h:20
virtual void toSld(QDomDocument &doc, QDomElement &element) const
used from subclasses to create SLD Rule elements following SLD v1.1 specs
Definition: qgsrendererv2.h:158
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:39
ScaleMethod
Definition: qgssymbolv2.h:61
virtual QgsLegendSymbolListV2 legendSymbolItemsV2() const
Return a list of symbology items for the legend.
Definition: qgsrendererv2.cpp:536
Definition: qgsrendererv2.h:117
Definition: qgsrendererv2.h:72
QList< QgsLegendSymbolItemV2 > QgsLegendSymbolListV2
Definition: qgslegendsymbolitemv2.h:90
QList< QPair< QString, QgsSymbolV2 * > > QgsLegendSymbolList
Definition: qgsrendererv2.h:41
virtual QgsSymbolV2 * symbolForFeature(QgsFeature &feature)=0
to be overridden
QScopedPointer< QgsSymbolV2 > mTempSymbol
Definition: qgssinglesymbolrendererv2.h:105
QScopedPointer< QgsExpression > mRotation
Definition: qgssinglesymbolrendererv2.h:100