QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
29 {
30  public:
31 
33 
34  virtual ~QgsSingleSymbolRendererV2();
35 
37  virtual QgsSymbolV2* symbolForFeature( QgsFeature& feature, QgsRenderContext& context ) override;
38 
40  virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feature, QgsRenderContext& context ) override;
41 
42  virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) override;
43 
44  virtual void stopRender( QgsRenderContext& context ) override;
45 
46  virtual QList<QString> usedAttributes() override;
47 
48  QgsSymbolV2* symbol() const;
49  void setSymbol( QgsSymbolV2* s );
50 
51  Q_DECL_DEPRECATED void setRotationField( const QString& fieldOrExpression ) override;
52  Q_DECL_DEPRECATED QString rotationField() const override;
53 
54  void setSizeScaleField( const QString& fieldOrExpression );
55  QString sizeScaleField() const;
56 
57  void setScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod );
58  QgsSymbolV2::ScaleMethod scaleMethod() const { return mScaleMethod; }
59 
60  virtual QString dump() const override;
61 
62  virtual QgsSingleSymbolRendererV2* clone() const override;
63 
65  virtual void toSld( QDomDocument& doc, QDomElement &element ) const override;
67  virtual void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const override;
68  static QgsFeatureRendererV2* createFromSld( QDomElement& element, QGis::GeometryType geomType );
69 
71  virtual int capabilities() override { return SymbolLevels | RotationField; }
72 
74  virtual QgsSymbolV2List symbols( QgsRenderContext& context ) override;
75 
77  static QgsFeatureRendererV2* create( QDomElement& element );
78 
80  virtual QDomElement save( QDomDocument& doc ) override;
81 
83  virtual QgsLegendSymbologyList legendSymbologyItems( QSize iconSize ) override;
84 
87  virtual QgsLegendSymbolList legendSymbolItems( double scaleDenominator = -1, const QString& rule = QString() ) override;
88 
91  virtual QgsLegendSymbolListV2 legendSymbolItemsV2() const override;
92 
93  virtual QSet< QString > legendKeysForFeature( QgsFeature& feature, QgsRenderContext& context ) override;
94 
95  virtual void setLegendSymbolItem( const QString& key, QgsSymbolV2* symbol ) override;
96 
100  static QgsSingleSymbolRendererV2* convertFromRenderer( const QgsFeatureRendererV2 *renderer );
101 
102  protected:
107 
108  // temporary stuff for rendering
110  double mOrigSize;
111 };
113 
114 
115 #endif // QGSSINGLESYMBOLRENDERERV2_H
virtual Q_DECL_DEPRECATED QString rotationField() const
return rotation field name (or empty string if not set or not supported by renderer) ...
virtual QSet< QString > legendKeysForFeature(QgsFeature &feature, QgsRenderContext &context)
Return legend keys matching a specified feature.
QgsSymbolV2::ScaleMethod scaleMethod() const
GeometryType
Definition: qgis.h:115
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:515
Container of fields for a vector layer.
Definition: qgsfield.h:252
virtual QgsLegendSymbolListV2 legendSymbolItemsV2() const
Return a list of symbology items for the legend.
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
virtual void toSld(QDomDocument &doc, QDomElement &element) const
used from subclasses to create SLD Rule elements following SLD v1.1 specs
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 QString dump() const
for debugging
virtual QgsLegendSymbolList legendSymbolItems(double scaleDenominator=-1, const QString &rule="")
return a list of item text / symbol
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbols()
For symbol levels.
QScopedPointer< QgsExpression > mSizeScale
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:516
Contains information about the context of a rendering operation.
ScaleMethod
Scale method.
Definition: qgssymbolv2.h:90
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