Class: QgsSvgMarkerSymbolLayer

Class Hierarchy

Inheritance diagram of qgis.core.QgsSvgMarkerSymbolLayer

Base classes

QgsMarkerSymbolLayer

Abstract base class for marker symbol layers.

QgsSymbolLayer

Constructor for QgsSymbolLayer.

class qgis.core.QgsSvgMarkerSymbolLayer(path: str | None, size: float = DEFAULT_SVGMARKER_SIZE, angle: float = DEFAULT_SVGMARKER_ANGLE, scaleMethod: Qgis.ScaleMethod = DEFAULT_SCALE_METHOD)[source]

Bases: QgsMarkerSymbolLayer

calculateAspectRatio(self, context: QgsSymbolRenderContext, scaledSize: float)[source]

Calculates the marker aspect ratio between width and height.

Parameters:
  • context (QgsSymbolRenderContext) – symbol render context

  • scaledSize (float) -> (float) – size of symbol to render

  • hasDataDefinedAspectRatio – will be set to True if marker has data defined aspectRatio

static create(properties: Dict[str, Any] = {}) QgsSymbolLayer | None[source]

Creates the symbol

Parameters:

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

Return type:

Optional[QgsSymbolLayer]

static createFromSld(element: QDomElement) QgsSymbolLayer | None[source]
Parameters:

element (QDomElement)

Return type:

Optional[QgsSymbolLayer]

defaultAspectRatio(self) float[source]

Returns the default marker aspect ratio between width and height, 0 if not yet calculated.

Return type:

float

fixedAspectRatio(self) float[source]

Returns the marker aspect ratio between width and height to be used in rendering, if the value set is lower or equal to 0 the aspect ratio will be preserved in rendering

See also

QgsSvgCache

Return type:

float

parameters(self) Dict[str, QgsProperty]

Returns the dynamic SVG parameters

Added in version 3.18.

Return type:

Dict[str, QgsProperty]

path(self) str[source]

Returns the marker SVG path.

See also

setPath()

Return type:

str

preservedAspectRatio(self) bool[source]

Returns the preserved aspect ratio value, True if fixed aspect ratio has been lower or equal to 0.

Return type:

bool

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

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

Parameters:
setFixedAspectRatio(self, ratio: float)[source]

Set the marker aspect ratio between width and height to be used in rendering, if the value set is lower or equal to 0 the aspect ratio will be preserved in rendering

Parameters:

ratio (float) – Fixed Aspect Ratio

See also

QgsSvgCache

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

Sets the dynamic SVG parameters

Added in version 3.18.

Parameters:

parameters (Dict[Optional[str], QgsProperty])

setPath(self, path: str | None)[source]

Set the marker SVG path.

Parameters:

path (Optional[str]) – SVG path

See also

path()

setPreservedAspectRatio(self, par: bool) bool[source]

Set preserved the marker aspect ratio between width and height.

Parameters:

par (bool) – Preserved Aspect Ratio

Return type:

bool

Returns:

the preserved aspect ratio value, True if fixed aspect ratio has been lower or equal to 0

setStrokeWidth(self, w: float)[source]
Parameters:

w (float)

setStrokeWidthMapUnitScale(self, scale: QgsMapUnitScale)[source]
Parameters:

scale (QgsMapUnitScale)

setStrokeWidthUnit(self, unit: Qgis.RenderUnit)[source]

Sets the units for the stroke width.

Parameters:

unit (Qgis.RenderUnit) – width units

strokeWidth(self) float[source]
Return type:

float

strokeWidthMapUnitScale(self) QgsMapUnitScale
Return type:

QgsMapUnitScale

strokeWidthUnit(self) Qgis.RenderUnit[source]

Returns the units for the stroke width.

Return type:

Qgis.RenderUnit

updateDefaultAspectRatio(self) float[source]

Calculates the default marker aspect ratio between width and height.

Return type:

float

Returns:

the default aspect ratio value