QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
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.h"
20#include "qgis_core.h"
21#include "qgssymbollayer.h"
22
23class QgsFillSymbol;
24class QgsLineSymbol;
25class QgsMarkerSymbol;
26
32class CORE_EXPORT QgsGeometryGeneratorSymbolLayer : public QgsSymbolLayer
33{
34 public:
36
38 static QgsSymbolLayer *create( const QVariantMap &properties ) SIP_FACTORY;
39
40 QString layerType() const override;
41
49
56 Qgis::SymbolType symbolType() const { return mSymbolType; }
57
58 void startRender( QgsSymbolRenderContext &context ) override;
59 void stopRender( QgsSymbolRenderContext &context ) override;
60 void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
61 void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
62 bool usesMapUnits() const override;
63 QColor color() const override;
64 Qgis::RenderUnit outputUnit() const override;
65 void setOutputUnit( Qgis::RenderUnit unit ) override;
66 QgsMapUnitScale mapUnitScale() const override;
67 bool rendersIdenticallyTo( const QgsSymbolLayer *other ) const override;
68
69 QgsSymbolLayer *clone() const override SIP_FACTORY;
70
71 QVariantMap properties() const override;
72
73 void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
74
78 void setGeometryExpression( const QString &exp );
79
83 QString geometryExpression() const;
84
94 Qgis::RenderUnit units() const { return mUnits; }
95
106
107 QgsSymbol *subSymbol() override { return mSymbol; }
108
109 bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
110
111 QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
112 bool hasDataDefinedProperties() const override;
113
119 bool isCompatibleWithSymbol( QgsSymbol *symbol ) const override;
120
133 void render( QgsSymbolRenderContext &context, Qgis::GeometryType geometryType = Qgis::GeometryType::Unknown, const QPolygonF *points = nullptr, const QVector<QPolygonF> *rings = nullptr );
134
135 void setColor( const QColor &color ) override;
136
137 private:
138 QgsGeometryGeneratorSymbolLayer( const QString &expression );
139
140#ifdef SIP_RUN
142#endif
143
147 QgsGeometry evaluateGeometryInPainterUnits( const QgsGeometry &input, const QgsFeature &feature, const QgsRenderContext &renderContext, QgsExpressionContext &expressionContext ) const;
148
153 QgsGeometry coerceToExpectedType( const QgsGeometry &geometry ) const;
154
155 std::unique_ptr<QgsExpression> mExpression;
156 std::unique_ptr<QgsFillSymbol> mFillSymbol;
157 std::unique_ptr<QgsLineSymbol> mLineSymbol;
158 std::unique_ptr<QgsMarkerSymbol> mMarkerSymbol;
159 QgsSymbol *mSymbol = nullptr;
160
165
167
168 bool mRenderingFeature = false;
169 bool mHasRenderedFeature = false;
170};
171
172#endif // QGSGEOMETRYGENERATORSYMBOLLAYER_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:56
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:358
@ Unknown
Unknown types.
Definition qgis.h:362
RenderUnit
Rendering size units.
Definition qgis.h:5183
@ MapUnits
Map units.
Definition qgis.h:5185
SymbolType
Symbol types.
Definition qgis.h:610
@ Marker
Marker symbol.
Definition qgis.h:611
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
A symbol layer subclass which alters rendered feature shapes through the use of QGIS expressions.
Qgis::RenderUnit units() const
Returns the unit for the geometry expression.
void setUnits(Qgis::RenderUnit units)
Sets the units for the geometry expression.
void setSymbolType(Qgis::SymbolType symbolType)
Set the type of symbol which should be created.
Qgis::SymbolType symbolType() const
Access the symbol type.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
static QgsSymbolLayer * create(const QVariantMap &properties)
Creates the symbol layer.
A geometry is the spatial representation of a feature.
A line symbol type, for rendering LineString and MultiLineString geometries.
Struct for storing maximum and minimum scales for measurements in map units.
A marker symbol type, for rendering Point and MultiPoint geometries.
Contains information about the context of a rendering operation.
Abstract base class for symbol layers.
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
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 QgsMapUnitScale mapUnitScale() const
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 bool rendersIdenticallyTo(const QgsSymbolLayer *other) const
Returns true if this symbol layer will always render identically to an other symbol layer.
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 Qgis::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol layer.
virtual void setColor(const QColor &color)
Sets the "representative" color for the symbol layer.
virtual QColor color() const
Returns the "representative" color of the symbol layer.
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 setOutputUnit(Qgis::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol layer.
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
QgsSymbolLayer(const QgsSymbolLayer &other)
Encapsulates the context in which a symbol is being rendered.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:231
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:84