QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
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#include "qgsmaplayerref.h"
25
29class QgsPaintEffect;
30
31
33class QgsAnnotationLayerSpatialIndex;
35
47class CORE_EXPORT QgsAnnotationLayer : public QgsMapLayer
48{
49 Q_OBJECT
50
51 public:
52
58 {
59
63 explicit LayerOptions( const QgsCoordinateTransformContext &transformContext )
64 : transformContext( transformContext )
65 {}
66
71
72 };
73
74
80 QgsAnnotationLayer( const QString &name, const QgsAnnotationLayer::LayerOptions &options );
81 ~QgsAnnotationLayer() override;
82
83#ifdef SIP_RUN
84 SIP_PYOBJECT __repr__();
85 % MethodCode
86 QString str = QStringLiteral( "<QgsAnnotationLayer: '%1'>" ).arg( sipCpp->name() );
87 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
88 % End
89#endif
90
94 void reset();
95
103 QString addItem( QgsAnnotationItem *item SIP_TRANSFER );
104
112 void replaceItem( const QString &id, QgsAnnotationItem *item SIP_TRANSFER );
113
117 bool removeItem( const QString &id );
118
122 void clear();
123
127 bool isEmpty() const;
128
135 QMap<QString, QgsAnnotationItem *> items() const { return mItems; }
136
142 QgsAnnotationItem *item( const QString &id ) const;
143
152 QStringList itemsInBounds( const QgsRectangle &bounds, QgsRenderContext &context, QgsFeedback *feedback = nullptr ) const;
153
162
171
172 Qgis::MapLayerProperties properties() const override;
173 QgsAnnotationLayer *clone() const override SIP_FACTORY;
174 QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
175 QgsRectangle extent() const override;
176 void setTransformContext( const QgsCoordinateTransformContext &context ) override;
177 bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override;
178 bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
179 bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &, StyleCategories categories = AllStyleCategories ) const override;
180 bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override;
181 bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories ) const override;
182 bool readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories ) override;
183 bool isEditable() const override;
184 bool supportsEditing() const override;
185 QgsDataProvider *dataProvider() override;
186 const QgsDataProvider *dataProvider() const override SIP_SKIP;
187 QString htmlMetadata() const override;
188 void resolveReferences( QgsProject *project ) override;
189
195 QgsPaintEffect *paintEffect() const;
196
205 void setPaintEffect( QgsPaintEffect *effect SIP_TRANSFER );
206
214 QgsMapLayer *linkedVisibilityLayer();
215
223 void setLinkedVisibilityLayer( QgsMapLayer *layer );
224
225 private:
226
227 QStringList queryIndex( const QgsRectangle &bounds, QgsFeedback *feedback = nullptr ) const;
228 bool writeItems( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) const;
229 bool readItems( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories );
230
231 QMap<QString, QgsAnnotationItem *> mItems;
232 QgsCoordinateTransformContext mTransformContext;
233
234 std::unique_ptr< QgsAnnotationLayerSpatialIndex > mSpatialIndex;
235 QSet< QString > mNonIndexedItems;
236
237 QgsDataProvider *mDataProvider = nullptr;
238
239 std::unique_ptr< QgsPaintEffect > mPaintEffect;
240
241 QgsMapLayerRef mLinkedLayer;
242
244
245};
246
247#ifndef SIP_RUN
249
255class QgsAnnotationLayerDataProvider : public QgsDataProvider
256{
257 Q_OBJECT
258
259 public:
260 QgsAnnotationLayerDataProvider( const QgsDataProvider::ProviderOptions &providerOptions,
262 QgsCoordinateReferenceSystem crs() const override;
263 QString name() const override;
264 QString description() const override;
265 QgsRectangle extent() const override;
266 bool isValid() const override;
267
268};
270#endif
271
272#endif // QGSANNOTATIONLAYER_H
AnnotationItemEditOperationResult
Results from an edit operation on an annotation item.
Definition qgis.h:2351
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:450
QFlags< MapLayerProperty > MapLayerProperties
Map layer properties.
Definition qgis.h:2118
Abstract base class for annotation item edit operations.
Encapsulates the context for an annotation item edit operation.
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:44
Base class for utility classes that encapsulate information necessary for rendering of map layers.
Base class for all map layer types.
Definition qgsmaplayer.h:76
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.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107
The class is used as a container of context for various read/write operations on other objects.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
#define str(x)
Definition qgis.cpp:39
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#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.