Class: QgsSimpleLineSymbolLayer

class qgis.core.QgsSimpleLineSymbolLayer

Bases: QgsLineSymbolLayer

A simple line symbol layer, which renders lines using a line in a variety of styles (e.g. solid, dotted, dashed).

QgsSimpleLineSymbolLayer(color: Union[QColor, Qt.GlobalColor, QGradient] = DEFAULT_SIMPLELINE_COLOR, width: float = DEFAULT_SIMPLELINE_WIDTH, penStyle: Qt.PenStyle = DEFAULT_SIMPLELINE_PENSTYLE) Constructor for QgsSimpleLineSymbolLayer. Creates a simple line symbol in the specified color, width (in millimeters) and penStyle.

Methods

alignDashPattern

Returns True if dash patterns should be aligned to the start and end of lines, by applying subtle tweaks to the pattern sizing in order to ensure that the end of a line is represented by a complete dash element.

canCauseArtifactsBetweenAdjacentTiles

rtype:

bool

clone

rtype:

QgsSimpleLineSymbolLayer

copyDataDefinedProperties

Copies all data defined properties of this layer to another symbol layer.

copyPaintEffect

Copies paint effect of this layer to another symbol layer

create

Creates a new QgsSimpleLineSymbolLayer, using the settings serialized in the properties map (corresponding to the output from QgsSimpleLineSymbolLayer.properties() ).

createFromSld

Creates a new QgsSimpleLineSymbolLayer from an SLD XML DOM element.

customDashPatternMapUnitScale

Returns the map unit scale for lengths used in the custom dash pattern.

customDashPatternUnit

Returns the units for lengths used in the custom dash pattern.

customDashVector

Returns the custom dash vector, which is the pattern of alternating drawn/skipped lengths used while rendering a custom dash pattern.

dashPatternOffset

Returns the dash pattern offset, which dictates how far along the dash pattern the pattern should start rendering at.

dashPatternOffsetMapUnitScale

Returns the map unit scale for the dash pattern offset value.

dashPatternOffsetUnit

Returns the units for the dash pattern offset.

drawInsidePolygon

Returns True if the line should only be drawn inside polygons, and any portion of the line which falls outside the polygon should be clipped away.

dxfColor

param context:

dxfCustomDashPattern

rtype:

Tuple[List[float], Qgis.RenderUnit]

dxfOffset

param e:

dxfPenStyle

rtype:

Qt.PenStyle

dxfWidth

param e:

estimateMaxBleed

param context:

installMasks

When rendering, install masks on context painter if recursive is True masks are installed recursively for all children symbol layers

layerType

rtype:

str

mapUnitScale

rtype:

QgsMapUnitScale

ogrFeatureStyle

param mmScaleFactor:

outputUnit

rtype:

Qgis.RenderUnit

penCapStyle

Returns the pen cap style used to render the line (e.g. flat, square, round, etc).

penJoinStyle

Returns the pen join style used to render the line (e.g. miter, bevel, round, etc).

penStyle

Returns the pen style used to render the line (e.g. solid, dashed, etc).

properties

rtype:

Dict[str, Any]

removeMasks

When rendering, remove previously installed masks from context painter if recursive is True masks are removed recursively for all children symbol layers

renderPolygonStroke

param points:

renderPolyline

param points:

restoreOldDataDefinedProperties

Restores older data defined properties from string map.

setAlignDashPattern

Sets whether dash patterns should be aligned to the start and end of lines, by applying subtle tweaks to the pattern sizing in order to ensure that the end of a line is represented by a complete dash element.

setCustomDashPatternMapUnitScale

Sets the map unit scale for lengths used in the custom dash pattern.

setCustomDashPatternUnit

Sets the unit for lengths used in the custom dash pattern.

setCustomDashVector

Sets the custom dash vector, which is the pattern of alternating drawn/skipped lengths used while rendering a custom dash pattern.

setDashPatternOffset

Sets the dash pattern offset, which dictates how far along the dash pattern the pattern should start rendering at.

setDashPatternOffsetMapUnitScale

Sets the map unit scale for the dash pattern offset.

setDashPatternOffsetUnit

Sets the unit for the dash pattern offset.

setDrawInsidePolygon

Sets whether the line should only be drawn inside polygons, and any portion of the line which falls outside the polygon should be clipped away.

setMapUnitScale

param scale:

setOutputUnit

param unit:

setPenCapStyle

Sets the pen cap style used to render the line (e.g. flat, square, round, etc).

setPenJoinStyle

Sets the pen join style used to render the line (e.g. miter, bevel, round, etc).

setPenStyle

Sets the pen style used to render the line (e.g. solid, dashed, etc).

setTrimDistanceEnd

Sets the trim distance for the end of the line, which dictates a length from the end of the line at which the actual rendering should end.

setTrimDistanceEndMapUnitScale

Sets the map unit scale for the trim distance for the end of the line.

setTrimDistanceEndUnit

Sets the unit for the trim distance for the end of the line.

setTrimDistanceStart

Sets the trim distance for the start of the line, which dictates a length from the start of the line at which the actual rendering should start.

setTrimDistanceStartMapUnitScale

Sets the map unit scale for the trim distance for the start of the line.

setTrimDistanceStartUnit

Sets the unit for the trim distance for the start of the line.

setTweakDashPatternOnCorners

Sets whether dash patterns tweaks should be applied on sharp corners, to ensure that a double-length dash is drawn running into and out of the corner.

setUseCustomDashPattern

Sets whether the line uses a custom dash pattern.

shouldRenderUsingSelectionColor

Returns True if the symbol layer should be rendered using the selection color from the render context.

startRender

param context:

stopRender

param context:

toSld

param doc:

trimDistanceEnd

Returns the trim distance for the end of the line, which dictates a length from the end of the line at which the actual rendering should end.

trimDistanceEndMapUnitScale

Returns the map unit scale for the trim distance for the end of the line.

trimDistanceEndUnit

Returns the unit for the trim distance for the end of the line.

trimDistanceStart

Returns the trim distance for the start of the line, which dictates a length from the start of the line at which the actual rendering should start.

trimDistanceStartMapUnitScale

Returns the map unit scale for the trim distance for the start of the line.

trimDistanceStartUnit

Returns the unit for the trim distance for the start of the line.

tweakDashPatternOnCorners

Returns True if dash patterns tweaks should be applied on sharp corners, to ensure that a double-length dash is drawn running into and out of the corner.

useCustomDashPattern

Returns True if the line uses a custom dash pattern.

usesMapUnits

rtype:

bool

alignDashPattern(self) bool

Returns True if dash patterns should be aligned to the start and end of lines, by applying subtle tweaks to the pattern sizing in order to ensure that the end of a line is represented by a complete dash element.

New in version 3.16.

Return type:

bool

canCauseArtifactsBetweenAdjacentTiles(self) bool
Return type:

bool

clone(self) QgsSimpleLineSymbolLayer
Return type:

QgsSimpleLineSymbolLayer

copyDataDefinedProperties(self, destLayer: QgsSymbolLayer)

Copies all data defined properties of this layer to another symbol layer.

Parameters:

destLayer – destination layer

copyPaintEffect(self, destLayer: QgsSymbolLayer)

Copies paint effect of this layer to another symbol layer

Parameters:

destLayer – destination layer

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

Creates a new QgsSimpleLineSymbolLayer, using the settings serialized in the properties map (corresponding to the output from QgsSimpleLineSymbolLayer.properties() ).

Parameters:

properties (Dict[str) –

Return type:

QgsSymbolLayer

createFromSld(element: QDomElement) QgsSymbolLayer

Creates a new QgsSimpleLineSymbolLayer from an SLD XML DOM element.

Parameters:

element (QDomElement) –

Return type:

QgsSymbolLayer

customDashPatternMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for lengths used in the custom dash pattern.

Return type:

QgsMapUnitScale

customDashPatternUnit(self) Qgis.RenderUnit

Returns the units for lengths used in the custom dash pattern.

Return type:

Qgis.RenderUnit

customDashVector(self) List[float]

Returns the custom dash vector, which is the pattern of alternating drawn/skipped lengths used while rendering a custom dash pattern.

Units for the vector are specified by customDashPatternUnit()

This setting is only used when useCustomDashPattern() returns True.

Return type:

List[float]

dashPatternOffset(self) float

Returns the dash pattern offset, which dictates how far along the dash pattern the pattern should start rendering at.

Offset units can be retrieved by calling dashPatternOffsetUnit().

New in version 3.16.

Return type:

float

dashPatternOffsetMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the dash pattern offset value.

New in version 3.16.

Return type:

QgsMapUnitScale

dashPatternOffsetUnit(self) Qgis.RenderUnit

Returns the units for the dash pattern offset.

New in version 3.16.

Return type:

Qgis.RenderUnit

drawInsidePolygon(self) bool

Returns True if the line should only be drawn inside polygons, and any portion of the line which falls outside the polygon should be clipped away.

This setting only has an effect when the line symbol is being used to render polygon rings.

Return type:

bool

dxfColor(self, context: QgsSymbolRenderContext) QColor
Parameters:

context (QgsSymbolRenderContext) –

Return type:

QColor

dxfCustomDashPattern(self) Tuple[List[float], Qgis.RenderUnit]
Return type:

Tuple[List[float], Qgis.RenderUnit]

dxfOffset(self, e: QgsDxfExport, context: QgsSymbolRenderContext) float
Parameters:
Return type:

float

dxfPenStyle(self) Qt.PenStyle
Return type:

Qt.PenStyle

dxfWidth(self, e: QgsDxfExport, context: QgsSymbolRenderContext) float
Parameters:
Return type:

float

estimateMaxBleed(self, context: QgsRenderContext) float
Parameters:

context (QgsRenderContext) –

Return type:

float

installMasks(self, context: QgsRenderContext, recursive: bool)

When rendering, install masks on context painter if recursive is True masks are installed recursively for all children symbol layers

See also

prepareMasks()

See also

removeMasks()

New in version 3.30.

layerType(self) str
Return type:

str

mapUnitScale(self) QgsMapUnitScale
Return type:

QgsMapUnitScale

ogrFeatureStyle(self, mmScaleFactor: float, mapUnitScaleFactor: float) str
Parameters:
  • mmScaleFactor (float) –

  • mapUnitScaleFactor (float) –

Return type:

str

outputUnit(self) Qgis.RenderUnit
Return type:

Qgis.RenderUnit

penCapStyle(self) Qt.PenCapStyle

Returns the pen cap style used to render the line (e.g. flat, square, round, etc).

See also

setPenCapStyle()

Return type:

Qt.PenCapStyle

penJoinStyle(self) Qt.PenJoinStyle

Returns the pen join style used to render the line (e.g. miter, bevel, round, etc).

Return type:

Qt.PenJoinStyle

penStyle(self) Qt.PenStyle

Returns the pen style used to render the line (e.g. solid, dashed, etc).

See also

setPenStyle()

Return type:

Qt.PenStyle

properties(self) Dict[str, Any]
Return type:

Dict[str, Any]

removeMasks(self, context: QgsRenderContext, recursive: bool)

When rendering, remove previously installed masks from context painter if recursive is True masks are removed recursively for all children symbol layers

See also

prepareMasks()

See also

installMasks()

New in version 3.30.

renderPolygonStroke(self, points: QPolygonF, rings: Iterable[QPolygonF], context: QgsSymbolRenderContext)
Parameters:
renderPolyline(self, points: QPolygonF, context: QgsSymbolRenderContext)
Parameters:
restoreOldDataDefinedProperties(self, stringMap: Dict[str, Any])

Restores older data defined properties from string map.

setAlignDashPattern(self, enabled: bool)

Sets whether dash patterns should be aligned to the start and end of lines, by applying subtle tweaks to the pattern sizing in order to ensure that the end of a line is represented by a complete dash element.

New in version 3.16.

Parameters:

enabled (bool) –

setCustomDashPatternMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale for lengths used in the custom dash pattern.

Parameters:

scale (QgsMapUnitScale) –

setCustomDashPatternUnit(self, unit: Qgis.RenderUnit)

Sets the unit for lengths used in the custom dash pattern.

Parameters:

unit (Qgis.RenderUnit) –

setCustomDashVector(self, vector: Iterable[float])

Sets the custom dash vector, which is the pattern of alternating drawn/skipped lengths used while rendering a custom dash pattern.

Units for the vector are specified by customDashPatternUnit()

This setting is only used when useCustomDashPattern() returns True.

Parameters:

vector (Iterable[float]) –

setDashPatternOffset(self, offset: float)

Sets the dash pattern offset, which dictates how far along the dash pattern the pattern should start rendering at.

Offset units are set via setDashPatternOffsetUnit().

New in version 3.16.

Parameters:

offset (float) –

setDashPatternOffsetMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale for the dash pattern offset.

New in version 3.16.

Parameters:

scale (QgsMapUnitScale) –

setDashPatternOffsetUnit(self, unit: Qgis.RenderUnit)

Sets the unit for the dash pattern offset.

New in version 3.16.

Parameters:

unit (Qgis.RenderUnit) –

setDrawInsidePolygon(self, drawInsidePolygon: bool)

Sets whether the line should only be drawn inside polygons, and any portion of the line which falls outside the polygon should be clipped away.

This setting only has an effect when the line symbol is being used to render polygon rings.

Parameters:

drawInsidePolygon (bool) –

setMapUnitScale(self, scale: QgsMapUnitScale)
Parameters:

scale (QgsMapUnitScale) –

setOutputUnit(self, unit: Qgis.RenderUnit)
Parameters:

unit (Qgis.RenderUnit) –

setPenCapStyle(self, style: Qt.PenCapStyle)

Sets the pen cap style used to render the line (e.g. flat, square, round, etc).

See also

penCapStyle()

Parameters:

style (Qt.PenCapStyle) –

setPenJoinStyle(self, style: Qt.PenJoinStyle)

Sets the pen join style used to render the line (e.g. miter, bevel, round, etc).

See also

penJoinStyle()

Parameters:

style (Qt.PenJoinStyle) –

setPenStyle(self, style: Qt.PenStyle)

Sets the pen style used to render the line (e.g. solid, dashed, etc).

See also

penStyle()

Parameters:

style (Qt.PenStyle) –

setTrimDistanceEnd(self, distance: float)

Sets the trim distance for the end of the line, which dictates a length from the end of the line at which the actual rendering should end.

Trim units can be set by calling setTrimDistanceEndUnit().

New in version 3.20.

Parameters:

distance (float) –

setTrimDistanceEndMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale for the trim distance for the end of the line.

New in version 3.20.

Parameters:

scale (QgsMapUnitScale) –

setTrimDistanceEndUnit(self, unit: Qgis.RenderUnit)

Sets the unit for the trim distance for the end of the line.

New in version 3.20.

Parameters:

unit (Qgis.RenderUnit) –

setTrimDistanceStart(self, distance: float)

Sets the trim distance for the start of the line, which dictates a length from the start of the line at which the actual rendering should start.

Trim units can be set by calling setTrimDistanceStartUnit().

New in version 3.20.

Parameters:

distance (float) –

setTrimDistanceStartMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale for the trim distance for the start of the line.

New in version 3.20.

Parameters:

scale (QgsMapUnitScale) –

setTrimDistanceStartUnit(self, unit: Qgis.RenderUnit)

Sets the unit for the trim distance for the start of the line.

New in version 3.20.

Parameters:

unit (Qgis.RenderUnit) –

setTweakDashPatternOnCorners(self, enabled: bool)

Sets whether dash patterns tweaks should be applied on sharp corners, to ensure that a double-length dash is drawn running into and out of the corner.

Note

This setting is only applied if alignDashPattern() is True.

New in version 3.16.

Parameters:

enabled (bool) –

setUseCustomDashPattern(self, b: bool)

Sets whether the line uses a custom dash pattern.

Parameters:

b (bool) –

shouldRenderUsingSelectionColor(self, context: QgsSymbolRenderContext) bool

Returns True if the symbol layer should be rendered using the selection color from the render context.

New in version 3.34.

startRender(self, context: QgsSymbolRenderContext)
Parameters:

context (QgsSymbolRenderContext) –

stopRender(self, context: QgsSymbolRenderContext)
Parameters:

context (QgsSymbolRenderContext) –

toSld(self, doc: QDomDocument, element: QDomElement, props: Dict[str, Any])
Parameters:
  • doc (QDomDocument) –

  • element (QDomElement) –

  • props (Dict[str) –

trimDistanceEnd(self) float

Returns the trim distance for the end of the line, which dictates a length from the end of the line at which the actual rendering should end.

Trim units can be retrieved by calling trimDistanceEndUnit().

New in version 3.20.

Return type:

float

trimDistanceEndMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the trim distance for the end of the line.

New in version 3.20.

Return type:

QgsMapUnitScale

trimDistanceEndUnit(self) Qgis.RenderUnit

Returns the unit for the trim distance for the end of the line.

New in version 3.20.

Return type:

Qgis.RenderUnit

trimDistanceStart(self) float

Returns the trim distance for the start of the line, which dictates a length from the start of the line at which the actual rendering should start.

Trim units can be retrieved by calling trimDistanceStartUnit().

New in version 3.20.

Return type:

float

trimDistanceStartMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the trim distance for the start of the line.

New in version 3.20.

Return type:

QgsMapUnitScale

trimDistanceStartUnit(self) Qgis.RenderUnit

Returns the unit for the trim distance for the start of the line.

New in version 3.20.

Return type:

Qgis.RenderUnit

tweakDashPatternOnCorners(self) bool

Returns True if dash patterns tweaks should be applied on sharp corners, to ensure that a double-length dash is drawn running into and out of the corner.

Note

This setting is only applied if alignDashPattern() is True.

New in version 3.16.

Return type:

bool

useCustomDashPattern(self) bool

Returns True if the line uses a custom dash pattern.

Return type:

bool

usesMapUnits(self) bool
Return type:

bool