QGIS API Documentation  2.15.0-Master (02a0ebe)
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 
26 {
27  public:
28 
30 
31  virtual ~QgsSingleSymbolRendererV2();
32 
34  virtual QgsSymbolV2* symbolForFeature( QgsFeature& feature, QgsRenderContext& context ) override;
35 
37  virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feature, QgsRenderContext& context ) override;
38 
39  virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) override;
40 
41  virtual void stopRender( QgsRenderContext& context ) override;
42 
43  virtual QList<QString> usedAttributes() override;
44 
45  QgsSymbolV2* symbol() const;
46  void setSymbol( QgsSymbolV2* s );
47 
48  Q_DECL_DEPRECATED void setRotationField( const QString& fieldOrExpression ) override;
49  Q_DECL_DEPRECATED QString rotationField() const override;
50 
51  void setSizeScaleField( const QString& fieldOrExpression );
52  QString sizeScaleField() const;
53 
54  void setScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod );
55  QgsSymbolV2::ScaleMethod scaleMethod() const { return mScaleMethod; }
56 
57  virtual QString dump() const override;
58 
59  virtual QgsSingleSymbolRendererV2* clone() const override;
60 
61  virtual void toSld( QDomDocument& doc, QDomElement &element ) const override;
62  static QgsFeatureRendererV2* createFromSld( QDomElement& element, QGis::GeometryType geomType );
63 
65  virtual int capabilities() override { return SymbolLevels | RotationField; }
66 
68  virtual QgsSymbolV2List symbols( QgsRenderContext& context ) override;
69 
71  static QgsFeatureRendererV2* create( QDomElement& element );
72 
74  virtual QDomElement save( QDomDocument& doc ) override;
75 
77  virtual QgsLegendSymbologyList legendSymbologyItems( QSize iconSize ) override;
78 
81  virtual QgsLegendSymbolList legendSymbolItems( double scaleDenominator = -1, const QString& rule = QString() ) override;
82 
85  virtual QgsLegendSymbolListV2 legendSymbolItemsV2() const override;
86 
87  virtual QSet< QString > legendKeysForFeature( QgsFeature& feature, QgsRenderContext& context ) override;
88 
89  virtual void setLegendSymbolItem( const QString& key, QgsSymbolV2* symbol ) override;
90 
94  static QgsSingleSymbolRendererV2* convertFromRenderer( const QgsFeatureRendererV2 *renderer );
95 
96  protected:
101 
102  // temporary stuff for rendering
104  double mOrigSize;
105 };
107 
108 
109 #endif // QGSSINGLESYMBOLRENDERERV2_H
virtual QSet< QString > legendKeysForFeature(QgsFeature &feature, QgsRenderContext &context)
Return legend keys matching a specified feature.
GeometryType
Definition: qgis.h:115
virtual QString dump() const
for debugging
virtual Q_DECL_DEPRECATED QgsSymbolV2 * originalSymbolForFeature(QgsFeature &feature)
Return symbol for feature.
virtual QDomElement save(QDomDocument &doc)
store renderer info to XML element
virtual int capabilities() override
returns bitwise OR-ed capabilities of the renderer
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:514
QgsSymbolV2::ScaleMethod scaleMethod() const
Container of fields for a vector layer.
Definition: qgsfield.h:193
virtual QList< QString > usedAttributes()=0
Returns a set of attributes required for this renderer.
QScopedPointer< QgsSymbolV2 > mSymbol
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:187
QgsSymbolV2::ScaleMethod mScaleMethod
virtual QgsLegendSymbologyList legendSymbologyItems(QSize iconSize)
return a list of symbology items for the legend
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started.
virtual void stopRender(QgsRenderContext &context)=0
Needs to be called when a render cycle has finished to clean up.
virtual QgsFeatureRendererV2 * clone() const =0
virtual Q_DECL_DEPRECATED QgsSymbolV2 * symbolForFeature(QgsFeature &feature)
To be overridden.
virtual QgsLegendSymbolList legendSymbolItems(double scaleDenominator=-1, const QString &rule="")
return a list of item text / symbol
virtual Q_DECL_DEPRECATED QString rotationField() const
return rotation field name (or empty string if not set or not supported by renderer) ...
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbols()
For symbol levels.
QScopedPointer< QgsExpression > mSizeScale
virtual void toSld(QDomDocument &doc, QDomElement &element) const
used from subclasses to create SLD Rule elements following SLD v1.1 specs
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:515
Contains information about the context of a rendering operation.
ScaleMethod
Scale method.
Definition: qgssymbolv2.h:87
virtual QgsLegendSymbolListV2 legendSymbolItemsV2() const
Return a list of symbology items for the legend.
rotate symbols by attribute value
virtual Q_DECL_DEPRECATED void setRotationField(const QString &fieldName)
sets rotation field of renderer (if supported by the renderer)
QScopedPointer< QgsSymbolV2 > mTempSymbol
virtual void setLegendSymbolItem(const QString &key, QgsSymbolV2 *symbol)
Sets the symbol to be used for a legend symbol item.
QScopedPointer< QgsExpression > mRotation