QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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#include "qgsgeometry.h"
24#include "qgscallout.h"
25
26class QgsFeedback;
27class QgsMarkerSymbol;
28class QgsLineSymbol;
29class QgsFillSymbol;
36
43class CORE_EXPORT QgsAnnotationItem
44{
45
46#ifdef SIP_RUN
48 if ( sipCpp->type() == QLatin1String( "marker" ) )
49 {
50 sipType = sipType_QgsAnnotationMarkerItem;
51 }
52 else if ( sipCpp->type() == QLatin1String( "linestring" ) )
53 {
54 sipType = sipType_QgsAnnotationLineItem;
55 }
56 else if ( sipCpp->type() == QLatin1String( "polygon" ) )
57 {
58 sipType = sipType_QgsAnnotationPolygonItem;
59 }
60 else if ( sipCpp->type() == QLatin1String( "pointtext" ) )
61 {
62 sipType = sipType_QgsAnnotationPointTextItem;
63 }
64 else if ( sipCpp->type() == QLatin1String( "linetext" ) )
65 {
66 sipType = sipType_QgsAnnotationLineTextItem;
67 }
68 else if ( sipCpp->type() == QLatin1String( "recttext" ) )
69 {
70 sipType = sipType_QgsAnnotationRectangleTextItem;
71 }
72 else if ( sipCpp->type() == QLatin1String( "picture" ) )
73 {
74 sipType = sipType_QgsAnnotationPictureItem;
75 }
76 else
77 {
78 sipType = 0;
79 }
81#endif
82
83 public:
84
86
87#ifndef SIP_RUN
88 QgsAnnotationItem( const QgsAnnotationItem &other ) = delete;
90#endif
91
93
99 virtual Qgis::AnnotationItemFlags flags() const;
100
108 virtual QgsAnnotationItem *clone() const = 0 SIP_FACTORY;
109
113 virtual QString type() const = 0;
114
118 virtual QgsRectangle boundingBox() const = 0;
119
123 virtual QgsRectangle boundingBox( QgsRenderContext &context ) const { Q_UNUSED( context ) return boundingBox();}
124
131 virtual void render( QgsRenderContext &context, QgsFeedback *feedback ) = 0;
132
141 virtual bool writeXml( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const = 0;
142
151 virtual bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) = 0;
152
159
166
172 Q_DECL_DEPRECATED virtual QgsAnnotationItemEditOperationTransientResults *transientEditResults( QgsAbstractAnnotationItemEditOperation *operation ) SIP_FACTORY;
173
180
187 int zIndex() const { return mZIndex; }
188
195 void setZIndex( int index ) { mZIndex = index; }
196
203 bool enabled() const { return mEnabled; }
204
211 void setEnabled( bool enabled ) { mEnabled = enabled; }
212
218 Q_DECL_DEPRECATED virtual QList< QgsAnnotationItemNode > nodes() const SIP_DEPRECATED;
219
225 virtual QList< QgsAnnotationItemNode > nodesV2( const QgsAnnotationItemEditContext &context ) const;
226
233 bool useSymbologyReferenceScale() const { return mUseReferenceScale; }
234
241 void setUseSymbologyReferenceScale( bool enabled ) { mUseReferenceScale = enabled; }
242
258 double symbologyReferenceScale() const { return mReferenceScale; }
259
275 void setSymbologyReferenceScale( double scale ) { mReferenceScale = scale; }
276
292 QgsCallout *callout() const;
293
305 void setCallout( QgsCallout *callout SIP_TRANSFER );
306
320 QgsGeometry calloutAnchor() const;
321
335 void setCalloutAnchor( const QgsGeometry &anchor );
336
349 QSizeF offsetFromCallout() const;
350
363 void setOffsetFromCallout( const QSizeF &offset );
364
373 Qgis::RenderUnit offsetFromCalloutUnit() const;
374
383 void setOffsetFromCalloutUnit( Qgis::RenderUnit unit );
384
385 protected:
386
392 virtual void copyCommonProperties( const QgsAnnotationItem *other );
393
400 virtual bool writeCommonProperties( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
401
408 virtual bool readCommonProperties( const QDomElement &element, const QgsReadWriteContext &context );
409
417 void renderCallout( QgsRenderContext &context, const QRectF &rect, double angle, QgsCallout::QgsCalloutContext &calloutContext, QgsFeedback *feedback );
418
419 private:
420
421 int mZIndex = 0;
422 bool mEnabled = true;
423 bool mUseReferenceScale = false;
424 double mReferenceScale = 0;
425
426 std::unique_ptr< QgsCallout > mCallout;
427 QgsGeometry mCalloutAnchor;
428 QSizeF mOffsetFromCallout;
429 Qgis::RenderUnit mOffsetFromCalloutUnit = Qgis::RenderUnit::Millimeters;
430
431#ifdef SIP_RUN
432 QgsAnnotationItem( const QgsAnnotationItem &other );
433#endif
434
435};
436
437#endif // QGSANNOTATIONITEM_H
AnnotationItemEditOperationResult
Results from an edit operation on an annotation item.
Definition qgis.h:2351
QFlags< AnnotationItemFlag > AnnotationItemFlags
Annotation item flags.
Definition qgis.h:2302
RenderUnit
Rendering size units.
Definition qgis.h:4839
@ Millimeters
Millimeters.
Abstract base class for annotation item edit operations.
Encapsulates the context for an annotation item edit operation.
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...
virtual ~QgsAnnotationItem()
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 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.
Contains additional contextual information about the context in which a callout is being rendered.
Definition qgscallout.h:249
Abstract base class for callout renderers.
Definition qgscallout.h:54
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 geometry is the spatial representation of a feature.
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_DEPRECATED
Definition qgis_sip.h:106
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:76
#define SIP_END
Definition qgis_sip.h:208