QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
QgsGeometryGeneratorSymbolLayer Class Reference

A symbol layer subclass which alters rendered feature shapes through the use of QGIS expressions. More...

#include <qgsgeometrygeneratorsymbollayer.h>

Inheritance diagram for QgsGeometryGeneratorSymbolLayer:
Inheritance graph
[legend]

Public Member Functions

 ~QgsGeometryGeneratorSymbolLayer () override
 
QgsSymbolLayerclone () const override
 Shall be reimplemented by subclasses to create a deep copy of the instance.
 
QColor color () const override
 Returns the "representative" color of the symbol layer.
 
void drawPreviewIcon (QgsSymbolRenderContext &context, QSize size) override
 
QString geometryExpression () const
 Gets the expression to generate this geometry.
 
bool hasDataDefinedProperties () const override
 Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
 
bool isCompatibleWithSymbol (QgsSymbol *symbol) const override
 Will always return true.
 
QString layerType () const override
 Returns a string that represents this layer type.
 
QgsMapUnitScale mapUnitScale () const override
 
Qgis::RenderUnit outputUnit () const override
 Returns the units to use for sizes and widths within the symbol layer.
 
QVariantMap properties () const override
 Should be reimplemented by subclasses to return a string map that contains the configuration information for the symbol layer.
 
void render (QgsSymbolRenderContext &context, Qgis::GeometryType geometryType=Qgis::GeometryType::Unknown, const QPolygonF *points=nullptr, const QVector< QPolygonF > *rings=nullptr)
 Will render this symbol layer using the context.
 
void setColor (const QColor &color) override
 Sets the "representative" color for the symbol layer.
 
void setGeometryExpression (const QString &exp)
 Set the expression to generate this geometry.
 
void setOutputUnit (Qgis::RenderUnit unit) override
 Sets the units to use for sizes and widths within the symbol layer.
 
bool setSubSymbol (QgsSymbol *symbol) override
 Sets layer's subsymbol. takes ownership of the passed symbol.
 
void setSymbolType (Qgis::SymbolType symbolType)
 Set the type of symbol which should be created.
 
void setUnits (Qgis::RenderUnit units)
 Sets the units for the geometry expression.
 
void startFeatureRender (const QgsFeature &feature, QgsRenderContext &context) override
 Called before the layer will be rendered for a particular feature.
 
void startRender (QgsSymbolRenderContext &context) override
 Called before a set of rendering operations commences on the supplied render context.
 
void stopFeatureRender (const QgsFeature &feature, QgsRenderContext &context) override
 Called after the layer has been rendered for a particular feature.
 
void stopRender (QgsSymbolRenderContext &context) override
 Called after a set of rendering operations has finished on the supplied render context.
 
QgsSymbolsubSymbol () override
 Returns the symbol's sub symbol, if present.
 
Qgis::SymbolType symbolType () const
 Access the symbol type.
 
Qgis::RenderUnit units () const
 Returns the unit for the geometry expression.
 
QSet< QString > usedAttributes (const QgsRenderContext &context) const override
 Returns the set of attributes referenced by the layer.
 
bool usesMapUnits () const override
 Returns true if the symbol layer has any components which use map unit based sizes.
 
- Public Member Functions inherited from QgsSymbolLayer
virtual ~QgsSymbolLayer ()
 
virtual bool canCauseArtifactsBetweenAdjacentTiles () const
 Returns true if the symbol layer rendering can cause visible artifacts across a single feature when the feature is rendered as a series of adjacent map tiles each containing a portion of the feature's geometry.
 
QgsPropertyCollectiondataDefinedProperties ()
 Returns a reference to the symbol layer's property collection, used for data defined overrides.
 
const QgsPropertyCollectiondataDefinedProperties () const
 Returns a reference to the symbol layer's property collection, used for data defined overrides.
 
virtual double dxfAngle (QgsSymbolRenderContext &context) const
 Gets angle.
 
virtual QColor dxfBrushColor (QgsSymbolRenderContext &context) const
 Gets brush/fill color.
 
virtual Qt::BrushStyle dxfBrushStyle () const
 Gets brush/fill style.
 
virtual QColor dxfColor (QgsSymbolRenderContext &context) const
 Gets color.
 
virtual QVector< qreal > dxfCustomDashPattern (Qgis::RenderUnit &unit) const
 Gets dash pattern.
 
virtual double dxfOffset (const QgsDxfExport &e, QgsSymbolRenderContext &context) const
 Gets offset.
 
virtual Qt::PenStyle dxfPenStyle () const
 Gets pen style.
 
virtual double dxfSize (const QgsDxfExport &e, QgsSymbolRenderContext &context) const
 Gets marker size.
 
virtual double dxfWidth (const QgsDxfExport &e, QgsSymbolRenderContext &context) const
 Gets line width.
 
bool enabled () const
 Returns true if symbol layer is enabled and will be drawn.
 
virtual double estimateMaxBleed (const QgsRenderContext &context) const
 Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when drawn in the specified /a context.
 
virtual QColor fillColor () const
 Returns the fill color for the symbol layer.
 
virtual Qgis::SymbolLayerFlags flags () const
 Returns flags which control the symbol layer's behavior.
 
QString id () const
 Returns symbol layer identifier This id is unique in the whole project.
 
bool installMasks (QgsRenderContext &context, bool recursive, const QRectF &rect=QRectF())
 When rendering, install masks on context painter.
 
bool isLocked () const
 Returns true if the symbol layer colors are locked and the layer will ignore any symbol-level color changes.
 
virtual QList< QgsSymbolLayerReferencemasks () const
 Returns masks defined by this symbol layer.
 
virtual QString ogrFeatureStyle (double mmScaleFactor, double mapUnitScaleFactor) const
 
QgsSymbolLayeroperator= (const QgsSymbolLayer &other)=delete
 
QgsPaintEffectpaintEffect () const
 Returns the current paint effect for the layer.
 
virtual void prepareExpressions (const QgsSymbolRenderContext &context)
 Prepares all data defined property expressions for evaluation.
 
virtual void prepareMasks (const QgsSymbolRenderContext &context)
 Prepares all mask internal objects according to what is defined in context This should be called prior to calling startRender() method.
 
int renderingPass () const
 Specifies the rendering pass in which this symbol layer should be rendered.
 
void setDataDefinedProperties (const QgsPropertyCollection &collection)
 Sets the symbol layer's property collection, used for data defined overrides.
 
virtual void setDataDefinedProperty (Property key, const QgsProperty &property)
 Sets a data defined property for the layer.
 
void setEnabled (bool enabled)
 Sets whether symbol layer is enabled and should be drawn.
 
virtual void setFillColor (const QColor &color)
 Sets the fill color for the symbol layer.
 
void setId (const QString &id)
 Set symbol layer identifier This id has to be unique in the whole project.
 
void setLocked (bool locked)
 Sets whether the layer's colors are locked.
 
virtual void setMapUnitScale (const QgsMapUnitScale &scale)
 
void setPaintEffect (QgsPaintEffect *effect)
 Sets the current paint effect for the layer.
 
void setRenderingPass (int renderingPass)
 Specifies the rendering pass in which this symbol layer should be rendered.
 
virtual void setStrokeColor (const QColor &color)
 Sets the stroke color for the symbol layer.
 
void setUserFlags (Qgis::SymbolLayerUserFlags flags)
 Sets user-controlled flags which control the symbol layer's behavior.
 
virtual QColor strokeColor () const
 Returns the stroke color for the symbol layer.
 
virtual void toSld (QDomDocument &doc, QDomElement &element, const QVariantMap &props) const
 Saves the symbol layer as SLD.
 
Qgis::SymbolType type () const
 
Qgis::SymbolLayerUserFlags userFlags () const
 Returns user-controlled flags which control the symbol layer's behavior.
 
virtual bool writeDxf (QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const
 write as DXF
 

Static Public Member Functions

static QgsSymbolLayercreate (const QVariantMap &properties)
 Creates the symbol layer.
 
- Static Public Member Functions inherited from QgsSymbolLayer
static const QgsPropertiesDefinitionpropertyDefinitions ()
 Returns the symbol layer property definitions.
 

Additional Inherited Members

- Public Types inherited from QgsSymbolLayer
enum class  Property : int {
  Size = 0 , Angle , Name , FillColor ,
  StrokeColor , StrokeWidth , StrokeStyle , Offset ,
  Character , Width , Height , PreserveAspectRatio ,
  FillStyle , JoinStyle , SecondaryColor , LineAngle ,
  LineDistance , GradientType , CoordinateMode , GradientSpread ,
  GradientReference1X , GradientReference1Y , GradientReference2X , GradientReference2Y ,
  GradientReference1IsCentroid , GradientReference2IsCentroid , BlurRadius , ShapeburstUseWholeShape ,
  ShapeburstMaxDistance , ShapeburstIgnoreRings , File , DistanceX ,
  DistanceY , DisplacementX , DisplacementY , Opacity ,
  CustomDash , CapStyle , Placement , Interval ,
  OffsetAlongLine , AverageAngleLength , HorizontalAnchor , VerticalAnchor ,
  LayerEnabled , ArrowWidth , ArrowStartWidth , ArrowHeadLength ,
  ArrowHeadThickness , ArrowHeadType , ArrowType , OffsetX ,
  OffsetY , PointCount , RandomSeed , ClipPoints ,
  DensityArea , FontFamily , FontStyle , DashPatternOffset ,
  TrimStart , TrimEnd , LineStartWidthValue , LineEndWidthValue ,
  LineStartColorValue , LineEndColorValue , MarkerClipping , RandomOffsetX ,
  RandomOffsetY , LineClipping , SkipMultiples , ShowMarker
}
 Data definable properties. More...
 
- Protected Member Functions inherited from QgsSymbolLayer
 QgsSymbolLayer (const QgsSymbolLayer &other)
 
 QgsSymbolLayer (Qgis::SymbolType type, bool locked=false)
 Constructor for QgsSymbolLayer.
 
void copyDataDefinedProperties (QgsSymbolLayer *destLayer) const
 Copies all data defined properties of this layer to another symbol layer.
 
void copyPaintEffect (QgsSymbolLayer *destLayer) const
 Copies paint effect of this layer to another symbol layer.
 
void removeMasks (QgsRenderContext &context, bool recursive)
 When rendering, remove previously installed masks from context painter if recursive is true masks are removed recursively for all children symbol layers.
 
void restoreOldDataDefinedProperties (const QVariantMap &stringMap)
 Restores older data defined properties from string map.
 
bool shouldRenderUsingSelectionColor (const QgsSymbolRenderContext &context) const
 Returns true if the symbol layer should be rendered using the selection color from the render context.
 
- Protected Attributes inherited from QgsSymbolLayer
QPainterPath mClipPath
 
QColor mColor
 
QgsPropertyCollection mDataDefinedProperties
 
bool mEnabled = true
 True if layer is enabled and should be drawn.
 
QgsFields mFields
 
QString mId
 
bool mLocked = false
 
std::unique_ptr< QgsPaintEffectmPaintEffect
 
int mRenderingPass = 0
 
Qgis::SymbolType mType
 
Qgis::SymbolLayerUserFlags mUserFlags
 User controlled flags.
 
- Static Protected Attributes inherited from QgsSymbolLayer
static const bool SELECT_FILL_BORDER = false
 Whether fill styles for selected features also highlight symbol stroke.
 
static const bool SELECT_FILL_STYLE = false
 Whether fill styles for selected features uses symbol layer style.
 
static const bool SELECTION_IS_OPAQUE = true
 Whether styles for selected features ignore symbol alpha.
 

Detailed Description

A symbol layer subclass which alters rendered feature shapes through the use of QGIS expressions.

Definition at line 32 of file qgsgeometrygeneratorsymbollayer.h.

Constructor & Destructor Documentation

◆ ~QgsGeometryGeneratorSymbolLayer()

QgsGeometryGeneratorSymbolLayer::~QgsGeometryGeneratorSymbolLayer ( )
overridedefault

Member Function Documentation

◆ clone()

QgsSymbolLayer * QgsGeometryGeneratorSymbolLayer::clone ( ) const
overridevirtual

Shall be reimplemented by subclasses to create a deep copy of the instance.

Implements QgsSymbolLayer.

Definition at line 181 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ color()

QColor QgsGeometryGeneratorSymbolLayer::color ( ) const
overridevirtual

Returns the "representative" color of the symbol layer.

Depending on the symbol layer type, this will have different meaning. For instance, a line symbol layer will generally return the stroke color of the layer, while a fill symbol layer will return the "fill" color instead of stroke.

Some symbol layer types will return an invalid QColor if they have no representative color associated (e.g. raster image based symbol layers).

See also
setColor()
strokeColor()
fillColor()

Reimplemented from QgsSymbolLayer.

Definition at line 138 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ create()

QgsSymbolLayer * QgsGeometryGeneratorSymbolLayer::create ( const QVariantMap &  properties)
static

Creates the symbol layer.

Definition at line 31 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ drawPreviewIcon()

void QgsGeometryGeneratorSymbolLayer::drawPreviewIcon ( QgsSymbolRenderContext context,
QSize  size 
)
overridevirtual

Implements QgsSymbolLayer.

Definition at line 222 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ geometryExpression()

QString QgsGeometryGeneratorSymbolLayer::geometryExpression ( ) const

Gets the expression to generate this geometry.

Definition at line 276 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ hasDataDefinedProperties()

bool QgsGeometryGeneratorSymbolLayer::hasDataDefinedProperties ( ) const
overridevirtual

Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.

Since
QGIS 3.4.5

Reimplemented from QgsSymbolLayer.

Definition at line 313 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ isCompatibleWithSymbol()

bool QgsGeometryGeneratorSymbolLayer::isCompatibleWithSymbol ( QgsSymbol symbol) const
overridevirtual

Will always return true.

This is a hybrid layer, it constructs its own geometry so it does not care about the geometry of its parents.

Reimplemented from QgsSymbolLayer.

Definition at line 321 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ layerType()

QString QgsGeometryGeneratorSymbolLayer::layerType ( ) const
overridevirtual

Returns a string that represents this layer type.

Used for serialization. Should match with the string used to register this symbol layer in the registry.

Implements QgsSymbolLayer.

Definition at line 67 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ mapUnitScale()

QgsMapUnitScale QgsGeometryGeneratorSymbolLayer::mapUnitScale ( ) const
overridevirtual

Reimplemented from QgsSymbolLayer.

Definition at line 170 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ outputUnit()

Qgis::RenderUnit QgsGeometryGeneratorSymbolLayer::outputUnit ( ) const
overridevirtual

Returns the units to use for sizes and widths within the symbol layer.

Individual symbol layer subclasses will interpret this in different ways, e.g., a marker symbol layer may use it to specify the units for the marker size, while a line symbol layer may use it to specify the units for the line width.

Returns
output unit, or QgsUnitTypes::RenderUnknownUnit if the symbol layer contains mixed units
See also
setOutputUnit()

Reimplemented from QgsSymbolLayer.

Definition at line 149 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ properties()

QVariantMap QgsGeometryGeneratorSymbolLayer::properties ( ) const
overridevirtual

Should be reimplemented by subclasses to return a string map that contains the configuration information for the symbol layer.

This is used to serialize a symbol layer perstistently.

Implements QgsSymbolLayer.

Definition at line 201 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ render()

void QgsGeometryGeneratorSymbolLayer::render ( QgsSymbolRenderContext context,
Qgis::GeometryType  geometryType = Qgis::GeometryType::Unknown,
const QPolygonF *  points = nullptr,
const QVector< QPolygonF > *  rings = nullptr 
)

Will render this symbol layer using the context.

In comparison to other symbols there is no geometry passed in, since the geometry will be created based on information from the context which contains a QgsRenderContext which in turn contains an expression context which is available to the evaluated expression.

Parameters
contextThe rendering context which will be used to render and to construct a geometry.
geometryTypetype of original geometry being rendered by the parent symbol (since QGIS 3.22)
pointsoptional list of original points which are being rendered by the parent symbol (since QGIS 3.22)
ringsoptional list of original rings which are being rendered by the parent symbol (since QGIS 3.22)

Definition at line 384 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ setColor()

void QgsGeometryGeneratorSymbolLayer::setColor ( const QColor &  color)
overridevirtual

Sets the "representative" color for the symbol layer.

Depending on the symbol layer type, this will have different meaning. For instance, a line symbol layer will generally set the stroke color of the layer, while a fill symbol layer will set the "fill" color instead of stroke.

See also
color()
setStrokeColor()
setFillColor()

Reimplemented from QgsSymbolLayer.

Definition at line 519 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ setGeometryExpression()

void QgsGeometryGeneratorSymbolLayer::setGeometryExpression ( const QString &  exp)

Set the expression to generate this geometry.

Definition at line 271 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ setOutputUnit()

void QgsGeometryGeneratorSymbolLayer::setOutputUnit ( Qgis::RenderUnit  unit)
overridevirtual

Sets the units to use for sizes and widths within the symbol layer.

Individual symbol layer subclasses will interpret this in different ways, e.g., a marker symbol layer may use it to specify the units for the marker size, while a line symbol layer may use it to specify the units for the line width.

Parameters
unitoutput units
See also
outputUnit()

Reimplemented from QgsSymbolLayer.

Definition at line 160 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ setSubSymbol()

bool QgsGeometryGeneratorSymbolLayer::setSubSymbol ( QgsSymbol symbol)
overridevirtual

Sets layer's subsymbol. takes ownership of the passed symbol.

Reimplemented from QgsSymbolLayer.

Definition at line 281 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ setSymbolType()

void QgsGeometryGeneratorSymbolLayer::setSymbolType ( Qgis::SymbolType  symbolType)

Set the type of symbol which should be created.

Should match with the return type of the expression.

Parameters
symbolTypeThe symbol type which shall be used below this symbol.

Definition at line 72 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ setUnits()

void QgsGeometryGeneratorSymbolLayer::setUnits ( Qgis::RenderUnit  units)
inline

Sets the units for the geometry expression.

By default this is QgsUnitTypes::MapUnits, which means that the geometryExpression() will return geometries in the associated layer's CRS.

See also
units()
Since
QGIS 3.22

Definition at line 104 of file qgsgeometrygeneratorsymbollayer.h.

◆ startFeatureRender()

void QgsGeometryGeneratorSymbolLayer::startFeatureRender ( const QgsFeature feature,
QgsRenderContext context 
)
overridevirtual

Called before the layer will be rendered for a particular feature.

This is always followed by a call to stopFeatureRender() after the feature has been completely rendered (i.e. all parts have been rendered).

The default implementation does nothing.

Note
In some circumstances, startFeatureRender() and stopFeatureRender() may not be called before a symbol layer is rendered. E.g., when a symbol layer is being rendered in isolation and not as a result of rendering a feature (for instance, when rendering a legend patch or other non-feature based shape).
See also
stopFeatureRender()
startRender()
Since
QGIS 3.12

Reimplemented from QgsSymbolLayer.

Definition at line 113 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ startRender()

void QgsGeometryGeneratorSymbolLayer::startRender ( QgsSymbolRenderContext context)
overridevirtual

Called before a set of rendering operations commences on the supplied render context.

This is always followed by a call to stopRender() after all rendering operations have been completed.

Subclasses can use this method to prepare for a set of rendering operations, e.g. by pre-evaluating paths or images to render, and performing other one-time optimisations.

See also
startFeatureRender()
stopRender()

Implements QgsSymbolLayer.

Definition at line 98 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ stopFeatureRender()

void QgsGeometryGeneratorSymbolLayer::stopFeatureRender ( const QgsFeature feature,
QgsRenderContext context 
)
overridevirtual

Called after the layer has been rendered for a particular feature.

This is always preceded by a call to startFeatureRender() just before the feature will be rendered.

The default implementation does nothing.

Note
In some circumstances, startFeatureRender() and stopFeatureRender() may not be called before a symbol layer is rendered. E.g., when a symbol layer is being rendered in isolation and not as a result of rendering a feature (for instance, when rendering a legend patch or other non-feature based shape).
See also
startFeatureRender()
stopRender()
Since
QGIS 3.12

Reimplemented from QgsSymbolLayer.

Definition at line 122 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ stopRender()

void QgsGeometryGeneratorSymbolLayer::stopRender ( QgsSymbolRenderContext context)
overridevirtual

Called after a set of rendering operations has finished on the supplied render context.

This is always preceded by a call to startRender() before all rendering operations are commenced.

Subclasses can use this method to cleanup after a set of rendering operations.

See also
startRender()
stopFeatureRender()

Implements QgsSymbolLayer.

Definition at line 107 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ subSymbol()

QgsSymbol * QgsGeometryGeneratorSymbolLayer::subSymbol ( )
inlineoverridevirtual

Returns the symbol's sub symbol, if present.

Reimplemented from QgsSymbolLayer.

Definition at line 106 of file qgsgeometrygeneratorsymbollayer.h.

◆ symbolType()

Qgis::SymbolType QgsGeometryGeneratorSymbolLayer::symbolType ( ) const
inline

Access the symbol type.

This defines the type of geometry that is created by this generator.

Returns
Symbol type

Definition at line 56 of file qgsgeometrygeneratorsymbollayer.h.

◆ units()

Qgis::RenderUnit QgsGeometryGeneratorSymbolLayer::units ( ) const
inline

Returns the unit for the geometry expression.

By default this is QgsUnitTypes::MapUnits, which means that the geometryExpression() will return geometries in the associated layer's CRS.

See also
setUnits()
Since
QGIS 3.22

Definition at line 93 of file qgsgeometrygeneratorsymbollayer.h.

◆ usedAttributes()

QSet< QString > QgsGeometryGeneratorSymbolLayer::usedAttributes ( const QgsRenderContext context) const
overridevirtual

Returns the set of attributes referenced by the layer.

This includes attributes required by any data defined properties associated with the layer.

Reimplemented from QgsSymbolLayer.

Definition at line 306 of file qgsgeometrygeneratorsymbollayer.cpp.

◆ usesMapUnits()

bool QgsGeometryGeneratorSymbolLayer::usesMapUnits ( ) const
overridevirtual

Returns true if the symbol layer has any components which use map unit based sizes.

Since
QGIS 3.18

Reimplemented from QgsSymbolLayer.

Definition at line 127 of file qgsgeometrygeneratorsymbollayer.cpp.


The documentation for this class was generated from the following files: