-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSocket.h
More file actions
72 lines (59 loc) · 1.2 KB
/
Socket.h
File metadata and controls
72 lines (59 loc) · 1.2 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
#ifndef SOCKET_H
#define SOCKET_H
#include <QPoint>
#include <QDebug>
#include "Serializable.h"
class Node;
class Edge;
enum class Location {
LEFT_TOP = 0,
LEFT_MIDDLE,
LEFT_BOTTOM,
RIGHT_TOP,
RIGHT_MIDDLE,
RIGHT_BOTTOM
};
enum class Type {
INTO = 0,
OUTO
};
class Socket : public Serializable
{
public:
Socket() {}
Socket(Node *parent);
~Socket();
void setLocation(Location);
void setLocalSocketPosition(QPoint);
QPoint getSocketLocalPosition();
QPoint socketPosition;
Location location;
Type type;
int index;
Node *parent = nullptr;
Node *getParent() {
return parent;
}
void addEdge(Edge *e) {
edges.append(e);
}
QVector<Edge*> getEdges() {
return edges;
}
Node *getImmediateParent();
QPoint getSocketGlobalPosition();
bool hasEdge();
bool hasInputEdge();
void clearEdges() {
edges.clear();
edges.squeeze();
}
void removeEdge(Edge *e) {
edges.removeOne(e);
}
QString id;
QVector<Edge*> edges;
virtual QJsonObject serialize() override;
virtual Socket* deserialize(QJsonObject, NodeScene*) override;
};
#endif // SOCKET_H