Class: QgsSymbolRenderContext

class qgis.core.QgsSymbolRenderContext(c: QgsRenderContext, u: QgsUnitTypes.RenderUnit, opacity: float = 1, selected: bool = False, renderHints: Union[QgsSymbol.RenderHints, QgsSymbol.RenderHint] = 0, f: QgsFeature = None, fields: QgsFields = QgsFields(), mapUnitScale: QgsMapUnitScale = QgsMapUnitScale())

Bases: sip.wrapper

Constructor for QgsSymbolRenderContext

Parameters
  • c

  • u

  • opacity – value between 0 (fully transparent) and 1 (fully opaque)

  • selected – set to True if symbol should be drawn in a “selected” state

  • renderHints – flags controlling rendering behavior

  • f

  • fields

  • mapUnitScale

    Enums

    Methods

    expressionContextScope

    This scope is always available when a symbol of this type is being rendered.

    feature

    Returns the current feature being rendered.

    fields

    Fields of the layer.

    geometryPartCount

    Part count of current geometry

    geometryPartNum

    Part number of current geometry

    mapUnitScale

    Deprecated since version Will: be removed in QGIS 4.0

    opacity

    Returns the opacity for the symbol.

    originalGeometryType

    Returns the geometry type for the original feature geometry being rendered.

    outputLineWidth

    Deprecated since version Use: the size conversion methods in QgsRenderContext instead.

    outputPixelSize

    Deprecated since version Use: the size conversion methods in QgsRenderContext instead.

    outputUnit

    Returns the output unit for the context.

    renderContext

    Returns a reference to the context’s render context.

    renderHints

    Returns the rendering hint flags for the symbol.

    selected

    Returns True if symbols should be rendered using the selected symbol coloring and style.

    setExpressionContextScope

    Set an expression scope for this symbol.

    setFeature

    setGeometryPartCount

    Sets the part count of current geometry

    setGeometryPartNum

    Sets the part number of current geometry

    setMapUnitScale

    Deprecated since version Will: be removed in QGIS 4.0

    setOpacity

    Sets the opacity for the symbol.

    setOriginalGeometryType

    Sets the geometry type for the original feature geometry being rendered.

    setOriginalValueVariable

    Sets the original value variable value for data defined symbology

    setOutputUnit

    Sets the output unit for the context.

    setRenderHints

    Sets rendering hint flags for the symbol.

    setSelected

    Sets whether symbols should be rendered using the selected symbol coloring and style.

    Signals

    Attributes

expressionContextScope(self) → QgsExpressionContextScope

This scope is always available when a symbol of this type is being rendered.

Returns

An expression scope for details about this symbol

feature(self) → QgsFeature

Returns the current feature being rendered. This may be None.

fields(self) → QgsFields

Fields of the layer. Currently only available in startRender() calls to allow symbols with data-defined properties prepare the expressions (other times fields() returns an empty QgsFields object).

New in version 2.4.

geometryPartCount(self) → int

Part count of current geometry

New in version 2.16.

geometryPartNum(self) → int

Part number of current geometry

New in version 2.16.

mapUnitScale(self) → QgsMapUnitScale

Deprecated since version Will: be removed in QGIS 4.0

opacity(self) → float

Returns the opacity for the symbol.

Returns

opacity value between 0 (fully transparent) and 1 (fully opaque)

See also

setOpacity()

originalGeometryType(self) → QgsWkbTypes.GeometryType

Returns the geometry type for the original feature geometry being rendered. This can be useful if symbol layers alter their appearance based on geometry type - eg offsetting a simple line style will look different if the simple line is rendering a polygon feature (a closed buffer) vs a line feature (an unclosed offset line).

New in version 3.0.

outputLineWidth(self, width: float) → float

Deprecated since version Use: the size conversion methods in QgsRenderContext instead.

outputPixelSize(self, size: float) → float

Deprecated since version Use: the size conversion methods in QgsRenderContext instead.

outputUnit(self) → QgsUnitTypes.RenderUnit

Returns the output unit for the context.

Deprecated since version No: longer used and will be removed in QGIS 4.0

renderContext(self) → QgsRenderContext

Returns a reference to the context’s render context.

renderHints(self) → QgsSymbol.RenderHints

Returns the rendering hint flags for the symbol.

See also

setRenderHints()

selected(self) → bool

Returns True if symbols should be rendered using the selected symbol coloring and style.

See also

setSelected()

setExpressionContextScope(self, contextScope: QgsExpressionContextScope)

Set an expression scope for this symbol.

Will take ownership.

Parameters

contextScope – An expression scope for details about this symbol

setFeature(self, f: QgsFeature)
setGeometryPartCount(self, count: int)

Sets the part count of current geometry

New in version 2.16.

setGeometryPartNum(self, num: int)

Sets the part number of current geometry

New in version 2.16.

setMapUnitScale(self, scale: QgsMapUnitScale)

Deprecated since version Will: be removed in QGIS 4.0

setOpacity(self, opacity: float)

Sets the opacity for the symbol.

Parameters

opacity – opacity value between 0 (fully transparent) and 1 (fully opaque)

See also

opacity()

setOriginalGeometryType(self, type: QgsWkbTypes.GeometryType)

Sets the geometry type for the original feature geometry being rendered.

New in version 3.0.

setOriginalValueVariable(self, value: Any)

Sets the original value variable value for data defined symbology

Parameters

value – value for original value variable. This usually represents the symbol property value before any data defined overrides have been applied.

New in version 2.12.

setOutputUnit(self, u: QgsUnitTypes.RenderUnit)

Sets the output unit for the context.

Deprecated since version No: longer used and will be removed in QGIS 4.0

setRenderHints(self, hints: Union[QgsSymbol.RenderHints, QgsSymbol.RenderHint])

Sets rendering hint flags for the symbol.

See also

renderHints()

setSelected(self, selected: bool)

Sets whether symbols should be rendered using the selected symbol coloring and style.

See also

selected()