Blender  V2.93
COM_NodeGraph.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * Copyright 2013, Blender Foundation.
17  */
18 
19 #pragma once
20 
21 #include "BLI_vector.hh"
22 
23 #include <map>
24 #include <set>
25 
26 #include "DNA_node_types.h"
27 
28 #ifdef WITH_CXX_GUARDEDALLOC
29 # include "MEM_guardedalloc.h"
30 #endif
31 
32 namespace blender::compositor {
33 
34 class CompositorContext;
35 class Node;
36 class NodeInput;
37 class NodeOutput;
38 
43 class NodeGraph {
44  public:
45  struct Link {
48 
50  {
51  }
52  };
53 
54  private:
55  Vector<Node *> m_nodes;
56  Vector<Link> m_links;
57 
58  public:
59  ~NodeGraph();
60 
61  const Vector<Node *> &nodes() const
62  {
63  return m_nodes;
64  }
65  const Vector<Link> &links() const
66  {
67  return m_links;
68  }
69 
71 
72  protected:
73  typedef std::pair<Vector<Node *>::iterator, Vector<Node *>::iterator> NodeRange;
74 
75  static bNodeSocket *find_b_node_input(bNode *b_node, const char *identifier);
76  static bNodeSocket *find_b_node_output(bNode *b_node, const char *identifier);
77 
78  void add_node(Node *node, bNodeTree *b_ntree, bNodeInstanceKey key, bool is_active_group);
79  void add_link(NodeOutput *fromSocket, NodeInput *toSocket);
80 
82  int nodes_start,
83  bNodeTree *tree,
84  bNodeInstanceKey parent_key);
85 
87  bNodeTree *b_ntree,
88  bNode *b_node,
89  bNodeInstanceKey key,
90  bool is_active_group);
91 
92  NodeOutput *find_output(const NodeRange &node_range, bNodeSocket *b_socket);
93  void add_bNodeLink(const NodeRange &node_range, bNodeLink *b_nodelink);
94 
95  /* **** Special proxy node type conversions **** */
96  /* These nodes are not represented in the node graph themselves,
97  * but converted into a number of proxy links
98  */
99 
100  void add_proxies_mute(bNodeTree *b_ntree,
101  bNode *b_node,
102  bNodeInstanceKey key,
103  bool is_active_group);
104  void add_proxies_skip(bNodeTree *b_ntree,
105  bNode *b_node,
106  bNodeInstanceKey key,
107  bool is_active_group);
108 
109  void add_proxies_group_inputs(bNode *b_node, bNode *b_node_io);
110  void add_proxies_group_outputs(bNode *b_node, bNode *b_node_io, bool use_buffer);
112 
113  void add_proxies_reroute(bNodeTree *b_ntree,
114  bNode *b_node,
115  bNodeInstanceKey key,
116  bool is_active_group);
117 
118 #ifdef WITH_CXX_GUARDEDALLOC
119  MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeGraph")
120 #endif
121 };
122 
123 } // namespace blender::compositor
Read Guarded memory(de)allocation.
Overall context of the compositor.
static bNodeSocket * find_b_node_input(bNode *b_node, const char *identifier)
void add_bNodeTree(const CompositorContext &context, int nodes_start, bNodeTree *tree, bNodeInstanceKey parent_key)
void add_bNode(const CompositorContext &context, bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group)
std::pair< Vector< Node * >::iterator, Vector< Node * >::iterator > NodeRange
Definition: COM_NodeGraph.h:73
void from_bNodeTree(const CompositorContext &context, bNodeTree *tree)
void add_proxies_group_inputs(bNode *b_node, bNode *b_node_io)
void add_link(NodeOutput *fromSocket, NodeInput *toSocket)
void add_proxies_reroute(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group)
void add_proxies_skip(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group)
NodeOutput * find_output(const NodeRange &node_range, bNodeSocket *b_socket)
const Vector< Node * > & nodes() const
Definition: COM_NodeGraph.h:61
void add_proxies_mute(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group)
static bNodeSocket * find_b_node_output(bNode *b_node, const char *identifier)
const Vector< Link > & links() const
Definition: COM_NodeGraph.h:65
void add_bNodeLink(const NodeRange &node_range, bNodeLink *b_nodelink)
void add_proxies_group(const CompositorContext &context, bNode *b_node, bNodeInstanceKey key)
void add_proxies_group_outputs(bNode *b_node, bNode *b_node_io, bool use_buffer)
void add_node(Node *node, bNodeTree *b_ntree, bNodeInstanceKey key, bool is_active_group)
NodeInput are sockets that can receive data/input.
Definition: COM_Node.h:210
NodeOutput are sockets that can send data/input.
Definition: COM_Node.h:258
OperationNode * node
void * tree
Definition: node.h:98