Class: QgsMaskIdProvider

class qgis.core.QgsMaskIdProvider

Bases: sip.wrapper

This class allows the creation of mask ids based on the different label layers and to give a mask id from a label layer.

Some rendering operations may need multiple mask images. This is the case for label rendering in which we can have different mask images: one different for each labeling rule for instance. Some label layers may need to share their mask images, some other need to have distinct mask images. Label layers share the same mask image if the set of symbol layers they mask is the same.

A “mask id” is then associated to each label layer. They are contiguous integer numbers starting at 0.

New in version 3.12:

Methods

insertLabelLayer

Inserts a label layer to the provider and returns its associated mask id.

maskId

Returns the mask id associated with a label layer and its optional label rule.

size

Returns the number of identifiers allocated.

insertLabelLayer(self, layerId: str, ruleId: str, maskedSymbolLayers: Iterable[QgsSymbolLayerReference]) int

Inserts a label layer to the provider and returns its associated mask id.

Parameters:
  • layerId (str) – id of the vector layer that carries these labels

  • ruleId (str) – id of the labeling rule, if any

  • maskedSymbolLayers (Iterable[QgsSymbolLayerReference]) – the symbol layers that are masked by this label layer

Return type:

int

Returns:

the associated mask id.

maskId(self, labelLayerId: str = '', labelRuleId: str = '') int

Returns the mask id associated with a label layer and its optional label rule. Returns -1 if not found.

Parameters:
  • labelLayerId (str = '') –

  • labelRuleId (str = '') –

Return type:

int

size(self) int

Returns the number of identifiers allocated.

Return type:

int