Class: QgsAbstractRasterLayerLabeling

Abstract base class for labeling settings for raster layers.

Added in version 3.42.

Note

This is an abstract class, with methods which must be implemented by a subclass.

The following methods must be implemented: clone(), hasNonDefaultCompositionMode(), requiresAdvancedEffects(), save(), type()

Class Hierarchy

Inheritance diagram of qgis.core.QgsAbstractRasterLayerLabeling

Subclasses

QgsRasterLayerSimpleLabeling

Basic implementation of the labeling interface for raster layers.

Abstract Methods

clone

Returns a new copy of the object

hasNonDefaultCompositionMode

Returns True the labeling requires a non-default composition mode.

requiresAdvancedEffects

Returns True if drawing labels requires advanced effects like composition modes, which could prevent it being used as an isolated cached image or exported to a vector format.

save

Saves the labeling configuration to an XML element.

type

Unique type string of the labeling configuration implementation

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsAbstractRasterLayerLabeling. See the FAQ for more details.

accept

Accepts the specified symbology visitor, causing it to visit all symbols associated with the labeling.

isInScaleRange

Tests whether the labels should be visible at the specified scale.

multiplyOpacity

Multiply opacity by opacityFactor.

toSld

Writes the SE 1.1 TextSymbolizer element based on the current layer labeling settings

Static Methods

createFromElement

Tries to create an instance of an implementation based on the XML data.

defaultLabelingForLayer

Creates default labeling for a raster layer.

class qgis.core.QgsAbstractRasterLayerLabeling[source]

Bases: object

virtual accept(self, visitor: QgsStyleEntityVisitorInterface | None) bool[source]

Accepts the specified symbology visitor, causing it to visit all symbols associated with the labeling.

Returns True if the visitor should continue visiting other objects, or False if visiting should be canceled.

Parameters:

visitor (Optional[QgsStyleEntityVisitorInterface])

Return type:

bool

abstract clone(self) QgsAbstractRasterLayerLabeling | None[source]

Returns a new copy of the object

Return type:

Optional[QgsAbstractRasterLayerLabeling]

static createFromElement(element: QDomElement, context: QgsReadWriteContext) QgsAbstractRasterLayerLabeling | None[source]

Tries to create an instance of an implementation based on the XML data.

Parameters:
Return type:

Optional[QgsAbstractRasterLayerLabeling]

static defaultLabelingForLayer(layer: QgsRasterLayer | None) QgsAbstractRasterLayerLabeling | None[source]

Creates default labeling for a raster layer.

Parameters:

layer (Optional[QgsRasterLayer])

Return type:

Optional[QgsAbstractRasterLayerLabeling]

abstract hasNonDefaultCompositionMode(self) bool[source]

Returns True the labeling requires a non-default composition mode.

This method is pessimistic, in that it will return True in cases where composition modes cannot be easily determined in advance (e.g. when data-defined overrides are in place for composition modes).

The default composition mode is QPainter.CompositionMode_SourceOver.

Added in version 3.44.

Return type:

bool

virtual isInScaleRange(self, scale: float) bool[source]

Tests whether the labels should be visible at the specified scale. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.

Return type:

bool

Returns:

True if the labels are visible at the given scale.

Parameters:

scale (float)

virtual multiplyOpacity(self, opacityFactor: float)[source]

Multiply opacity by opacityFactor.

This method multiplies the opacity of the labeling elements (text, shadow, buffer etc.) by opacity effectively changing the opacity of the whole labeling elements.

Parameters:

opacityFactor (float)

abstract requiresAdvancedEffects(self) bool[source]

Returns True if drawing labels requires advanced effects like composition modes, which could prevent it being used as an isolated cached image or exported to a vector format.

Return type:

bool

abstract save(self, doc: QDomDocument, context: QgsReadWriteContext) QDomElement[source]

Saves the labeling configuration to an XML element.

Parameters:
Return type:

QDomElement

virtual toSld(self, parent: QDomNode, props: Dict[str, Any])[source]

Writes the SE 1.1 TextSymbolizer element based on the current layer labeling settings

Parameters:
  • parent (QDomNode)

  • props (Dict[str, Any])

abstract type(self) str[source]

Unique type string of the labeling configuration implementation

Return type:

str