-
Notifications
You must be signed in to change notification settings - Fork 948
Expand file tree
/
Copy pathConnection.hpp
More file actions
162 lines (115 loc) · 2.94 KB
/
Connection.hpp
File metadata and controls
162 lines (115 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#pragma once
#include <QtCore/QObject>
#include <QtCore/QUuid>
#include <QtCore/QVariant>
#include "PortType.hpp"
#include "NodeData.hpp"
#include "Serializable.hpp"
#include "ConnectionState.hpp"
#include "ConnectionGeometry.hpp"
#include "TypeConverter.hpp"
#include "QUuidStdHash.hpp"
#include "Export.hpp"
#include "memory.hpp"
class QPointF;
namespace QtNodes
{
class Node;
class NodeData;
class ConnectionGraphicsObject;
class ConnectionStyle;
///
class NODE_EDITOR_PUBLIC Connection
: public QObject
, public Serializable
{
Q_OBJECT
public:
/// New Connection is attached to the port of the given Node.
/// The port has parameters (portType, portIndex).
/// The opposite connection end will require another port.
Connection(PortType portType,
Node& node,
PortIndex portIndex,
ConnectionStyle const &style);
Connection(Node& nodeIn,
PortIndex portIndexIn,
Node& nodeOut,
PortIndex portIndexOut,
ConnectionStyle const &style,
TypeConverter converter =
TypeConverter{});
Connection(const Connection&) = delete;
Connection operator=(const Connection&) = delete;
~Connection();
public:
QJsonObject
save() const override;
public:
QUuid
id() const;
/// Remembers the end being dragged.
/// Invalidates Node address.
/// Grabs mouse.
void
setRequiredPort(PortType portType);
PortType
requiredPort() const;
void
setGraphicsObject(std::unique_ptr<ConnectionGraphicsObject>&& graphics);
/// Assigns a node to the required port.
/// It is assumed that there is a required port, no extra checks
void
setNodeToPort(Node& node,
PortType portType,
PortIndex portIndex);
void
removeFromNodes() const;
public:
ConnectionGraphicsObject&
getConnectionGraphicsObject() const;
ConnectionState const &
connectionState() const;
ConnectionState&
connectionState();
ConnectionGeometry&
connectionGeometry();
ConnectionGeometry const&
connectionGeometry() const;
Node*
getNode(PortType portType) const;
Node*&
getNode(PortType portType);
PortIndex
getPortIndex(PortType portType) const;
void
clearNode(PortType portType);
NodeDataType
dataType(PortType portType) const;
void
setTypeConverter(TypeConverter converter);
ConnectionStyle const &
connectionStyle() const;
public: // data propagation
void
propagateData(std::shared_ptr<NodeData> nodeData) const;
void
propagateEmptyData() const;
private:
QUuid _uid;
private:
Node* _outNode = nullptr;
Node* _inNode = nullptr;
PortIndex _outPortIndex;
PortIndex _inPortIndex;
private:
ConnectionState _connectionState;
ConnectionGeometry _connectionGeometry;
ConnectionStyle const &_connectionStyle;
std::unique_ptr<ConnectionGraphicsObject>_connectionGraphicsObject;
TypeConverter _converter;
signals:
void
updated(Connection& conn) const;
};
}