QGIS API Documentation  3.17.0-Master (a84647cf30)
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  QString type() const override;
44  void render( QgsRenderContext &context, QgsFeedback *feedback ) override;
45  bool writeXml( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
46 
50  static QgsAnnotationPointTextItem *create() SIP_FACTORY;
51 
52  bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) override;
54  QgsRectangle boundingBox() const override;
55 
63  QgsPointXY point() const { return mPoint; }
64 
72  void setPoint( QgsPointXY point ) { mPoint = point; }
73 
79  QString text() const { return mText; }
80 
86  void setText( const QString &text ) { mText = text; }
87 
93  QgsTextFormat format() const;
94 
100  void setFormat( const QgsTextFormat &format );
101 
107  double angle() const { return mAngle; }
108 
114  void setAngle( double angle ) { mAngle = angle; }
115 
121  Qt::Alignment alignment() const;
122 
128  void setAlignment( Qt::Alignment alignment );
129 
130  private:
131 
132  QString mText;
133  QgsPointXY mPoint;
134  QgsTextFormat mTextFormat;
135  double mAngle = 0;
136  Qt::Alignment mAlignment = Qt::AlignHCenter;
137 
138 #ifdef SIP_RUN
140 #endif
141 
142 };
143 
144 #endif // QGSANNOTATIONPOINTTEXTITEM_H
The class is used as a container of context for various read/write operations on other objects...
A rectangle specified with double values.
Definition: qgsrectangle.h:41
virtual QString type() const =0
Returns a unique (untranslated) string identifying the type of item.
A class to represent a 2D point.
Definition: qgspointxy.h:43
virtual QgsAnnotationItem * clone()=0
Returns a clone of the item.
void setAngle(double angle)
Sets the text's rotation angle, in degrees clockwise.
void setText(const QString &text)
Sets the text rendered by the item.
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
virtual bool readXml(const QDomElement &element, const QgsReadWriteContext &context)=0
Reads the item's state from the given DOM element.
Base class for feedback objects to be used for cancellation of something running in a worker thread...
Definition: qgsfeedback.h:43
double angle() const
Returns the text's rotation angle, in degrees clockwise.
An annotation item which renders a text string at a point location.
void setPoint(QgsPointXY point)
Sets the point location of the text.
QString text() const
Returns the text rendered by the item.
#define SIP_FACTORY
Definition: qgis_sip.h:76
virtual bool writeXml(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const =0
Writes the item's state into an XML element.
virtual void render(QgsRenderContext &context, QgsFeedback *feedback)=0
Renders the item to the specified render context.
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
Contains information about the context of a rendering operation.
QgsPointXY point() const
Returns the point location of the text.
virtual QgsRectangle boundingBox() const =0
Returns the bounding box of the item's geographic location, in the parent layer's coordinate referenc...
Container for all settings relating to text rendering.
Definition: qgstextformat.h:39