QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
Loading...
Searching...
No Matches
qgsannotationrectitem.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsannotationrectitem.h
3 ----------------
4 begin : July 2024
5 copyright : (C) 2024 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSANNOTATIONRECTITEM_H
19#define QGSANNOTATIONRECTITEM_H
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
23#include "qgsannotationitem.h"
24
33class CORE_EXPORT QgsAnnotationRectItem : public QgsAnnotationItem
34{
35 public:
42
43 Qgis::AnnotationItemFlags flags() const override;
44 void render( QgsRenderContext &context, QgsFeedback *feedback ) override;
45 QList< QgsAnnotationItemNode > nodesV2( const QgsAnnotationItemEditContext &context ) const override;
48 QgsRectangle boundingBox() const override;
49 QgsRectangle boundingBox( QgsRenderContext &context ) const override;
50
61 QgsRectangle bounds() const { return mBounds; }
62
73 void setBounds( const QgsRectangle &bounds );
74
80 Qgis::AnnotationPlacementMode placementMode() const;
81
87 void setPlacementMode( Qgis::AnnotationPlacementMode mode );
88
97 QSizeF fixedSize() const;
98
107 void setFixedSize( const QSizeF &size );
108
115 Qgis::RenderUnit fixedSizeUnit() const;
116
123 void setFixedSizeUnit( Qgis::RenderUnit unit );
124
131 bool backgroundEnabled() const { return mDrawBackground; }
132
139 void setBackgroundEnabled( bool enabled ) { mDrawBackground = enabled; }
140
147 const QgsFillSymbol *backgroundSymbol() const;
148
157 void setBackgroundSymbol( QgsFillSymbol *symbol SIP_TRANSFER );
158
165 bool frameEnabled() const { return mDrawFrame; }
166
173 void setFrameEnabled( bool enabled ) { mDrawFrame = enabled; }
174
181 const QgsFillSymbol *frameSymbol() const;
182
191 void setFrameSymbol( QgsFillSymbol *symbol SIP_TRANSFER );
192
193 protected:
194 void copyCommonProperties( const QgsAnnotationItem *other ) override;
195 bool writeCommonProperties( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
196 bool readCommonProperties( const QDomElement &element, const QgsReadWriteContext &context ) override;
197
207 virtual void renderInBounds( QgsRenderContext &context, const QRectF &painterRect, QgsFeedback *feedback ) = 0;
208
209 private:
211 QgsRectangle mBounds;
212
213 QSizeF mFixedSize;
215 bool mDrawBackground = false;
216 std::unique_ptr< QgsFillSymbol > mBackgroundSymbol;
217 bool mDrawFrame = false;
218 std::unique_ptr< QgsFillSymbol > mFrameSymbol;
219
220#ifdef SIP_RUN
222#endif
223};
224#endif // QGSANNOTATIONRECTITEM_H
AnnotationItemEditOperationResult
Results from an edit operation on an annotation item.
Definition qgis.h:2608
QFlags< AnnotationItemFlag > AnnotationItemFlags
Annotation item flags.
Definition qgis.h:2559
RenderUnit
Rendering size units.
Definition qgis.h:5340
@ Millimeters
Millimeters.
Definition qgis.h:5341
AnnotationPlacementMode
Annotation item placement modes.
Definition qgis.h:2569
@ SpatialBounds
Item is rendered inside fixed spatial bounds, and size will depend on map scale.
Definition qgis.h:2570
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.
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
virtual bool writeCommonProperties(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Writes common properties from the base class into an XML element.
virtual QList< QgsAnnotationItemNode > nodesV2(const QgsAnnotationItemEditContext &context) const
Returns the nodes for the item, used for editing the item.
virtual QgsRectangle boundingBox() const =0
Returns the bounding box of the item's geographic location, in the parent layer's coordinate referenc...
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 QgsAnnotationItemEditOperationTransientResults * transientEditResultsV2(QgsAbstractAnnotationItemEditOperation *operation, const QgsAnnotationItemEditContext &context)
Retrieves the results of a transient (in progress) edit operation on the item.
virtual void copyCommonProperties(const QgsAnnotationItem *other)
Copies common properties from the base class from an other item.
virtual Qgis::AnnotationItemFlags flags() const
Returns item flags.
virtual Qgis::AnnotationItemEditOperationResult applyEditV2(QgsAbstractAnnotationItemEditOperation *operation, const QgsAnnotationItemEditContext &context)
Applies an edit operation to the item.
virtual bool readCommonProperties(const QDomElement &element, const QgsReadWriteContext &context)
Reads common properties from the base class from the given DOM element.
virtual void renderInBounds(QgsRenderContext &context, const QRectF &painterRect, QgsFeedback *feedback)=0
Renders the item to the specified render context.
QgsRectangle bounds() const
Returns the bounds of the item.
~QgsAnnotationRectItem() override
QgsAnnotationRectItem(const QgsRectangle &bounds)
Constructor for QgsAnnotationRectItem, rendering the annotation within the specified bounds geometry.
bool frameEnabled() const
Returns true if the item's frame should be rendered.
void setBackgroundEnabled(bool enabled)
Sets whether the item's background should be rendered.
void setFrameEnabled(bool enabled)
Sets whether the item's frame should be rendered.
bool backgroundEnabled() const
Returns true if the item's background should be rendered.
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 container for the context for various read/write operations on objects.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_FACTORY
Definition qgis_sip.h:83