QGIS API Documentation 4.3.0-Master (6402a64e93b)
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
25class QgsMapToPixel;
26
35class CORE_EXPORT QgsAnnotationRectItem : public QgsAnnotationItem
36{
37 public:
44
45 Qgis::AnnotationItemFlags flags() const override;
46 void render( QgsRenderContext &context, QgsFeedback *feedback ) override;
47 QList< QgsAnnotationItemNode > nodesV2( const QgsAnnotationItemEditContext &context ) const override;
50 QgsRectangle boundingBox() const override;
51 QgsRectangle boundingBox( QgsRenderContext &context ) const override;
52
63 QgsRectangle bounds() const { return mBounds; }
64
75 void setBounds( const QgsRectangle &bounds );
76
82 Qgis::AnnotationPlacementMode placementMode() const;
83
89 void setPlacementMode( Qgis::AnnotationPlacementMode mode );
90
99 QSizeF fixedSize() const;
100
109 void setFixedSize( const QSizeF &size );
110
117 Qgis::RenderUnit fixedSizeUnit() const;
118
125 void setFixedSizeUnit( Qgis::RenderUnit unit );
126
133 double rotation() const { return mRotation; }
134
141 void setRotation( double rotation ) { mRotation = rotation; }
142
149 Qgis::SymbolRotationMode rotationMode() const { return mRotationMode; }
150
157 void setRotationMode( Qgis::SymbolRotationMode mode ) { mRotationMode = mode; }
158
171 double appliedRotation( double mapRotation ) const;
172
180 QgsGeometry rotatedBoundsGeometry( const QgsRectangle &layerBounds, const QgsRenderContext &renderContext ) const SIP_SKIP;
181
189 static QgsRectangle boundsFromPixelRect( const QgsMapToPixel *mapToPixel, const QPointF &centerPixel, double widthPixels, double heightPixels ) SIP_SKIP;
190
197 bool backgroundEnabled() const { return mDrawBackground; }
198
205 void setBackgroundEnabled( bool enabled ) { mDrawBackground = enabled; }
206
213 const QgsFillSymbol *backgroundSymbol() const;
214
223 void setBackgroundSymbol( QgsFillSymbol *symbol SIP_TRANSFER );
224
231 bool frameEnabled() const { return mDrawFrame; }
232
239 void setFrameEnabled( bool enabled ) { mDrawFrame = enabled; }
240
247 const QgsFillSymbol *frameSymbol() const;
248
257 void setFrameSymbol( QgsFillSymbol *symbol SIP_TRANSFER );
258
259 protected:
260 void copyCommonProperties( const QgsAnnotationItem *other ) override;
261 bool writeCommonProperties( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
262 bool readCommonProperties( const QDomElement &element, const QgsReadWriteContext &context ) override;
263
273 virtual void renderInBounds( QgsRenderContext &context, const QRectF &painterRect, QgsFeedback *feedback ) = 0;
274
275 private:
277 QgsRectangle mBounds;
278 QSizeF mFixedSize;
280 double mRotation = 0;
282 bool mDrawBackground = false;
283 std::unique_ptr< QgsFillSymbol > mBackgroundSymbol;
284 bool mDrawFrame = false;
285 std::unique_ptr< QgsFillSymbol > mFrameSymbol;
286
287#ifdef SIP_RUN
289#endif
290};
291#endif // QGSANNOTATIONRECTITEM_H
SymbolRotationMode
Modes for handling how symbol and text entity rotation is handled when maps are rotated.
Definition qgis.h:848
@ IgnoreMapRotation
Entity ignores map rotation.
Definition qgis.h:850
AnnotationItemEditOperationResult
Results from an edit operation on an annotation item.
Definition qgis.h:2706
QFlags< AnnotationItemFlag > AnnotationItemFlags
Annotation item flags.
Definition qgis.h:2657
RenderUnit
Rendering size units.
Definition qgis.h:5655
@ Millimeters
Millimeters.
Definition qgis.h:5656
AnnotationPlacementMode
Annotation item placement modes.
Definition qgis.h:2667
@ SpatialBounds
Item is rendered inside fixed spatial bounds, and size will depend on map scale.
Definition qgis.h:2668
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.
void setRotationMode(Qgis::SymbolRotationMode mode)
Sets the mode used to render the item with respect to the rotation of the map.
QgsRectangle bounds() const
Returns the bounds of the item.
double rotation() const
Returns the rotation of the item, in degrees clockwise.
Qgis::SymbolRotationMode rotationMode() const
Returns the method used to render the item with respect to the rotation of the map.
~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 setRotation(double rotation)
Sets the rotation of the item, in degrees clockwise.
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 geometry is the spatial representation of a feature.
Perform transforms between map coordinates and device coordinates.
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_SKIP
Definition qgis_sip.h:133
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_FACTORY
Definition qgis_sip.h:83