QGIS API Documentation  3.20.0-Odense (decaadbb31)
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 "qgis.h"
21 #include "qgssymbollayer.h"
22 
23 class QgsFillSymbol;
24 class QgsLineSymbol;
25 class QgsMarkerSymbol;
26 
32 {
33  public:
35 
37  static QgsSymbolLayer *create( const QVariantMap &properties ) SIP_FACTORY;
38 
39  QString layerType() const override;
40 
47  void setSymbolType( Qgis::SymbolType symbolType );
48 
55  Qgis::SymbolType symbolType() const { return mSymbolType; }
56 
57  void startRender( QgsSymbolRenderContext &context ) override;
58  void stopRender( QgsSymbolRenderContext &context ) override;
59  void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
60  void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
61  bool usesMapUnits() const override;
62 
63  QgsSymbolLayer *clone() const override SIP_FACTORY;
64 
65  QVariantMap properties() const override;
66 
67  void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
68 
72  void setGeometryExpression( const QString &exp );
73 
77  QString geometryExpression() const { return mExpression->expression(); }
78 
79  QgsSymbol *subSymbol() override { return mSymbol; }
80 
81  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
82 
83  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
84  bool hasDataDefinedProperties() const override;
85 
91  bool isCompatibleWithSymbol( QgsSymbol *symbol ) const override;
92 
103  virtual void render( QgsSymbolRenderContext &context );
104 
105  void setColor( const QColor &color ) override;
106 
107  private:
108  QgsGeometryGeneratorSymbolLayer( const QString &expression );
109 
110 #ifdef SIP_RUN
112 #endif
113 
114  std::unique_ptr<QgsExpression> mExpression;
115  std::unique_ptr<QgsFillSymbol> mFillSymbol;
116  std::unique_ptr<QgsLineSymbol> mLineSymbol;
117  std::unique_ptr<QgsMarkerSymbol> mMarkerSymbol;
118  QgsSymbol *mSymbol = nullptr;
119 
123  Qgis::SymbolType mSymbolType;
124 
125  bool mRenderingFeature = false;
126  bool mHasRenderedFeature = false;
127 };
128 
129 #endif // QGSGEOMETRYGENERATORSYMBOLLAYER_H
SymbolType
Symbol types.
Definition: qgis.h:168
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgsfillsymbol.h:30
Qgis::SymbolType symbolType() const
Access the symbol type.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:30
A marker symbol type, for rendering Point and MultiPoint geometries.
Contains information about the context of a rendering operation.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
virtual void startFeatureRender(const QgsFeature &feature, QgsRenderContext &context)
Called before the layer will be rendered for a particular feature.
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
virtual void startRender(QgsSymbolRenderContext &context)=0
Called before a set of rendering operations commences on the supplied render context.
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
virtual QString layerType() const =0
Returns a string that represents this layer type.
virtual void stopRender(QgsSymbolRenderContext &context)=0
Called after a set of rendering operations has finished on the supplied render context.
virtual bool isCompatibleWithSymbol(QgsSymbol *symbol) const
Returns if the layer can be used below the specified symbol.
virtual void stopFeatureRender(const QgsFeature &feature, QgsRenderContext &context)
Called after the layer has been rendered for a particular feature.
virtual bool usesMapUnits() const
Returns true if the symbol layer has any components which use map unit based sizes.
virtual void setColor(const QColor &color)
The fill color.
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:38
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:76