Class: QgsAbstractVectorLayerLabeling¶
Abstract base class - its implementations define different approaches to the labeling of a vector layer.
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()
, setSettings()
, settings()
, type()
Class Hierarchy¶
Subclasses¶
Rule based labeling for a vector layer. |
|
Basic implementation of the labeling interface. |
Abstract Methods
Returns a new copy of the object |
|
Returns |
|
Returns |
|
Returns labeling configuration as XML element |
|
Set pal settings for a specific provider (takes ownership). |
|
Gets associated label settings. |
|
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 QgsAbstractVectorLayerLabeling. See the FAQ for more details.
Accepts the specified symbology visitor, causing it to visit all symbols associated with the labeling. |
|
Multiply opacity by opacityFactor. |
|
Gets list of sub-providers within the layer's labeling. |
|
Writes the SE 1.1 TextSymbolizer element based on the current layer labeling settings |
|
Writes a TextSymbolizer element contents based on the provided labeling settings |
Static Methods
Try to create instance of an implementation based on the XML data |
|
Returns the default layer settings to use for the specified vector layer. |
- class qgis.core.QgsAbstractVectorLayerLabeling[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, orFalse
if visiting should be canceled.Added in version 3.10.
- Parameters:
visitor (Optional[QgsStyleEntityVisitorInterface])
- Return type:
bool
- abstract clone(self) QgsAbstractVectorLayerLabeling | None [source]¶
Returns a new copy of the object
- Return type:
Optional[QgsAbstractVectorLayerLabeling]
- static create(element: QDomElement, context: QgsReadWriteContext) QgsAbstractVectorLayerLabeling | None [source]¶
Try to create instance of an implementation based on the XML data
- Parameters:
element (QDomElement)
context (QgsReadWriteContext)
- Return type:
Optional[QgsAbstractVectorLayerLabeling]
- static defaultSettingsForLayer(layer: QgsVectorLayer | None) QgsPalLayerSettings [source]¶
Returns the default layer settings to use for the specified vector
layer
.Added in version 3.20.
- Parameters:
layer (Optional[QgsVectorLayer])
- Return type:
- 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 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.Added in version 3.32.
- 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]¶
Returns labeling configuration as XML element
- Parameters:
doc (QDomDocument)
context (QgsReadWriteContext)
- Return type:
QDomElement
- abstract setSettings(self, settings: QgsPalLayerSettings | None, providerId: str | None = '')[source]¶
Set pal settings for a specific provider (takes ownership).
- Parameters:
settings (Optional[QgsPalLayerSettings]) – Pal layer settings
providerId (Optional[str] = '') – The id of the provider
- abstract settings(self, providerId: str | None = '') QgsPalLayerSettings [source]¶
Gets associated label settings. In case of multiple sub-providers with different settings, they are identified by their ID (e.g. in case of rule-based labeling, provider ID == rule key)
- Parameters:
providerId (Optional[str] = '')
- Return type:
- virtual subProviders(self) List[str] [source]¶
Gets list of sub-providers within the layer’s labeling.
- Return type:
List[str]
- virtual toSld(self, parent: QDomNode, props: Dict[str, Any])[source]¶
Writes the SE 1.1 TextSymbolizer element based on the current layer labeling settings
Deprecated since version 3.44: Use the version with
QgsSldExportContext
instead.- Parameters:
parent (QDomNode)
props (Dict[str, Any])
- virtual toSld(self, parent: QDomNode, context: QgsSldExportContext) bool [source]
Writes the SE 1.1 TextSymbolizer element based on the current layer labeling settings.
Added in version 3.44.
- Parameters:
parent (QDomNode)
context (
QgsSldExportContext
)
- Return type:
bool
- abstract type(self) str [source]¶
Unique type string of the labeling configuration implementation
- Return type:
str
- virtual writeTextSymbolizer(self, parent: QDomNode, settings: QgsPalLayerSettings, props: Dict[str, Any])[source]¶
Writes a TextSymbolizer element contents based on the provided labeling settings
- Parameters:
parent (QDomNode) – the node that will have the text symbolizer element added to it
settings (
QgsPalLayerSettings
) – the settings getting translated to a TextSymbolizerprops (Dict[str, Any]) – a open ended set of properties that can drive/inform the SLD encoding
Deprecated since version 3.44: Use the version with
QgsSldExportContext
instead.
- virtual writeTextSymbolizer(self, parent: QDomNode, settings: QgsPalLayerSettings, context: QgsSldExportContext) bool [source]
Writes a TextSymbolizer element contents based on the provided labeling settings
- Parameters:
parent (QDomNode) – the node that will have the text symbolizer element added to it
settings (
QgsPalLayerSettings
) – the settings getting translated to a TextSymbolizercontext (
QgsSldExportContext
) – export context
Added in version 3.44.
- Return type:
bool