QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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 
53  void stopRender( QgsSymbolRenderContext &context ) override;
54 
55  QgsSymbolLayer *clone() const override SIP_FACTORY;
56 
57  QgsStringMap properties() const override;
58 
59  void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
60 
64  void setGeometryExpression( const QString &exp );
65 
69  QString geometryExpression() const { return mExpression->expression(); }
70 
71  QgsSymbol *subSymbol() override { return mSymbol; }
72 
73  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
74 
75  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
76  bool hasDataDefinedProperties() const override;
77 
83  bool isCompatibleWithSymbol( QgsSymbol *symbol ) const override;
84 
95  virtual void render( QgsSymbolRenderContext &context );
96 
97  void setColor( const QColor &color ) override;
98 
99  private:
100  QgsGeometryGeneratorSymbolLayer( const QString &expression );
101 
102 #ifdef SIP_RUN
104 #endif
105 
106  std::unique_ptr<QgsExpression> mExpression;
107  QgsFillSymbol *mFillSymbol = nullptr;
108  QgsLineSymbol *mLineSymbol = nullptr;
109  QgsMarkerSymbol *mMarkerSymbol = nullptr;
110  QgsSymbol *mSymbol = nullptr;
111 
115  QgsSymbol::SymbolType mSymbolType;
116 };
117 
118 #endif // QGSGEOMETRYGENERATORSYMBOLLAYER_H
QgsSymbol * subSymbol() override
Returns the symbol&#39;s sub symbol, if present.
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:61
QString geometryExpression() const
Gets the expression to generate this geometry.
virtual QgsStringMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QMap< QString, QString > QgsStringMap
Definition: qgis.h:587
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgssymbol.h:766
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgssymbol.h:966
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties...
virtual void setColor(const QColor &color)
The fill color.
SymbolType
Type of the symbol.
Definition: qgssymbol.h:83
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer&#39;s subsymbol. takes ownership of the passed symbol.
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
virtual void drawPreviewIcon(QgsSymbolRenderContext &context, QSize size)=0
#define SIP_FACTORY
Definition: qgis_sip.h:69
virtual bool isCompatibleWithSymbol(QgsSymbol *symbol) const
Returns if the layer can be used below the specified symbol.
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
Contains information about the context of a rendering operation.
virtual void stopRender(QgsSymbolRenderContext &context)=0
QgsSymbol::SymbolType symbolType() const
Access the symbol type.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgssymbol.h:1061
virtual void startRender(QgsSymbolRenderContext &context)=0
virtual QString layerType() const =0
Returns a string that represents this layer type.