QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
qgsannotationitem.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsannotationitem.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 QGSANNOTATIONITEM_H
18 #define QGSANNOTATIONITEM_H
19 
20 #include "qgis_core.h"
21 #include "qgis_sip.h"
23 #include "qgsrendercontext.h"
24 #include "qgslinestring.h"
25 #include "qgspolygon.h"
26 
27 class QgsFeedback;
28 class QgsMarkerSymbol;
29 class QgsLineSymbol;
30 class QgsFillSymbol;
31 
38 class CORE_EXPORT QgsAnnotationItem
39 {
40 
41 #ifdef SIP_RUN
43  if ( sipCpp->type() == QLatin1String( "marker" ) )
44  {
45  sipType = sipType_QgsAnnotationMarkerItem;
46  }
47  else if ( sipCpp->type() == QLatin1String( "linestring" ) )
48  {
49  sipType = sipType_QgsAnnotationLineItem;
50  }
51  else if ( sipCpp->type() == QLatin1String( "polygon" ) )
52  {
53  sipType = sipType_QgsAnnotationPolygonItem;
54  }
55  else if ( sipCpp->type() == QLatin1String( "pointtext" ) )
56  {
57  sipType = sipType_QgsAnnotationPointTextItem;
58  }
59  else
60  {
61  sipType = 0;
62  }
63  SIP_END
64 #endif
65 
66  public:
67 
71  QgsAnnotationItem() = default;
72 
73 #ifndef SIP_RUN
75  QgsAnnotationItem( const QgsAnnotationItem &other ) = delete;
77  QgsAnnotationItem &operator=( const QgsAnnotationItem &other ) = delete;
78 #endif
79 
80  virtual ~QgsAnnotationItem() = default;
81 
86 
90  virtual QString type() const = 0;
91 
95  virtual QgsRectangle boundingBox() const = 0;
96 
103  virtual void render( QgsRenderContext &context, QgsFeedback *feedback ) = 0;
104 
108  virtual bool writeXml( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const = 0;
109 
113  virtual bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) = 0;
114 
121  int zIndex() const { return mZIndex; }
122 
129  void setZIndex( int index ) { mZIndex = index; }
130 
131  private:
132 
133  int mZIndex = 0;
134 
135 #ifdef SIP_RUN
136  QgsAnnotationItem( const QgsAnnotationItem &other );
137 #endif
138 
139 };
140 
141 #endif // QGSANNOTATIONITEM_H
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
void setZIndex(int index)
Sets the item's z index, which controls the order in which annotation items are rendered in the layer...
virtual bool writeXml(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const =0
Writes the item's state into an XML element.
virtual QgsRectangle boundingBox() const =0
Returns the bounding box of the item's geographic location, in the parent layer's coordinate referenc...
virtual QString type() const =0
Returns a unique (untranslated) string identifying the type of item.
virtual void render(QgsRenderContext &context, QgsFeedback *feedback)=0
Renders the item to the specified render context.
virtual bool readXml(const QDomElement &element, const QgsReadWriteContext &context)=0
Reads the item's state from the given DOM element.
QgsAnnotationItem(const QgsAnnotationItem &other)=delete
QgsAnnotationItem cannot be copied.
QgsAnnotationItem & operator=(const QgsAnnotationItem &other)=delete
QgsAnnotationItem cannot be copied.
virtual QgsAnnotationItem * clone()=0
Returns a clone of the item.
int zIndex() const
Returns the item's z index, which controls the order in which annotation items are rendered in the la...
virtual ~QgsAnnotationItem()=default
QgsAnnotationItem()=default
Constructor for an annotation item.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgssymbol.h:1307
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgssymbol.h:1204
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgssymbol.h:1004
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 SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:177
#define SIP_FACTORY
Definition: qgis_sip.h:76
#define SIP_END
Definition: qgis_sip.h:194