QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
qgsannotationlinetextitem.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsannotationlinetextitem.h
3 ----------------
4 begin : March 2023
5 copyright : (C) 2023 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 QGSANNOTATIONLINETEXTITEM_H
19#define QGSANNOTATIONLINETEXTITEM_H
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
23#include "qgsannotationitem.h"
24#include "qgstextformat.h"
25
26class QgsCurve;
27
35{
36 public:
37
41 QgsAnnotationLineTextItem( const QString &text, QgsCurve *curve SIP_TRANSFER );
43
44 Qgis::AnnotationItemFlags flags() const override;
45 QString type() const override;
46 void render( QgsRenderContext &context, QgsFeedback *feedback ) override;
47 bool writeXml( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
48 QList< QgsAnnotationItemNode > nodesV2( const QgsAnnotationItemEditContext &context ) const override;
51
56
57 bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) override;
58 QgsRectangle boundingBox() const override;
59 QgsRectangle boundingBox( QgsRenderContext &context ) const override;
60
61 QgsAnnotationLineTextItem *clone() const override SIP_FACTORY;
62
70 const QgsCurve *geometry() const { return mCurve.get(); }
71
79 void setGeometry( QgsCurve *geometry SIP_TRANSFER );
80
86 QString text() const { return mText; }
87
93 void setText( const QString &text ) { mText = text; }
94
100 QgsTextFormat format() const;
101
107 void setFormat( const QgsTextFormat &format );
108
115 double offsetFromLine() const { return mOffsetFromLineDistance; }
116
123 void setOffsetFromLine( double distance ) { mOffsetFromLineDistance = distance; }
124
131 void setOffsetFromLineUnit( Qgis::RenderUnit unit ) { mOffsetFromLineUnit = unit; }
132
139 Qgis::RenderUnit offsetFromLineUnit() const { return mOffsetFromLineUnit; }
140
148 void setOffsetFromLineMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetFromLineScale = scale; }
149
157 const QgsMapUnitScale &offsetFromLineMapUnitScale() const { return mOffsetFromLineScale; }
158
159 private:
160
161 QString mText;
162 std::unique_ptr< QgsCurve > mCurve;
163 QgsTextFormat mTextFormat;
164
165 double mOffsetFromLineDistance = 0;
167 QgsMapUnitScale mOffsetFromLineScale;
168
169#ifdef SIP_RUN
171#endif
172
173};
174
175#endif // QGSANNOTATIONLINETEXTITEM_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.
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
virtual bool writeXml(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const =0
Writes the item's state into an XML element.
virtual QList< QgsAnnotationItemNode > nodesV2(const QgsAnnotationItemEditContext &context) const
Returns the nodes for the item, used for editing the item.
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.
virtual QgsAnnotationItemEditOperationTransientResults * transientEditResultsV2(QgsAbstractAnnotationItemEditOperation *operation, const QgsAnnotationItemEditContext &context)
Retrieves the results of a transient (in progress) edit operation on the 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.
An annotation item which renders text along a line geometry.
double offsetFromLine() const
Returns the offset distance from the line geometry() to the text's baseline.
void setOffsetFromLine(double distance)
Sets the offset distance from the line geometry() to the text's baseline.
void setOffsetFromLineMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the offset from line geometry() distance.
void setText(const QString &text)
Sets the text rendered by the item.
void setOffsetFromLineUnit(Qgis::RenderUnit unit)
Sets the unit for the offset from line geometry() distance.
QString text() const
Returns the text rendered by the item.
Qgis::RenderUnit offsetFromLineUnit() const
Returns the units for the offset from line geometry() distance.
~QgsAnnotationLineTextItem() override
const QgsMapUnitScale & offsetFromLineMapUnitScale() const
Returns the map unit scale for the offset from line geometry() distance.
Abstract base class for curved geometry type.
Definition qgscurve.h:35
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
Struct for storing maximum and minimum scales for measurements in map units.
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.
Container for all settings relating to text rendering.
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:76