QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
QgsHtmlAnnotation Class Reference

An annotation item that embeds HTML content. More...

#include <qgshtmlannotation.h>

Inheritance diagram for QgsHtmlAnnotation:
Inheritance graph
[legend]

Public Member Functions

 QgsHtmlAnnotation (QObject *parent=nullptr)
 Constructor for QgsHtmlAnnotation. More...
 
QgsHtmlAnnotationclone () const override
 Clones the annotation, returning a new copy of the annotation reflecting the annotation's current state. More...
 
QSizeF minimumFrameSize () const override
 Returns the minimum frame size for the annotation. More...
 
void readXml (const QDomElement &itemElem, const QgsReadWriteContext &context) override
 Restores the annotation's state from a DOM element. More...
 
void setAssociatedFeature (const QgsFeature &feature) override
 Sets the feature associated with the annotation. More...
 
void setSourceFile (const QString &htmlFile)
 Sets the file path for the source HTML file. More...
 
QString sourceFile () const
 Returns the file path for the source HTML file. More...
 
void writeXml (QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context) const override
 Writes the annotation state to a DOM element. More...
 
- Public Member Functions inherited from QgsAnnotation
 QgsAnnotation (QObject *parent=nullptr)
 Constructor for QgsAnnotation. More...
 
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...
 
QgsMargins contentsMargin () const
 Returns the margins (in millimeters) between the outside of the frame and the annotation content. More...
 
QgsFillSymbolfillSymbol () 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...
 
QgsMapLayermapLayer () 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...
 
QgsMarkerSymbolmarkerSymbol () const
 Returns the symbol that is drawn at the annotation's map position. 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...
 
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...
 

Static Public Member Functions

static QgsHtmlAnnotationcreate ()
 Returns a new QgsHtmlAnnotation object. More...
 

Protected Member Functions

void renderAnnotation (QgsRenderContext &context, QSizeF size) const override
 Renders the annotation's contents to a target /a context at the specified /a size. More...
 
- Protected Member Functions inherited from QgsAnnotation
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...
 

Additional Inherited Members

- Signals inherited from QgsAnnotation
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...
 
- Properties inherited from QgsAnnotation
QSizeF frameSize
 
bool hasFixedMapPosition
 
QgsPointXY mapPosition
 
bool visible
 

Detailed Description

An annotation item that embeds HTML content.

Since
QGIS 3.0

Definition at line 35 of file qgshtmlannotation.h.

Constructor & Destructor Documentation

◆ QgsHtmlAnnotation()

QgsHtmlAnnotation::QgsHtmlAnnotation ( QObject *  parent = nullptr)

Constructor for QgsHtmlAnnotation.

Definition at line 40 of file qgshtmlannotation.cpp.

Member Function Documentation

◆ clone()

QgsHtmlAnnotation * QgsHtmlAnnotation::clone ( ) const
overridevirtual

Clones the annotation, returning a new copy of the annotation reflecting the annotation's current state.

Implements QgsAnnotation.

Definition at line 51 of file qgshtmlannotation.cpp.

◆ create()

static QgsHtmlAnnotation* QgsHtmlAnnotation::create ( )
inlinestatic

Returns a new QgsHtmlAnnotation object.

Definition at line 69 of file qgshtmlannotation.h.

◆ minimumFrameSize()

QSizeF QgsHtmlAnnotation::minimumFrameSize ( ) const
overridevirtual

Returns the minimum frame size for the annotation.

Subclasses should implement this if they cannot be resized smaller than a certain minimum size.

Reimplemented from QgsAnnotation.

Definition at line 96 of file qgshtmlannotation.cpp.

◆ readXml()

void QgsHtmlAnnotation::readXml ( const QDomElement &  itemElem,
const QgsReadWriteContext context 
)
overridevirtual

Restores the annotation's state from a DOM element.

Derived classes should call _readXml() within their implementation of this method.

See also
writeXml()
_readXml()

Implements QgsAnnotation.

Definition at line 119 of file qgshtmlannotation.cpp.

◆ renderAnnotation()

void QgsHtmlAnnotation::renderAnnotation ( QgsRenderContext context,
QSizeF  size 
) const
overrideprotectedvirtual

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.

Implements QgsAnnotation.

Definition at line 79 of file qgshtmlannotation.cpp.

◆ setAssociatedFeature()

void QgsHtmlAnnotation::setAssociatedFeature ( const QgsFeature feature)
overridevirtual

Sets the feature associated with the annotation.

See also
associatedFeature()

Reimplemented from QgsAnnotation.

Definition at line 140 of file qgshtmlannotation.cpp.

◆ setSourceFile()

void QgsHtmlAnnotation::setSourceFile ( const QString &  htmlFile)

Sets the file path for the source HTML file.

See also
sourceFile()

Definition at line 59 of file qgshtmlannotation.cpp.

◆ sourceFile()

QString QgsHtmlAnnotation::sourceFile ( ) const
inline

Returns the file path for the source HTML file.

See also
setSourceFile()

Definition at line 59 of file qgshtmlannotation.h.

◆ writeXml()

void QgsHtmlAnnotation::writeXml ( QDomElement &  elem,
QDomDocument &  doc,
const QgsReadWriteContext context 
) const
overridevirtual

Writes the annotation state to a DOM element.

Derived classes should call _writeXml() within their implementation of this method.

See also
readXml()
_writeXml()

Implements QgsAnnotation.

Definition at line 110 of file qgshtmlannotation.cpp.


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