QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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
74  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
qgspolygon.h
QgsAnnotationItem::~QgsAnnotationItem
virtual ~QgsAnnotationItem()=default
QgsAnnotationItem::QgsAnnotationItem
QgsAnnotationItem()=default
Constructor for an annotation item.
qgslinestring.h
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:35
QgsAnnotationItem::readXml
virtual bool readXml(const QDomElement &element, const QgsReadWriteContext &context)=0
Reads the item's state from the given DOM element.
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:58
QgsAnnotationItem::clone
virtual QgsAnnotationItem * clone()=0
Returns a clone of the item.
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:42
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:177
QgsMarkerSymbol
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgssymbol.h:931
QgsAnnotationItem::writeXml
virtual bool writeXml(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const =0
Writes the item's state into an XML element.
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
qgis_sip.h
qgsrendercontext.h
QgsLineSymbol
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgssymbol.h:1131
QgsAnnotationItem::render
virtual void render(QgsRenderContext &context, QgsFeedback *feedback)=0
Renders the item to the specified render context.
QgsAnnotationItem::zIndex
int zIndex() const
Returns the item's z index, which controls the order in which annotation items are rendered in the la...
Definition: qgsannotationitem.h:121
QgsAnnotationItem::boundingBox
virtual QgsRectangle boundingBox() const =0
Returns the bounding box of the item's geographic location, in the parent layer's coordinate referenc...
QgsAnnotationItem::operator=
QgsAnnotationItem & operator=(const QgsAnnotationItem &other)=delete
QgsAnnotationItem cannot be copied.
QgsFillSymbol
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgssymbol.h:1234
SIP_END
#define SIP_END
Definition: qgis_sip.h:194
qgscoordinatereferencesystem.h
QgsAnnotationItem::setZIndex
void setZIndex(int index)
Sets the item's z index, which controls the order in which annotation items are rendered in the layer...
Definition: qgsannotationitem.h:129
QgsAnnotationItem
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
Definition: qgsannotationitem.h:39
QgsAnnotationItem::type
virtual QString type() const =0
Returns a unique (untranslated) string identifying the type of item.