QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
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
28class QgsPaintEffect;
29
30
32class QgsAnnotationLayerSpatialIndex;
34
46class CORE_EXPORT QgsAnnotationLayer : public QgsMapLayer
47{
48 Q_OBJECT
49
50 public:
51
57 {
58
62 explicit LayerOptions( const QgsCoordinateTransformContext &transformContext )
63 : transformContext( transformContext )
64 {}
65
70
71 };
72
73
79 QgsAnnotationLayer( const QString &name, const QgsAnnotationLayer::LayerOptions &options );
80 ~QgsAnnotationLayer() override;
81
82#ifdef SIP_RUN
83 SIP_PYOBJECT __repr__();
84 % MethodCode
85 QString str = QStringLiteral( "<QgsAnnotationLayer: '%1'>" ).arg( sipCpp->name() );
86 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
87 % End
88#endif
89
93 void reset();
94
102 QString addItem( QgsAnnotationItem *item SIP_TRANSFER );
103
111 void replaceItem( const QString &id, QgsAnnotationItem *item SIP_TRANSFER );
112
116 bool removeItem( const QString &id );
117
121 void clear();
122
126 bool isEmpty() const;
127
134 QMap<QString, QgsAnnotationItem *> items() const { return mItems; }
135
141 QgsAnnotationItem *item( const QString &id );
142
151 QStringList itemsInBounds( const QgsRectangle &bounds, QgsRenderContext &context, QgsFeedback *feedback = nullptr ) const;
152
161
162 Qgis::MapLayerProperties properties() const override;
163 QgsAnnotationLayer *clone() const override SIP_FACTORY;
164 QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
165 QgsRectangle extent() const override;
166 void setTransformContext( const QgsCoordinateTransformContext &context ) override;
167 bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override;
168 bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
169 bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &, StyleCategories categories = AllStyleCategories ) const override;
170 bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override;
171 bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories ) const override;
172 bool readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories ) override;
173 bool isEditable() const override;
174 bool supportsEditing() const override;
175 QgsDataProvider *dataProvider() override;
176 const QgsDataProvider *dataProvider() const override SIP_SKIP;
177 QString htmlMetadata() const override;
178
184 QgsPaintEffect *paintEffect() const;
185
194 void setPaintEffect( QgsPaintEffect *effect SIP_TRANSFER );
195
196 private:
197
198 QStringList queryIndex( const QgsRectangle &bounds, QgsFeedback *feedback = nullptr ) const;
199 bool writeItems( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) const;
200 bool readItems( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories );
201
202 QMap<QString, QgsAnnotationItem *> mItems;
203 QgsCoordinateTransformContext mTransformContext;
204
205 std::unique_ptr< QgsAnnotationLayerSpatialIndex > mSpatialIndex;
206 QSet< QString > mNonIndexedItems;
207
208 QgsDataProvider *mDataProvider = nullptr;
209
210 std::unique_ptr< QgsPaintEffect > mPaintEffect;
211
213
214};
215
216#ifndef SIP_RUN
218
224class QgsAnnotationLayerDataProvider : public QgsDataProvider
225{
226 Q_OBJECT
227
228 public:
229 QgsAnnotationLayerDataProvider( const QgsDataProvider::ProviderOptions &providerOptions,
230 QgsDataProvider::ReadFlags flags );
231 QgsCoordinateReferenceSystem crs() const override;
232 QString name() const override;
233 QString description() const override;
234 QgsRectangle extent() const override;
235 bool isValid() const override;
236
237};
239#endif
240
241#endif // QGSANNOTATIONLAYER_H
AnnotationItemEditOperationResult
Results from an edit operation on an annotation item.
Definition: qgis.h:1530
Abstract base class for annotation item edit operations.
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
Implementation of threaded rendering for annotation layers.
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.
This class represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Abstract base class for spatial data provider implementations.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45
Base class for utility classes that encapsulate information necessary for rendering of map layers.
Base class for all map layer types.
Definition: qgsmaplayer.h:73
virtual Qgis::MapLayerProperties properties() const
Returns the map layer properties of this layer.
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
Base class for visual effects which can be applied to QPicture drawings.
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.
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:74
#define str(x)
Definition: qgis.cpp:37
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:76
const QgsCoordinateReferenceSystem & crs
Setting options for loading annotation layers.
LayerOptions(const QgsCoordinateTransformContext &transformContext)
Constructor for LayerOptions.
QgsCoordinateTransformContext transformContext
Coordinate transform context.
Setting options for creating vector data providers.