Class: QgsAnnotationItem

class qgis.core.QgsAnnotationItem

Bases: sip.wrapper

Abstract base class for annotation items which are drawn with QgsAnnotationLayers.

New in version 3.16.

QgsAnnotationItem() Constructor for an annotation item.

Methods

applyEdit

Applies an edit operation to the item.

boundingBox

Returns the bounding box of the item's geographic location, in the parent layer's coordinate reference system.

clone

Returns a clone of the item.

copyCommonProperties

Copies common properties from the base class from an other item.

flags

Returns item flags.

nodes

Returns the nodes for the item, used for editing the item.

readCommonProperties

Reads common properties from the base class from the given DOM element.

readXml

Reads the item's state from the given DOM element.

render

Renders the item to the specified render context.

setSymbologyReferenceScale

Sets the annotation's symbology reference scale.

setUseSymbologyReferenceScale

Sets whether the annotation item uses a symbology reference scale.

setZIndex

Sets the item's z index, which controls the order in which annotation items are rendered in the layer.

symbologyReferenceScale

Returns the annotation's symbology reference scale.

transientEditResults

Retrieves the results of a transient (in progress) edit operation on the item.

type

Returns a unique (untranslated) string identifying the type of item.

useSymbologyReferenceScale

Returns True if the annotation item uses a symbology reference scale.

writeCommonProperties

Writes common properties from the base class into an XML element.

writeXml

Writes the item's state into an XML element.

zIndex

Returns the item's z index, which controls the order in which annotation items are rendered in the layer.

applyEdit(self, operation: QgsAbstractAnnotationItemEditOperation) Qgis.AnnotationItemEditOperationResult

Applies an edit operation to the item.

New in version 3.22.

Parameters

operation (QgsAbstractAnnotationItemEditOperation) –

Return type

Qgis.AnnotationItemEditOperationResult

boundingBox(self) QgsRectangle

Returns the bounding box of the item’s geographic location, in the parent layer’s coordinate reference system.

boundingBox(self, context: QgsRenderContext) -> QgsRectangle Returns the bounding box of the item’s geographic location, in the parent layer’s coordinate reference system.

Return type

QgsRectangle

clone(self) QgsAnnotationItem

Returns a clone of the item. Ownership is transferred to the caller.

Implementations should include a call to copyCommonProperties() to copy the base class properties.

Return type

QgsAnnotationItem

copyCommonProperties(self, other: QgsAnnotationItem)

Copies common properties from the base class from an other item.

New in version 3.22.

Parameters

other (QgsAnnotationItem) –

flags(self) Qgis.AnnotationItemFlags

Returns item flags.

New in version 3.22.

Return type

Qgis.AnnotationItemFlags

nodes(self) List[QgsAnnotationItemNode]

Returns the nodes for the item, used for editing the item.

New in version 3.22.

Return type

List[QgsAnnotationItemNode]

readCommonProperties(self, element: QDomElement, context: QgsReadWriteContext) bool

Reads common properties from the base class from the given DOM element.

See also

readXml()

New in version 3.22.

Parameters
Return type

bool

readXml(self, element: QDomElement, context: QgsReadWriteContext) bool

Reads the item’s state from the given DOM element.

Implementations should include a call to readCommonProperties() to read the base class properties.

See also

writeXml()

Parameters
Return type

bool

render(self, context: QgsRenderContext, feedback: QgsFeedback)

Renders the item to the specified render context.

The feedback argument can be used to detect render cancellations during expensive render operations.

Parameters
setSymbologyReferenceScale(self, scale: float)

Sets the annotation’s symbology reference scale.

The reference scale will only be used if useSymbologyReferenceScale() returns True.

This represents the desired scale denominator for the rendered map, eg 1000.0 for a 1:1000 map render.

The symbology reference scale is an optional property which specifies the reference scale at which symbology in paper units (such a millimeters or points) is fixed to. For instance, if the scale is 1000 then a 2mm thick line will be rendered at exactly 2mm thick when a map is rendered at 1:1000, or 1mm thick when rendered at 1:2000, or 4mm thick at 1:500.

Parameters

scale (float) –

setUseSymbologyReferenceScale(self, enabled: bool)

Sets whether the annotation item uses a symbology reference scale.

Parameters

enabled (bool) –

setZIndex(self, index: int)

Sets the item’s z index, which controls the order in which annotation items are rendered in the layer.

See also

zIndex()

Parameters

index (int) –

symbologyReferenceScale(self) float

Returns the annotation’s symbology reference scale.

The reference scale will only be used if useSymbologyReferenceScale() returns True.

This represents the desired scale denominator for the rendered map, eg 1000.0 for a 1:1000 map render.

The symbology reference scale is an optional property which specifies the reference scale at which symbology in paper units (such a millimeters or points) is fixed to. For instance, if the scale is 1000 then a 2mm thick line will be rendered at exactly 2mm thick when a map is rendered at 1:1000, or 1mm thick when rendered at 1:2000, or 4mm thick at 1:500.

Return type

float

transientEditResults(self, operation: QgsAbstractAnnotationItemEditOperation) QgsAnnotationItemEditOperationTransientResults

Retrieves the results of a transient (in progress) edit operation on the item.

New in version 3.22.

Parameters

operation (QgsAbstractAnnotationItemEditOperation) –

Return type

QgsAnnotationItemEditOperationTransientResults

type(self) str

Returns a unique (untranslated) string identifying the type of item.

Return type

str

useSymbologyReferenceScale(self) bool

Returns True if the annotation item uses a symbology reference scale.

Return type

bool

writeCommonProperties(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) bool

Writes common properties from the base class into an XML element.

See also

writeXml()

New in version 3.22.

Parameters
Return type

bool

writeXml(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) bool

Writes the item’s state into an XML element.

Implementations should include a call to writeCommonProperties() to store the base class properties.

See also

readXml()

Parameters
Return type

bool

zIndex(self) int

Returns the item’s z index, which controls the order in which annotation items are rendered in the layer.

See also

setZIndex()

Return type

int