11#!/usr/bin/python
22# -*- coding: utf-8 -*-
3- import example_auto_nodes
4- from NodeGraphQt import NodeGraph , setup_context_menu
5- from NodeGraphQt import QtWidgets , QtCore , PropertiesBinWidget , \
6- NodeTreeWidget , BackdropNode , NodePublishWidget
7- import os
8- import sys
9- import inspect
3+ from NodeGraphQt import NodeGraph , setup_context_menu , \
4+ QtWidgets , QtCore , PropertiesBinWidget , BackdropNode
5+ from example_auto_nodes import Publish , RootNode , update_nodes , setup_node_menu
106import importlib
11- from example_auto_nodes import AutoNode , ModuleNode , \
12- SubGraphNode , Publish , RootNode , update_nodes
7+ import inspect
8+ import sys
9+ import os
1310
1411
1512def get_nodes_from_folder (folder_path ):
@@ -49,58 +46,16 @@ def get_published_nodes_from_folder(folder_path):
4946 return nodes
5047
5148
52- def cook_node (graph , node ):
53- node .update_stream (forceCook = True )
54-
55-
56- def print_functions (graph , node ):
57- for func in node .module_functions :
58- print (func )
59-
60-
61- def toggle_auto_cook (graph , node ):
62- node .auto_cook = not node .auto_cook
63-
64-
65- def enter_node (graph , node ):
66- graph .set_node_space (node )
67-
68-
69- def allow_edit (graph , node ):
70- node .set_property ('published' , False )
71-
72-
73- def print_path (graph , node ):
74- print (node .path ())
75-
76-
77- def find_node_by_path (graph , node ):
78- print (graph .get_node_by_path (node .path ()))
79-
80-
81- def print_children (graph , node ):
82- children = node .children ()
83- print (len (children ), children )
84-
85-
86- def publish_node (graph , node ):
87- wid = NodePublishWidget (node = node )
88- wid .show ()
89-
90-
91- def cook_nodes (nodes ):
92- update_nodes (nodes )
93-
94-
9549if __name__ == '__main__' :
96- app = QtWidgets .QApplication ([] )
50+ app = QtWidgets .QApplication ()
9751
9852 # create node graph.
9953 graph = NodeGraph ()
10054 graph .use_OpenGL ()
10155
10256 # set up default menu and commands.
10357 setup_context_menu (graph )
58+ setup_node_menu (graph , Publish )
10459
10560 # show the properties bin when a node is "double clicked" in the graph.
10661 properties_bin = PropertiesBinWidget (node_graph = graph )
@@ -111,40 +66,20 @@ def show_prop_bin(node):
11166 properties_bin .show ()
11267 graph .node_double_clicked .connect (show_prop_bin )
11368
114- # show the nodes list when a node is "double clicked" in the graph.
115- node_tree = NodeTreeWidget (node_graph = graph )
116-
117- def show_nodes_list (node ):
118- if not node_tree .isVisible ():
119- node_tree .update ()
120- node_tree .show ()
121- graph .node_double_clicked .connect (show_nodes_list )
122-
12369 # register nodes
12470 reg_nodes = get_nodes_from_folder (os .getcwd () + "/example_auto_nodes" )
12571 BackdropNode .__identifier__ = 'Utility::Backdrop'
12672 reg_nodes .append (BackdropNode )
12773 reg_nodes .extend (get_published_nodes_from_folder (os .getcwd () + "/example_auto_nodes/published_nodes" ))
12874 [graph .register_node (n ) for n in reg_nodes ]
12975
130- # setup node menu
131- node_menu = graph .context_nodes_menu ()
132- node_menu .add_command ('Allow Edit' , allow_edit , node_class = Publish )
133- node_menu .add_command ('Enter Node' , enter_node , node_class = SubGraphNode )
134- node_menu .add_command ('Publish Node' , publish_node , node_class = SubGraphNode )
135- node_menu .add_command ('Print Children' , print_children , node_class = SubGraphNode )
136- node_menu .add_command ('Print Functions' , print_functions , node_class = ModuleNode )
137- node_menu .add_command ('Cook Node' , cook_node , node_class = AutoNode )
138- node_menu .add_command ('Toggle Auto Cook' , toggle_auto_cook , node_class = AutoNode )
139- node_menu .add_command ('Print Path' , print_path , node_class = AutoNode )
140- node_menu .add_command ('Find Node By Path' , find_node_by_path , node_class = AutoNode )
141-
14276 # create root node
77+ # if we want to use sub graph system, root node is must.
14378 graph .add_node (RootNode ())
14479
14580 # create test nodes
14681 graph .load_session (r'example_auto_nodes/networks/example_SubGraph.json' )
147- cook_nodes (graph .root_node ().children ())
82+ update_nodes (graph .root_node ().children ())
14883
14984 # widget used for the node graph.
15085 graph_widget = graph .widget
0 commit comments