Blender V4.3
COM_Node.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include "BLI_vector.hh"
8
9#include "DNA_node_types.h"
10
11/* common node includes
12 * added here so node files don't have to include themselves
13 */
15#include "COM_NodeConverter.h"
16
17namespace blender::compositor {
18
19class NodeOperation;
20class NodeConverter;
21
25class Node {
26 private:
30 bNodeTree *editor_node_tree_;
31
35 const bNode *editor_node_;
36
40 bool in_active_group_;
41
45 bNodeInstanceKey instance_key_;
46
47 protected:
52
57
58 public:
59 Node(bNode *editor_node, bool create_sockets = true);
60 virtual ~Node();
61
65 const bNode *get_bnode() const
66 {
67 return editor_node_;
68 }
69
74 {
75 return editor_node_tree_;
76 }
77
84 void set_bnode(bNode *node)
85 {
86 editor_node_ = node;
87 }
88
93 void set_bnodetree(bNodeTree *nodetree)
94 {
95 editor_node_tree_ = nodetree;
96 }
97
102 {
103 return inputs_;
104 }
105
110 {
111 return outputs_;
112 }
113
118 NodeOutput *get_output_socket(unsigned int index = 0) const;
119
124 NodeInput *get_input_socket(unsigned int index) const;
125
130 void set_is_in_active_group(bool value)
131 {
132 in_active_group_ = value;
133 }
134
141 inline bool is_in_active_group() const
142 {
143 return in_active_group_;
144 }
145
154 virtual void convert_to_operations(NodeConverter &converter,
155 const CompositorContext &context) const = 0;
156
158 {
159 instance_key_ = instance_key;
160 }
162 {
163 return instance_key_;
164 }
165
166 protected:
172 void add_input_socket(DataType datatype);
173 void add_input_socket(DataType datatype, bNodeSocket *socket);
174
180 void add_output_socket(DataType datatype);
181 void add_output_socket(DataType datatype, bNodeSocket *socket);
182
183 bNodeSocket *get_editor_input_socket(int editor_node_input_socket_index);
184 bNodeSocket *get_editor_output_socket(int editor_node_output_socket_index);
185};
186
192 private:
193 Node *node_;
194 bNodeSocket *editor_socket_;
195
196 DataType datatype_;
197
202 NodeOutput *link_;
203
204 public:
205 NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype);
206
207 Node *get_node() const
208 {
209 return node_;
210 }
212 {
213 return datatype_;
214 }
216 {
217 return editor_socket_;
218 }
219
220 void set_link(NodeOutput *link);
221 bool is_linked() const
222 {
223 return link_;
224 }
226 {
227 return link_;
228 }
229
230 float get_editor_value_float() const;
231 void get_editor_value_color(float *value) const;
232 void get_editor_value_vector(float *value) const;
233};
234
240 private:
241 Node *node_;
242 bNodeSocket *editor_socket_;
243
244 DataType datatype_;
245
246 public:
247 NodeOutput(Node *node, bNodeSocket *b_socket, DataType datatype);
248
249 Node *get_node() const
250 {
251 return node_;
252 }
254 {
255 return datatype_;
256 }
258 {
259 return editor_socket_;
260 }
261
263 void get_editor_value_color(float *value);
264 void get_editor_value_vector(float *value);
265};
266
267} // namespace blender::compositor
Overall context of the compositor.
NodeInput are sockets that can receive data/input.
Definition COM_Node.h:191
NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype)
Definition COM_Node.cc:126
void get_editor_value_color(float *value) const
Definition COM_Node.cc:143
bNodeSocket * get_bnode_socket() const
Definition COM_Node.h:215
DataType get_data_type() const
Definition COM_Node.h:211
float get_editor_value_float() const
Definition COM_Node.cc:136
void set_link(NodeOutput *link)
Definition COM_Node.cc:131
void get_editor_value_vector(float *value) const
Definition COM_Node.cc:150
NodeOutput are sockets that can send data/input.
Definition COM_Node.h:239
bNodeSocket * get_bnode_socket() const
Definition COM_Node.h:257
void get_editor_value_vector(float *value)
Definition COM_Node.cc:180
NodeOutput(Node *node, bNodeSocket *b_socket, DataType datatype)
Definition COM_Node.cc:161
void get_editor_value_color(float *value)
Definition COM_Node.cc:173
DataType get_data_type() const
Definition COM_Node.h:253
NodeOutput * get_output_socket(unsigned int index=0) const
Definition COM_Node.cc:85
Span< NodeInput * > get_input_sockets() const
get access to the vector of input sockets
Definition COM_Node.h:101
void add_output_socket(DataType datatype)
add an NodeOutput to the collection of output-sockets
Definition COM_Node.cc:75
void set_instance_key(bNodeInstanceKey instance_key)
Definition COM_Node.h:157
bNodeInstanceKey get_instance_key() const
Definition COM_Node.h:161
void set_bnode(bNode *node)
set the reference to the bNode
Definition COM_Node.h:84
NodeInput * get_input_socket(unsigned int index) const
Definition COM_Node.cc:90
void add_input_socket(DataType datatype)
add an NodeInput to the collection of input-sockets
Definition COM_Node.cc:64
bool is_in_active_group() const
Is this node part of the active group the active group is the group that is currently being edited....
Definition COM_Node.h:141
void set_bnodetree(bNodeTree *nodetree)
set the reference to the bNodeTree
Definition COM_Node.h:93
bNodeSocket * get_editor_output_socket(int editor_node_output_socket_index)
Definition COM_Node.cc:108
Vector< NodeInput * > inputs_
the list of actual input-sockets
Definition COM_Node.h:51
bNodeTree * get_bnodetree() const
get the reference to the SDNA bNodeTree struct
Definition COM_Node.h:73
const bNode * get_bnode() const
get the reference to the SDNA bNode struct
Definition COM_Node.h:65
Node(bNode *editor_node, bool create_sockets=true)
Definition COM_Node.cc:18
Span< NodeOutput * > get_output_sockets() const
get access to the vector of input sockets
Definition COM_Node.h:109
Vector< NodeOutput * > outputs_
the list of actual output-sockets
Definition COM_Node.h:56
void set_is_in_active_group(bool value)
Is this node in the active group (the group that is being edited)
Definition COM_Node.h:130
bNodeSocket * get_editor_input_socket(int editor_node_input_socket_index)
Definition COM_Node.cc:95
virtual void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const =0
convert node to operation
OperationNode * node
DataType
possible data types for sockets
Definition COM_defines.h:21