QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsgeometrygeneratorsymbollayer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgeometrygeneratorsymbollayer.h
3  ---------------------
4  begin : November 2015
5  copyright : (C) 2015 by Matthias Kuhn
6  email : matthias at opengis dot ch
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 
16 #ifndef QGSGEOMETRYGENERATORSYMBOLLAYER_H
17 #define QGSGEOMETRYGENERATORSYMBOLLAYER_H
18 
19 #include "qgis_core.h"
20 #include "qgssymbollayer.h"
21 
27 {
28  public:
30 
31  static QgsSymbolLayer *create( const QgsStringMap &properties ) SIP_FACTORY;
32 
33  QString layerType() const override;
34 
41  void setSymbolType( QgsSymbol::SymbolType symbolType );
42 
49  QgsSymbol::SymbolType symbolType() const { return mSymbolType; }
50 
51  void startRender( QgsSymbolRenderContext &context ) override;
52  void stopRender( QgsSymbolRenderContext &context ) override;
53  void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
54  void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
55 
56  QgsSymbolLayer *clone() const override SIP_FACTORY;
57 
58  QgsStringMap properties() const override;
59 
60  void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
61 
65  void setGeometryExpression( const QString &exp );
66 
70  QString geometryExpression() const { return mExpression->expression(); }
71 
72  QgsSymbol *subSymbol() override { return mSymbol; }
73 
74  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
75 
76  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
77  bool hasDataDefinedProperties() const override;
78 
84  bool isCompatibleWithSymbol( QgsSymbol *symbol ) const override;
85 
96  virtual void render( QgsSymbolRenderContext &context );
97 
98  void setColor( const QColor &color ) override;
99 
100  private:
101  QgsGeometryGeneratorSymbolLayer( const QString &expression );
102 
103 #ifdef SIP_RUN
105 #endif
106 
107  std::unique_ptr<QgsExpression> mExpression;
108  std::unique_ptr<QgsFillSymbol> mFillSymbol;
109  std::unique_ptr<QgsLineSymbol> mLineSymbol;
110  std::unique_ptr<QgsMarkerSymbol> mMarkerSymbol;
111  QgsSymbol *mSymbol = nullptr;
112 
116  QgsSymbol::SymbolType mSymbolType;
117 
118  bool mRenderingFeature = false;
119  bool mHasRenderedFeature = false;
120 };
121 
122 #endif // QGSGEOMETRYGENERATORSYMBOLLAYER_H
QgsSymbolLayer::setSubSymbol
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
Definition: qgssymbollayer.h:356
QgsSymbolLayer::startFeatureRender
virtual void startFeatureRender(const QgsFeature &feature, QgsRenderContext &context)
Called before the layer will be rendered for a particular feature.
Definition: qgssymbollayer.cpp:118
QgsSymbolLayer::isCompatibleWithSymbol
virtual bool isCompatibleWithSymbol(QgsSymbol *symbol) const
Returns if the layer can be used below the specified symbol.
Definition: qgssymbollayer.cpp:229
QgsGeometryGeneratorSymbolLayer::subSymbol
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
Definition: qgsgeometrygeneratorsymbollayer.h:72
QgsSymbolLayer::setColor
virtual void setColor(const QColor &color)
The fill color.
Definition: qgssymbollayer.h:232
QgsSymbolLayer::hasDataDefinedProperties
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
Definition: qgssymbollayer.cpp:216
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:58
QgsSymbol
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:64
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsSymbolRenderContext
Definition: qgssymbol.h:695
QgsSymbolLayer::clone
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsSymbolLayer
Definition: qgssymbollayer.h:53
QgsSymbolLayer::stopFeatureRender
virtual void stopFeatureRender(const QgsFeature &feature, QgsRenderContext &context)
Called after the layer has been rendered for a particular feature.
Definition: qgssymbollayer.cpp:123
QgsGeometryGeneratorSymbolLayer
Definition: qgsgeometrygeneratorsymbollayer.h:27
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsGeometryGeneratorSymbolLayer::~QgsGeometryGeneratorSymbolLayer
~QgsGeometryGeneratorSymbolLayer() override
qgssymbollayer.h
QgsSymbolLayer::usedAttributes
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
Definition: qgssymbollayer.cpp:247
QgsStringMap
QMap< QString, QString > QgsStringMap
Definition: qgis.h:758
QgsSymbolLayer::stopRender
virtual void stopRender(QgsSymbolRenderContext &context)=0
Called after a set of rendering operations has finished on the supplied render context.
QgsSymbolLayer::layerType
virtual QString layerType() const =0
Returns a string that represents this layer type.
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
QgsSymbol::SymbolType
SymbolType
Type of the symbol.
Definition: qgssymbol.h:86
QgsSymbolLayer::startRender
virtual void startRender(QgsSymbolRenderContext &context)=0
Called before a set of rendering operations commences on the supplied render context.
QgsGeometryGeneratorSymbolLayer::symbolType
QgsSymbol::SymbolType symbolType() const
Access the symbol type.
Definition: qgsgeometrygeneratorsymbollayer.h:49