QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
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.h"
21#include "qgis_core.h"
22#include "qgis_sip.h"
23#include "qgspointxy.h"
24#include "qgsvertexid.h"
25
26#include <QString>
27
28using namespace Qt::StringLiterals;
29
35class CORE_EXPORT QgsAnnotationItemNode
36{
37 public:
38
40
44 QgsAnnotationItemNode( const QgsVertexId &id, const QgsPointXY &point, Qgis::AnnotationItemNodeType type, Qt::CursorShape cursor = Qt::CursorShape::ArrowCursor )
45 : mId( id )
46 , mPoint( point )
47 , mType( type )
48 , mCursor( cursor )
49 {}
50
51#ifdef SIP_RUN
52 SIP_PYOBJECT __repr__();
53 % MethodCode
54 QString str = u"<QgsAnnotationItemNode: %1 - %2 (%3, %4)>"_s.arg( sipCpp->id().vertex )
55 .arg( qgsEnumValueToKey( sipCpp->type() ) )
56 .arg( sipCpp->point().x() )
57 .arg( sipCpp->point().y() );
58 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
59 % End
60#endif
61
65 QgsVertexId id() const { return mId; }
66
74 QgsPointXY point() const { return mPoint; }
75
83 void setPoint( QgsPointXY point ) { mPoint = point; }
84
90 Qgis::AnnotationItemNodeType type() const { return mType; }
91
98
105 Qt::CursorShape cursor() const
106 {
107 return mCursor;
108 }
109
116 void setCursor( Qt::CursorShape shape )
117 {
118 mCursor = shape;
119 }
120
121 // TODO c++20 - replace with = default
122 bool operator==( const QgsAnnotationItemNode &other ) const
123 {
124 return mId == other.mId && mType == other.mType && mPoint == other.mPoint;
125 }
126
127 bool operator!=( const QgsAnnotationItemNode &other ) const
128 {
129 return !( *this == other );
130 }
131
132 private:
133
134 QgsVertexId mId;
135 QgsPointXY mPoint;
137 Qt::CursorShape mCursor = Qt::CursorShape::ArrowCursor;
138
139};
140
141#endif // QGSANNOTATIONITEMEDITNODE_H
AnnotationItemNodeType
Annotation item node types.
Definition qgis.h:2565
@ VertexHandle
Node is a handle for manipulating vertices.
Definition qgis.h:2566
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.
QgsAnnotationItemNode(const QgsVertexId &id, const QgsPointXY &point, Qgis::AnnotationItemNodeType type, Qt::CursorShape cursor=Qt::CursorShape::ArrowCursor)
Constructor for QgsAnnotationItemNode, with the specified id, point and type.
Qt::CursorShape cursor() const
Returns the mouse cursor shape to use when hovering the node.
void setType(Qgis::AnnotationItemNodeType type)
Sets the node type.
bool operator==(const QgsAnnotationItemNode &other) const
void setCursor(Qt::CursorShape shape)
Sets the mouse cursor shape to use when hovering the node.
QgsAnnotationItemNode()=default
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.
Represents a 2D point.
Definition qgspointxy.h:62
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
Definition qgis.h:7091
Utility class for identifying a unique vertex within a geometry.
Definition qgsvertexid.h:34