Skip to content

Commit b082f39

Browse files
authored
Merge pull request #152 from cesioarg/master
Add logic nodes + wrappers for build-in modules
2 parents f113149 + d2680a9 commit b082f39

File tree

16 files changed

+834
-69
lines changed

16 files changed

+834
-69
lines changed

NodeGraphQt/base/node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ def update_streams(self, *args):
853853
for port, nodeList in node.connected_output_nodes().items():
854854
nodes.extend(nodeList)
855855

856-
if not nodes:
856+
if not node.connected_output_nodes():
857857
try:
858858
node.run()
859859
except Exception as error:

example.nodes

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
{
2+
"nodes":{
3+
"0x15095e08":{
4+
"type_":"Viewers.DataViewerNode",
5+
"icon":null,
6+
"name":"Output",
7+
"color":[
8+
13,
9+
18,
10+
23,
11+
255
12+
],
13+
"border_color":[
14+
74,
15+
84,
16+
85,
17+
255
18+
],
19+
"text_color":[
20+
255,
21+
255,
22+
255,
23+
180
24+
],
25+
"disabled":false,
26+
"selected":true,
27+
"width":170,
28+
"height":91.0,
29+
"pos":[
30+
149.0,
31+
-146.0
32+
],
33+
"custom":{
34+
"data":""
35+
}
36+
},
37+
"0x15126848":{
38+
"type_":"Inputs.BoolInputNode",
39+
"icon":null,
40+
"name":"Bool",
41+
"color":[
42+
13,
43+
18,
44+
23,
45+
255
46+
],
47+
"border_color":[
48+
74,
49+
84,
50+
85,
51+
255
52+
],
53+
"text_color":[
54+
255,
55+
255,
56+
255,
57+
180
58+
],
59+
"disabled":false,
60+
"selected":true,
61+
"width":170,
62+
"height":103.0,
63+
"pos":[
64+
-413.0,
65+
-212.0
66+
],
67+
"custom":{
68+
"out":true,
69+
"combo":"True"
70+
}
71+
},
72+
"0x15140308":{
73+
"type_":"Logics.BooleanNode",
74+
"icon":null,
75+
"name":"Boolean",
76+
"color":[
77+
13,
78+
18,
79+
23,
80+
255
81+
],
82+
"border_color":[
83+
74,
84+
84,
85+
85,
86+
255
87+
],
88+
"text_color":[
89+
255,
90+
255,
91+
255,
92+
180
93+
],
94+
"disabled":false,
95+
"selected":true,
96+
"width":170,
97+
"height":103.0,
98+
"pos":[
99+
-143.0,
100+
-149.0
101+
],
102+
"custom":{
103+
"out":null,
104+
"funcs":"and"
105+
}
106+
},
107+
"0x1514a4c8":{
108+
"type_":"Inputs.BoolInputNode",
109+
"icon":null,
110+
"name":"Bool 1",
111+
"color":[
112+
13,
113+
18,
114+
23,
115+
255
116+
],
117+
"border_color":[
118+
74,
119+
84,
120+
85,
121+
255
122+
],
123+
"text_color":[
124+
255,
125+
255,
126+
255,
127+
180
128+
],
129+
"disabled":false,
130+
"selected":true,
131+
"width":170,
132+
"height":103.0,
133+
"pos":[
134+
-411.25,
135+
-61.5
136+
],
137+
"custom":{
138+
"out":true,
139+
"combo":"True"
140+
}
141+
}
142+
},
143+
"connections":[
144+
{
145+
"in":[
146+
"0x15095e08",
147+
"data"
148+
],
149+
"out":[
150+
"0x15140308",
151+
"out"
152+
]
153+
},
154+
{
155+
"out":[
156+
"0x15126848",
157+
"out"
158+
],
159+
"in":[
160+
"0x15140308",
161+
"a"
162+
]
163+
},
164+
{
165+
"in":[
166+
"0x15140308",
167+
"b"
168+
],
169+
"out":[
170+
"0x1514a4c8",
171+
"out"
172+
]
173+
}
174+
]
175+
}

example_auto_nodes/module_nodes.py

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,18 @@
22
get_functions_from_module,
33
get_functions_from_type)
44

5-
import math
65
import os
76
import sys
87
import random
98
import numpy
109
import numpydoc.docscrape
1110
import inspect
1211

13-
# add basic math functions to math library
14-
math.add = lambda x, y: x + y
15-
math.sub = lambda x, y: x - y
16-
math.mul = lambda x, y: x * y
17-
math.div = lambda x, y: x / y
18-
19-
20-
def get_value(self,index):
21-
return self[index]
22-
23-
24-
def get_item(self,index):
25-
return self.items()[index]
12+
import example_auto_nodes.wrappers.math as _math
13+
import example_auto_nodes.wrappers.list as _list
14+
import example_auto_nodes.wrappers.dict as _dict
15+
import example_auto_nodes.wrappers.str as _str
16+
import example_auto_nodes.wrappers.tuple as _tuple
2617

2718

2819
class MathModuleNode(ModuleNode):
@@ -36,7 +27,7 @@ class MathModuleNode(ModuleNode):
3627
# set the initial default node name.
3728
NODE_NAME = 'math module'
3829

39-
module_functions = get_functions_from_type(math)
30+
module_functions = get_functions_from_type(_math)
4031

4132
def __init__(self):
4233
super(MathModuleNode, self).__init__(float, float)
@@ -162,8 +153,8 @@ class StringFunctionsNode(ModuleNode):
162153
# set the initial default node name.
163154
NODE_NAME = 'String Functions'
164155

165-
module_functions = get_functions_from_type(str)
166-
module_functions["get value"] = get_value
156+
module_functions = get_functions_from_type(_str)
157+
167158

168159
def __init__(self):
169160
super(StringFunctionsNode, self).__init__()
@@ -180,8 +171,7 @@ class ListFunctionsNode(ModuleNode):
180171
# set the initial default node name.
181172
NODE_NAME = 'List Functions'
182173

183-
module_functions = get_functions_from_type(list)
184-
module_functions["get value"] = get_value
174+
module_functions = get_functions_from_type(_list)
185175

186176
def __init__(self):
187177
super(ListFunctionsNode, self).__init__()
@@ -198,8 +188,7 @@ class DictFunctionsNode(ModuleNode):
198188
# set the initial default node name.
199189
NODE_NAME = 'Dict Functions'
200190

201-
module_functions = get_functions_from_type(list)
202-
module_functions["get item"] = get_item
191+
module_functions = get_functions_from_type(_dict)
203192

204193
def __init__(self):
205194
super(DictFunctionsNode, self).__init__()
@@ -216,8 +205,7 @@ class TupleFunctionsNode(ModuleNode):
216205
# set the initial default node name.
217206
NODE_NAME = 'Tuple Functions'
218207

219-
module_functions = get_functions_from_type(tuple)
220-
module_functions["get value"] = get_value
208+
module_functions = get_functions_from_type(_tuple)
221209

222210
def __init__(self):
223211
super(TupleFunctionsNode, self).__init__()

example_auto_nodes/wrappers/__init__.py

Whitespace-only changes.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
def clear(self):
2+
self.clear()
3+
return self
4+
5+
6+
def copy(self):
7+
return self.copy()
8+
9+
10+
def fromkeys(self, iterable, value=None):
11+
return self.fromkeys(iterable, value)
12+
13+
14+
def get(self, key, default=None):
15+
return self.get(key, default)
16+
17+
18+
def items(self):
19+
return list(self.items())
20+
21+
22+
def keys(self):
23+
return list(self.keys())
24+
25+
26+
def pop(self, index):
27+
return self.pop(index)
28+
29+
30+
def popitem(self):
31+
return self.popitem()
32+
33+
34+
def setdefault(self, key, default=None):
35+
self.setdefault(key, default)
36+
return self
37+
38+
39+
def update(self, e):
40+
self.update(e)
41+
return self
42+
43+
44+
def values(self):
45+
return list(self.values())
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
def append(self, object):
2+
self.append(object)
3+
return self
4+
5+
6+
def clear(self):
7+
self.clear()
8+
return self
9+
10+
11+
def copy(self):
12+
return self.copy()
13+
14+
15+
def count(self, value):
16+
return self.count(value)
17+
18+
19+
def extend(self, iterable):
20+
self.extend(iterable)
21+
return self
22+
23+
def index(self, value):
24+
return self.index(value)
25+
26+
27+
def insert(self, index, obj):
28+
self.insert(index, obj)
29+
return self
30+
31+
32+
def pop(self, index=-1):
33+
return self.pop(index)
34+
35+
36+
def remove(self, value):
37+
return self.remove(value)
38+
39+
40+
def reverse(self):
41+
self.reverse()
42+
return self
43+
44+
45+
def sort(self):
46+
self.sort()
47+
return self
48+
49+
50+
# custom functions
51+
def get(self, index):
52+
return self.__getitem__(index)

0 commit comments

Comments
 (0)