QGIS API Documentation 4.3.0-Master (6402a64e93b)
Loading...
Searching...
No Matches
QgsAnnotationRectItem Class Referenceabstract

Abstract base class for annotation items which render annotations in a rectangular shape. More...

#include <qgsannotationrectitem.h>

Inheritance diagram for QgsAnnotationRectItem:

Public Member Functions

 QgsAnnotationRectItem (const QgsRectangle &bounds)
 Constructor for QgsAnnotationRectItem, rendering the annotation within the specified bounds geometry.
 ~QgsAnnotationRectItem () override
double appliedRotation (double mapRotation) const
 Returns the effective on-screen rotation of the item, in degrees clockwise.
Qgis::AnnotationItemEditOperationResult applyEditV2 (QgsAbstractAnnotationItemEditOperation *operation, const QgsAnnotationItemEditContext &context) override
 Applies an edit operation to the item.
bool backgroundEnabled () const
 Returns true if the item's background should be rendered.
const QgsFillSymbolbackgroundSymbol () const
 Returns the symbol used to render the item's background.
QgsRectangle boundingBox () const override
 Returns the bounding box of the item's geographic location, in the parent layer's coordinate reference system.
QgsRectangle boundingBox (QgsRenderContext &context) const override
 Returns the bounding box of the item's geographic location, in the parent layer's coordinate reference system.
QgsRectangle bounds () const
 Returns the bounds of the item.
QSizeF fixedSize () const
 Returns the fixed size to use for the item, when the placementMode() is Qgis::AnnotationPlacementMode::FixedSize.
Qgis::RenderUnit fixedSizeUnit () const
 Returns the units to use for fixed item sizes, when the placementMode() is Qgis::AnnotationPlacementMode::FixedSize.
Qgis::AnnotationItemFlags flags () const override
 Returns item flags.
bool frameEnabled () const
 Returns true if the item's frame should be rendered.
const QgsFillSymbolframeSymbol () const
 Returns the symbol used to render the item's frame.
QList< QgsAnnotationItemNodenodesV2 (const QgsAnnotationItemEditContext &context) const override
 Returns the nodes for the item, used for editing the item.
Qgis::AnnotationPlacementMode placementMode () const
 Returns the placement mode for the item.
void render (QgsRenderContext &context, QgsFeedback *feedback) override
 Renders the item to the specified render context.
QgsGeometry rotatedBoundsGeometry (const QgsRectangle &layerBounds, const QgsRenderContext &renderContext) const
 Returns the polygon geometry (in layer coordinates) for the item occupying the given layerBounds, rotated to match how the item is rendered in renderContext.
double rotation () const
 Returns the rotation of the item, in degrees clockwise.
Qgis::SymbolRotationMode rotationMode () const
 Returns the method used to render the item with respect to the rotation of the map.
void setBackgroundEnabled (bool enabled)
 Sets whether the item's background should be rendered.
void setBackgroundSymbol (QgsFillSymbol *symbol)
 Sets the symbol used to render the item's background.
void setBounds (const QgsRectangle &bounds)
 Sets the bounds of the item.
void setFixedSize (const QSizeF &size)
 Sets the fixed size to use for the item, when the placementMode() is Qgis::AnnotationPlacementMode::FixedSize.
void setFixedSizeUnit (Qgis::RenderUnit unit)
 Sets the unit to use for fixed item sizes, when the placementMode() is Qgis::AnnotationPlacementMode::FixedSize.
void setFrameEnabled (bool enabled)
 Sets whether the item's frame should be rendered.
void setFrameSymbol (QgsFillSymbol *symbol)
 Sets the symbol used to render the item's frame.
void setPlacementMode (Qgis::AnnotationPlacementMode mode)
 Sets the placement mode for the item.
void setRotation (double rotation)
 Sets the rotation of the item, in degrees clockwise.
void setRotationMode (Qgis::SymbolRotationMode mode)
 Sets the mode used to render the item with respect to the rotation of the map.
QgsAnnotationItemEditOperationTransientResultstransientEditResultsV2 (QgsAbstractAnnotationItemEditOperation *operation, const QgsAnnotationItemEditContext &context) override
 Retrieves the results of a transient (in progress) edit operation on the item.
Public Member Functions inherited from QgsAnnotationItem
 QgsAnnotationItem ()
 QgsAnnotationItem (const QgsAnnotationItem &other)=delete
virtual ~QgsAnnotationItem ()
virtual Q_DECL_DEPRECATED Qgis::AnnotationItemEditOperationResult applyEdit (QgsAbstractAnnotationItemEditOperation *operation)
 Applies an edit operation to the item.
QgsCalloutcallout () const
 Returns the item's callout renderer, responsible for drawing item callouts.
QgsGeometry calloutAnchor () const
 Returns the callout's anchor geometry.
virtual QgsAnnotationItemclone () const =0
 Returns a clone of the item.
bool enabled () const
 Returns true if the item is enabled and will be rendered in the layer.
virtual Q_DECL_DEPRECATED QList< QgsAnnotationItemNodenodes () const
 Returns the nodes for the item, used for editing the item.
QSizeF offsetFromCallout () const
 Returns the (optional) offset of the annotation item from the calloutAnchor().
Qgis::RenderUnit offsetFromCalloutUnit () const
 Returns the units for the offsetFromCallout().
QgsAnnotationItemoperator= (const QgsAnnotationItem &other)=delete
virtual bool readXml (const QDomElement &element, const QgsReadWriteContext &context)=0
 Reads the item's state from the given DOM element.
void setCallout (QgsCallout *callout)
 Sets the item's callout renderer, responsible for drawing item callouts.
void setCalloutAnchor (const QgsGeometry &anchor)
 Sets the callout's anchor geometry.
void setEnabled (bool enabled)
 Sets if the item will be rendered or not in the layer.
void setOffsetFromCallout (const QSizeF &offset)
 Sets the offset of the annotation item from the calloutAnchor().
void setOffsetFromCalloutUnit (Qgis::RenderUnit unit)
 Sets the unit for the offsetFromCallout().
void setSymbologyReferenceScale (double scale)
 Sets the annotation's symbology reference scale.
void setUseSymbologyReferenceScale (bool enabled)
 Sets whether the annotation item uses a symbology reference scale.
void setZIndex (int index)
 Sets the item's z index, which controls the order in which annotation items are rendered in the layer.
double symbologyReferenceScale () const
 Returns the annotation's symbology reference scale.
virtual Q_DECL_DEPRECATED QgsAnnotationItemEditOperationTransientResultstransientEditResults (QgsAbstractAnnotationItemEditOperation *operation)
 Retrieves the results of a transient (in progress) edit operation on the item.
virtual QString type () const =0
 Returns a unique (untranslated) string identifying the type of item.
bool useSymbologyReferenceScale () const
 Returns true if the annotation item uses a symbology reference scale.
virtual bool writeXml (QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const =0
 Writes the item's state into an XML element.
int zIndex () const
 Returns the item's z index, which controls the order in which annotation items are rendered in the layer.

Static Public Member Functions

static QgsRectangle boundsFromPixelRect (const QgsMapToPixel *mapToPixel, const QPointF &centerPixel, double widthPixels, double heightPixels)
 Returns the axis-aligned bounds, in map coordinates, of a rectangle centered on centerPixel with size widthPixels by heightPixels, using mapToPixel for the pixel to map conversion.

Protected Member Functions

void copyCommonProperties (const QgsAnnotationItem *other) override
 Copies common properties from the base class from an other item.
bool readCommonProperties (const QDomElement &element, const QgsReadWriteContext &context) override
 Reads common properties from the base class from the given DOM element.
virtual void renderInBounds (QgsRenderContext &context, const QRectF &painterRect, QgsFeedback *feedback)=0
 Renders the item to the specified render context.
bool writeCommonProperties (QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const override
 Writes common properties from the base class into an XML element.
Protected Member Functions inherited from QgsAnnotationItem
void renderCallout (QgsRenderContext &context, const QRectF &rect, double angle, QgsCallout::QgsCalloutContext &calloutContext, QgsFeedback *feedback)
 Renders the item's callout.

Detailed Description

Abstract base class for annotation items which render annotations in a rectangular shape.

Subclasses should implement the pure virtual render() method which takes a painter bounds argument.

Since
QGIS 3.40

Definition at line 35 of file qgsannotationrectitem.h.

Constructor & Destructor Documentation

◆ QgsAnnotationRectItem()

QgsAnnotationRectItem::QgsAnnotationRectItem ( const QgsRectangle & bounds)

Constructor for QgsAnnotationRectItem, rendering the annotation within the specified bounds geometry.

Definition at line 39 of file qgsannotationrectitem.cpp.

◆ ~QgsAnnotationRectItem()

QgsAnnotationRectItem::~QgsAnnotationRectItem ( )
overridedefault

Member Function Documentation

◆ appliedRotation()

double QgsAnnotationRectItem::appliedRotation ( double mapRotation) const

Returns the effective on-screen rotation of the item, in degrees clockwise.

This is the item's own rotation(), to which mapRotation (the current map rotation, in degrees clockwise) is added when the item's rotationMode() is Qgis::SymbolRotationMode::RespectMapRotation and its placement mode is not Qgis::AnnotationPlacementMode::RelativeToMapFrame.

See also
rotation()
rotationMode()
Since
QGIS 4.4

Definition at line 67 of file qgsannotationrectitem.cpp.

◆ applyEditV2()

Qgis::AnnotationItemEditOperationResult QgsAnnotationRectItem::applyEditV2 ( QgsAbstractAnnotationItemEditOperation * operation,
const QgsAnnotationItemEditContext & context )
overridevirtual

Applies an edit operation to the item.

Since
QGIS 3.40

Reimplemented from QgsAnnotationItem.

Definition at line 313 of file qgsannotationrectitem.cpp.

◆ backgroundEnabled()

bool QgsAnnotationRectItem::backgroundEnabled ( ) const
inline

Returns true if the item's background should be rendered.

See also
setBackgroundEnabled()
backgroundSymbol()

Definition at line 197 of file qgsannotationrectitem.h.

◆ backgroundSymbol()

const QgsFillSymbol * QgsAnnotationRectItem::backgroundSymbol ( ) const

Returns the symbol used to render the item's background.

See also
backgroundEnabled()
setBackgroundSymbol()

Definition at line 716 of file qgsannotationrectitem.cpp.

◆ boundingBox() [1/2]

QgsRectangle QgsAnnotationRectItem::boundingBox ( ) const
overridevirtual

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

Implements QgsAnnotationItem.

Definition at line 577 of file qgsannotationrectitem.cpp.

◆ boundingBox() [2/2]

QgsRectangle QgsAnnotationRectItem::boundingBox ( QgsRenderContext & context) const
overridevirtual

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

Reimplemented from QgsAnnotationItem.

Definition at line 612 of file qgsannotationrectitem.cpp.

◆ bounds()

QgsRectangle QgsAnnotationRectItem::bounds ( ) const
inline

Returns the bounds of the item.

The coordinate reference system for the item will be the parent layer's QgsAnnotationLayer::crs().

When the placementMode() is Qgis::AnnotationPlacementMode::FixedSize then the item will be placed at the center of the bounds.

See also
setBounds()

Definition at line 63 of file qgsannotationrectitem.h.

◆ boundsFromPixelRect()

QgsRectangle QgsAnnotationRectItem::boundsFromPixelRect ( const QgsMapToPixel * mapToPixel,
const QPointF & centerPixel,
double widthPixels,
double heightPixels )
static

Returns the axis-aligned bounds, in map coordinates, of a rectangle centered on centerPixel with size widthPixels by heightPixels, using mapToPixel for the pixel to map conversion.

Note
Not available in Python bindings
Since
QGIS 4.4

Definition at line 121 of file qgsannotationrectitem.cpp.

◆ copyCommonProperties()

void QgsAnnotationRectItem::copyCommonProperties ( const QgsAnnotationItem * other)
overrideprotectedvirtual

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

Since
QGIS 3.22

Reimplemented from QgsAnnotationItem.

Definition at line 736 of file qgsannotationrectitem.cpp.

◆ fixedSize()

QSizeF QgsAnnotationRectItem::fixedSize ( ) const

Returns the fixed size to use for the item, when the placementMode() is Qgis::AnnotationPlacementMode::FixedSize.

Units are retrieved via fixedSizeUnit()

See also
setFixedSize()
fixedSizeUnit()

Definition at line 821 of file qgsannotationrectitem.cpp.

◆ fixedSizeUnit()

Qgis::RenderUnit QgsAnnotationRectItem::fixedSizeUnit ( ) const

Returns the units to use for fixed item sizes, when the placementMode() is Qgis::AnnotationPlacementMode::FixedSize.

See also
setFixedSizeUnit()
fixedSize()

Definition at line 831 of file qgsannotationrectitem.cpp.

◆ flags()

Qgis::AnnotationItemFlags QgsAnnotationRectItem::flags ( ) const
overridevirtual

Returns item flags.

Since
QGIS 3.22

Reimplemented from QgsAnnotationItem.

Definition at line 53 of file qgsannotationrectitem.cpp.

◆ frameEnabled()

bool QgsAnnotationRectItem::frameEnabled ( ) const
inline

Returns true if the item's frame should be rendered.

See also
setFrameEnabled()
frameSymbol()

Definition at line 231 of file qgsannotationrectitem.h.

◆ frameSymbol()

const QgsFillSymbol * QgsAnnotationRectItem::frameSymbol ( ) const

Returns the symbol used to render the item's frame.

See also
frameEnabled()
setFrameSymbol()

Definition at line 726 of file qgsannotationrectitem.cpp.

◆ nodesV2()

QList< QgsAnnotationItemNode > QgsAnnotationRectItem::nodesV2 ( const QgsAnnotationItemEditContext & context) const
overridevirtual

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

Since
QGIS 3.40

Reimplemented from QgsAnnotationItem.

Definition at line 259 of file qgsannotationrectitem.cpp.

◆ placementMode()

Qgis::AnnotationPlacementMode QgsAnnotationRectItem::placementMode ( ) const

Returns the placement mode for the item.

See also
setPlacementMode()

Definition at line 841 of file qgsannotationrectitem.cpp.

◆ readCommonProperties()

bool QgsAnnotationRectItem::readCommonProperties ( const QDomElement & element,
const QgsReadWriteContext & context )
overrideprotectedvirtual

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

See also
readXml()
Since
QGIS 3.22

Reimplemented from QgsAnnotationItem.

Definition at line 790 of file qgsannotationrectitem.cpp.

◆ render()

void QgsAnnotationRectItem::render ( QgsRenderContext & context,
QgsFeedback * feedback )
overridevirtual

Renders the item to the specified render context.

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

Implements QgsAnnotationItem.

Definition at line 130 of file qgsannotationrectitem.cpp.

◆ renderInBounds()

virtual void QgsAnnotationRectItem::renderInBounds ( QgsRenderContext & context,
const QRectF & painterRect,
QgsFeedback * feedback )
protectedpure virtual

Renders the item to the specified render context.

The painterRect argument specifies the bounds in painter units where the rectangular item should be rendered within.

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

Implemented in QgsAnnotationPictureItem, and QgsAnnotationRectangleTextItem.

◆ rotatedBoundsGeometry()

QgsGeometry QgsAnnotationRectItem::rotatedBoundsGeometry ( const QgsRectangle & layerBounds,
const QgsRenderContext & renderContext ) const

Returns the polygon geometry (in layer coordinates) for the item occupying the given layerBounds, rotated to match how the item is rendered in renderContext.

Note
Not available in Python bindings
Since
QGIS 4.4

Definition at line 75 of file qgsannotationrectitem.cpp.

◆ rotation()

double QgsAnnotationRectItem::rotation ( ) const
inline

Returns the rotation of the item, in degrees clockwise.

See also
setRotation()
Since
QGIS 4.4

Definition at line 133 of file qgsannotationrectitem.h.

◆ rotationMode()

Qgis::SymbolRotationMode QgsAnnotationRectItem::rotationMode ( ) const
inline

Returns the method used to render the item with respect to the rotation of the map.

See also
setRotationMode()
Since
QGIS 4.4

Definition at line 149 of file qgsannotationrectitem.h.

◆ setBackgroundEnabled()

void QgsAnnotationRectItem::setBackgroundEnabled ( bool enabled)
inline

Sets whether the item's background should be rendered.

See also
backgroundEnabled()
setBackgroundSymbol()

Definition at line 205 of file qgsannotationrectitem.h.

◆ setBackgroundSymbol()

void QgsAnnotationRectItem::setBackgroundSymbol ( QgsFillSymbol * symbol)

Sets the symbol used to render the item's background.

The item takes ownership of the symbol.

See also
backgroundSymbol()
setBackgroundEnabled()

Definition at line 721 of file qgsannotationrectitem.cpp.

◆ setBounds()

void QgsAnnotationRectItem::setBounds ( const QgsRectangle & bounds)

Sets the bounds of the item.

The coordinate reference system for the bounds will be the parent layer's QgsAnnotationLayer::crs().

When the placementMode() is Qgis::AnnotationPlacementMode::FixedSize then the item will be placed at the center of the bounds.

See also
bounds()

Definition at line 711 of file qgsannotationrectitem.cpp.

◆ setFixedSize()

void QgsAnnotationRectItem::setFixedSize ( const QSizeF & size)

Sets the fixed size to use for the item, when the placementMode() is Qgis::AnnotationPlacementMode::FixedSize.

Units are set via setFixedSizeUnit()

See also
fixedSize()
setFixedSizeUnit()

Definition at line 826 of file qgsannotationrectitem.cpp.

◆ setFixedSizeUnit()

void QgsAnnotationRectItem::setFixedSizeUnit ( Qgis::RenderUnit unit)

Sets the unit to use for fixed item sizes, when the placementMode() is Qgis::AnnotationPlacementMode::FixedSize.

See also
fixedSizeUnit()
setFixedSize()

Definition at line 836 of file qgsannotationrectitem.cpp.

◆ setFrameEnabled()

void QgsAnnotationRectItem::setFrameEnabled ( bool enabled)
inline

Sets whether the item's frame should be rendered.

See also
frameEnabled()
setFrameSymbol()

Definition at line 239 of file qgsannotationrectitem.h.

◆ setFrameSymbol()

void QgsAnnotationRectItem::setFrameSymbol ( QgsFillSymbol * symbol)

Sets the symbol used to render the item's frame.

The item takes ownership of the symbol.

See also
frameSymbol()
setBackgroundEnabled()

Definition at line 731 of file qgsannotationrectitem.cpp.

◆ setPlacementMode()

void QgsAnnotationRectItem::setPlacementMode ( Qgis::AnnotationPlacementMode mode)

Sets the placement mode for the item.

See also
placementMode()

Definition at line 846 of file qgsannotationrectitem.cpp.

◆ setRotation()

void QgsAnnotationRectItem::setRotation ( double rotation)
inline

Sets the rotation of the item, in degrees clockwise.

See also
rotation()
Since
QGIS 4.4

Definition at line 141 of file qgsannotationrectitem.h.

◆ setRotationMode()

void QgsAnnotationRectItem::setRotationMode ( Qgis::SymbolRotationMode mode)
inline

Sets the mode used to render the item with respect to the rotation of the map.

See also
rotationMode()
Since
QGIS 4.4

Definition at line 157 of file qgsannotationrectitem.h.

◆ transientEditResultsV2()

QgsAnnotationItemEditOperationTransientResults * QgsAnnotationRectItem::transientEditResultsV2 ( QgsAbstractAnnotationItemEditOperation * operation,
const QgsAnnotationItemEditContext & context )
overridevirtual

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

Since
QGIS 3.40

Reimplemented from QgsAnnotationItem.

Definition at line 432 of file qgsannotationrectitem.cpp.

◆ writeCommonProperties()

bool QgsAnnotationRectItem::writeCommonProperties ( QDomElement & element,
QDomDocument & document,
const QgsReadWriteContext & context ) const
overrideprotectedvirtual

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

See also
writeXml()
Since
QGIS 3.22

Reimplemented from QgsAnnotationItem.

Definition at line 758 of file qgsannotationrectitem.cpp.


The documentation for this class was generated from the following files: