QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
|
Abstract base class for annotation items which are drawn over a map. More...
#include <qgsannotation.h>
Signals | |
void | appearanceChanged () |
Emitted whenever the annotation's appearance changes. More... | |
void | mapLayerChanged () |
Emitted when the map layer associated with the annotation changes. More... | |
void | moved () |
Emitted when the annotation's position has changed and items need to be moved to reflect this. More... | |
Public Member Functions | |
QgsAnnotation (QObject *parent=nullptr) | |
Constructor for QgsAnnotation. More... | |
~QgsAnnotation () override | |
virtual bool | accept (QgsStyleEntityVisitorInterface *visitor) const |
Accepts the specified style entity visitor, causing it to visit all style entities associated within the annotation. More... | |
QgsFeature | associatedFeature () const |
Returns the feature associated with the annotation, or an invalid feature if none has been set. More... | |
virtual QgsAnnotation * | clone () const =0 |
Clones the annotation, returning a new copy of the annotation reflecting the annotation's current state. More... | |
QgsMargins | contentsMargin () const |
Returns the margins (in millimeters) between the outside of the frame and the annotation content. More... | |
QgsFillSymbol * | fillSymbol () const |
Returns the symbol that is used for rendering the annotation frame. More... | |
Q_DECL_DEPRECATED QPointF | frameOffsetFromReferencePoint () const |
Returns the annotation's frame's offset (in pixels) from the mapPosition() reference point. More... | |
QPointF | frameOffsetFromReferencePointMm () const |
Returns the annotation's frame's offset (in millimeters) from the mapPosition() reference point. More... | |
Q_DECL_DEPRECATED QSizeF | frameSize () const |
Returns the size (in pixels) of the annotation's frame (the main area in which the annotation's content is drawn). More... | |
QSizeF | frameSizeMm () const |
Returns the size (in millimeters) of the annotation's frame (the main area in which the annotation's content is drawn). More... | |
bool | hasFixedMapPosition () const |
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... | |
bool | isVisible () const |
Returns true if the annotation is visible and should be rendered. More... | |
QgsMapLayer * | mapLayer () const |
Returns the map layer associated with the annotation. More... | |
QgsPointXY | mapPosition () const |
Returns the map position of the annotation, if it is attached to a fixed map position. More... | |
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... | |
QgsMarkerSymbol * | markerSymbol () const |
Returns the symbol that is drawn at the annotation's map position. More... | |
virtual void | readXml (const QDomElement &itemElem, const QgsReadWriteContext &context)=0 |
Restores the annotation's state from a DOM element. More... | |
QPointF | relativePosition () const |
Returns the relative position of the annotation, if it is not attached to a fixed map position. More... | |
void | render (QgsRenderContext &context) const |
Renders the annotation to a target render context. More... | |
virtual void | setAssociatedFeature (const QgsFeature &feature) |
Sets the feature associated with the annotation. More... | |
void | setContentsMargin (const QgsMargins &margins) |
Sets the margins (in millimeters) between the outside of the frame and the annotation content. More... | |
void | setFillSymbol (QgsFillSymbol *symbol) |
Sets the fill symbol used for rendering the annotation frame. More... | |
Q_DECL_DEPRECATED void | setFrameOffsetFromReferencePoint (QPointF offset) |
Sets the annotation's frame's offset (in pixels) from the mapPosition() reference point. More... | |
void | setFrameOffsetFromReferencePointMm (QPointF offset) |
Sets the annotation's frame's offset (in millimeters) from the mapPosition() reference point. More... | |
Q_DECL_DEPRECATED void | setFrameSize (QSizeF size) |
Sets the size (in pixels) of the annotation's frame (the main area in which the annotation's content is drawn). More... | |
void | setFrameSizeMm (QSizeF size) |
Sets the size (in millimeters) of the annotation's frame (the main area in which the annotation's content is drawn). More... | |
void | setHasFixedMapPosition (bool fixed) |
Sets whether the annotation is attached to a fixed map position, or uses a position relative to the current map extent. More... | |
void | setMapLayer (QgsMapLayer *layer) |
Sets the map layer associated with the annotation. More... | |
void | setMapPosition (const QgsPointXY &position) |
Sets the map position of the annotation, if it is attached to a fixed map position. More... | |
void | setMapPositionCrs (const QgsCoordinateReferenceSystem &crs) |
Sets the CRS of the map position. More... | |
void | setMarkerSymbol (QgsMarkerSymbol *symbol) |
Sets the symbol that is drawn at the annotation's map position. More... | |
void | setRelativePosition (QPointF position) |
Sets the relative position of the annotation, if it is not attached to a fixed map position. More... | |
void | setVisible (bool visible) |
Sets whether the annotation is visible and should be rendered. More... | |
virtual void | writeXml (QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context) const =0 |
Writes the annotation state to a DOM element. More... | |
Protected Member Functions | |
void | _readXml (const QDomElement &annotationElem, const QgsReadWriteContext &context) |
Reads common annotation properties from a DOM element. More... | |
void | _writeXml (QDomElement &itemElem, QDomDocument &doc, const QgsReadWriteContext &context) const |
Writes common annotation properties to a DOM element. More... | |
void | copyCommonProperties (QgsAnnotation *target) const |
Copies common annotation properties to the targe annotation. More... | |
virtual QSizeF | minimumFrameSize () const |
Returns the minimum frame size for the annotation. More... | |
virtual void | renderAnnotation (QgsRenderContext &context, QSizeF size) const =0 |
Renders the annotation's contents to a target /a context at the specified /a size. More... | |
Properties | |
QSizeF | frameSize |
bool | hasFixedMapPosition |
QgsPointXY | mapPosition |
bool | visible |
Abstract base class for annotation items which are drawn over a map.
QgsAnnotation is an abstract base 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().
Derived classes should implement their custom painting routines within a renderAnnotation() override.
Definition at line 53 of file qgsannotation.h.
QgsAnnotation::QgsAnnotation | ( | QObject * | parent = nullptr | ) |
Constructor for QgsAnnotation.
Definition at line 33 of file qgsannotation.cpp.
|
overridedefault |
|
protected |
Reads common annotation properties from a DOM element.
This method should be called from subclasses in their readXml method.
Definition at line 308 of file qgsannotation.cpp.
|
protected |
Writes common annotation properties to a DOM element.
This method should be called from subclasses in their writeXml method.
Definition at line 263 of file qgsannotation.cpp.
|
virtual |
Accepts the specified style entity visitor, causing it to visit all style entities associated within the annotation.
Returns true
if the visitor should continue visiting other objects, or false
if visiting should be canceled.
Definition at line 193 of file qgsannotation.cpp.
|
signal |
Emitted whenever the annotation's appearance changes.
|
inline |
Returns the feature associated with the annotation, or an invalid feature if none has been set.
Definition at line 307 of file qgsannotation.h.
|
pure virtual |
Clones the annotation, returning a new copy of the annotation reflecting the annotation's current state.
Implemented in QgsHtmlAnnotation, QgsSvgAnnotation, QgsTextAnnotation, and QgsFormAnnotation.
|
inline |
Returns the margins (in millimeters) between the outside of the frame and the annotation content.
Definition at line 237 of file qgsannotation.h.
|
protected |
Copies common annotation properties to the targe annotation.
Can be used within QgsAnnotation::clone() implementations to assist with creating copies.
Definition at line 409 of file qgsannotation.cpp.
QgsFillSymbol * QgsAnnotation::fillSymbol | ( | ) | const |
Returns the symbol that is used for rendering the annotation frame.
Definition at line 135 of file qgsannotation.cpp.
QPointF QgsAnnotation::frameOffsetFromReferencePoint | ( | ) | const |
Returns the annotation's frame's offset (in pixels) from the mapPosition() reference point.
Definition at line 91 of file qgsannotation.cpp.
|
inline |
Returns the annotation's frame's offset (in millimeters) from the mapPosition() reference point.
Definition at line 191 of file qgsannotation.h.
QSizeF QgsAnnotation::frameSize | ( | ) | const |
Returns the size (in pixels) of the annotation's frame (the main area in which the annotation's content is drawn).
Definition at line 110 of file qgsannotation.cpp.
|
inline |
Returns the size (in millimeters) of the annotation's frame (the main area in which the annotation's content is drawn).
Definition at line 223 of file qgsannotation.h.
|
inline |
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.
Definition at line 111 of file qgsannotation.h.
|
inline |
Returns true
if the annotation is visible and should be rendered.
Definition at line 95 of file qgsannotation.h.
|
inline |
Returns the map layer associated with the annotation.
Annotations can be associated with a map layer if their visibility should be synchronized with the layer's visibility.
Definition at line 292 of file qgsannotation.h.
|
signal |
Emitted when the map layer associated with the annotation changes.
|
inline |
Returns the map position of the annotation, if it is attached to a fixed map position.
Definition at line 127 of file qgsannotation.h.
|
inline |
Returns the CRS of the map position, or an invalid CRS if the annotation does not have a fixed map position.
Definition at line 141 of file qgsannotation.h.
|
inline |
Returns the symbol that is drawn at the annotation's map position.
Definition at line 284 of file qgsannotation.h.
|
protectedvirtual |
Returns the minimum frame size for the annotation.
Subclasses should implement this if they cannot be resized smaller than a certain minimum size.
Reimplemented in QgsHtmlAnnotation, and QgsFormAnnotation.
Definition at line 219 of file qgsannotation.cpp.
|
signal |
Emitted when the annotation's position has changed and items need to be moved to reflect this.
|
pure virtual |
Restores the annotation's state from a DOM element.
Derived classes should call _readXml() within their implementation of this method.
Implemented in QgsHtmlAnnotation, QgsSvgAnnotation, QgsTextAnnotation, and QgsFormAnnotation.
|
inline |
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.
Definition at line 155 of file qgsannotation.h.
void QgsAnnotation::render | ( | QgsRenderContext & | context | ) | const |
Renders the annotation to a target render context.
Definition at line 140 of file qgsannotation.cpp.
|
protectedpure virtual |
Renders the annotation's contents to a target /a context at the specified /a size.
Derived classes should implement their custom annotation drawing logic here.
Implemented in QgsHtmlAnnotation, QgsSvgAnnotation, QgsTextAnnotation, and QgsFormAnnotation.
|
virtual |
Sets the feature associated with the annotation.
Reimplemented in QgsHtmlAnnotation, and QgsFormAnnotation.
Definition at line 188 of file qgsannotation.cpp.
void QgsAnnotation::setContentsMargin | ( | const QgsMargins & | margins | ) |
Sets the margins (in millimeters) between the outside of the frame and the annotation content.
Definition at line 123 of file qgsannotation.cpp.
void QgsAnnotation::setFillSymbol | ( | QgsFillSymbol * | symbol | ) |
Sets the fill symbol used for rendering the annotation frame.
Ownership of the symbol is transferred to the annotation.
Definition at line 129 of file qgsannotation.cpp.
void QgsAnnotation::setFrameOffsetFromReferencePoint | ( | QPointF | offset | ) |
Sets the annotation's frame's offset (in pixels) from the mapPosition() reference point.
Definition at line 85 of file qgsannotation.cpp.
void QgsAnnotation::setFrameOffsetFromReferencePointMm | ( | QPointF | offset | ) |
Sets the annotation's frame's offset (in millimeters) from the mapPosition() reference point.
Definition at line 96 of file qgsannotation.cpp.
void QgsAnnotation::setFrameSize | ( | QSizeF | size | ) |
Sets the size (in pixels) of the annotation's frame (the main area in which the annotation's content is drawn).
Definition at line 104 of file qgsannotation.cpp.
void QgsAnnotation::setFrameSizeMm | ( | QSizeF | size | ) |
Sets the size (in millimeters) of the annotation's frame (the main area in which the annotation's content is drawn).
Definition at line 115 of file qgsannotation.cpp.
void QgsAnnotation::setHasFixedMapPosition | ( | bool | fixed | ) |
Sets whether the annotation is attached to a fixed map position, or uses a position relative to the current map extent.
Definition at line 58 of file qgsannotation.cpp.
void QgsAnnotation::setMapLayer | ( | QgsMapLayer * | layer | ) |
Sets the map layer associated with the annotation.
Annotations can be associated with a map layer if their visibility should be synchronized with the layer's visibility.
Definition at line 182 of file qgsannotation.cpp.
void QgsAnnotation::setMapPosition | ( | const QgsPointXY & | position | ) |
Sets the map position of the annotation, if it is attached to a fixed map position.
Definition at line 67 of file qgsannotation.cpp.
void QgsAnnotation::setMapPositionCrs | ( | const QgsCoordinateReferenceSystem & | crs | ) |
Sets the CRS of the map position.
Definition at line 73 of file qgsannotation.cpp.
void QgsAnnotation::setMarkerSymbol | ( | QgsMarkerSymbol * | symbol | ) |
Sets the symbol that is drawn at the annotation's map position.
Ownership of the symbol is transferred to the annotation.
Definition at line 176 of file qgsannotation.cpp.
void QgsAnnotation::setRelativePosition | ( | QPointF | position | ) |
Sets 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.
Definition at line 79 of file qgsannotation.cpp.
void QgsAnnotation::setVisible | ( | bool | visible | ) |
Sets whether the annotation is visible and should be rendered.
Definition at line 49 of file qgsannotation.cpp.
|
pure virtual |
Writes the annotation state to a DOM element.
Derived classes should call _writeXml() within their implementation of this method.
Implemented in QgsHtmlAnnotation, QgsSvgAnnotation, QgsTextAnnotation, and QgsFormAnnotation.
|
readwrite |
Definition at line 53 of file qgsannotation.h.
|
readwrite |
Definition at line 53 of file qgsannotation.h.
|
readwrite |
Definition at line 53 of file qgsannotation.h.
|
readwrite |
Definition at line 53 of file qgsannotation.h.