QGIS API Documentation  3.24.2-Tisler (13c1a02865)
qgsannotationitemnode.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsannotationitemnode.h
3  ----------------
4  copyright : (C) 2021 by Nyall Dawson
5  email : nyall dot dawson at gmail dot com
6  ***************************************************************************/
7 
8 /***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #ifndef QGSANNOTATIONITEMEDITNODE_H
18 #define QGSANNOTATIONITEMEDITNODE_H
19 
20 #include "qgis_core.h"
21 #include "qgis_sip.h"
22 #include "qgspointxy.h"
23 #include "qgsvertexid.h"
24 #include "qgis.h"
25 
31 class CORE_EXPORT QgsAnnotationItemNode
32 {
33  public:
34 
38  QgsAnnotationItemNode() = default;
39 
44  : mId( id )
45  , mPoint( point )
46  , mType( type )
47  {}
48 
49 #ifdef SIP_RUN
50  SIP_PYOBJECT __repr__();
51  % MethodCode
52  QString str = QStringLiteral( "<QgsAnnotationItemNode: %1 - %2 (%3, %4)>" ).arg( sipCpp->id().vertex )
53  .arg( qgsEnumValueToKey( sipCpp->type() ) )
54  .arg( sipCpp->point().x() )
55  .arg( sipCpp->point().y() );
56  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
57  % End
58 #endif
59 
63  QgsVertexId id() const { return mId; }
64 
72  QgsPointXY point() const { return mPoint; }
73 
81  void setPoint( QgsPointXY point ) { mPoint = point; }
82 
88  Qgis::AnnotationItemNodeType type() const { return mType; }
89 
95  void setType( Qgis::AnnotationItemNodeType type ) { mType = type; }
96 
97  // TODO c++20 - replace with = default
98  bool operator==( const QgsAnnotationItemNode &other ) const
99  {
100  return mId == other.mId && mType == other.mType && mPoint == other.mPoint;
101  }
102 
103  bool operator!=( const QgsAnnotationItemNode &other ) const
104  {
105  return !( *this == other );
106  }
107 
108  private:
109 
110  QgsVertexId mId;
111  QgsPointXY mPoint;
113 
114 };
115 
116 #endif // QGSANNOTATIONITEMEDITNODE_H
AnnotationItemNodeType
Annotation item GUI flags.
Definition: qgis.h:837
@ VertexHandle
Node is a handle for manipulating vertices.
Contains information about a node used for editing an annotation item.
QgsAnnotationItemNode(const QgsVertexId &id, const QgsPointXY &point, Qgis::AnnotationItemNodeType type)
Constructor for QgsAnnotationItemNode, with the specified id, point and type.
void setPoint(QgsPointXY point)
Sets the node's position, in geographic coordinates.
Qgis::AnnotationItemNodeType type() const
Returns the node type.
QgsPointXY point() const
Returns the node's position, in geographic coordinates.
void setType(Qgis::AnnotationItemNodeType type)
Sets the node type.
bool operator==(const QgsAnnotationItemNode &other) const
QgsAnnotationItemNode()=default
Default constructor.
bool operator!=(const QgsAnnotationItemNode &other) const
QgsVertexId id() const
Returns the ID number of the node, used for uniquely identifying the node in the item.
A class to represent a 2D point.
Definition: qgspointxy.h:59
#define str(x)
Definition: qgis.cpp:37
QString qgsEnumValueToKey(const T &value)
Returns the value for the given key of an enum.
Definition: qgis.h:1737
Utility class for identifying a unique vertex within a geometry.
Definition: qgsvertexid.h:31