Class: QgsPalLabeling

class qgis.core.QgsPalLabeling

Bases: sip.wrapper

QgsPalLabeling(QgsPalLabeling)

Methods

geometryRequiresPreparation

Checks whether a geometry requires preparation before registration with PAL

prepareGeometry

Prepares a geometry for registration with PAL.

splitToGraphemes

Splits a text string to a list of graphemes, which are the smallest allowable character divisions in the string.

splitToLines

Splits a text string to a list of separate lines, using a specified wrap character (wrapCharacter).

staticWillUseLayer

called to find out whether the layer is used for labeling

geometryRequiresPreparation(geometry: QgsGeometry, context: QgsRenderContext, ct: QgsCoordinateTransform, clipGeometry: QgsGeometry = QgsGeometry(), mergeLines: bool = False) → bool

Checks whether a geometry requires preparation before registration with PAL

Parameters
  • geometry (QgsGeometry) – geometry to prepare

  • context (QgsRenderContext) – render context

  • ct (QgsCoordinateTransform) – coordinate transform, or invalid transform if no transformation required

  • clipGeometry (QgsGeometry = QgsGeometry()) – geometry to clip features to, if applicable

  • mergeLines (bool = False) – True if touching lines from this layer will be merged and treated as single features during labeling

Return type

bool

Returns

True if geometry requires preparation

New in version 2.9.

prepareGeometry(geometry: QgsGeometry, context: QgsRenderContext, ct: QgsCoordinateTransform, clipGeometry: QgsGeometry = QgsGeometry(), mergeLines: bool = False)QgsGeometry

Prepares a geometry for registration with PAL. Handles reprojection, rotation, clipping, etc.

Parameters
  • geometry (QgsGeometry) – geometry to prepare

  • context (QgsRenderContext) – render context

  • ct (QgsCoordinateTransform) – coordinate transform, or invalid transform if no transformation required

  • clipGeometry (QgsGeometry = QgsGeometry()) – geometry to clip features to, if applicable

  • mergeLines (bool = False) – True if touching lines from this layer will be merged and treated as single features during labeling

Return type

QgsGeometry

Returns

prepared geometry

New in version 2.9.

splitToGraphemes(text: str) → List[str]

Splits a text string to a list of graphemes, which are the smallest allowable character divisions in the string. This accounts for scripts were individual characters are not allowed to be split apart (e.g., Arabic and Indic based scripts)

Parameters

text (str) – string to split

Return type

List[str]

Returns

list of graphemes

New in version 2.10.

splitToLines(text: str, wrapCharacter: str, autoWrapLength: int = 0, useMaxLineLengthWhenAutoWrapping: bool = True) → List[str]

Splits a text string to a list of separate lines, using a specified wrap character (wrapCharacter). The text string will be split on either newline characters or the wrap character.

Since QGIS 3.4 the autoWrapLength argument can be used to specify an ideal length of line to automatically wrap text to (automatic wrapping is disabled if autoWrapLength is 0). This automatic wrapping is performed after processing wrapping using wrapCharacter. When auto wrapping is enabled, the useMaxLineLengthWhenAutoWrapping argument controls whether the lines should be wrapped to an ideal maximum of autoWrapLength characters, or if False then the lines are wrapped to an ideal minimum length of autoWrapLength characters.

New in version 2.9.

Parameters
  • text (str) –

  • wrapCharacter (str) –

  • autoWrapLength (int = 0) –

  • useMaxLineLengthWhenAutoWrapping (bool = True) –

Return type

List[str]

staticWillUseLayer(layer: QgsVectorLayer) → bool

called to find out whether the layer is used for labeling

New in version 2.4.

Parameters

layer (QgsVectorLayer) –

Return type

bool