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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright 2011, Blender Foundation.
*/
#pragma once
#include "BLI_vector.hh"
#include "DNA_node_types.h"
/* common node includes
* added here so node files don't have to include themselves
*/
#include "COM_CompositorContext.h"
#include "COM_NodeConverter.h"
namespace blender::compositor {
class NodeOperation;
class NodeConverter;
/**
* My node documentation.
*/
class Node {
private:
/**
* \brief stores the reference to the SDNA bNode struct
*/
bNodeTree *editor_node_tree_;
/**
* \brief stores the reference to the SDNA bNode struct
*/
bNode *editor_node_;
/**
* \brief Is this node part of the active group
*/
bool in_active_group_;
/**
* \brief Instance key to identify the node in an instance hash table
*/
bNodeInstanceKey instance_key_;
protected:
/**
* \brief the list of actual input-sockets \see NodeInput
*/
Vector<NodeInput *> inputs;
/**
* \brief the list of actual output-sockets \see NodeOutput
*/
Vector<NodeOutput *> outputs;
public:
Node(bNode *editor_node, bool create_sockets = true);
virtual ~Node();
/**
* \brief get the reference to the SDNA bNode struct
*/
bNode *get_bnode() const
{
return editor_node_;
}
/**
* \brief get the reference to the SDNA bNodeTree struct
*/
bNodeTree *get_bnodetree() const
{
return editor_node_tree_;
}
/**
* \brief set the reference to the bNode
* \note used in Node instances to receive the storage/settings and complex
* node for highlight during execution.
* \param bNode:
*/
void set_bnode(bNode *node)
{
editor_node_ = node;
}
/**
* \brief set the reference to the bNodeTree
* \param bNodeTree:
*/
void set_bnodetree(bNodeTree *nodetree)
{
editor_node_tree_ = nodetree;
}
/**
* \brief get access to the vector of input sockets
*/
const Vector<NodeInput *> &get_input_sockets() const
{
return this->inputs;
}
/**
* \brief get access to the vector of input sockets
*/
const Vector<NodeOutput *> &get_output_sockets() const
{
return this->outputs;
}
/**
* get the reference to a certain outputsocket
* \param index:
* the index of the needed outputsocket
*/
NodeOutput *get_output_socket(const unsigned int index = 0) const;
/**
* get the reference to a certain inputsocket
* \param index:
* the index of the needed inputsocket
*/
NodeInput *get_input_socket(const unsigned int index) const;
/**
* \brief Is this node in the active group (the group that is being edited)
* \param is_in_active_group:
*/
void set_is_in_active_group(bool value)
{
in_active_group_ = value;
}
/**
* \brief Is this node part of the active group
* the active group is the group that is currently being edited. When no group is edited,
* the active group will be the main tree (all nodes that are not part of a group will be active)
* \return bool [false:true]
*/
inline bool is_in_active_group() const
{
return in_active_group_;
}
/**
* \brief convert node to operation
*
* \todo this must be described further
*
* \param system: the ExecutionSystem where the operations need to be added
* \param context: reference to the CompositorContext
*/
virtual void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const = 0;
void set_instance_key(bNodeInstanceKey instance_key)
{
instance_key_ = instance_key;
}
bNodeInstanceKey get_instance_key() const
{
return instance_key_;
}
protected:
/**
* \brief add an NodeInput to the collection of input-sockets
* \note may only be called in an constructor
* \param socket: the NodeInput to add
*/
void add_input_socket(DataType datatype);
void add_input_socket(DataType datatype, bNodeSocket *socket);
/**
* \brief add an NodeOutput to the collection of output-sockets
* \note may only be called in an constructor
* \param socket: the NodeOutput to add
*/
void add_output_socket(DataType datatype);
void add_output_socket(DataType datatype, bNodeSocket *socket);
bNodeSocket *get_editor_input_socket(int editor_node_input_socket_index);
bNodeSocket *get_editor_output_socket(int editor_node_output_socket_index);
};
/**
* \brief NodeInput are sockets that can receive data/input
* \ingroup Model
*/
class NodeInput {
private:
Node *node_;
bNodeSocket *editor_socket_;
DataType datatype_;
/**
* \brief link connected to this NodeInput.
* An input socket can only have a single link
*/
NodeOutput *link_;
public:
NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype);
Node *get_node() const
{
return node_;
}
DataType get_data_type() const
{
return datatype_;
}
bNodeSocket *get_bnode_socket() const
{
return editor_socket_;
}
void set_link(NodeOutput *link);
bool is_linked() const
{
return link_;
}
NodeOutput *get_link()
{
return link_;
}
float get_editor_value_float() const;
void get_editor_value_color(float *value) const;
void get_editor_value_vector(float *value) const;
};
/**
* \brief NodeOutput are sockets that can send data/input
* \ingroup Model
*/
class NodeOutput {
private:
Node *node_;
bNodeSocket *editor_socket_;
DataType datatype_;
public:
NodeOutput(Node *node, bNodeSocket *b_socket, DataType datatype);
Node *get_node() const
{
return node_;
}
DataType get_data_type() const
{
return datatype_;
}
bNodeSocket *get_bnode_socket() const
{
return editor_socket_;
}
float get_editor_value_float();
void get_editor_value_color(float *value);
void get_editor_value_vector(float *value);
};
} // namespace blender::compositor
|