QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
26 class QgsAnnotationItem;
28 class QgsPaintEffect;
29 
30 
32 class QgsAnnotationLayerSpatialIndex;
34 
46 class CORE_EXPORT QgsAnnotationLayer : public QgsMapLayer
47 {
48  Q_OBJECT
49 
50  public:
51 
56  struct LayerOptions
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 isEditable() const override;
172  bool supportsEditing() const override;
173  QgsDataProvider *dataProvider() override;
174  const QgsDataProvider *dataProvider() const override SIP_SKIP;
175  QString htmlMetadata() const override;
176 
182  QgsPaintEffect *paintEffect() const;
183 
192  void setPaintEffect( QgsPaintEffect *effect SIP_TRANSFER );
193 
194  private:
195 
196  QStringList queryIndex( const QgsRectangle &bounds, QgsFeedback *feedback = nullptr ) const;
197 
198  QMap<QString, QgsAnnotationItem *> mItems;
199  QgsCoordinateTransformContext mTransformContext;
200 
201  std::unique_ptr< QgsAnnotationLayerSpatialIndex > mSpatialIndex;
202  QSet< QString > mNonIndexedItems;
203 
204  QgsDataProvider *mDataProvider = nullptr;
205 
206  std::unique_ptr< QgsPaintEffect > mPaintEffect;
207 
209 
210 };
211 
212 #ifndef SIP_RUN
213 
220 class QgsAnnotationLayerDataProvider : public QgsDataProvider
221 {
222  Q_OBJECT
223 
224  public:
225  QgsAnnotationLayerDataProvider( const QgsDataProvider::ProviderOptions &providerOptions,
226  QgsDataProvider::ReadFlags flags );
227  QgsCoordinateReferenceSystem crs() const override;
228  QString name() const override;
229  QString description() const override;
230  QgsRectangle extent() const override;
231  bool isValid() const override;
232 
233 };
235 #endif
236 
237 #endif // QGSANNOTATIONLAYER_H
QgsCoordinateTransformContext
Contains information about the context in which a coordinate transform is executed.
Definition: qgscoordinatetransformcontext.h:57
QgsDataProvider::ProviderOptions
Setting options for creating vector data providers.
Definition: qgsdataprovider.h:107
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
QgsDataProvider
Abstract base class for spatial data provider implementations.
Definition: qgsdataprovider.h:40
QgsMapLayer::clone
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsMapLayer::properties
virtual Qgis::MapLayerProperties properties() const
Returns the map layer properties of this layer.
Definition: qgsmaplayer.cpp:164
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:59
QgsAnnotationLayerRenderer
Implementation of threaded rendering for annotation layers.
Definition: qgsannotationlayerrenderer.h:40
QgsAnnotationLayer::LayerOptions
Setting options for loading annotation layers.
Definition: qgsannotationlayer.h:56
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsMapLayerRenderer
Base class for utility classes that encapsulate information necessary for rendering of map layers.
Definition: qgsmaplayerrenderer.h:54
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
Qgis::AnnotationItemEditOperationResult
AnnotationItemEditOperationResult
Results from an edit operation on an annotation item.
Definition: qgis.h:1153
geos::unique_ptr
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:79
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
qgsmaplayer.h
qgis_sip.h
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
qgsmaplayerrenderer.h
QgsAnnotationLayer::LayerOptions::transformContext
QgsCoordinateTransformContext transformContext
Coordinate transform context.
Definition: qgsannotationlayer.h:69
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
QgsAbstractAnnotationItemEditOperation
Abstract base class for annotation item edit operations.
Definition: qgsannotationitemeditoperation.h:32
QgsAnnotationLayer::items
QMap< QString, QgsAnnotationItem * > items() const
Returns a map of items contained in the layer, by unique item ID.
Definition: qgsannotationlayer.h:134
str
#define str(x)
Definition: qgis.cpp:37
QgsMapLayer
Base class for all map layer types. This is the base class for all map layer types (vector,...
Definition: qgsmaplayer.h:72
QgsAnnotationLayer
Represents a map layer containing a set of georeferenced annotations, e.g. markers,...
Definition: qgsannotationlayer.h:46
QgsPaintEffect
Base class for visual effects which can be applied to QPicture drawings.
Definition: qgspainteffect.h:52
QgsAnnotationLayer::LayerOptions::LayerOptions
LayerOptions(const QgsCoordinateTransformContext &transformContext)
Constructor for LayerOptions.
Definition: qgsannotationlayer.h:62
QgsAnnotationItem
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
Definition: qgsannotationitem.h:42