Class: QgsSymbolLayer¶
Abstract base class for symbol layers.
Note
This is an abstract class, with methods which must be implemented by a subclass.
The following methods must be implemented: clone()
, drawPreviewIcon()
, layerType()
, properties()
, startRender()
, stopRender()
Class Hierarchy¶
Subclasses¶
Abstract base class for line symbol layers. |
|
Abstract base class for marker symbol layers. |
|
Abstract base class for fill symbol layers. |
|
A symbol layer subclass which alters rendered feature shapes through the use of QGIS expressions. |
Enums
Data definable properties. |
Abstract Methods
Shall be reimplemented by subclasses to create a deep copy of the instance. |
|
Returns a string that represents this layer type. |
|
Should be reimplemented by subclasses to return a string map that contains the configuration information for the symbol layer. |
|
Called before a set of rendering operations commences on the supplied render context. |
|
Called after a set of rendering operations has finished on the supplied render context. |
Methods
Copies all data defined properties of this layer to another symbol layer. |
|
Copies paint effect of this layer to another symbol layer |
|
Returns a reference to the symbol layer's property collection, used for data defined overrides. |
|
Returns |
|
Returns symbol layer identifier This id is unique in the whole project |
|
When rendering, install masks on context painter. |
|
Returns |
|
Returns the current paint effect for the layer. |
|
Returns the symbol layer property definitions. |
|
When rendering, remove previously installed masks from context painter if recursive is |
|
Specifies the rendering pass in which this symbol layer should be rendered. |
|
Restores older data defined properties from string map. |
|
Sets the symbol layer's property collection, used for data defined overrides. |
|
Sets whether symbol layer is enabled and should be drawn. |
|
Set symbol layer identifier This id has to be unique in the whole project |
|
Sets whether the layer's colors are locked. |
|
Sets the current paint effect for the layer. |
|
Specifies the rendering pass in which this symbol layer should be rendered. |
|
Sets user-controlled flags which control the symbol layer's behavior. |
|
Returns |
|
Returns user-controlled flags which control the symbol layer's behavior. |
Virtual Methods
In PyQGIS, only methods marked as virtual
can be safely overridden in a Python subclass of QgsSymbolLayer. See the FAQ for more details.
Returns |
|
Returns the "representative" color of the symbol layer. |
|
Gets angle |
|
Gets brush/fill color |
|
Gets brush/fill style |
|
Gets color |
|
Gets dash pattern |
|
Gets offset |
|
Gets pen style |
|
Gets marker size |
|
Gets line width |
|
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when drawn in the specified /a context. |
|
Returns the fill color for the symbol layer. |
|
Returns flags which control the symbol layer's behavior. |
|
Returns |
|
Returns if the layer can be used below the specified symbol |
|
Returns masks defined by this symbol layer. |
|
Returns the units to use for sizes and widths within the symbol layer. |
|
Prepares all data defined property expressions for evaluation. |
|
Prepares all mask internal objects according to what is defined in context This should be called prior to calling |
|
Sets the "representative" color for the symbol layer. |
|
Sets a data defined property for the layer. |
|
Sets the fill color for the symbol layer. |
|
Sets the units to use for sizes and widths within the symbol layer. |
|
Sets the stroke color for the symbol layer. |
|
Sets layer's subsymbol. |
|
Called before the layer will be rendered for a particular feature. |
|
Called after the layer has been rendered for a particular feature. |
|
Returns the stroke color for the symbol layer. |
|
Returns the symbol's sub symbol, if present. |
|
Saves the symbol layer as SLD. |
|
Returns the set of attributes referenced by the layer. |
|
Returns |
|
write as DXF |
- class qgis.core.QgsSymbolLayer[source]¶
Bases:
object
- __init__(type: Qgis.SymbolType, locked: bool = False)
Constructor for QgsSymbolLayer.
- Parameters:
type (Qgis.SymbolType) – specifies the associated symbol type
locked (bool = False) – if
True
, then symbol layer colors will be locked and will ignore any symbol-level color changes.
- class Property(*values)¶
Bases:
IntEnum
Data definable properties.
Size
: Symbol sizeAvailable as
QgsSymbolLayer.PropertySize
in older QGIS releases.Angle
: Symbol angleAvailable as
QgsSymbolLayer.PropertyAngle
in older QGIS releases.Name
: Name, eg shape name for simple markersAvailable as
QgsSymbolLayer.PropertyName
in older QGIS releases.FillColor
: Fill colorAvailable as
QgsSymbolLayer.PropertyFillColor
in older QGIS releases.StrokeColor
: Stroke colorAvailable as
QgsSymbolLayer.PropertyStrokeColor
in older QGIS releases.StrokeWidth
: Stroke widthAvailable as
QgsSymbolLayer.PropertyStrokeWidth
in older QGIS releases.StrokeStyle
: Stroke style (eg solid, dashed)Available as
QgsSymbolLayer.PropertyStrokeStyle
in older QGIS releases.Offset
: Symbol offsetAvailable as
QgsSymbolLayer.PropertyOffset
in older QGIS releases.Character
: Character, eg for font marker symbol layersAvailable as
QgsSymbolLayer.PropertyCharacter
in older QGIS releases.Width
: Symbol widthAvailable as
QgsSymbolLayer.PropertyWidth
in older QGIS releases.Height
: Symbol heightAvailable as
QgsSymbolLayer.PropertyHeight
in older QGIS releases.PreserveAspectRatio
: Preserve aspect ratio between width and heightAvailable as
QgsSymbolLayer.PropertyPreserveAspectRatio
in older QGIS releases.FillStyle
: Fill style (eg solid, dots)Available as
QgsSymbolLayer.PropertyFillStyle
in older QGIS releases.JoinStyle
: Line join styleAvailable as
QgsSymbolLayer.PropertyJoinStyle
in older QGIS releases.SecondaryColor
: Secondary color (eg for gradient fills)Available as
QgsSymbolLayer.PropertySecondaryColor
in older QGIS releases.LineAngle
: Line angle, or angle of hash lines for hash line symbolsAvailable as
QgsSymbolLayer.PropertyLineAngle
in older QGIS releases.LineDistance
: Distance between lines, or length of lines for hash line symbolsAvailable as
QgsSymbolLayer.PropertyLineDistance
in older QGIS releases.GradientType
: Gradient fill typeAvailable as
QgsSymbolLayer.PropertyGradientType
in older QGIS releases.CoordinateMode
: Gradient coordinate modeAvailable as
QgsSymbolLayer.PropertyCoordinateMode
in older QGIS releases.GradientSpread
: Gradient spread modeAvailable as
QgsSymbolLayer.PropertyGradientSpread
in older QGIS releases.GradientReference1X
: Gradient reference point 1 xAvailable as
QgsSymbolLayer.PropertyGradientReference1X
in older QGIS releases.GradientReference1Y
: Gradient reference point 1 yAvailable as
QgsSymbolLayer.PropertyGradientReference1Y
in older QGIS releases.GradientReference2X
: Gradient reference point 2 xAvailable as
QgsSymbolLayer.PropertyGradientReference2X
in older QGIS releases.GradientReference2Y
: Gradient reference point 2 yAvailable as
QgsSymbolLayer.PropertyGradientReference2Y
in older QGIS releases.GradientReference1IsCentroid
: Gradient reference point 1 is centroidAvailable as
QgsSymbolLayer.PropertyGradientReference1IsCentroid
in older QGIS releases.GradientReference2IsCentroid
: Gradient reference point 2 is centroidAvailable as
QgsSymbolLayer.PropertyGradientReference2IsCentroid
in older QGIS releases.BlurRadius
: Shapeburst blur radiusAvailable as
QgsSymbolLayer.PropertyBlurRadius
in older QGIS releases.ShapeburstUseWholeShape
: Shapeburst use whole shapeAvailable as
QgsSymbolLayer.PropertyShapeburstUseWholeShape
in older QGIS releases.ShapeburstMaxDistance
: Shapeburst fill from edge distanceAvailable as
QgsSymbolLayer.PropertyShapeburstMaxDistance
in older QGIS releases.ShapeburstIgnoreRings
: Shapeburst ignore ringsAvailable as
QgsSymbolLayer.PropertyShapeburstIgnoreRings
in older QGIS releases.File
: Filename, eg for svg filesAvailable as
QgsSymbolLayer.PropertyFile
in older QGIS releases.DistanceX
: Horizontal distance between pointsAvailable as
QgsSymbolLayer.PropertyDistanceX
in older QGIS releases.DistanceY
: Vertical distance between pointsAvailable as
QgsSymbolLayer.PropertyDistanceY
in older QGIS releases.DisplacementX
: Horizontal displacementAvailable as
QgsSymbolLayer.PropertyDisplacementX
in older QGIS releases.DisplacementY
: Vertical displacementAvailable as
QgsSymbolLayer.PropertyDisplacementY
in older QGIS releases.Opacity
: OpacityAvailable as
QgsSymbolLayer.PropertyOpacity
in older QGIS releases.CustomDash
: Custom dash patternAvailable as
QgsSymbolLayer.PropertyCustomDash
in older QGIS releases.CapStyle
: Line cap styleAvailable as
QgsSymbolLayer.PropertyCapStyle
in older QGIS releases.Placement
: Line marker placementAvailable as
QgsSymbolLayer.PropertyPlacement
in older QGIS releases.Interval
: Line marker intervalAvailable as
QgsSymbolLayer.PropertyInterval
in older QGIS releases.OffsetAlongLine
: Offset along lineAvailable as
QgsSymbolLayer.PropertyOffsetAlongLine
in older QGIS releases.AverageAngleLength
: Length to average symbol angles overAvailable as
QgsSymbolLayer.PropertyAverageAngleLength
in older QGIS releases.HorizontalAnchor
: Horizontal anchor pointAvailable as
QgsSymbolLayer.PropertyHorizontalAnchor
in older QGIS releases.VerticalAnchor
: Vertical anchor pointAvailable as
QgsSymbolLayer.PropertyVerticalAnchor
in older QGIS releases.LayerEnabled
: Whether symbol layer is enabledAvailable as
QgsSymbolLayer.PropertyLayerEnabled
in older QGIS releases.ArrowWidth
: Arrow tail widthAvailable as
QgsSymbolLayer.PropertyArrowWidth
in older QGIS releases.ArrowStartWidth
: Arrow tail start widthAvailable as
QgsSymbolLayer.PropertyArrowStartWidth
in older QGIS releases.ArrowHeadLength
: Arrow head lengthAvailable as
QgsSymbolLayer.PropertyArrowHeadLength
in older QGIS releases.ArrowHeadThickness
: Arrow head thicknessAvailable as
QgsSymbolLayer.PropertyArrowHeadThickness
in older QGIS releases.ArrowHeadType
: Arrow head typeAvailable as
QgsSymbolLayer.PropertyArrowHeadType
in older QGIS releases.ArrowType
: Arrow typeAvailable as
QgsSymbolLayer.PropertyArrowType
in older QGIS releases.OffsetX
: Horizontal offsetAvailable as
QgsSymbolLayer.PropertyOffsetX
in older QGIS releases.OffsetY
: Vertical offsetAvailable as
QgsSymbolLayer.PropertyOffsetY
in older QGIS releases.PointCount
: Point countAvailable as
QgsSymbolLayer.PropertyPointCount
in older QGIS releases.RandomSeed
: Random number seedAvailable as
QgsSymbolLayer.PropertyRandomSeed
in older QGIS releases.ClipPoints
: Whether markers should be clipped to polygon boundariesAvailable as
QgsSymbolLayer.PropertyClipPoints
in older QGIS releases.DensityArea
: Density areaAvailable as
QgsSymbolLayer.PropertyDensityArea
in older QGIS releases.FontFamily
: Font familyAvailable as
QgsSymbolLayer.PropertyFontFamily
in older QGIS releases.FontStyle
: Font styleAvailable as
QgsSymbolLayer.PropertyFontStyle
in older QGIS releases.DashPatternOffset
: Dash pattern offset,Available as
QgsSymbolLayer.PropertyDashPatternOffset
in older QGIS releases.TrimStart
: Trim distance from start of lineAdded in version 3.20.
Available as
QgsSymbolLayer.PropertyTrimStart
in older QGIS releases.TrimEnd
: Trim distance from end of lineAdded in version 3.20.
Available as
QgsSymbolLayer.PropertyTrimEnd
in older QGIS releases.LineStartWidthValue
: Start line width for interpolated line rendererAdded in version 3.22.
Available as
QgsSymbolLayer.PropertyLineStartWidthValue
in older QGIS releases.LineEndWidthValue
: End line width for interpolated line rendererAdded in version 3.22.
Available as
QgsSymbolLayer.PropertyLineEndWidthValue
in older QGIS releases.LineStartColorValue
: Start line color for interpolated line rendererAdded in version 3.22.
Available as
QgsSymbolLayer.PropertyLineStartColorValue
in older QGIS releases.LineEndColorValue
: End line color for interpolated line rendererAdded in version 3.22.
Available as
QgsSymbolLayer.PropertyLineEndColorValue
in older QGIS releases.MarkerClipping
: Marker clipping modeAdded in version 3.24.
Available as
QgsSymbolLayer.PropertyMarkerClipping
in older QGIS releases.RandomOffsetX
: Random offset XAdded in version 3.24.
Available as
QgsSymbolLayer.PropertyRandomOffsetX
in older QGIS releases.RandomOffsetY
: Random offset YAdded in version 3.24.
Available as
QgsSymbolLayer.PropertyRandomOffsetY
in older QGIS releases.LineClipping
: Line clipping modeAdded in version 3.24.
Available as
QgsSymbolLayer.PropertyLineClipping
in older QGIS releases.SkipMultiples
: Skip multiples ofAdded in version 3.40.
ShowMarker
: Show markersAdded in version 3.40.
- virtual canCauseArtifactsBetweenAdjacentTiles(self) bool [source]¶
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.The default implementation returns
False
.Added in version 3.18.
- Return type:
bool
- abstract clone(self) QgsSymbolLayer | None [source]¶
Shall be reimplemented by subclasses to create a deep copy of the instance.
- Return type:
Optional[QgsSymbolLayer]
- virtual color(self) QColor [source]¶
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
See also
See also
- Return type:
QColor
- copyDataDefinedProperties(self, destLayer: QgsSymbolLayer | None)[source]¶
Copies all data defined properties of this layer to another symbol layer.
- Parameters:
destLayer (Optional[QgsSymbolLayer]) – destination layer
- copyPaintEffect(self, destLayer: QgsSymbolLayer | None)[source]¶
Copies paint effect of this layer to another symbol layer
- Parameters:
destLayer (Optional[QgsSymbolLayer]) – destination layer
- dataDefinedProperties(self) QgsPropertyCollection ¶
Returns a reference to the symbol layer’s property collection, used for data defined overrides.
See also
See also
Property
- Return type:
- abstract drawPreviewIcon(self, context: QgsSymbolRenderContext, size: QSize)[source]¶
- Parameters:
context (QgsSymbolRenderContext)
size (QSize)
- virtual dxfAngle(self, context: QgsSymbolRenderContext) float [source]¶
Gets angle
- Parameters:
context (QgsSymbolRenderContext)
- Return type:
float
- virtual dxfBrushColor(self, context: QgsSymbolRenderContext) QColor [source]¶
Gets brush/fill color
- Parameters:
context (QgsSymbolRenderContext)
- Return type:
QColor
- virtual dxfBrushStyle(self) Qt.BrushStyle [source]¶
Gets brush/fill style
- Return type:
Qt.BrushStyle
- virtual dxfColor(self, context: QgsSymbolRenderContext) QColor [source]¶
Gets color
- Parameters:
context (QgsSymbolRenderContext)
- Return type:
QColor
- virtual dxfCustomDashPattern(self)¶
Gets dash pattern
- virtual dxfOffset(self, e: QgsDxfExport, context: QgsSymbolRenderContext) float [source]¶
Gets offset
- Parameters:
e (QgsDxfExport)
context (QgsSymbolRenderContext)
- Return type:
float
- virtual dxfSize(self, e: QgsDxfExport, context: QgsSymbolRenderContext) float [source]¶
Gets marker size
- Parameters:
e (QgsDxfExport)
context (QgsSymbolRenderContext)
- Return type:
float
- virtual dxfWidth(self, e: QgsDxfExport, context: QgsSymbolRenderContext) float [source]¶
Gets line width
- Parameters:
e (QgsDxfExport)
context (QgsSymbolRenderContext)
- Return type:
float
- enabled(self) bool [source]¶
Returns
True
if symbol layer is enabled and will be drawn.See also
- Return type:
bool
- virtual estimateMaxBleed(self, context: QgsRenderContext) float [source]¶
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when drawn in the specified /a context. For example, polygons drawn with an stroke will draw half the width of the stroke outside of the polygon. This amount is estimated, since it may be affected by data defined symbology rules.
- Parameters:
context (QgsRenderContext)
- Return type:
float
- virtual fillColor(self) QColor [source]¶
Returns the fill color for the symbol layer.
This property is not supported by all symbol layer types, only those with a fill component. Symbol layers without a fill component will return an invalid QColor.
See also
See also
See also
- Return type:
QColor
- virtual flags(self) Qgis.SymbolLayerFlags [source]¶
Returns flags which control the symbol layer’s behavior.
Added in version 3.22.
- Return type:
- virtual hasDataDefinedProperties(self) bool [source]¶
Returns
True
if the symbol layer (or any of its sub-symbols) contains data defined properties.Added in version 3.4.5.
- Return type:
bool
- id(self) str [source]¶
Returns symbol layer identifier This id is unique in the whole project
Added in version 3.30.
- Return type:
str
- installMasks(self, context: QgsRenderContext, recursive: bool, rect: QRectF = QRectF()) bool [source]¶
When rendering, install masks on
context
painter.If
recursive
isTrue
masks are installed recursively for all children symbol layers.Since QGIS 3.38 the
rect
argument can be used to specify a target bounds (in painter coordinates) for mask geometries. Only mask geometries which intersectrect
will be installed.- Return type:
bool
- Returns:
True
if any masks were installed (since QGIS 3.38)
See also
See also
Added in version 3.30.
- Parameters:
context (QgsRenderContext)
recursive (bool)
rect (QRectF = QRectF())
- virtual isCompatibleWithSymbol(self, symbol: QgsSymbol | None) bool [source]¶
Returns if the layer can be used below the specified symbol
- Parameters:
symbol (Optional[QgsSymbol])
- Return type:
bool
- isLocked(self) bool [source]¶
Returns
True
if the symbol layer colors are locked and the layer will ignore any symbol-level color changes.See also
- Return type:
bool
- abstract layerType(self) str [source]¶
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.
- Return type:
str
- virtual mapUnitScale(self) QgsMapUnitScale [source]¶
- Return type:
- virtual masks(self) List[QgsSymbolLayerReference] ¶
Returns masks defined by this symbol layer. This is a list of symbol layers of other layers that should be occluded.
Added in version 3.12.
- Return type:
List[QgsSymbolLayerReference]
- virtual ogrFeatureStyle(self, mmScaleFactor: float, mapUnitScaleFactor: float) str [source]¶
- Parameters:
mmScaleFactor (float)
mapUnitScaleFactor (float)
- Return type:
str
- virtual outputUnit(self) Qgis.RenderUnit [source]¶
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.
- Return type:
- Returns:
output unit, or
QgsUnitTypes
.RenderUnknownUnit if the symbol layer contains mixed units
See also
- paintEffect(self) QgsPaintEffect | None [source]¶
Returns the current paint effect for the layer.
- Return type:
Optional[QgsPaintEffect]
- Returns:
paint effect
See also
- virtual prepareExpressions(self, context: QgsSymbolRenderContext)[source]¶
Prepares all data defined property expressions for evaluation. This should be called prior to evaluating data defined properties.
- Parameters:
context (QgsSymbolRenderContext) – symbol render context
- virtual prepareMasks(self, context: QgsSymbolRenderContext)[source]¶
Prepares all mask internal objects according to what is defined in
context
This should be called prior to callingstartRender()
method.Added in version 3.26.
- Parameters:
context (QgsSymbolRenderContext)
- abstract properties(self) Dict[str, Any] [source]¶
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.
- Return type:
Dict[str, Any]
- propertyDefinitions() Dict[int, QgsPropertyDefinition] ¶
Returns the symbol layer property definitions.
- Return type:
Dict[int, QgsPropertyDefinition]
- removeMasks(self, context: QgsRenderContext, recursive: bool)[source]¶
When rendering, remove previously installed masks from
context
painter ifrecursive
isTrue
masks are removed recursively for all children symbol layersSee also
See also
Added in version 3.30.
- Parameters:
context (QgsRenderContext)
recursive (bool)
- renderingPass(self) int [source]¶
Specifies the rendering pass in which this symbol layer should be rendered. The lower the number, the lower the symbol will be rendered. 0: first pass, 1: second pass, … Defaults to 0
- Return type:
int
- restoreOldDataDefinedProperties(self, stringMap: Dict[str, Any])[source]¶
Restores older data defined properties from string map.
- Parameters:
stringMap (Dict[str, Any])
- virtual setColor(self, color: QColor | Qt.GlobalColor)[source]¶
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
See also
See also
- Parameters:
color (Union[QColor, Qt.GlobalColor])
- setDataDefinedProperties(self, collection: QgsPropertyCollection)[source]¶
Sets the symbol layer’s property collection, used for data defined overrides.
- Parameters:
collection (QgsPropertyCollection) – property collection. Existing properties will be replaced.
See also
- virtual setDataDefinedProperty(self, key: QgsSymbolLayer.Property, property: QgsProperty)[source]¶
Sets a data defined property for the layer. Any existing property with the same key will be overwritten.
See also
See also
Property
- Parameters:
key (QgsSymbolLayer.Property)
property (QgsProperty)
- setEnabled(self, enabled: bool)[source]¶
Sets whether symbol layer is enabled and should be drawn. Disabled layers are not drawn, but remain part of the symbol and can be re-enabled when desired.
See also
- Parameters:
enabled (bool)
- virtual setFillColor(self, color: QColor | Qt.GlobalColor)[source]¶
Sets the fill
color
for the symbol layer.This property is not supported by all symbol layer types, only those with a fill component.
See also
See also
See also
- Parameters:
color (Union[QColor, Qt.GlobalColor])
- setId(self, id: str | None)[source]¶
Set symbol layer identifier This id has to be unique in the whole project
Added in version 3.30.
- Parameters:
id (Optional[str])
- setLocked(self, locked: bool)[source]¶
Sets whether the layer’s colors are locked.
If
locked
isTrue
then the symbol layer colors are locked and the layer will ignore any symbol-level color changes.See also
- Parameters:
locked (bool)
- virtual setMapUnitScale(self, scale: QgsMapUnitScale)[source]¶
- Parameters:
scale (QgsMapUnitScale)
- virtual setOutputUnit(self, unit: Qgis.RenderUnit)[source]¶
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:
unit (Qgis.RenderUnit) – output units
See also
- setPaintEffect(self, effect: QgsPaintEffect | None)[source]¶
Sets the current paint effect for the layer.
- Parameters:
effect (Optional[QgsPaintEffect]) – paint effect. Ownership is transferred to the layer.
See also
- setRenderingPass(self, renderingPass: int)[source]¶
Specifies the rendering pass in which this symbol layer should be rendered. The lower the number, the lower the symbol will be rendered. 0: first pass, 1: second pass, … Defaults to 0
- Parameters:
renderingPass (int)
- virtual setStrokeColor(self, color: QColor | Qt.GlobalColor)[source]¶
Sets the stroke
color
for the symbol layer.This property is not supported by all symbol layer types, only those with a stroke component.
See also
See also
See also
- Parameters:
color (Union[QColor, Qt.GlobalColor])
- virtual setSubSymbol(self, symbol: QgsSymbol | None) bool [source]¶
Sets layer’s subsymbol. takes ownership of the passed symbol
- Parameters:
symbol (Optional[QgsSymbol])
- Return type:
bool
- setUserFlags(self, flags: Qgis.SymbolLayerUserFlags | Qgis.SymbolLayerUserFlag)[source]¶
Sets user-controlled
flags
which control the symbol layer’s behavior.See also
Added in version 3.34.
- Parameters:
flags (Union[Qgis.SymbolLayerUserFlags, Qgis.SymbolLayerUserFlag])
- shouldRenderUsingSelectionColor(self, context: QgsSymbolRenderContext) bool [source]¶
Returns
True
if the symbol layer should be rendered using the selection color from the render context.Added in version 3.34.
- Parameters:
context (QgsSymbolRenderContext)
- Return type:
bool
- virtual startFeatureRender(self, feature: QgsFeature, context: QgsRenderContext)[source]¶
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()
andstopFeatureRender()
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
See also
Added in version 3.12.
- Parameters:
feature (QgsFeature)
context (QgsRenderContext)
- abstract startRender(self, context: QgsSymbolRenderContext)[source]¶
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
See also
- Parameters:
context (QgsSymbolRenderContext)
- virtual stopFeatureRender(self, feature: QgsFeature, context: QgsRenderContext)[source]¶
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()
andstopFeatureRender()
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
See also
Added in version 3.12.
- Parameters:
feature (QgsFeature)
context (QgsRenderContext)
- abstract stopRender(self, context: QgsSymbolRenderContext)[source]¶
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
See also
- Parameters:
context (QgsSymbolRenderContext)
- virtual strokeColor(self) QColor [source]¶
Returns the stroke color for the symbol layer.
This property is not supported by all symbol layer types, only those with a stroke component. Symbol layers without a stroke component will return an invalid QColor.
See also
See also
See also
- Return type:
QColor
- virtual subSymbol(self) QgsSymbol | None [source]¶
Returns the symbol’s sub symbol, if present.
- Return type:
Optional[QgsSymbol]
- virtual toSld(self, doc: QDomDocument, element: QDomElement, props: Dict[str, Any])[source]¶
Saves the symbol layer as SLD.
Deprecated since version 3.44: Use the version with
QgsSldExportContext
instead.- Parameters:
doc (QDomDocument)
element (QDomElement)
props (Dict[str, Any])
- virtual toSld(self, doc: QDomDocument, element: QDomElement, context: QgsSldExportContext) bool [source]
Saves the symbol layer as SLD.
Returns
True
if the symbol layer was successfully exported to SLD.Added in version 3.44.
- Parameters:
doc (QDomDocument)
element (QDomElement)
context (
QgsSldExportContext
)
- Return type:
bool
- type(self) Qgis.SymbolType [source]¶
- Return type:
- virtual usedAttributes(self, context: QgsRenderContext) Set[str] ¶
Returns the set of attributes referenced by the layer. This includes attributes required by any data defined properties associated with the layer.
- Parameters:
context (QgsRenderContext)
- Return type:
Set[str]
- userFlags(self) Qgis.SymbolLayerUserFlags [source]¶
Returns user-controlled flags which control the symbol layer’s behavior.
See also
Added in version 3.34.
- Return type:
- virtual usesMapUnits(self) bool [source]¶
Returns
True
if the symbol layer has any components which use map unit based sizes.Added in version 3.18.
- Return type:
bool
- virtual writeDxf(self, e: QgsDxfExport, mmMapUnitScaleFactor: float, layerName: str | None, context: QgsSymbolRenderContext, shift: QPointF | QPoint = QPointF(0, 0)) bool [source]¶
write as DXF
- Parameters:
e (QgsDxfExport)
mmMapUnitScaleFactor (float)
layerName (Optional[str])
context (QgsSymbolRenderContext)
shift (Union[QPointF, QPoint] = QPointF(0, 0))
- Return type:
bool