29using namespace Qt::StringLiterals;
78 return mCallout.get();
88 return mCalloutAnchor;
93 mCalloutAnchor = anchor;
113 element.setAttribute( u
"enabled"_s,
static_cast<int>(
enabled() ) );
114 element.setAttribute( u
"zIndex"_s,
zIndex() );
120 element.setAttribute( u
"calloutType"_s, mCallout->type() );
121 mCallout->saveProperties( doc, element, context );
123 if ( !mCalloutAnchor.isEmpty() )
125 element.setAttribute( u
"calloutAnchor"_s, mCalloutAnchor.asWkt() );
127 if ( mOffsetFromCallout.isValid() )
137 setEnabled( element.attribute( u
"enabled"_s, u
"1"_s ).toInt() );
138 setZIndex( element.attribute( u
"zIndex"_s ).toInt() );
142 const QString calloutType = element.attribute( u
"calloutType"_s );
143 if ( calloutType.isEmpty() )
154 const QString calloutAnchorWkt = element.attribute( u
"calloutAnchor"_s );
157 mOffsetFromCallout = element.attribute( u
"offsetFromCallout"_s ).isEmpty() ? QSizeF() :
QgsSymbolLayerUtils::decodeSize( element.attribute( u
"offsetFromCallout"_s ) );
168 if ( !mCallout || mCalloutAnchor.isEmpty() )
186 mCallout->startRender( context );
187 mCallout->render( context, rect, angle, anchor, calloutContext );
188 mCallout->stopRender( context );
193 return mOffsetFromCalloutUnit;
198 mOffsetFromCalloutUnit = unit;
203 return mOffsetFromCallout;
208 mOffsetFromCallout = offset;
AnnotationItemEditOperationResult
Results from an edit operation on an annotation item.
@ Invalid
Operation has invalid parameters for the item, no change occurred.
QFlags< AnnotationItemFlag > AnnotationItemFlags
Annotation item flags.
RenderUnit
Rendering size units.
@ 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.
virtual bool writeCommonProperties(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Writes common properties from the base class into an XML element.
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 ~QgsAnnotationItem()
void setCallout(QgsCallout *callout)
Sets the item's callout renderer, responsible for drawing item callouts.
virtual QList< QgsAnnotationItemNode > nodesV2(const QgsAnnotationItemEditContext &context) const
Returns the nodes for the item, used for editing the item.
void setOffsetFromCallout(const QSizeF &offset)
Sets the offset of the annotation item from the calloutAnchor().
void setEnabled(bool enabled)
Sets if the item will be rendered or not in the layer.
QgsGeometry calloutAnchor() const
Returns the callout's anchor geometry.
bool enabled() const
Returns true if the item is enabled and will be rendered in the layer.
Qgis::RenderUnit offsetFromCalloutUnit() const
Returns the units for the offsetFromCallout().
virtual Q_DECL_DEPRECATED QgsAnnotationItemEditOperationTransientResults * transientEditResults(QgsAbstractAnnotationItemEditOperation *operation)
Retrieves the results of a transient (in progress) edit operation on the item.
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.
void setSymbologyReferenceScale(double scale)
Sets the annotation's symbology reference scale.
virtual Qgis::AnnotationItemFlags flags() const
Returns item flags.
void setOffsetFromCalloutUnit(Qgis::RenderUnit unit)
Sets the unit for the offsetFromCallout().
virtual Q_DECL_DEPRECATED QList< QgsAnnotationItemNode > nodes() const
Returns the nodes for the item, used for editing the item.
virtual Qgis::AnnotationItemEditOperationResult applyEditV2(QgsAbstractAnnotationItemEditOperation *operation, const QgsAnnotationItemEditContext &context)
Applies an edit operation to the item.
void setCalloutAnchor(const QgsGeometry &anchor)
Sets the callout's anchor geometry.
QSizeF offsetFromCallout() const
Returns the (optional) offset of the annotation item from the calloutAnchor().
int zIndex() const
Returns the item's z index, which controls the order in which annotation items are rendered in the la...
virtual Q_DECL_DEPRECATED Qgis::AnnotationItemEditOperationResult applyEdit(QgsAbstractAnnotationItemEditOperation *operation)
Applies an edit operation to the item.
QgsCallout * callout() const
Returns the item's callout renderer, responsible for drawing item callouts.
double symbologyReferenceScale() const
Returns the annotation's symbology reference scale.
virtual bool readCommonProperties(const QDomElement &element, const QgsReadWriteContext &context)
Reads common properties from the base class from the given DOM element.
void renderCallout(QgsRenderContext &context, const QRectF &rect, double angle, QgsCallout::QgsCalloutContext &calloutContext, QgsFeedback *feedback)
Renders the item's callout.
static QgsCalloutRegistry * calloutRegistry()
Returns the application's callout registry, used for managing callout types.
static QgsCallout * defaultCallout()
Create a new instance of a callout with default settings.
Contains additional contextual information about the context in which a callout is being rendered.
Abstract base class for callout renderers.
Custom exception class for Coordinate Reference System related exceptions.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
A geometry is the spatial representation of a feature.
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
static Q_INVOKABLE QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
QgsPointXY transform(const QgsPointXY &p) const
Transforms a point p from map (world) coordinates to device coordinates.
A container for the context for various read/write operations on objects.
Contains information about the context of a rendering operation.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
static QString encodeSize(QSizeF size)
Encodes a QSizeF to a string.
static QSizeF decodeSize(const QString &string)
Decodes a QSizeF from a string.
static Q_INVOKABLE Qgis::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
static Q_INVOKABLE QString encodeUnit(Qgis::DistanceUnit unit)
Encodes a distance unit to a string.
#define Q_NOWARN_DEPRECATED_POP
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
#define Q_NOWARN_DEPRECATED_PUSH