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 (QgsRenderContext) –
u (QgsUnitTypes.RenderUnit) –
opacity (float = 1) – value between 0 (fully transparent) and 1 (fully opaque)
selected (bool = False) – set to
True
if symbol should be drawn in a “selected” staterenderHints (Union[QgsSymbol.RenderHints) – flags controlling rendering behavior
f (
QgsFeature
= None) –fields (
QgsFields
= QgsFields()) –mapUnitScale (
QgsMapUnitScale
= QgsMapUnitScale()) –Methods
This scope is always available when a symbol of this type is being rendered.
Returns the current feature being rendered.
Fields of the layer.
Part count of current geometry
Part number of current geometry
Returns the opacity for the symbol.
Returns the geometry type for the original feature geometry being rendered.
Returns the output unit for the context.
Returns the symbol patch shape, to use if rendering symbol preview icons.
Returns a reference to the context’s render context.
Returns the rendering hint flags for the symbol.
Returns
True
if symbols should be rendered using the selected symbol coloring and style.Set an expression scope for this symbol.
- param f
Sets the part count of current geometry
Sets the part number of current geometry
Sets the
opacity
for the symbol.Sets the geometry type for the original feature geometry being rendered.
Sets the original value variable value for data defined symbology
Sets the output unit for the context.
Sets the symbol patch
shape
, to use if rendering symbol preview icons.Sets rendering hint flags for the symbol.
Sets whether symbols should be rendered using the selected symbol coloring and style.
-
expressionContextScope
(self) → QgsExpressionContextScope¶ This scope is always available when a symbol of this type is being rendered.
- Return type
- Returns
An expression scope for details about this symbol
-
feature
(self) → QgsFeature¶ Returns the current feature being rendered. This may be
None
.- Return type
-
fields
(self) → QgsFields¶ Fields of the layer. Currently only available in
startRender()
calls to allow symbols with data-defined properties prepare the expressions (other timesfields()
returns an emptyQgsFields
object).New in version 2.4.
- Return type
-
geometryPartCount
(self) → int¶ Part count of current geometry
New in version 2.16.
- Return type
int
-
geometryPartNum
(self) → int¶ Part number of current geometry
New in version 2.16.
- Return type
int
-
mapUnitScale
(self) → QgsMapUnitScale¶ Deprecated since version Will: be removed in QGIS 4.0
- Return type
-
opacity
(self) → float¶ Returns the opacity for the symbol.
- Return type
float
- Returns
opacity value between 0 (fully transparent) and 1 (fully opaque)
See also
-
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).
See also
New in version 3.0.
- Return type
-
outputLineWidth
(self, width: float) → float¶ Deprecated since version Use: the size conversion methods in
QgsRenderContext
instead.- Parameters
width (float) –
- Return type
float
-
outputPixelSize
(self, size: float) → float¶ Deprecated since version Use: the size conversion methods in
QgsRenderContext
instead.- Parameters
size (float) –
- Return type
float
-
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
- Return type
-
patchShape
(self) → QgsLegendPatchShape¶ Returns the symbol patch shape, to use if rendering symbol preview icons.
See also
New in version 3.14.
- Return type
-
renderContext
(self) → QgsRenderContext¶ Returns a reference to the context’s render context.
- Return type
-
renderHints
(self) → QgsSymbol.RenderHints¶ Returns the rendering hint flags for the symbol.
See also
- Return type
-
selected
(self) → bool¶ Returns
True
if symbols should be rendered using the selected symbol coloring and style.See also
- Return type
bool
-
setExpressionContextScope
(self, contextScope: QgsExpressionContextScope)¶ Set an expression scope for this symbol.
Will take ownership.
- Parameters
contextScope (QgsExpressionContextScope) – An expression scope for details about this symbol
-
setFeature
(self, f: QgsFeature)¶ - Parameters
f (QgsFeature) –
-
setGeometryPartCount
(self, count: int)¶ Sets the part count of current geometry
New in version 2.16.
- Parameters
count (int) –
-
setGeometryPartNum
(self, num: int)¶ Sets the part number of current geometry
New in version 2.16.
- Parameters
num (int) –
-
setMapUnitScale
(self, scale: QgsMapUnitScale)¶ Deprecated since version Will: be removed in QGIS 4.0
- Parameters
scale (QgsMapUnitScale) –
-
setOpacity
(self, opacity: float)¶ Sets the
opacity
for the symbol.- Parameters
opacity (float) – opacity value between 0 (fully transparent) and 1 (fully opaque)
See also
-
setOriginalGeometryType
(self, type: QgsWkbTypes.GeometryType)¶ Sets the geometry type for the original feature geometry being rendered.
See also
New in version 3.0.
- Parameters
type (QgsWkbTypes.GeometryType) –
-
setOriginalValueVariable
(self, value: Any)¶ Sets the original value variable value for data defined symbology
- Parameters
value (Any) – 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
- Parameters
u (QgsUnitTypes.RenderUnit) –
-
setPatchShape
(self, shape: QgsLegendPatchShape)¶ Sets the symbol patch
shape
, to use if rendering symbol preview icons.See also
New in version 3.14.
- Parameters
shape (QgsLegendPatchShape) –
-
setRenderHints
(self, hints: Union[QgsSymbol.RenderHints, QgsSymbol.RenderHint])¶ Sets rendering hint flags for the symbol.
See also
- Parameters
hints (Union[QgsSymbol.RenderHints) –
-
setSelected
(self, selected: bool)¶ Sets whether symbols should be rendered using the selected symbol coloring and style.
See also
- Parameters
selected (bool) –