28 QString expression = properties.value( QStringLiteral(
"geometryModifier" ) );
29 if ( expression.isEmpty() )
31 expression = QStringLiteral(
"$geometry" );
35 if ( properties.value( QStringLiteral(
"SymbolType" ) ) == QLatin1String(
"Marker" ) )
39 else if ( properties.value( QStringLiteral(
"SymbolType" ) ) == QLatin1String(
"Line" ) )
52 QgsGeometryGeneratorSymbolLayer::QgsGeometryGeneratorSymbolLayer(
const QString &expression )
54 , mExpression(
new QgsExpression( expression ) )
62 return QStringLiteral(
"GeometryGenerator" );
71 mSymbol = mFillSymbol;
77 mSymbol = mLineSymbol;
83 mSymbol = mMarkerSymbol;
109 clone->mFillSymbol = mFillSymbol->
clone();
111 clone->mLineSymbol = mLineSymbol->
clone();
113 clone->mMarkerSymbol = mMarkerSymbol->
clone();
126 props.insert( QStringLiteral(
"geometryModifier" ), mExpression->expression() );
127 switch ( mSymbolType )
130 props.insert( QStringLiteral(
"SymbolType" ), QStringLiteral(
"Marker" ) );
133 props.insert( QStringLiteral(
"SymbolType" ), QStringLiteral(
"Line" ) );
136 props.insert( QStringLiteral(
"SymbolType" ), QStringLiteral(
"Fill" ) );
150 mExpression.reset(
new QgsExpression( exp ) );
155 switch ( symbol->
type() )
182 + mExpression->referencedColumns();
202 subSymbolExpressionContextScope->
setFeature( f );
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
void drawPreviewIcon(QgsSymbolRenderContext &context, QSize size) override
static QgsLineSymbol * createSimple(const QgsStringMap &properties)
Create a line symbol with one symbol layer: SimpleLine with specified properties. ...
static QgsFillSymbol * createSimple(const QgsStringMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties. ...
void startRender(QgsSymbolRenderContext &context) override
void copyPaintEffect(QgsSymbolLayer *destLayer) const
Copies paint effect of this layer to another symbol layer.
~QgsGeometryGeneratorSymbolLayer() override
void stopRender(QgsSymbolRenderContext &context) override
A geometry is the spatial representation of a feature.
virtual void render(QgsSymbolRenderContext &context)
Will render this symbol layer using the context.
void restoreOldDataDefinedProperties(const QgsStringMap &stringMap)
Restores older data defined properties from string map.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QMap< QString, QString > QgsStringMap
void startRender(QgsRenderContext &context, const QgsFields &fields=QgsFields())
Begins the rendering process for the symbol.
QgsSymbolLayer(QgsSymbol::SymbolType type, bool locked=false)
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
SymbolType
Type of the symbol.
QString layerType() const override
Returns a string that represents this layer type.
QgsFillSymbol * clone() const override
Get a deep copy of this symbol.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
virtual QColor color() const
The fill color.
void renderFeature(const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false, int currentVertexMarkerType=0, int currentVertexMarkerSize=0)
Render a feature.
bool setSubSymbol(QgsSymbol *symbol) override
set layer's subsymbol. takes ownership of the passed symbol
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void drawPreviewIcon(QPainter *painter, QSize size, QgsRenderContext *customContext=nullptr)
Draw icon of the symbol that occupyies area given by size using the painter.
void setSymbolType(QgsSymbol::SymbolType symbolType)
Set the type of symbol which should be created.
QgsSymbolRenderContext * symbolRenderContext()
Returns the symbol render context.
Single scope for storing variables and functions for use within a QgsExpressionContext.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the scope.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
QgsExpressionContext & expressionContext()
Gets the expression context.
QSet< QString > usedAttributes(const QgsRenderContext &context) const
Return a list of attributes required to render this feature.
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.
QPainter * painter()
Returns the destination QPainter for the render operation.
void setGeometryExpression(const QString &exp)
Set the expression to generate this geometry.
void setColor(const QColor &color) override
The fill color.
static QgsSymbolLayer * create(const QgsStringMap &properties)
bool isCompatibleWithSymbol(QgsSymbol *symbol) const override
Will always return true.
QgsSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
const QgsFeature * feature() const
Current feature being rendered - may be null.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
QgsSymbol::SymbolType symbolType() const
Access the symbol type.
QgsFeature feature() const
Convenience function for retrieving the feature for the context, if set.
static QgsMarkerSymbol * createSimple(const QgsStringMap &properties)
Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
void stopRender(QgsRenderContext &context)
Ends the rendering process.
QgsMarkerSymbol * clone() const override
Get a deep copy of this symbol.
void copyDataDefinedProperties(QgsSymbolLayer *destLayer) const
Copies all data defined properties of this layer to another symbol layer.
QgsLineSymbol * clone() const override
Get a deep copy of this symbol.
void setColor(const QColor &color)
QgsExpressionContextScope * expressionContextScope()
This scope is always available when a symbol of this type is being rendered.