QGIS API Documentation 4.1.0-Master (60fea48833c)
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:
39
43 QgsAnnotationItemNode( const QgsVertexId &id, const QgsPointXY &point, Qgis::AnnotationItemNodeType type, Qt::CursorShape cursor = Qt::CursorShape::ArrowCursor )
44 : mId( id )
45 , mPoint( point )
46 , mType( type )
47 , mCursor( cursor )
48 {}
49
50 // clang-format off
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 // clang-format on
62
67 {
68 return mId;
69 }
70
78 QgsPointXY point() const { return mPoint; }
79
87 void setPoint( QgsPointXY point ) { mPoint = point; }
88
94 Qgis::AnnotationItemNodeType type() const { return mType; }
95
102
109 Qt::CursorShape cursor() const { return mCursor; }
110
117 void setCursor( Qt::CursorShape shape ) { mCursor = shape; }
118
119 // TODO c++20 - replace with = default
120 bool operator==( const QgsAnnotationItemNode &other ) const { return mId == other.mId && mType == other.mType && mPoint == other.mPoint; }
121
122 bool operator!=( const QgsAnnotationItemNode &other ) const { return !( *this == other ); }
123
124 private:
125 QgsVertexId mId;
126 QgsPointXY mPoint;
128 Qt::CursorShape mCursor = Qt::CursorShape::ArrowCursor;
129};
130
131#endif // QGSANNOTATIONITEMEDITNODE_H
AnnotationItemNodeType
Annotation item node types.
Definition qgis.h:2596
@ VertexHandle
Node is a handle for manipulating vertices.
Definition qgis.h:2597
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:7157
Utility class for identifying a unique vertex within a geometry.
Definition qgsvertexid.h:34