QGIS API Documentation 3.39.0-Master (3aed037ce22)
Loading...
Searching...
No Matches
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
24class QgsFeedback;
25class QgsMarkerSymbol;
26class QgsLineSymbol;
27class QgsFillSymbol;
33
40class CORE_EXPORT QgsAnnotationItem
41{
42
43#ifdef SIP_RUN
45 if ( sipCpp->type() == QLatin1String( "marker" ) )
46 {
47 sipType = sipType_QgsAnnotationMarkerItem;
48 }
49 else if ( sipCpp->type() == QLatin1String( "linestring" ) )
50 {
51 sipType = sipType_QgsAnnotationLineItem;
52 }
53 else if ( sipCpp->type() == QLatin1String( "polygon" ) )
54 {
55 sipType = sipType_QgsAnnotationPolygonItem;
56 }
57 else if ( sipCpp->type() == QLatin1String( "pointtext" ) )
58 {
59 sipType = sipType_QgsAnnotationPointTextItem;
60 }
61 else if ( sipCpp->type() == QLatin1String( "linetext" ) )
62 {
63 sipType = sipType_QgsAnnotationLineTextItem;
64 }
65 else
66 {
67 sipType = 0;
68 }
70#endif
71
72 public:
73
74 QgsAnnotationItem() = default;
75
76#ifndef SIP_RUN
77 QgsAnnotationItem( const QgsAnnotationItem &other ) = delete;
79#endif
80
81 virtual ~QgsAnnotationItem() = default;
82
88 virtual Qgis::AnnotationItemFlags flags() const;
89
97 virtual QgsAnnotationItem *clone() const = 0 SIP_FACTORY;
98
102 virtual QString type() const = 0;
103
107 virtual QgsRectangle boundingBox() const = 0;
108
112 virtual QgsRectangle boundingBox( QgsRenderContext &context ) const { Q_UNUSED( context ) return boundingBox();}
113
120 virtual void render( QgsRenderContext &context, QgsFeedback *feedback ) = 0;
121
130 virtual bool writeXml( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const = 0;
131
140 virtual bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) = 0;
141
148
155
162 int zIndex() const { return mZIndex; }
163
170 void setZIndex( int index ) { mZIndex = index; }
171
178 bool enabled() const { return mEnabled; }
179
186 void setEnabled( bool enabled ) { mEnabled = enabled; }
187
193 virtual QList< QgsAnnotationItemNode > nodes() const;
194
201 bool useSymbologyReferenceScale() const { return mUseReferenceScale; }
202
209 void setUseSymbologyReferenceScale( bool enabled ) { mUseReferenceScale = enabled; }
210
226 double symbologyReferenceScale() const { return mReferenceScale; }
227
243 void setSymbologyReferenceScale( double scale ) { mReferenceScale = scale; }
244
245 protected:
246
252 void copyCommonProperties( const QgsAnnotationItem *other );
253
260 bool writeCommonProperties( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
261
268 bool readCommonProperties( const QDomElement &element, const QgsReadWriteContext &context );
269
270 private:
271
272 int mZIndex = 0;
273 bool mEnabled = true;
274 bool mUseReferenceScale = false;
275 double mReferenceScale = 0;
276
277#ifdef SIP_RUN
278 QgsAnnotationItem( const QgsAnnotationItem &other );
279#endif
280
281};
282
283#endif // QGSANNOTATIONITEM_H
AnnotationItemEditOperationResult
Results from an edit operation on an annotation item.
Definition qgis.h:2218
QFlags< AnnotationItemFlag > AnnotationItemFlags
Annotation item flags.
Definition qgis.h:2183
Abstract base class for annotation item edit operations.
Encapsulates the transient results of an in-progress annotation edit operation.
Contains information about a node used for editing an annotation item.
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
void setUseSymbologyReferenceScale(bool enabled)
Sets whether the annotation item uses a symbology reference scale.
void setZIndex(int index)
Sets the item's z index, which controls the order in which annotation items are rendered in the layer...
bool useSymbologyReferenceScale() const
Returns true if the annotation item uses a symbology reference scale.
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...
void setEnabled(bool enabled)
Sets if the item will be rendered or not in the layer.
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.
bool enabled() const
Returns true if the item is enabled and will be rendered in the layer.
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 & operator=(const QgsAnnotationItem &other)=delete
void setSymbologyReferenceScale(double scale)
Sets the annotation's symbology reference scale.
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
virtual QgsRectangle boundingBox(QgsRenderContext &context) const
Returns the bounding box of the item's geographic location, in the parent layer's coordinate referenc...
double symbologyReferenceScale() const
Returns the annotation's symbology reference scale.
virtual QgsAnnotationItem * clone() const =0
Returns a clone of the item.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
A line symbol type, for rendering LineString and MultiLineString geometries.
A marker symbol type, for rendering Point and MultiPoint geometries.
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 SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:191
#define SIP_FACTORY
Definition qgis_sip.h:76
#define SIP_END
Definition qgis_sip.h:208