26 QString expression =
properties.value( QStringLiteral(
"geometryModifier" ) ).toString();
27 if ( expression.isEmpty() )
29 expression = QStringLiteral(
"$geometry" );
33 if (
properties.value( QStringLiteral(
"SymbolType" ) ) == QLatin1String(
"Marker" ) )
37 else if (
properties.value( QStringLiteral(
"SymbolType" ) ) == QLatin1String(
"Line" ) )
50 QgsGeometryGeneratorSymbolLayer::QgsGeometryGeneratorSymbolLayer(
const QString &expression )
53 , mSymbolType(
Qgis::SymbolType::Marker )
60 return QStringLiteral(
"GeometryGenerator" );
69 mSymbol = mFillSymbol.get();
75 mSymbol = mLineSymbol.get();
81 mSymbol = mMarkerSymbol.get();
104 mRenderingFeature =
true;
105 mHasRenderedFeature =
false;
110 mRenderingFeature =
false;
116 return mFillSymbol->usesMapUnits();
117 else if ( mLineSymbol )
118 return mLineSymbol->usesMapUnits();
119 else if ( mMarkerSymbol )
120 return mMarkerSymbol->usesMapUnits();
129 clone->mFillSymbol.reset( mFillSymbol->clone() );
131 clone->mLineSymbol.reset( mLineSymbol->clone() );
133 clone->mMarkerSymbol.reset( mMarkerSymbol->clone() );
135 clone->setSymbolType( mSymbolType );
146 props.insert( QStringLiteral(
"geometryModifier" ), mExpression->expression() );
147 switch ( mSymbolType )
150 props.insert( QStringLiteral(
"SymbolType" ), QStringLiteral(
"Marker" ) );
153 props.insert( QStringLiteral(
"SymbolType" ), QStringLiteral(
"Line" ) );
156 props.insert( QStringLiteral(
"SymbolType" ), QStringLiteral(
"Fill" ) );
175 switch ( symbol->
type() )
202 + mExpression->referencedColumns();
220 if ( mRenderingFeature && mHasRenderedFeature )
233 subSymbolExpressionContextScope->
setFeature( f );
237 if ( mRenderingFeature )
238 mHasRenderedFeature =
true;
The Qgis class provides global constants for use throughout the application.
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.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QgsFeature feature() const
Convenience function for retrieving the feature for the context, if set.
Class for parsing and evaluation of expressions (formerly called "search strings").
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
static QgsFillSymbol * createSimple(const QVariantMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties.
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
void drawPreviewIcon(QgsSymbolRenderContext &context, QSize size) override
bool hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
void setGeometryExpression(const QString &exp)
Set the expression to generate this geometry.
void setSymbolType(Qgis::SymbolType symbolType)
Set the type of symbol which should be created.
QString layerType() const override
Returns a string that represents this layer type.
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
bool isCompatibleWithSymbol(QgsSymbol *symbol) const override
Will always return true.
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...
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
void setColor(const QColor &color) override
The fill color.
~QgsGeometryGeneratorSymbolLayer() override
static QgsSymbolLayer * create(const QVariantMap &properties)
Creates the symbol layer.
virtual void render(QgsSymbolRenderContext &context)
Will render this symbol layer using the context.
void stopFeatureRender(const QgsFeature &feature, QgsRenderContext &context) override
Called after the layer has been rendered for a particular feature.
QgsSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
void startFeatureRender(const QgsFeature &feature, QgsRenderContext &context) override
Called before the layer will be rendered for a particular feature.
A geometry is the spatial representation of a feature.
A line symbol type, for rendering LineString and MultiLineString geometries.
static QgsLineSymbol * createSimple(const QVariantMap &properties)
Create a line symbol with one symbol layer: SimpleLine with specified properties.
A marker symbol type, for rendering Point and MultiPoint geometries.
static QgsMarkerSymbol * createSimple(const QVariantMap &properties)
Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
Contains information about the context of a rendering operation.
QPainter * painter()
Returns the destination QPainter for the render operation.
QgsExpressionContext & expressionContext()
Gets the expression context.
virtual QColor color() const
The fill color.
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
void copyDataDefinedProperties(QgsSymbolLayer *destLayer) const
Copies all data defined properties of this layer to another symbol layer.
void restoreOldDataDefinedProperties(const QVariantMap &stringMap)
Restores older data defined properties from string map.
void copyPaintEffect(QgsSymbolLayer *destLayer) const
Copies paint effect of this layer to another symbol layer.
bool selected() const
Returns true if symbols should be rendered using the selected symbol coloring and style.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
const QgsFeature * feature() const
Returns the current feature being rendered.
QgsExpressionContextScope * expressionContextScope()
This scope is always available when a symbol of this type is being rendered.
const QgsLegendPatchShape * patchShape() const
Returns the symbol patch shape, to use if rendering symbol preview icons.
Abstract base class for all rendered symbols.
QgsSymbolRenderContext * symbolRenderContext()
Returns the symbol render context.
void stopRender(QgsRenderContext &context)
Ends the rendering process.
void drawPreviewIcon(QPainter *painter, QSize size, QgsRenderContext *customContext=nullptr, bool selected=false, const QgsExpressionContext *expressionContext=nullptr, const QgsLegendPatchShape *patchShape=nullptr)
Draws an icon of the symbol that occupies an area given by size using the specified painter.
void renderFeature(const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false, int currentVertexMarkerType=0, double currentVertexMarkerSize=0.0) SIP_THROW(QgsCsException)
Render a feature.
QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns a list of attributes required to render this feature.
void setColor(const QColor &color)
Sets the color for the symbol.
Qgis::SymbolType type() const
Returns the symbol's type.
void startRender(QgsRenderContext &context, const QgsFields &fields=QgsFields())
Begins the rendering process for the symbol.