QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
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:
36
41 QgsAnnotationRectItem( const QgsRectangle &bounds );
43
44 Qgis::AnnotationItemFlags flags() const override;
45 void render( QgsRenderContext &context, QgsFeedback *feedback ) override;
46 QList< QgsAnnotationItemNode > nodesV2( const QgsAnnotationItemEditContext &context ) const override;
49 QgsRectangle boundingBox() const override;
50 QgsRectangle boundingBox( QgsRenderContext &context ) const override;
51
62 QgsRectangle bounds() const { return mBounds; }
63
74 void setBounds( const QgsRectangle &bounds );
75
81 Qgis::AnnotationPlacementMode placementMode() const;
82
88 void setPlacementMode( Qgis::AnnotationPlacementMode mode );
89
98 QSizeF fixedSize() const;
99
108 void setFixedSize( const QSizeF &size );
109
116 Qgis::RenderUnit fixedSizeUnit() const;
117
124 void setFixedSizeUnit( Qgis::RenderUnit unit );
125
132 bool backgroundEnabled() const { return mDrawBackground; }
133
140 void setBackgroundEnabled( bool enabled ) { mDrawBackground = enabled; }
141
148 const QgsFillSymbol *backgroundSymbol() const;
149
158 void setBackgroundSymbol( QgsFillSymbol *symbol SIP_TRANSFER );
159
166 bool frameEnabled() const { return mDrawFrame; }
167
174 void setFrameEnabled( bool enabled ) { mDrawFrame = enabled; }
175
182 const QgsFillSymbol *frameSymbol() const;
183
192 void setFrameSymbol( QgsFillSymbol *symbol SIP_TRANSFER );
193
194 protected:
195 void copyCommonProperties( const QgsAnnotationItem *other ) override;
196 bool writeCommonProperties( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
197 bool readCommonProperties( const QDomElement &element, const QgsReadWriteContext &context ) override;
198
208 virtual void renderInBounds( QgsRenderContext &context, const QRectF &painterRect, QgsFeedback *feedback ) = 0;
209
210 private:
211
213 QgsRectangle mBounds;
214
215 QSizeF mFixedSize;
217 bool mDrawBackground = false;
218 std::unique_ptr< QgsFillSymbol > mBackgroundSymbol;
219 bool mDrawFrame = false;
220 std::unique_ptr< QgsFillSymbol > mFrameSymbol;
221
222#ifdef SIP_RUN
224#endif
225
226};
227#endif // QGSANNOTATIONRECTITEM_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.
AnnotationPlacementMode
Annotation item placement modes.
Definition qgis.h:2312
@ SpatialBounds
Item is rendered inside fixed spatial bounds, and size will depend on map scale.
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.
Abstract base class for annotation items which render annotations in a rectangular shape.
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
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.
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_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:76