Class: QgsTemplatedLineSymbolLayerBase

class qgis.core.QgsTemplatedLineSymbolLayerBase(rotateSymbol: bool = True, interval: float = 3)

Bases: QgsLineSymbolLayer

Constructor for QgsTemplatedLineSymbolLayerBase. Creates a template line placed at the specified interval (in millimeters).

The rotateSymbol argument specifies whether individual symbols should be rotated to match the line segment alignment.

Base class for templated line symbols, e.g. line symbols which draw markers or hash lines at intervals along the line feature.

New in version 3.8.

Parameters
  • rotateSymbol (bool = True) –

  • interval

CentralPoint = 4
CurvePoint = 5
FirstVertex = 3
Interval = 0
LastVertex = 2
class Placement

Bases: int

SegmentCenter = 6
Vertex = 1
averageAngleLength(self) → float

Returns the length of line over which the line’s direction is averaged when calculating individual symbol angles. Longer lengths smooth out angles from jagged lines to a greater extent.

Units are retrieved through averageAngleUnit()

Return type

float

averageAngleMapUnitScale(self) → QgsMapUnitScale

Returns the map unit scale for the length over which the line’s direction is averaged when calculating individual symbol angles.

Return type

QgsMapUnitScale

averageAngleUnit(self) → QgsUnitTypes.RenderUnit

Returns the unit for the length over which the line’s direction is averaged when calculating individual symbol angles.

Return type

QgsUnitTypes.RenderUnit

copyDataDefinedProperties()
copyPaintEffect()
copyTemplateSymbolProperties(self, destLayer: QgsTemplatedLineSymbolLayerBase)

Copies all common properties of this layer to another templated symbol layer.

Parameters

destLayer (QgsTemplatedLineSymbolLayerBase) –

interval(self) → float

Returns the interval between individual symbols. Units are specified through intervalUnits().

See also

setInterval()

See also

intervalUnit()

Return type

float

intervalMapUnitScale(self) → QgsMapUnitScale

Returns the map unit scale for the interval between symbols.

See also

intervalUnit()

See also

interval()

Return type

QgsMapUnitScale

intervalUnit(self) → QgsUnitTypes.RenderUnit

Returns the units for the interval between symbols.

See also

interval()

Return type

QgsUnitTypes.RenderUnit

mapUnitScale(self) → QgsMapUnitScale
Return type

QgsMapUnitScale

offsetAlongLine(self) → float

Returns the offset along the line for the symbol placement. For Interval placements, this is the distance between the start of the line and the first symbol. For FirstVertex and LastVertex placements, this is the distance between the symbol and the start of the line or the end of the line respectively. This setting has no effect for Vertex or CentralPoint placements.

Return type

float

Returns

The offset along the line. The unit for the offset is retrievable via offsetAlongLineUnit.

See also

placement()

offsetAlongLineMapUnitScale(self) → QgsMapUnitScale

Returns the map unit scale used for calculating the offset in map units along line for symbols.

Return type

QgsMapUnitScale

offsetAlongLineUnit(self) → QgsUnitTypes.RenderUnit

Returns the unit used for calculating the offset along line for symbols.

Return type

QgsUnitTypes.RenderUnit

Returns

Offset along line unit type.

outputUnit(self) → QgsUnitTypes.RenderUnit
Return type

QgsUnitTypes.RenderUnit

placement(self) → QgsTemplatedLineSymbolLayerBase.Placement

Returns the placement of the symbols.

See also

setPlacement()

Return type

QgsTemplatedLineSymbolLayerBase.Placement

properties(self) → Dict[str, str]
Return type

Dict[str, str]

renderPolygonStroke(self, points: QPolygonF, rings: Iterable[QPolygonF], context: QgsSymbolRenderContext)
Parameters
renderPolyline(self, points: QPolygonF, context: QgsSymbolRenderContext)
Parameters
renderSymbol(self, point: Union[QPointF, QPoint], feature: QgsFeature, context: QgsRenderContext, layer: int = -1, selected: bool = False)

Renders the templated symbol at the specified point, using the given render context.

The feature argument is used to pass the feature currently being rendered (when available).

If only a single symbol layer from the symbol should be rendered, it should be specified in the layer argument. A layer of -1 indicates that all symbol layers should be rendered.

If selected is true then the symbol will be drawn using the “selected feature” style and colors instead of the symbol’s normal style.

Parameters
  • point (Union[QPointF) –

  • feature (QgsFeature) –

  • context (QgsRenderContext) –

  • layer (int = -1) –

  • selected (bool = False) –

restoreOldDataDefinedProperties()
rotateSymbols(self) → bool

Returns True if the repeating symbols be rotated to match their line segment orientation.

Return type

bool

setAverageAngleLength(self, length: float)

Sets the length of line over which the line’s direction is averaged when calculating individual symbol angles. Longer lengths smooth out angles from jagged lines to a greater extent.

Units are set through setAverageAngleUnit()

Parameters

length (float) –

setAverageAngleMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale for the length over which the line’s direction is averaged when calculating individual symbol angles.

Parameters

scale (QgsMapUnitScale) –

setAverageAngleUnit(self, unit: QgsUnitTypes.RenderUnit)

Sets the unit for the length over which the line’s direction is averaged when calculating individual symbol angles.

Parameters

unit (QgsUnitTypes.RenderUnit) –

setCommonProperties(destLayer: QgsTemplatedLineSymbolLayerBase, properties: Dict[str, str])

Sets all common symbol properties in the destLayer, using the settings serialized in the properties map.

Parameters
setInterval(self, interval: float)

Sets the interval between individual symbols.

Parameters

interval (float) – interval size. Units are specified through setIntervalUnit()

See also

interval()

setIntervalMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale for the interval between symbols.

See also

setInterval()

Parameters

scale (QgsMapUnitScale) –

setIntervalUnit(self, unit: QgsUnitTypes.RenderUnit)

Sets the units for the interval between symbols.

Parameters

unit (QgsUnitTypes.RenderUnit) – interval units

See also

intervalUnit()

See also

setInterval()

setMapUnitScale(self, scale: QgsMapUnitScale)
Parameters

scale (QgsMapUnitScale) –

setOffsetAlongLine(self, offsetAlongLine: float)

Sets the the offset along the line for the symbol placement. For Interval placements, this is the distance between the start of the line and the first symbol. For FirstVertex and LastVertex placements, this is the distance between the symbol and the start of the line or the end of the line respectively. This setting has no effect for Vertex or CentralPoint placements.

Parameters

offsetAlongLine (float) – Distance to offset markers along the line. The offset unit is set via setOffsetAlongLineUnit.

See also

setPlacement()

setOffsetAlongLineMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale used for calculating the offset in map units along line for symbols.

Parameters

scale (QgsMapUnitScale) –

setOffsetAlongLineUnit(self, unit: QgsUnitTypes.RenderUnit)

Sets the unit used for calculating the offset along line for symbols.

Parameters

unit (QgsUnitTypes.RenderUnit) – Offset along line unit type.

setPlacement(self, placement: QgsTemplatedLineSymbolLayerBase.Placement)

Sets the placement of the symbols.

See also

placement()

Parameters

placement (QgsTemplatedLineSymbolLayerBase.Placement) –

setRotateSymbols(self, rotate: bool)

Sets whether the repeating symbols should be rotated to match their line segment orientation.

See also

rotateSymbols()

Parameters

rotate (bool) –

setSymbolAngle(self, angle: float)

Sets the symbol’s angle, in degrees clockwise.

Parameters

angle (float) –

setSymbolLineAngle(self, angle: float)

Sets the line angle modification for the symbol’s angle. This angle is added to the symbol’s rotation and data defined rotation before rendering the symbol, and is used for orienting symbols to match the line’s angle.

Parameters

angle (float) – Angle in degrees, valid values are between 0 and 360

symbolAngle(self) → float

Returns the symbol’s current angle, in degrees clockwise.

Return type

float