23 QString expression =
properties.value( QStringLiteral(
"geometryModifier" ) ).toString();
24 if ( expression.isEmpty() )
26 expression = QStringLiteral(
"$geometry" );
30 if (
properties.value( QStringLiteral(
"SymbolType" ) ) == QLatin1String(
"Marker" ) )
34 else if (
properties.value( QStringLiteral(
"SymbolType" ) ) == QLatin1String(
"Line" ) )
47 QgsGeometryGeneratorSymbolLayer::QgsGeometryGeneratorSymbolLayer(
const QString &expression )
57 return QStringLiteral(
"GeometryGenerator" );
66 mSymbol = mFillSymbol.get();
72 mSymbol = mLineSymbol.get();
78 mSymbol = mMarkerSymbol.get();
101 mRenderingFeature =
true;
102 mHasRenderedFeature =
false;
107 mRenderingFeature =
false;
113 return mFillSymbol->usesMapUnits();
114 else if ( mLineSymbol )
115 return mLineSymbol->usesMapUnits();
116 else if ( mMarkerSymbol )
117 return mMarkerSymbol->usesMapUnits();
126 clone->mFillSymbol.reset( mFillSymbol->clone() );
128 clone->mLineSymbol.reset( mLineSymbol->clone() );
130 clone->mMarkerSymbol.reset( mMarkerSymbol->clone() );
132 clone->setSymbolType( mSymbolType );
143 props.insert( QStringLiteral(
"geometryModifier" ), mExpression->expression() );
144 switch ( mSymbolType )
147 props.insert( QStringLiteral(
"SymbolType" ), QStringLiteral(
"Marker" ) );
150 props.insert( QStringLiteral(
"SymbolType" ), QStringLiteral(
"Line" ) );
153 props.insert( QStringLiteral(
"SymbolType" ), QStringLiteral(
"Fill" ) );
172 switch ( symbol->
type() )
199 + mExpression->referencedColumns();
217 if ( mRenderingFeature && mHasRenderedFeature )
230 subSymbolExpressionContextScope->
setFeature( f );
234 if ( mRenderingFeature )
235 mHasRenderedFeature =
true;
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 id, geometry and a list of field/values...
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.
QgsSymbol::SymbolType symbolType() const
Access the symbol type.
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.
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.
void setSymbolType(QgsSymbol::SymbolType symbolType)
Set the type of symbol which should be created.
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.
SymbolType type() const
Returns the symbol's type.
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.
SymbolType
Type of the symbol.
void startRender(QgsRenderContext &context, const QgsFields &fields=QgsFields())
Begins the rendering process for the symbol.