QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 "qgslinestring.h"
24 #include "qgspolygon.h"
25 
26 class QgsFeedback;
27 class QgsMarkerSymbol;
28 class QgsLineSymbol;
29 class QgsFillSymbol;
33 class QgsRenderContext;
35 
42 class CORE_EXPORT QgsAnnotationItem
43 {
44 
45 #ifdef SIP_RUN
47  if ( sipCpp->type() == QLatin1String( "marker" ) )
48  {
49  sipType = sipType_QgsAnnotationMarkerItem;
50  }
51  else if ( sipCpp->type() == QLatin1String( "linestring" ) )
52  {
53  sipType = sipType_QgsAnnotationLineItem;
54  }
55  else if ( sipCpp->type() == QLatin1String( "polygon" ) )
56  {
57  sipType = sipType_QgsAnnotationPolygonItem;
58  }
59  else if ( sipCpp->type() == QLatin1String( "pointtext" ) )
60  {
61  sipType = sipType_QgsAnnotationPointTextItem;
62  }
63  else
64  {
65  sipType = 0;
66  }
67  SIP_END
68 #endif
69 
70  public:
71 
75  QgsAnnotationItem() = default;
76 
77 #ifndef SIP_RUN
78  QgsAnnotationItem( const QgsAnnotationItem &other ) = delete;
81  QgsAnnotationItem &operator=( const QgsAnnotationItem &other ) = delete;
82 #endif
83 
84  virtual ~QgsAnnotationItem() = default;
85 
91  virtual Qgis::AnnotationItemFlags flags() const;
92 
100  virtual QgsAnnotationItem *clone() = 0 SIP_FACTORY;
101 
105  virtual QString type() const = 0;
106 
110  virtual QgsRectangle boundingBox() const = 0;
111 
115  virtual QgsRectangle boundingBox( QgsRenderContext &context ) const { Q_UNUSED( context ) return boundingBox();}
116 
123  virtual void render( QgsRenderContext &context, QgsFeedback *feedback ) = 0;
124 
133  virtual bool writeXml( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const = 0;
134 
143  virtual bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) = 0;
144 
151 
158 
165  int zIndex() const { return mZIndex; }
166 
173  void setZIndex( int index ) { mZIndex = index; }
174 
180  virtual QList< QgsAnnotationItemNode > nodes() const;
181 
188  bool useSymbologyReferenceScale() const { return mUseReferenceScale; }
189 
196  void setUseSymbologyReferenceScale( bool enabled ) { mUseReferenceScale = enabled; }
197 
213  double symbologyReferenceScale() const { return mReferenceScale; }
214 
230  void setSymbologyReferenceScale( double scale ) { mReferenceScale = scale; }
231 
232  protected:
233 
239  void copyCommonProperties( const QgsAnnotationItem *other );
240 
247  bool writeCommonProperties( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
248 
255  bool readCommonProperties( const QDomElement &element, const QgsReadWriteContext &context );
256 
257  private:
258 
259  int mZIndex = 0;
260 
261  bool mUseReferenceScale = false;
262  double mReferenceScale = 0;
263 
264 #ifdef SIP_RUN
265  QgsAnnotationItem( const QgsAnnotationItem &other );
266 #endif
267 
268 };
269 
270 #endif // QGSANNOTATIONITEM_H
qgspolygon.h
QgsAnnotationItem::useSymbologyReferenceScale
bool useSymbologyReferenceScale() const
Returns true if the annotation item uses a symbology reference scale.
Definition: qgsannotationitem.h:188
qgslinestring.h
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:59
QgsAnnotationItem::boundingBox
virtual QgsRectangle boundingBox(QgsRenderContext &context) const
Returns the bounding box of the item's geographic location, in the parent layer's coordinate referenc...
Definition: qgsannotationitem.h:115
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
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
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:186
QgsMarkerSymbol
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgsmarkersymbol.h:30
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
QgsLineSymbol
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:29
QgsAbstractAnnotationItemEditOperation
Abstract base class for annotation item edit operations.
Definition: qgsannotationitemeditoperation.h:32
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:165
QgsAnnotationItemNode
Contains information about a node used for editing an annotation item.
Definition: qgsannotationitemnode.h:31
QgsFillSymbol
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgsfillsymbol.h:29
QgsAnnotationItem::setSymbologyReferenceScale
void setSymbologyReferenceScale(double scale)
Sets the annotation's symbology reference scale.
Definition: qgsannotationitem.h:230
QgsAnnotationItem::symbologyReferenceScale
double symbologyReferenceScale() const
Returns the annotation's symbology reference scale.
Definition: qgsannotationitem.h:213
SIP_END
#define SIP_END
Definition: qgis_sip.h:203
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:173
QgsAnnotationItem
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
Definition: qgsannotationitem.h:42
QgsAnnotationItemEditOperationTransientResults
Encapsulates the transient results of an in-progress annotation edit operation.
Definition: qgsannotationitemeditoperation.h:226
QgsAnnotationItem::setUseSymbologyReferenceScale
void setUseSymbologyReferenceScale(bool enabled)
Sets whether the annotation item uses a symbology reference scale.
Definition: qgsannotationitem.h:196