QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
Public Member Functions | List of all members
QgsAnnotation Class Referenceabstract

An interface for annotation items which are drawn over a map. More...

#include <qgsannotation.h>

Inheritance diagram for QgsAnnotation:
Inheritance graph
[legend]

Public Member Functions

virtual QgsPoint mapPosition () const
 Returns the map position of the annotation, if it is attached to a fixed map position. More...
 
virtual QgsCoordinateReferenceSystem mapPositionCrs () const
 Returns the CRS of the map position, or an invalid CRS if the annotation does not have a fixed map position. More...
 
virtual bool mapPositionFixed () const =0
 Returns true if the annotation is attached to a fixed map position, or false if the annotation uses a position relative to the current map extent. More...
 
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr)=0
 Paint the annotation to a destination painter. More...
 
virtual QPointF relativePosition () const
 Returns the relative position of the annotation, if it is not attached to a fixed map position. More...
 
virtual double scaleFactor () const =0
 Returns a scaling factor which should be applied to painters before rendering the item. More...
 
virtual void setItemData (int role, const QVariant &value)=0
 deprecated - do not use More...
 
virtual bool showItem () const =0
 Returns true if the annotation should be shown. More...
 

Detailed Description

An interface for annotation items which are drawn over a map.

Note
added in QGIS 2.18

QgsAnnotation is an interface class for map annotation items. These annotations can be drawn within a map, and have either a fixed map position (retrieved using mapPosition()) or are placed relative to the map's frame (retrieved using relativePosition()). Annotations with a fixed map position also have a corresponding QgsCoordinateReferenceSystem, which can be determined by calling mapPositionCrs().

Definition at line 40 of file qgsannotation.h.

Member Function Documentation

◆ mapPosition()

virtual QgsPoint QgsAnnotation::mapPosition ( ) const
inlinevirtual

Returns the map position of the annotation, if it is attached to a fixed map position.

See also
mapPositionFixed()
mapPositionCrs()

Reimplemented in QgsAnnotationItem.

Definition at line 61 of file qgsannotation.h.

◆ mapPositionCrs()

virtual QgsCoordinateReferenceSystem QgsAnnotation::mapPositionCrs ( ) const
inlinevirtual

Returns the CRS of the map position, or an invalid CRS if the annotation does not have a fixed map position.

Reimplemented in QgsAnnotationItem.

Definition at line 66 of file qgsannotation.h.

◆ mapPositionFixed()

virtual bool QgsAnnotation::mapPositionFixed ( ) const
pure virtual

Returns true if the annotation is attached to a fixed map position, or false if the annotation uses a position relative to the current map extent.

See also
mapPosition()
relativePositon()

Implemented in QgsAnnotationItem.

◆ paint()

virtual void QgsAnnotation::paint ( QPainter painter,
const QStyleOptionGraphicsItem option,
QWidget widget = nullptr 
)
pure virtual

Paint the annotation to a destination painter.

Implemented in QgsAnnotationItem, QgsHtmlAnnotationItem, and QgsFormAnnotationItem.

◆ relativePosition()

virtual QPointF QgsAnnotation::relativePosition ( ) const
inlinevirtual

Returns the relative position of the annotation, if it is not attached to a fixed map position.

The coordinates in the return point should be between 0 and 1, and represent the relative percentage for the position compared to the map width and height.

See also
mapPositionFixed()

Reimplemented in QgsAnnotationItem.

Definition at line 73 of file qgsannotation.h.

◆ scaleFactor()

virtual double QgsAnnotation::scaleFactor ( ) const
pure virtual

Returns a scaling factor which should be applied to painters before rendering the item.

Implemented in QgsAnnotationItem.

◆ setItemData()

virtual void QgsAnnotation::setItemData ( int  role,
const QVariant value 
)
pure virtual

deprecated - do not use

Implemented in QgsAnnotationItem.

◆ showItem()

virtual bool QgsAnnotation::showItem ( ) const
pure virtual

Returns true if the annotation should be shown.

Implemented in QgsAnnotationItem.


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