Welcome to mirror list, hosted at ThFree Co, Russian Federation.

COM_NodeGraph.h « intern « compositor « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7c6322d2a42ba605d1c4bc2003c057f8ad8594c0 (plain)
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
/*
 * Copyright 2013, Blender Foundation.
 *
 * 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.
 *
 * Contributor:
 *		Lukas Toenne
 */

#ifndef _COM_NodeGraph_h
#define _COM_NodeGraph_h

#include <map>
#include <set>
#include <vector>

extern "C" {
#include "DNA_node_types.h"
}

#ifdef WITH_CXX_GUARDEDALLOC
#  include "MEM_guardedalloc.h"
#endif

class CompositorContext;
class Node;
class NodeInput;
class NodeOutput;

/** Internal representation of DNA node data.
 *  This structure is converted into operations by \a NodeCompiler.
 */
class NodeGraph {
public:
	class Link {
	private:
		NodeOutput *m_from;
		NodeInput *m_to;

	public:
		Link(NodeOutput *from, NodeInput *to) :
		    m_from(from),
		    m_to(to)
		{}

		NodeOutput *getFromSocket() const { return m_from; }
		NodeInput *getToSocket() const { return m_to; }
	};

	typedef std::vector<Node *> Nodes;
	typedef Nodes::iterator NodeIterator;
	typedef std::vector<Link> Links;

private:
	Nodes m_nodes;
	Links m_links;

public:
	NodeGraph();
	~NodeGraph();

	const Nodes &nodes() const { return m_nodes; }
	const Links &links() const { return m_links; }

	void from_bNodeTree(const CompositorContext &context, bNodeTree *tree);

protected:
	typedef std::pair<NodeIterator, NodeIterator> NodeRange;
	typedef std::vector<NodeInput *> NodeInputs;

	static bNodeSocket *find_b_node_input(bNode *b_node, const char *identifier);
	static bNodeSocket *find_b_node_output(bNode *b_node, const char *identifier);

	void add_node(Node *node, bNodeTree *b_ntree, bNodeInstanceKey key, bool is_active_group);
	void add_link(NodeOutput *fromSocket, NodeInput *toSocket);

	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);

	NodeInputs find_inputs(const NodeRange &node_range, bNodeSocket *b_socket);
	NodeOutput *find_output(const NodeRange &node_range, bNodeSocket *b_socket);
	void add_bNodeLink(const NodeRange &node_range, bNodeLink *bNodeLink);

	/* **** Special proxy node type conversions **** */
	/* These nodes are not represented in the node graph themselves,
	 * but converted into a number of proxy links
	 */

	void add_proxies_mute(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);

	void add_proxies_group_inputs(bNode *b_node, bNode *b_node_io);
	void add_proxies_group_outputs(bNode *b_node, bNode *b_node_io, bool use_buffer);
	void add_proxies_group(const CompositorContext &context, bNode *b_node, bNodeInstanceKey key);

	void add_proxies_reroute(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group);

#ifdef WITH_CXX_GUARDEDALLOC
	MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeGraph")
#endif
};

#endif /* _COM_NodeGraph_h */