QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
23 class QgsSymbol;
24 
29 class CORE_EXPORT QgsSingleSymbolRenderer : public QgsFeatureRenderer
30 {
31  public:
32 
40  ~QgsSingleSymbolRenderer() override;
41 
42  QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
43  QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
44  void startRender( QgsRenderContext &context, const QgsFields &fields ) override;
45  void stopRender( QgsRenderContext &context ) override;
46  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
47  bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
48 
53  QgsSymbol *symbol() const;
54 
60  void setSymbol( QgsSymbol *s SIP_TRANSFER );
61 
62  QString dump() const override;
63 
64  QgsSingleSymbolRenderer *clone() const override SIP_FACTORY;
65 
66  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap &props = QgsStringMap() ) const override;
67 
75  static QgsFeatureRenderer *createFromSld( QDomElement &element, QgsWkbTypes::GeometryType geomType ) SIP_FACTORY;
76 
77  QgsFeatureRenderer::Capabilities capabilities() override { return SymbolLevels; }
78  QgsSymbolList symbols( QgsRenderContext &context ) const override;
79 
85  static QgsFeatureRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
86 
87  QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) override;
88  QgsLegendSymbolList legendSymbolItems() const override;
89  QSet< QString > legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
90  void setLegendSymbolItem( const QString &key, QgsSymbol *symbol SIP_TRANSFER ) override;
91 
97  static QgsSingleSymbolRenderer *convertFromRenderer( const QgsFeatureRenderer *renderer ) SIP_FACTORY;
98 
109  void setDataDefinedSizeLegend( QgsDataDefinedSizeLegend *settings SIP_TRANSFER );
110 
116  QgsDataDefinedSizeLegend *dataDefinedSizeLegend() const;
117 
118  protected:
119  std::unique_ptr<QgsSymbol> mSymbol;
120  std::unique_ptr<QgsDataDefinedSizeLegend> mDataDefinedSizeLegend;
121 
122  private:
123 #ifdef SIP_RUN
125  QgsSingleSymbolRenderer &operator=( const QgsSingleSymbolRenderer & );
126 #endif
127 
128 };
129 
130 
131 #endif // QGSSINGLESYMBOLRENDERER_H
QgsFeatureRenderer::setLegendSymbolItem
virtual void setLegendSymbolItem(const QString &key, QgsSymbol *symbol)
Sets the symbol to be used for a legend symbol item.
Definition: qgsrenderer.cpp:347
QgsFeatureRenderer::originalSymbolForFeature
virtual QgsSymbol * originalSymbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns symbol for feature.
Definition: qgsrenderer.cpp:81
QgsReadWriteContext
Definition: qgsreadwritecontext.h:34
QgsSingleSymbolRenderer::mSymbol
std::unique_ptr< QgsSymbol > mSymbol
Definition: qgssinglesymbolrenderer.h:119
QgsFeatureRenderer::accept
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
Definition: qgsrenderer.cpp:465
QgsFields
Definition: qgsfields.h:44
QgsDataDefinedSizeLegend
Definition: qgsdatadefinedsizelegend.h:41
qgis.h
QgsRenderContext
Definition: qgsrendercontext.h:57
QgsFeatureRenderer::usedAttributes
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const =0
Returns a list of attributes required by this renderer.
QgsStyleEntityVisitorInterface
Definition: qgsstyleentityvisitor.h:33
QgsSingleSymbolRenderer
Definition: qgssinglesymbolrenderer.h:29
QgsFeatureRenderer::legendSymbolItems
virtual QgsLegendSymbolList legendSymbolItems() const
Returns a list of symbology items for the legend.
Definition: qgsrenderer.cpp:353
QgsSymbol
Definition: qgssymbol.h:63
QgsFeatureRenderer::toSld
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:312
QgsFeatureRenderer::stopRender
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
Definition: qgsrenderer.cpp:107
QgsFeatureRenderer::SymbolLevels
@ SymbolLevels
Rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
Definition: qgsrenderer.h:254
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsSingleSymbolRenderer::mDataDefinedSizeLegend
std::unique_ptr< QgsDataDefinedSizeLegend > mDataDefinedSizeLegend
Definition: qgssinglesymbolrenderer.h:120
QgsFeatureRenderer::save
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context)
store renderer info to XML element
Definition: qgsrenderer.cpp:184
QgsSymbolList
QList< QgsSymbol * > QgsSymbolList
Definition: qgsrenderer.h:45
QgsFeatureRenderer::clone
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
QgsSingleSymbolRenderer::capabilities
QgsFeatureRenderer::Capabilities capabilities() override
Returns details about internals of this renderer.
Definition: qgssinglesymbolrenderer.h:77
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsFeatureRenderer::symbols
virtual QgsSymbolList symbols(QgsRenderContext &context) const
Returns list of symbols used by the renderer.
Definition: qgsrenderer.cpp:143
QgsFeatureRenderer::symbolForFeature
virtual QgsSymbol * symbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const =0
To be overridden.
qgsrenderer.h
QgsStringMap
QMap< QString, QString > QgsStringMap
Definition: qgis.h:714
QgsFeatureRenderer
Definition: qgsrenderer.h:102
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:139
QgsFeatureRenderer::dump
virtual QString dump() const
Returns debug information about this renderer.
Definition: qgsrenderer.cpp:138
QgsFeature
Definition: qgsfeature.h:55
QgsLegendSymbolList
QList< QgsLegendSymbolItem > QgsLegendSymbolList
Definition: qgslegendsymbolitem.h:144
QgsFeatureRenderer::startRender
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
Definition: qgsrenderer.cpp:93
QgsFeatureRenderer::legendKeysForFeature
virtual QSet< QString > legendKeysForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns legend keys matching a specified feature.
Definition: qgsrenderer.cpp:86