QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
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_core.h"
21#include "qgis_sip.h"
22#include "qgspointxy.h"
23#include "qgsvertexid.h"
24#include "qgis.h"
25
31class CORE_EXPORT QgsAnnotationItemNode
32{
33 public:
34
36
40 QgsAnnotationItemNode( const QgsVertexId &id, const QgsPointXY &point, Qgis::AnnotationItemNodeType type, Qt::CursorShape cursor = Qt::CursorShape::ArrowCursor )
41 : mId( id )
42 , mPoint( point )
43 , mType( type )
44 , mCursor( cursor )
45 {}
46
47#ifdef SIP_RUN
48 SIP_PYOBJECT __repr__();
49 % MethodCode
50 QString str = QStringLiteral( "<QgsAnnotationItemNode: %1 - %2 (%3, %4)>" ).arg( sipCpp->id().vertex )
51 .arg( qgsEnumValueToKey( sipCpp->type() ) )
52 .arg( sipCpp->point().x() )
53 .arg( sipCpp->point().y() );
54 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
55 % End
56#endif
57
61 QgsVertexId id() const { return mId; }
62
70 QgsPointXY point() const { return mPoint; }
71
79 void setPoint( QgsPointXY point ) { mPoint = point; }
80
86 Qgis::AnnotationItemNodeType type() const { return mType; }
87
93 void setType( Qgis::AnnotationItemNodeType type ) { mType = type; }
94
101 Qt::CursorShape cursor() const
102 {
103 return mCursor;
104 }
105
112 void setCursor( Qt::CursorShape shape )
113 {
114 mCursor = shape;
115 }
116
117 // TODO c++20 - replace with = default
118 bool operator==( const QgsAnnotationItemNode &other ) const
119 {
120 return mId == other.mId && mType == other.mType && mPoint == other.mPoint;
121 }
122
123 bool operator!=( const QgsAnnotationItemNode &other ) const
124 {
125 return !( *this == other );
126 }
127
128 private:
129
130 QgsVertexId mId;
131 QgsPointXY mPoint;
133 Qt::CursorShape mCursor = Qt::CursorShape::ArrowCursor;
134
135};
136
137#endif // QGSANNOTATIONITEMEDITNODE_H
AnnotationItemNodeType
Annotation item node types.
Definition qgis.h:2339
@ VertexHandle
Node is a handle for manipulating vertices.
Contains information about a node used for editing an annotation item.
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.
A class to represent a 2D point.
Definition qgspointxy.h:60
#define str(x)
Definition qgis.cpp:39
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
Definition qgis.h:6108
Utility class for identifying a unique vertex within a geometry.
Definition qgsvertexid.h:30