QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsannotationpointtextitem.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsannotationpointtextitem.h
3  ----------------
4  begin : August 2020
5  copyright : (C) 2020 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 QGSANNOTATIONPOINTTEXTITEM_H
19 #define QGSANNOTATIONPOINTTEXTITEM_H
20 
21 #include "qgis_core.h"
22 #include "qgis_sip.h"
23 #include "qgsannotationitem.h"
24 #include "qgstextformat.h"
25 
26 
34 {
35  public:
36 
40  QgsAnnotationPointTextItem( const QString &text, QgsPointXY point );
41  ~QgsAnnotationPointTextItem() override;
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 
51  static QgsAnnotationPointTextItem *create() SIP_FACTORY;
52 
53  bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) override;
55  QgsRectangle boundingBox() const override;
56  QgsRectangle boundingBox( QgsRenderContext &context ) const override;
57  QList< QgsAnnotationItemNode > nodes() const override;
60 
68  QgsPointXY point() const { return mPoint; }
69 
77  void setPoint( QgsPointXY point ) { mPoint = point; }
78 
84  QString text() const { return mText; }
85 
91  void setText( const QString &text ) { mText = text; }
92 
98  QgsTextFormat format() const;
99 
105  void setFormat( const QgsTextFormat &format );
106 
112  double angle() const { return mAngle; }
113 
119  void setAngle( double angle ) { mAngle = angle; }
120 
126  Qt::Alignment alignment() const;
127 
133  void setAlignment( Qt::Alignment alignment );
134 
135  private:
136 
137  QString mText;
138  QgsPointXY mPoint;
139  QgsTextFormat mTextFormat;
140  double mAngle = 0;
141  Qt::Alignment mAlignment = Qt::AlignHCenter;
142 
143 #ifdef SIP_RUN
145 #endif
146 
147 };
148 
149 #endif // QGSANNOTATIONPOINTTEXTITEM_H
QgsAnnotationItem::nodes
virtual QList< QgsAnnotationItemNode > nodes() const
Returns the nodes for the item, used for editing the item.
Definition: qgsannotationitem.cpp:36
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
QgsAnnotationItem::readXml
virtual bool readXml(const QDomElement &element, const QgsReadWriteContext &context)=0
Reads the item's state from the given DOM element.
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:59
QgsAnnotationItem::clone
virtual QgsAnnotationItem * clone()=0
Returns a clone of the item.
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
Qgis::AnnotationItemEditOperationResult
AnnotationItemEditOperationResult
Results from an edit operation on an annotation item.
Definition: qgis.h:1153
QgsTextFormat
Container for all settings relating to text rendering.
Definition: qgstextformat.h:40
QgsAnnotationItem::writeXml
virtual bool writeXml(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const =0
Writes the item's state into an XML element.
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
qgis_sip.h
QgsAbstractAnnotationItemEditOperation
Abstract base class for annotation item edit operations.
Definition: qgsannotationitemeditoperation.h:32
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:58
QgsAnnotationItem::render
virtual void render(QgsRenderContext &context, QgsFeedback *feedback)=0
Renders the item to the specified render context.
QgsAnnotationItem::applyEdit
virtual Qgis::AnnotationItemEditOperationResult applyEdit(QgsAbstractAnnotationItemEditOperation *operation)
Applies an edit operation to the item.
Definition: qgsannotationitem.cpp:26
QgsAnnotationItem::boundingBox
virtual QgsRectangle boundingBox() const =0
Returns the bounding box of the item's geographic location, in the parent layer's coordinate referenc...
QgsAnnotationItem::flags
virtual Qgis::AnnotationItemFlags flags() const
Returns item flags.
Definition: qgsannotationitem.cpp:21
qgsannotationitem.h
qgstextformat.h
QgsAnnotationItem::transientEditResults
virtual QgsAnnotationItemEditOperationTransientResults * transientEditResults(QgsAbstractAnnotationItemEditOperation *operation)
Retrieves the results of a transient (in progress) edit operation on the item.
Definition: qgsannotationitem.cpp:31
MathUtils::angle
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
Definition: MathUtils.cpp:786
QgsAnnotationItem
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
Definition: qgsannotationitem.h:42
QgsAnnotationItemEditOperationTransientResults
Encapsulates the transient results of an in-progress annotation edit operation.
Definition: qgsannotationitemeditoperation.h:226
QgsAnnotationPointTextItem
An annotation item which renders a text string at a point location.
Definition: qgsannotationpointtextitem.h:33
QgsAnnotationItem::type
virtual QString type() const =0
Returns a unique (untranslated) string identifying the type of item.