QGIS API Documentation  2.99.0-Master (9caa722)
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  ***************************************************************************/
18 #include "qgis_core.h"
19 #include "qgis.h"
20 #include "qgsrenderer.h"
21 #include "qgssymbol.h"
22 #include "qgsexpression.h"
28 class CORE_EXPORT QgsSingleSymbolRenderer : public QgsFeatureRenderer
29 {
30  public:
34  virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
35  virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
36  virtual void startRender( QgsRenderContext &context, const QgsFields &fields ) override;
37  virtual void stopRender( QgsRenderContext &context ) override;
38  virtual QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
40  QgsSymbol *symbol() const;
41  void setSymbol( QgsSymbol *s SIP_TRANSFER );
43  virtual QString dump() const override;
45  virtual QgsSingleSymbolRenderer *clone() const override SIP_FACTORY;
47  virtual void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap &props = QgsStringMap() ) const override;
48  static QgsFeatureRenderer *createFromSld( QDomElement &element, QgsWkbTypes::GeometryType geomType );
50  virtual QgsFeatureRenderer::Capabilities capabilities() override { return SymbolLevels; }
51  virtual QgsSymbolList symbols( QgsRenderContext &context ) override;
54  static QgsFeatureRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
55  virtual QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) override;
56  virtual QgsLegendSymbolList legendSymbolItems() const override;
57  virtual QSet< QString > legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context ) override;
58  virtual void setLegendSymbolItem( const QString &key, QgsSymbol *symbol SIP_TRANSFER ) override;
63  static QgsSingleSymbolRenderer *convertFromRenderer( const QgsFeatureRenderer *renderer ) SIP_FACTORY;
75  void setDataDefinedSizeLegend( QgsDataDefinedSizeLegend *settings SIP_TRANSFER );
82  QgsDataDefinedSizeLegend *dataDefinedSizeLegend() const;
84  protected:
85  std::unique_ptr<QgsSymbol> mSymbol;
86  std::unique_ptr<QgsDataDefinedSizeLegend> mDataDefinedSizeLegend;
88  private:
89 #ifdef SIP_RUN
92 #endif
94 };
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
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:275
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context)
store renderer info to XML element
virtual QgsSymbol * originalSymbolForFeature(QgsFeature &feature, QgsRenderContext &context)
Return symbol for feature.
Definition: qgsrenderer.cpp:80
Container of fields for a vector layer.
Definition: qgsfields.h:41
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:61
std::unique_ptr< QgsDataDefinedSizeLegend > mDataDefinedSizeLegend
QMap< QString, QString > QgsStringMap
Definition: qgis.h:366
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started.
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const =0
Return a list of attributes required by this renderer.
QList< QgsSymbol * > QgsSymbolList
Definition: qgsrenderer.h:43
Definition: qgis_sip.h:36
Definition: qgis_sip.h:69
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:221
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:136
virtual QgsSymbolList symbols(QgsRenderContext &context)
Returns list of symbols used by the renderer.
Definition: qgsrenderer.h:247
virtual QgsSymbol * symbolForFeature(QgsFeature &feature, QgsRenderContext &context)=0
To be overridden.
Contains information about the context of a rendering operation.
virtual void stopRender(QgsRenderContext &context)=0
Needs to be called when a render cycle has finished to clean up.
virtual QgsFeatureRenderer::Capabilities capabilities() override
Returns details about internals of this renderer.
virtual QSet< QString > legendKeysForFeature(QgsFeature &feature, QgsRenderContext &context)
Return legend keys matching a specified feature.
Definition: qgsrenderer.cpp:85
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.