QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgsannotationlayer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsannotationlayer.h
3  ----------------
4  copyright : (C) 2019 by Sandro Mani
5  email : smani at sourcepole dot ch
6  ***************************************************************************/
7 
8 /***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #ifndef QGSANNOTATIONLAYER_H
18 #define QGSANNOTATIONLAYER_H
19 
20 #include "qgis_core.h"
21 #include "qgis_sip.h"
22 #include "qgsmaplayer.h"
23 #include "qgsmaplayerrenderer.h"
24 
25 class QgsAnnotationItem;
26 
27 
39 class CORE_EXPORT QgsAnnotationLayer : public QgsMapLayer
40 {
41  Q_OBJECT
42 
43  public:
44 
49  struct LayerOptions
50  {
51 
55  explicit LayerOptions( const QgsCoordinateTransformContext &transformContext )
56  : transformContext( transformContext )
57  {}
58 
63 
64  };
65 
66 
72  QgsAnnotationLayer( const QString &name, const QgsAnnotationLayer::LayerOptions &options );
73  ~QgsAnnotationLayer() override;
74 
75 #ifdef SIP_RUN
76  SIP_PYOBJECT __repr__();
77  % MethodCode
78  QString str = QStringLiteral( "<QgsAnnotationLayer: '%1'>" ).arg( sipCpp->name() );
79  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
80  % End
81 #endif
82 
86  void reset();
87 
95  QString addItem( QgsAnnotationItem *item SIP_TRANSFER );
96 
100  bool removeItem( const QString &id );
101 
105  void clear();
106 
110  bool isEmpty() const;
111 
118  QMap<QString, QgsAnnotationItem *> items() const { return mItems; }
119 
120  QgsAnnotationLayer *clone() const override SIP_FACTORY;
121  QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
122  QgsRectangle extent() const override;
123  void setTransformContext( const QgsCoordinateTransformContext &context ) override;
124  bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override;
125  bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
126  bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &, StyleCategories categories = AllStyleCategories ) const override;
127  bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override;
128 
129  private:
130  QMap<QString, QgsAnnotationItem *> mItems;
131  QgsCoordinateTransformContext mTransformContext;
132 };
133 
134 #endif // QGSANNOTATIONLAYER_H
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
Represents a map layer containing a set of georeferenced annotations, e.g.
QMap< QString, QgsAnnotationItem * > items() const
Returns a map of items contained in the layer, by unique item ID.
Contains information about the context in which a coordinate transform is executed.
Base class for utility classes that encapsulate information necessary for rendering of map layers.
Base class for all map layer types.
Definition: qgsmaplayer.h:70
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
The class is used as a container of context for various read/write operations on other objects.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
Contains information about the context of a rendering operation.
#define str(x)
Definition: qgis.cpp:37
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:76
Setting options for loading annotation layers.
LayerOptions(const QgsCoordinateTransformContext &transformContext)
Constructor for LayerOptions.
QgsCoordinateTransformContext transformContext
Coordinate transform context.