QGIS API Documentation  3.9.0-Master (224899f119)
qgssinglesymbolrenderer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssinglesymbolrenderer.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 QGSSINGLESYMBOLRENDERER_H
16 #define QGSSINGLESYMBOLRENDERER_H
17 
18 #include "qgis_core.h"
19 #include "qgis.h"
20 #include "qgsrenderer.h"
21 #include "qgssymbol.h"
22 #include "qgsexpression.h"
24 
29 class CORE_EXPORT QgsSingleSymbolRenderer : public QgsFeatureRenderer
30 {
31  public:
32 
40 
41  QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
42  QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
43  void startRender( QgsRenderContext &context, const QgsFields &fields ) override;
44  void stopRender( QgsRenderContext &context ) override;
45  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
46  bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
47 
52  QgsSymbol *symbol() const;
53 
59  void setSymbol( QgsSymbol *s SIP_TRANSFER );
60 
61  QString dump() const override;
62 
63  QgsSingleSymbolRenderer *clone() const override SIP_FACTORY;
64 
65  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap &props = QgsStringMap() ) const override;
66 
74  static QgsFeatureRenderer *createFromSld( QDomElement &element, QgsWkbTypes::GeometryType geomType ) SIP_FACTORY;
75 
76  QgsFeatureRenderer::Capabilities capabilities() override { return SymbolLevels; }
77  QgsSymbolList symbols( QgsRenderContext &context ) const override;
78 
84  static QgsFeatureRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
85 
86  QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) override;
87  QgsLegendSymbolList legendSymbolItems() const override;
88  QSet< QString > legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
89  void setLegendSymbolItem( const QString &key, QgsSymbol *symbol SIP_TRANSFER ) override;
90 
96  static QgsSingleSymbolRenderer *convertFromRenderer( const QgsFeatureRenderer *renderer ) SIP_FACTORY;
97 
108  void setDataDefinedSizeLegend( QgsDataDefinedSizeLegend *settings SIP_TRANSFER );
109 
115  QgsDataDefinedSizeLegend *dataDefinedSizeLegend() const;
116 
117  protected:
118  std::unique_ptr<QgsSymbol> mSymbol;
119  std::unique_ptr<QgsDataDefinedSizeLegend> mDataDefinedSizeLegend;
120 
121  private:
122 #ifdef SIP_RUN
124  QgsSingleSymbolRenderer &operator=( const QgsSingleSymbolRenderer & );
125 #endif
126 
127 };
128 
129 
130 #endif // QGSSINGLESYMBOLRENDERER_H
The class is used as a container of context for various read/write operations on other objects...
virtual QgsLegendSymbolList legendSymbolItems() const
Returns a list of symbology items for the legend.
QList< QgsLegendSymbolItem > QgsLegendSymbolList
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:61
virtual void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props=QgsStringMap()) const
used from subclasses to create SLD Rule elements following SLD v1.1 specs
Definition: qgsrenderer.h:301
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context)
store renderer info to XML element
Container of fields for a vector layer.
Definition: qgsfields.h:42
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:55
An interface for classes which can visit style entity (e.g.
std::unique_ptr< QgsDataDefinedSizeLegend > mDataDefinedSizeLegend
QMap< QString, QString > QgsStringMap
Definition: qgis.h:597
virtual QgsSymbol * symbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const =0
To be overridden.
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const =0
Returns a list of attributes required by this renderer.
QList< QgsSymbol * > QgsSymbolList
Definition: qgsrenderer.h:44
virtual QgsSymbol * originalSymbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns symbol for feature.
Definition: qgsrenderer.cpp:81
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsFeatureRenderer::Capabilities capabilities() override
Returns details about internals of this renderer.
#define SIP_FACTORY
Definition: qgis_sip.h:76
virtual void setLegendSymbolItem(const QString &key, QgsSymbol *symbol)
Sets the symbol to be used for a legend symbol item.
Rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
Definition: qgsrenderer.h:243
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:139
Contains information about the context of a rendering operation.
virtual QgsSymbolList symbols(QgsRenderContext &context) const
Returns list of symbols used by the renderer.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
Definition: qgsrenderer.cpp:93
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
virtual QSet< QString > legendKeysForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns legend keys matching a specified feature.
Definition: qgsrenderer.cpp:86
Object that keeps configuration of appearance of marker symbol&#39;s data-defined size in legend...
std::unique_ptr< QgsSymbol > mSymbol
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
virtual QString dump() const
Returns debug information about this renderer.