-
-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathgraphnode.h
More file actions
113 lines (73 loc) · 2.03 KB
/
graphnode.h
File metadata and controls
113 lines (73 loc) · 2.03 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
#ifndef GRAPHNODE_H
#define GRAPHNODE_H
#include <QObject>
#include <QVariant>
#include <amath.h>
#if defined(SHARED_DEFINE) && defined(_WIN32)
#ifdef NODEGRAPH_LIBRARY
#define NODEGRAPH_EXPORT __declspec(dllexport)
#else
#define NODEGRAPH_EXPORT __declspec(dllimport)
#endif
#else
#define NODEGRAPH_EXPORT
#endif
class AbstractNodeGraph;
class GraphNode;
class Widget;
class NODEGRAPH_EXPORT NodePort {
public:
explicit NodePort(GraphNode *node, bool out, uint32_t type, int32_t pos, std::string name, const Vector4 &color, QVariant var = QVariant()) :
m_name(name),
m_color(color),
m_var(var),
m_node(node),
m_type(type),
m_pos(pos),
m_out(out) {
}
std::string m_name;
std::string m_hints;
Vector4 m_color;
QVariant m_var = QVariant();
GraphNode *m_node;
void *m_userData = nullptr;
uint32_t m_type;
int32_t m_pos;
int32_t m_userFlags = 0;
bool m_out;
bool m_call = false;
};
class NODEGRAPH_EXPORT GraphNode : public QObject {
Q_OBJECT
public:
GraphNode();
~GraphNode();
AbstractNodeGraph *graph() const;
void setGraph(AbstractNodeGraph *graph);
virtual NodePort *port(int position);
virtual int portPosition(NodePort *port);
std::string typeName() const;
virtual void setTypeName(const std::string &name);
virtual bool isCall() const;
virtual Vector2 defaultSize() const;
virtual Vector4 color() const;
Vector2 position() const;
void setPosition(const Vector2 &position);
virtual Widget *widget();
virtual Widget *portWidget(int port);
std::vector<NodePort> &ports();
void saveUserData(QVariantMap &data);
void loadUserData(const QVariantMap &data);
signals:
void updated();
protected:
void onNameChanged();
protected:
std::vector<NodePort> m_ports;
std::string m_typeName;
Vector2 m_pos;
Widget *m_nodeWidget;
AbstractNodeGraph *m_graph;
};
#endif // GRAPHNODE_H