11#!/usr/bin/python
22# -*- coding: utf-8 -*-
3- import inspect
43import math
4+ import inspect
55from functools import partial
66
77# add basic math functions to math library
2121from NodeGraphQt import QtWidgets , QtCore , PropertiesBinWidget , NodeTreeWidget
2222
2323
24- def update_streams (node , * args ):
25- """
26- Update all nodes joined by pipes
27- """
28- nodes = []
29- trash = []
30-
31- for port , nodeList in node .connected_output_nodes ().items ():
32- nodes .extend (nodeList )
33-
34- while nodes :
35- node = nodes .pop ()
36- if node not in trash :
37- trash .append (node )
38-
39- for port , nodeList in node .connected_output_nodes ().items ():
40- nodes .extend (nodeList )
41-
42- if not nodes :
43- try :
44- node .run ()
45- except Exception as error :
46- print ("Error Update Streams: %s" % str (error ))
47-
48-
4924class DataInputNode (BaseNode ):
5025 """
5126 Input node data.
@@ -58,10 +33,7 @@ def __init__(self):
5833 super (DataInputNode , self ).__init__ ()
5934 self .add_output ('out' )
6035 self .add_text_input ('out' , 'Data Output' , text = '0.4' , tab = 'widgets' )
61- self .view .widgets ['out' ].value_changed .connect (partial (update_streams , self ))
62-
63- def run (self ):
64- return
36+ self .view .widgets ['out' ].value_changed .connect (self .update_streams )
6537
6638
6739class MathFunctionsNode (BaseNode ):
@@ -80,18 +52,17 @@ class MathFunctionsNode(BaseNode):
8052 def __init__ (self ):
8153 super (MathFunctionsNode , self ).__init__ ()
8254 self .set_color (25 , 58 , 51 )
83- self .add_combo_menu ('functions ' , 'Functions' , items = self .mathFuncs ,
55+ self .add_combo_menu ('funcs ' , 'Functions' , items = self .mathFuncs ,
8456 tab = 'widgets' )
8557
8658 # switch math function type
87- self .view .widgets ['functions' ].value_changed .connect (self .addFunction )
88- update = partial (update_streams , self )
89- self .view .widgets ['functions' ].value_changed .connect (update )
59+ self .view .widgets ['funcs' ].value_changed .connect (self .addFunction )
60+ self .view .widgets ['funcs' ].value_changed .connect (self .update_streams )
9061 self .add_output ('output' )
9162 self .create_property ('output' , None )
9263 self .trigger_type = 'no_inPorts'
9364
94- self .view .widgets ['functions ' ].widget .setCurrentIndex (2 )
65+ self .view .widgets ['funcs ' ].widget .setCurrentIndex (2 )
9566
9667 def addFunction (self , prop , func ):
9768 """
@@ -144,12 +115,12 @@ def run(self):
144115 def on_input_connected (self , to_port , from_port ):
145116 """Override node callback method."""
146117 self .set_property (to_port .name (), from_port .node ().run ())
147- update_streams (self )
118+ self . update_streams ()
148119
149120 def on_input_disconnected (self , to_port , from_port ):
150121 """Override node callback method."""
151122 self .set_property ('output' , None )
152- update_streams (self )
123+ self . update_streams ()
153124
154125
155126class DataViewerNode (BaseNode ):
0 commit comments