forked from paceholder/nodeeditor
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathConnection.hpp
More file actions
89 lines (60 loc) · 1.89 KB
/
Connection.hpp
File metadata and controls
89 lines (60 loc) · 1.89 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
#pragma once
#include <QtCore/QObject>
#include <QtCore/QUuid>
#include <QtCore/QVariant>
#include "NodeData.hpp"
#include "PortType.hpp"
#include "ConnectionGeometry.hpp"
#include "ConnectionID.hpp"
#include "ConnectionState.hpp"
#include "Export.hpp"
#include "QUuidStdHash.hpp"
#include "Serializable.hpp"
#include "TypeConverter.hpp"
#include "memory.hpp"
class QPointF;
namespace QtNodes {
class Node;
class NodeData;
class ConnectionGraphicsObject;
/// Connection is a representation in DataFlowScene of a connection
/// It is part of the model, and not the rendering system.
/// This class is not to be used if you're implementing FlowScene model yourself
class NODE_EDITOR_PUBLIC Connection : public QObject, public Serializable {
Q_OBJECT
public:
Connection(Node &nodeIn, PortIndex portIndexIn, Node &nodeOut,
PortIndex portIndexOut, TypeConverter converter = TypeConverter{});
Connection(const Connection &) = delete;
Connection operator=(const Connection &) = delete;
~Connection();
public:
QJsonObject save() const override;
public:
ConnectionID id() const;
Node *getNode(PortType portType) const;
private:
Node *&getNodePtrRef(PortType portType);
public:
PortIndex getPortIndex(PortType portType) const;
NodeDataType dataType(PortType portType) const;
void setTypeConverter(TypeConverter converter);
public: // data propagation
void propagateData(std::shared_ptr<NodeData> nodeData) const;
void propagateEmptyData() const;
private:
QUuid _uid;
private:
void setNodeToPort(Node &node, PortType portType, PortIndex portIndex);
Node *_outNode = nullptr;
Node *_inNode = nullptr;
PortIndex _outPortIndex;
PortIndex _inPortIndex;
private:
ConnectionState _connectionState;
std::unique_ptr<ConnectionGraphicsObject> _connectionGraphicsObject;
TypeConverter _converter;
signals:
void updated(Connection &conn) const;
};
} // namespace QtNodes