QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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:
40 QgsAnnotationLineTextItem( const QString &text, QgsCurve *curve SIP_TRANSFER );
42
43 Qgis::AnnotationItemFlags flags() const override;
44 QString type() const override;
45 void render( QgsRenderContext &context, QgsFeedback *feedback ) override;
46 bool writeXml( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
47 QList< QgsAnnotationItemNode > nodesV2( const QgsAnnotationItemEditContext &context ) const override;
50
55
56 bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) override;
57 QgsRectangle boundingBox() const override;
58 QgsRectangle boundingBox( QgsRenderContext &context ) const override;
59
61
69 const QgsCurve *geometry() const { return mCurve.get(); }
70
78 void setGeometry( QgsCurve *geometry SIP_TRANSFER );
79
85 QString text() const { return mText; }
86
92 void setText( const QString &text ) { mText = text; }
93
99 QgsTextFormat format() const;
100
106 void setFormat( const QgsTextFormat &format );
107
114 double offsetFromLine() const { return mOffsetFromLineDistance; }
115
122 void setOffsetFromLine( double distance ) { mOffsetFromLineDistance = distance; }
123
130 void setOffsetFromLineUnit( Qgis::RenderUnit unit ) { mOffsetFromLineUnit = unit; }
131
138 Qgis::RenderUnit offsetFromLineUnit() const { return mOffsetFromLineUnit; }
139
147 void setOffsetFromLineMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetFromLineScale = scale; }
148
156 const QgsMapUnitScale &offsetFromLineMapUnitScale() const { return mOffsetFromLineScale; }
157
158 private:
159 QString mText;
160 std::unique_ptr< QgsCurve > mCurve;
161 QgsTextFormat mTextFormat;
162
163 double mOffsetFromLineDistance = 0;
165 QgsMapUnitScale mOffsetFromLineScale;
166
167#ifdef SIP_RUN
169#endif
170};
171
172#endif // QGSANNOTATIONLINETEXTITEM_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
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 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.
QgsRectangle boundingBox() const override
Returns the bounding box of the item's geographic location, in the parent layer's coordinate referenc...
void setOffsetFromLineMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the offset from line geometry() distance.
const QgsCurve * geometry() const
Returns the geometry of the item.
static QgsAnnotationLineTextItem * create()
Creates a new linestring annotation item.
QgsAnnotationLineTextItem * clone() const override
Returns a clone of the item.
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.
QgsAnnotationLineTextItem(const QString &text, QgsCurve *curve)
Constructor for QgsAnnotationLineTextItem, with the specified curve and text.
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.
bool readXml(const QDomElement &element, const QgsReadWriteContext &context) override
Reads the item's state from the given DOM element.
Abstract base class for curved geometry type.
Definition qgscurve.h:36
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.
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.
Container for all settings relating to text rendering.
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_FACTORY
Definition qgis_sip.h:83