Subgroup: Scale

Class: QgsScaleBarRenderer

class qgis.core.QgsScaleBarRenderer

Bases: sip.wrapper

Constructor for QgsScaleBarRenderer.

QgsScaleBarRenderer(QgsScaleBarRenderer)

Abstract base class for scale bar renderers.

Scalebar renderer subclasses implement custom drawing logic, with the possibility to implement custom labeling.

New in version 3.0: Methods

calculateBoxSize Calculates the required box size (in millimeters) for a scalebar using the specified settings and scaleContext.
draw Draws the scalebar using the specified settings and scaleContext to a destination render context.
drawDefaultLabels Draws default scalebar labels using the specified settings and scaleContext to a destination render context.
firstLabelString Returns the text used for the first label in the scalebar.
firstLabelXOffset Returns the x-offset (in millimeters) used for the first label in the scalebar.
name Returns the unique name for this style.
segmentPositions Returns a list of positions for each segment within the scalebar.
segmentWidths Returns a list of widths of each segment of the scalebar.

Signals

Attributes

class ScaleBarContext

Bases: sip.wrapper

QgsScaleBarRenderer.ScaleBarContext(QgsScaleBarRenderer.ScaleBarContext)

scale
segmentWidth
size
calculateBoxSize(self, settings: QgsScaleBarSettings, scaleContext: QgsScaleBarRenderer.ScaleBarContext) → QSizeF

Calculates the required box size (in millimeters) for a scalebar using the specified settings and scaleContext.

draw(self, context: QgsRenderContext, settings: QgsScaleBarSettings, scaleContext: QgsScaleBarRenderer.ScaleBarContext)

Draws the scalebar using the specified settings and scaleContext to a destination render context.

drawDefaultLabels(self, context: QgsRenderContext, settings: QgsScaleBarSettings, scaleContext: QgsScaleBarRenderer.ScaleBarContext)

Draws default scalebar labels using the specified settings and scaleContext to a destination render context.

firstLabelString(self, settings: QgsScaleBarSettings) → str

Returns the text used for the first label in the scalebar.

firstLabelXOffset(self, settings: QgsScaleBarSettings) → float

Returns the x-offset (in millimeters) used for the first label in the scalebar.

name(self) → str

Returns the unique name for this style.

segmentPositions(self, scaleContext: QgsScaleBarRenderer.ScaleBarContext, settings: QgsScaleBarSettings) → List[float]

Returns a list of positions for each segment within the scalebar.

segmentWidths(self, scaleContext: QgsScaleBarRenderer.ScaleBarContext, settings: QgsScaleBarSettings) → List[float]

Returns a list of widths of each segment of the scalebar.