QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsannotationmanager.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsannotationmanager.h
3 ----------------------
4 Date : January 2017
5 Copyright : (C) 2017 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSANNOTATIONMANAGER_H
17#define QGSANNOTATIONMANAGER_H
18
19#include "qgis.h"
20#include "qgis_core.h"
21
22#include <QDomElement>
23#include <QObject>
24
26class QgsProject;
27class QgsAnnotation;
32
47class CORE_EXPORT QgsAnnotationManager : public QObject
48{
49 Q_OBJECT
50
51 public:
52
57 explicit QgsAnnotationManager( QgsProject *project SIP_TRANSFERTHIS = nullptr );
58
59 ~QgsAnnotationManager() override;
60
67 bool addAnnotation( QgsAnnotation *annotation SIP_TRANSFER );
68
78 bool removeAnnotation( QgsAnnotation *annotation );
79
84 void clear();
85
90 QList< QgsAnnotation * > annotations() const;
91
98 QList< QgsAnnotation * > cloneAnnotations() const SIP_FACTORY;
99
105 bool readXml( const QDomElement &element, const QgsReadWriteContext &context );
106
119 bool readXmlAndUpgradeToAnnotationLayerItems( const QDomElement &element, const QgsReadWriteContext &context,
120 QgsAnnotationLayer *layer, const QgsCoordinateTransformContext &transformContext ) SIP_SKIP;
121
126 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
127
137 bool accept( QgsStyleEntityVisitorInterface *visitor ) const;
138
139 signals:
140
142 void annotationAdded( QgsAnnotation *annotation );
143
146
149
150 private:
151
152 bool readXmlPrivate( const QDomElement &element, const QgsReadWriteContext &context, QgsAnnotationLayer *layer, const QgsCoordinateTransformContext &transformContext );
153 static std::unique_ptr< QgsAnnotationItem > convertToAnnotationItem( QgsAnnotation *annotation, QgsAnnotationLayer *layer,
154 const QgsCoordinateTransformContext &transformContext );
155
156 QgsProject *mProject = nullptr;
157
158 QList< QgsAnnotation * > mAnnotations;
159
160 QgsAnnotation *createAnnotationFromXml( const QDomElement &element, const QgsReadWriteContext &context );
161
162};
163
164#endif // QGSANNOTATIONMANAGER_H
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
Represents a map layer containing a set of georeferenced annotations, e.g.
QList< QgsAnnotation * > annotations() const
Returns a list of all annotations contained in the manager.
QList< QgsAnnotation * > cloneAnnotations() const
Returns a list containing clones of all annotations contained in the manager.
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Returns a DOM element representing the state of the manager.
void annotationRemoved()
Emitted when an annotation was removed from the manager.
QgsAnnotationManager(QgsProject *project=nullptr)
Constructor for QgsAnnotationManager.
void annotationAboutToBeRemoved(QgsAnnotation *annotation)
Emitted when an annotation is about to be removed from the manager.
bool readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads the manager's state from a DOM element, restoring all annotations present in the XML document.
bool readXmlAndUpgradeToAnnotationLayerItems(const QDomElement &element, const QgsReadWriteContext &context, QgsAnnotationLayer *layer, const QgsCoordinateTransformContext &transformContext)
Reads the manager's state from a DOM element, restoring annotations present in the XML document.
bool removeAnnotation(QgsAnnotation *annotation)
Removes an annotation from the manager.
bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified style entity visitor, causing it to visit all style entities associated within ...
void clear()
Removes and deletes all annotations from the manager.
bool addAnnotation(QgsAnnotation *annotation)
Adds an annotation to the manager.
void annotationAdded(QgsAnnotation *annotation)
Emitted when a annotation has been added to the manager.
Abstract base class for annotation items which are drawn over a map.
Contains information about the context in which a coordinate transform is executed.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:109
A container for the context for various read/write operations on objects.
An interface for classes which can visit style entity (e.g.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:84