Class: QgsSVGFillSymbolLayer

class qgis.core.QgsSVGFillSymbolLayer

Bases: QgsImageFillSymbolLayer

A class for filling symbols with a repeated SVG file.

QgsSVGFillSymbolLayer(svgFilePath: str, width: float = 20, rotation: float = 0) Constructor for QgsSVGFillSymbolLayer, using the SVG picture at the specified absolute file path.

QgsSVGFillSymbolLayer(svgData: Union[QByteArray, bytes, bytearray], width: float = 20, rotation: float = 0) Constructor for QgsSVGFillSymbolLayer, using the specified SVG picture data.

Methods

applyBrushTransformFromContext

Returns True if the image brush should be transformed using the render context's texture origin.

applyDataDefinedSettings

param context:

clone

rtype:

QgsSVGFillSymbolLayer

copyDataDefinedProperties

Copies all data defined properties of this layer to another symbol layer.

copyPaintEffect

Copies paint effect of this layer to another symbol layer

create

Creates a new QgsSVGFillSymbolLayer from a properties map.

createFromSld

Creates a new QgsSVGFillSymbolLayer from a SLD element.

layerType

rtype:

str

mapUnitScale

rtype:

QgsMapUnitScale

outputUnit

rtype:

QgsUnitTypes.RenderUnit

parameters

Returns the dynamic SVG parameters

patternWidth

Returns the width of the rendered SVG content within the fill (i.e.

patternWidthMapUnitScale

Returns the map unit scale for the pattern's width.

patternWidthUnit

Returns the units for the width of the SVG images in the pattern.

properties

rtype:

Dict[str, Any]

resolvePaths

Turns relative paths in properties map to absolute when reading and vice versa when writing.

restoreOldDataDefinedProperties

Restores older data defined properties from string map.

setMapUnitScale

param scale:

setOutputUnit

param unit:

setParameters

Sets the dynamic SVG parameters

setPatternWidth

Sets the width to render the SVG content as within the fill (i.e.

setPatternWidthMapUnitScale

Sets the map unit scale for the pattern's width.

setPatternWidthUnit

Sets the unit for the width of the SVG images in the pattern.

setSvgFilePath

Sets the path to the SVG file to render in the fill.

setSvgFillColor

Sets the fill color used for rendering the SVG content.

setSvgStrokeColor

Sets the stroke color used for rendering the SVG content.

setSvgStrokeWidth

Sets the stroke width used for rendering the SVG content.

setSvgStrokeWidthMapUnitScale

Sets the map unit scale for the pattern's stroke.

setSvgStrokeWidthUnit

Sets the unit for the stroke width.

startRender

param context:

stopRender

param context:

svgFilePath

Returns the path to the SVG file used to render the fill.

svgFillColor

Returns the fill color used for rendering the SVG content.

svgStrokeColor

Returns the stroke color used for rendering the SVG content.

svgStrokeWidth

Returns the stroke width used for rendering the SVG content.

svgStrokeWidthMapUnitScale

Returns the map unit scale for the pattern's stroke.

svgStrokeWidthUnit

Returns the units for the stroke width.

toSld

param doc:

usesMapUnits

rtype:

bool

applyBrushTransformFromContext(self) bool

Returns True if the image brush should be transformed using the render context’s texture origin.

New in version 3.16.

applyDataDefinedSettings(self, context: QgsSymbolRenderContext)
Parameters:

context (QgsSymbolRenderContext) –

clone(self) QgsSVGFillSymbolLayer
Return type:

QgsSVGFillSymbolLayer

copyDataDefinedProperties(self, destLayer: QgsSymbolLayer)

Copies all data defined properties of this layer to another symbol layer.

Parameters:

destLayer – destination layer

copyPaintEffect(self, destLayer: QgsSymbolLayer)

Copies paint effect of this layer to another symbol layer

Parameters:

destLayer – destination layer

New in version 2.9.

create(properties: Dict[str, Any] = {}) QgsSymbolLayer

Creates a new QgsSVGFillSymbolLayer from a properties map. The caller takes ownership of the returned object.

Parameters:

properties (Dict[str) –

Return type:

QgsSymbolLayer

createFromSld(element: QDomElement) QgsSymbolLayer

Creates a new QgsSVGFillSymbolLayer from a SLD element. The caller takes ownership of the returned object.

Parameters:

element (QDomElement) –

Return type:

QgsSymbolLayer

layerType(self) str
Return type:

str

mapUnitScale(self) QgsMapUnitScale
Return type:

QgsMapUnitScale

outputUnit(self) QgsUnitTypes.RenderUnit
Return type:

QgsUnitTypes.RenderUnit

parameters(self) Dict[str, QgsProperty]

Returns the dynamic SVG parameters

New in version 3.18.

Return type:

Dict[str, QgsProperty]

patternWidth(self) float

Returns the width of the rendered SVG content within the fill (i.e. the pattern repeat/tile size).

Units are retrieved by patternWidthUnit()

Return type:

float

patternWidthMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the pattern’s width.

See also

patternWidth()

Return type:

QgsMapUnitScale

patternWidthUnit(self) QgsUnitTypes.RenderUnit

Returns the units for the width of the SVG images in the pattern.

See also

patternWidth()

Return type:

QgsUnitTypes.RenderUnit

properties(self) Dict[str, Any]
Return type:

Dict[str, Any]

resolvePaths(properties: Dict[str, Any], pathResolver: QgsPathResolver, saving: bool)

Turns relative paths in properties map to absolute when reading and vice versa when writing. Used internally when reading/writing symbols.

New in version 3.0.

Parameters:
  • properties (Dict[str) –

  • pathResolver (QgsPathResolver) –

  • saving (bool) –

restoreOldDataDefinedProperties(self, stringMap: Dict[str, Any])

Restores older data defined properties from string map.

New in version 3.0.

setMapUnitScale(self, scale: QgsMapUnitScale)
Parameters:

scale (QgsMapUnitScale) –

setOutputUnit(self, unit: QgsUnitTypes.RenderUnit)
Parameters:

unit (QgsUnitTypes.RenderUnit) –

setParameters(self, parameters: Dict[str, QgsProperty])

Sets the dynamic SVG parameters

New in version 3.18.

Parameters:

parameters (Dict[str) –

setPatternWidth(self, width: float)

Sets the width to render the SVG content as within the fill (i.e. the pattern repeat/tile size).

Units are specified by setPatternWidthUnit()

See also

patternWidth()

Parameters:

width (float) –

setPatternWidthMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale for the pattern’s width.

Parameters:

scale (QgsMapUnitScale) –

setPatternWidthUnit(self, unit: QgsUnitTypes.RenderUnit)

Sets the unit for the width of the SVG images in the pattern.

Parameters:

unit (QgsUnitTypes.RenderUnit) –

setSvgFilePath(self, svgPath: str)

Sets the path to the SVG file to render in the fill.

This is usually an absolute file path. Other supported options include

  • relative paths to folders from the user’s SVG search paths

  • base64 encoded content, prefixed with a ‘base64:’ string

  • http(s) paths

See also

svgFilePath()

Parameters:

svgPath (str) –

setSvgFillColor(self, c: QColor | Qt.GlobalColor)

Sets the fill color used for rendering the SVG content.

Fill color is only supported for parametrized SVG files. Color opacity is ignored if the SVG file does not support parametrized fill opacity.

See also

svgFillColor()

Parameters:

c (Union[QColor) –

setSvgStrokeColor(self, c: QColor | Qt.GlobalColor)

Sets the stroke color used for rendering the SVG content.

Stroke color is only supported for parametrized SVG files. Color opacity is ignored if the SVG file does not support parametrized outline opacity.

See also

svgStrokeColor()

Parameters:

c (Union[QColor) –

setSvgStrokeWidth(self, w: float)

Sets the stroke width used for rendering the SVG content.

Stroke width is only supported for parametrized SVG files. Units are specified via setSvgStrokeWidthUnit()

See also

svgStrokeWidth()

Parameters:

w (float) –

setSvgStrokeWidthMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale for the pattern’s stroke.

Parameters:

scale (QgsMapUnitScale) –

setSvgStrokeWidthUnit(self, unit: QgsUnitTypes.RenderUnit)

Sets the unit for the stroke width.

Parameters:

unit (QgsUnitTypes.RenderUnit) –

startRender(self, context: QgsSymbolRenderContext)
Parameters:

context (QgsSymbolRenderContext) –

stopRender(self, context: QgsSymbolRenderContext)
Parameters:

context (QgsSymbolRenderContext) –

svgFilePath(self) str

Returns the path to the SVG file used to render the fill.

See also

setSvgFilePath()

Return type:

str

svgFillColor(self) QColor

Returns the fill color used for rendering the SVG content.

Fill color is only supported for parametrized SVG files.

See also

svgStrokeColor()

Return type:

QColor

svgStrokeColor(self) QColor

Returns the stroke color used for rendering the SVG content.

Stroke color is only supported for parametrized SVG files.

See also

svgFillColor()

Return type:

QColor

svgStrokeWidth(self) float

Returns the stroke width used for rendering the SVG content.

Stroke width is only supported for parametrized SVG files. Units are retrieved via setSvgStrokeWidthUnit()

Return type:

float

svgStrokeWidthMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the pattern’s stroke.

See also

svgStrokeWidth()

Return type:

QgsMapUnitScale

svgStrokeWidthUnit(self) QgsUnitTypes.RenderUnit

Returns the units for the stroke width.

See also

svgStrokeWidth()

Return type:

QgsUnitTypes.RenderUnit

toSld(self, doc: QDomDocument, element: QDomElement, props: Dict[str, Any])
Parameters:
  • doc (QDomDocument) –

  • element (QDomElement) –

  • props (Dict[str) –

usesMapUnits(self) bool
Return type:

bool