Class: QgsSymbolLayer¶
- class qgis.core.QgsSymbolLayer(type: QgsSymbol.SymbolType, locked: bool = False)¶
Bases:
sip.wrapper
Methods
Shall be reimplemented by subclasses to create a deep copy of the instance.
The fill color.
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.
- param context
Gets angle
Gets brush/fill color
Gets brush/fill style
Gets color
Gets dash pattern
Gets offset
Gets pen style
Gets line width
Returns
True
if symbol layer is enabled and will be drawn.Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when drawn in the specified /a context.
Gets fill color.
Returns
True
if the symbol layer (or any of its sub-symbols) contains data defined properties.Returns if the layer can be used below the specified symbol
- rtype
bool
Returns a string that represents this layer type.
- rtype
QgsMapUnitScale
Returns masks defined by this symbol layer.
- param mmScaleFactor
Returns the units to use for sizes and widths within the symbol layer.
Returns the current paint effect for the layer.
Prepares all data defined property expressions for evaluation.
Should be reimplemented by subclasses to return a string map that contains the configuration information for the symbol layer.
Returns the symbol layer property definitions.
Specifies the rendering pass in which this symbol layer should be rendered.
Restores older data defined properties from string map.
The fill color.
Sets the symbol layer's property collection, used for data defined overrides.
Sets a data defined property for the layer.
Sets whether symbol layer is enabled and should be drawn.
Set fill color.
- param locked
- param scale
Sets the units to use for sizes and widths within the symbol layer.
Sets the current paint effect for the layer.
Specifies the rendering pass in which this symbol layer should be rendered.
Set stroke color.
Sets layer's subsymbol.
Called before the layer will be rendered for a particular
feature
.Called before a set of rendering operations commences on the supplied render
context
.Called after the layer has been rendered for a particular
feature
.Called after a set of rendering operations has finished on the supplied render
context
.Gets stroke color.
Returns the symbol's sub symbol, if present.
- param doc
- rtype
QgsSymbol.SymbolType
Returns the set of attributes referenced by the layer.
Returns
True
if the symbol layer has any components which use map unit based sizes.write as DXF
Attributes
- class Property¶
Bases:
int
- PropertyAngle = 1¶
- PropertyArrowHeadLength = 47¶
- PropertyArrowHeadThickness = 48¶
- PropertyArrowHeadType = 49¶
- PropertyArrowStartWidth = 46¶
- PropertyArrowType = 50¶
- PropertyArrowWidth = 45¶
- PropertyAverageAngleLength = 41¶
- PropertyBlurRadius = 26¶
- PropertyCapStyle = 37¶
- PropertyCharacter = 8¶
- PropertyClipPoints = 55¶
- PropertyCoordinateMode = 18¶
- PropertyCustomDash = 36¶
- PropertyDashPatternOffset = 59¶
- PropertyDensityArea = 56¶
- PropertyDisplacementX = 33¶
- PropertyDisplacementY = 34¶
- PropertyDistanceX = 31¶
- PropertyDistanceY = 32¶
- PropertyFile = 30¶
- PropertyFillColor = 3¶
- PropertyFillStyle = 12¶
- PropertyFontFamily = 57¶
- PropertyFontStyle = 58¶
- PropertyGradientReference1IsCentroid = 24¶
- PropertyGradientReference1X = 20¶
- PropertyGradientReference1Y = 21¶
- PropertyGradientReference2IsCentroid = 25¶
- PropertyGradientReference2X = 22¶
- PropertyGradientReference2Y = 23¶
- PropertyGradientSpread = 19¶
- PropertyGradientType = 17¶
- PropertyHeight = 10¶
- PropertyHorizontalAnchor = 42¶
- PropertyInterval = 39¶
- PropertyJoinStyle = 13¶
- PropertyLayerEnabled = 44¶
- PropertyLineAngle = 15¶
- PropertyLineDistance = 16¶
- PropertyName = 2¶
- PropertyOffset = 7¶
- PropertyOffsetAlongLine = 40¶
- PropertyOffsetX = 51¶
- PropertyOffsetY = 52¶
- PropertyOpacity = 35¶
- PropertyPlacement = 38¶
- PropertyPointCount = 53¶
- PropertyPreserveAspectRatio = 11¶
- PropertyRandomSeed = 54¶
- PropertySecondaryColor = 14¶
- PropertyShapeburstIgnoreRings = 29¶
- PropertyShapeburstMaxDistance = 28¶
- PropertyShapeburstUseWholeShape = 27¶
- PropertySize = 0¶
- PropertyStrokeColor = 4¶
- PropertyStrokeStyle = 6¶
- PropertyStrokeWidth = 5¶
- PropertyVerticalAnchor = 43¶
- PropertyWidth = 9¶
- clone(self) QgsSymbolLayer ¶
Shall be reimplemented by subclasses to create a deep copy of the instance.
- Return type
- color(self) QColor ¶
The fill color.
- Return type
QColor
- copyDataDefinedProperties(self, destLayer: QgsSymbolLayer)¶
Copies all data defined properties of this layer to another symbol layer.
- Parameters
destLayer (QgsSymbolLayer) – destination layer
- copyPaintEffect(self, destLayer: QgsSymbolLayer)¶
Copies paint effect of this layer to another symbol layer
- Parameters
destLayer (QgsSymbolLayer) – destination layer
New in version 2.9.
- dataDefinedProperties(self) QgsPropertyCollection ¶
Returns a reference to the symbol layer’s property collection, used for data defined overrides.
See also
See also
Property
New in version 3.0.
- Return type
- drawPreviewIcon(self, context: QgsSymbolRenderContext, size: QSize)¶
- Parameters
context (QgsSymbolRenderContext) –
size (QSize) –
- dxfAngle(self, context: QgsSymbolRenderContext) float ¶
Gets angle
- Parameters
context (QgsSymbolRenderContext) –
- Return type
float
- dxfBrushColor(self, context: QgsSymbolRenderContext) QColor ¶
Gets brush/fill color
- Parameters
context (QgsSymbolRenderContext) –
- Return type
QColor
- dxfBrushStyle(self) Qt.BrushStyle ¶
Gets brush/fill style
- Return type
Qt.BrushStyle
- dxfColor(self, context: QgsSymbolRenderContext) QColor ¶
Gets color
- Parameters
context (QgsSymbolRenderContext) –
- Return type
QColor
- dxfCustomDashPattern(self) Tuple[List[float], QgsUnitTypes.RenderUnit] ¶
Gets dash pattern
- Return type
Tuple[List[float], QgsUnitTypes.RenderUnit]
- dxfOffset(self, e: QgsDxfExport, context: QgsSymbolRenderContext) float ¶
Gets offset
- Parameters
e (QgsDxfExport) –
context (QgsSymbolRenderContext) –
- Return type
float
- dxfPenStyle(self) Qt.PenStyle ¶
Gets pen style
- Return type
Qt.PenStyle
- dxfWidth(self, e: QgsDxfExport, context: QgsSymbolRenderContext) float ¶
Gets line width
- Parameters
e (QgsDxfExport) –
context (QgsSymbolRenderContext) –
- Return type
float
- enabled(self) bool ¶
Returns
True
if symbol layer is enabled and will be drawn.See also
New in version 3.0.
- Return type
bool
- estimateMaxBleed(self, context: QgsRenderContext) float ¶
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
- fillColor(self) QColor ¶
Gets fill color. Supported by marker and fill layers.
New in version 2.1.
- Return type
QColor
- hasDataDefinedProperties(self) bool ¶
Returns
True
if the symbol layer (or any of its sub-symbols) contains data defined properties.New in version 3.4.5.
- Return type
bool
- isCompatibleWithSymbol(self, symbol: QgsSymbol) bool ¶
Returns if the layer can be used below the specified symbol
- Parameters
symbol (QgsSymbol) –
- Return type
bool
- isLocked(self) bool ¶
- Return type
bool
- layerType(self) str ¶
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
- mapUnitScale(self) QgsMapUnitScale ¶
- Return type
- 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.
New in version 3.12.
- Return type
List[QgsSymbolLayerReference]
- ogrFeatureStyle(self, mmScaleFactor: float, mapUnitScaleFactor: float) str ¶
- Parameters
mmScaleFactor (float) –
mapUnitScaleFactor (float) –
- Return type
str
- outputUnit(self) QgsUnitTypes.RenderUnit ¶
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 ¶
Returns the current paint effect for the layer.
- Return type
- Returns
paint effect
See also
New in version 2.9.
- prepareExpressions(self, context: QgsSymbolRenderContext)¶
Prepares all data defined property expressions for evaluation. This should be called prior to evaluating data defined properties.
- Parameters
context (QgsSymbolRenderContext) – symbol render context
New in version 2.12.
- properties(self) Dict[str, str] ¶
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, str]
- propertyDefinitions() Dict[int, QgsPropertyDefinition] ¶
Returns the symbol layer property definitions.
New in version 3.0.
- Return type
Dict[int, QgsPropertyDefinition]
- renderingPass(self) int ¶
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, str])¶
Restores older data defined properties from string map.
New in version 3.0.
- Parameters
stringMap (Dict[str) –
- setColor(self, color: Union[QColor, Qt.GlobalColor])¶
The fill color.
- Parameters
color (Union[QColor) –
- setDataDefinedProperties(self, collection: QgsPropertyCollection)¶
Sets the symbol layer’s property collection, used for data defined overrides.
- Parameters
collection (QgsPropertyCollection) – property collection. Existing properties will be replaced.
See also
New in version 3.0.
- setDataDefinedProperty(self, key: QgsSymbolLayer.Property, property: QgsProperty)¶
Sets a data defined property for the layer. Any existing property with the same key will be overwritten.
See also
See also
Property
New in version 3.0.
- Parameters
key (QgsSymbolLayer.Property) –
property (QgsProperty) –
- setEnabled(self, enabled: bool)¶
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
New in version 3.0.
- Parameters
enabled (bool) –
- setFillColor(self, color: Union[QColor, Qt.GlobalColor])¶
Set fill color. Supported by marker and fill layers.
New in version 2.1.
- Parameters
color (Union[QColor) –
- setLocked(self, locked: bool)¶
- Parameters
locked (bool) –
- setMapUnitScale(self, scale: QgsMapUnitScale)¶
- Parameters
scale (QgsMapUnitScale) –
- setOutputUnit(self, unit: QgsUnitTypes.RenderUnit)¶
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 (QgsUnitTypes.RenderUnit) – output units
See also
- setPaintEffect(self, effect: QgsPaintEffect)¶
Sets the current paint effect for the layer.
- Parameters
effect (QgsPaintEffect) – paint effect. Ownership is transferred to the layer.
See also
New in version 2.9.
- setRenderingPass(self, renderingPass: int)¶
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) –
- setStrokeColor(self, color: Union[QColor, Qt.GlobalColor])¶
Set stroke color. Supported by marker and fill layers.
New in version 2.1.
- Parameters
color (Union[QColor) –
- setSubSymbol(self, symbol: QgsSymbol) bool ¶
Sets layer’s subsymbol. takes ownership of the passed symbol
- Parameters
symbol (QgsSymbol) –
- Return type
bool
- startFeatureRender(self, feature: QgsFeature, context: QgsRenderContext)¶
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
New in version 3.12.
- Parameters
feature (QgsFeature) –
context (QgsRenderContext) –
- startRender(self, context: QgsSymbolRenderContext)¶
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) –
- stopFeatureRender(self, feature: QgsFeature, context: QgsRenderContext)¶
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
New in version 3.12.
- Parameters
feature (QgsFeature) –
context (QgsRenderContext) –
- stopRender(self, context: QgsSymbolRenderContext)¶
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) –
- strokeColor(self) QColor ¶
Gets stroke color. Supported by marker and fill layers.
New in version 2.1.
- Return type
QColor
- toSld(self, doc: QDomDocument, element: QDomElement, props: Dict[str, str])¶
- Parameters
doc (QDomDocument) –
element (QDomElement) –
props (Dict[str) –
- type(self) QgsSymbol.SymbolType ¶
- Return type
- 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]
- usesMapUnits(self) bool ¶
Returns
True
if the symbol layer has any components which use map unit based sizes.New in version 3.18.
- Return type
bool
- writeDxf(self, e: QgsDxfExport, mmMapUnitScaleFactor: float, layerName: str, context: QgsSymbolRenderContext, shift: Union[QPointF, QPoint] = QPointF(0, 0)) bool ¶
write as DXF
- Parameters
e (QgsDxfExport) –
mmMapUnitScaleFactor (float) –
layerName (str) –
context (QgsSymbolRenderContext) –
shift (Union[QPointF) –
- Return type
bool