-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Leon Thomm
committed
Aug 1, 2020
1 parent
8a58db8
commit 273f525
Showing
20 changed files
with
885 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
packages/random/nodes/random___RandInts0/random___RandInts0.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
from custom_src.NodeInstance import NodeInstance | ||
from custom_src.Node import Node | ||
from custom_src.retain import M | ||
|
||
|
||
# API METHODS | ||
|
||
# self.main_widget <- access to main widget | ||
# self.update_shape() <- recomputes the whole shape and content positions | ||
|
||
# Ports | ||
# self.input(index) <- access to input data | ||
# self.set_output_val(index, val) <- set output data port value | ||
# self.exec_output(index) <- executes an execution output | ||
|
||
# self.create_new_input(type_, label, widget_name=None, widget_pos='under', pos=-1) | ||
# self.delete_input(index) | ||
# self.create_new_output(type_, label, pos=-1) | ||
# self.delete_output(index) | ||
|
||
|
||
# Logging | ||
# mylog = self.new_log('Example Log') | ||
# mylog.log('I\'m alive!!') | ||
# self.log_message('hello global!', target='global') | ||
# self.log_message('that\'s not good', target='error') | ||
|
||
# ------------------------------------------------------------------------------ | ||
|
||
import random | ||
|
||
|
||
class RandInts_NodeInstance(NodeInstance): | ||
def __init__(self, parent_node: Node, flow, configuration=None): | ||
super(RandInts_NodeInstance, self).__init__(parent_node, flow, configuration) | ||
|
||
|
||
self.special_actions['make executable'] = {'method': M(self.action_make_executable)} | ||
self.active = False | ||
|
||
self.initialized() | ||
|
||
def action_make_executable(self): | ||
del self.special_actions['make executable'] | ||
self.special_actions['make passve'] = {'method': M(self.action_make_passive)} | ||
self.create_new_input('exec', '', pos=0) | ||
self.create_new_output('exec', '', pos=0) | ||
self.active = True | ||
|
||
def action_make_passive(self): | ||
del self.special_actions['make passve'] | ||
self.special_actions['make executable'] = {'method': M(self.action_make_executable)} | ||
self.delete_input(0) | ||
self.delete_output(0) | ||
self.active = False | ||
|
||
def update_event(self, input_called=-1): | ||
if self.active and input_called==0: | ||
self.set_output_val(1, [random.randint(self.input(2), self.input(3)) for i in range(self.input(1))]) | ||
self.exec_output(0) | ||
else: | ||
self.set_output_val(0, [random.randint(self.input(1), self.input(2)) for i in range(self.input(0))]) | ||
|
||
def get_data(self): | ||
data = {'active': self.active} | ||
return data | ||
|
||
def set_data(self, data): | ||
self.active = data['active'] | ||
|
||
def removing(self): | ||
pass |
72 changes: 72 additions & 0 deletions
72
packages/random/nodes/random___RandInts0/random___RandInts0___METACODE.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
from custom_src.NodeInstance import NodeInstance | ||
from custom_src.Node import Node | ||
from custom_src.retain import M | ||
|
||
|
||
# API METHODS | ||
|
||
# self.main_widget <- access to main widget | ||
# self.update_shape() <- recomputes the whole shape and content positions | ||
|
||
# Ports | ||
# self.input(index) <- access to input data | ||
# self.set_output_val(index, val) <- set output data port value | ||
# self.exec_output(index) <- executes an execution output | ||
|
||
# self.create_new_input(type_, label, widget_name=None, widget_pos='under', pos=-1) | ||
# self.delete_input(index) | ||
# self.create_new_output(type_, label, pos=-1) | ||
# self.delete_output(index) | ||
|
||
|
||
# Logging | ||
# mylog = self.new_log('Example Log') | ||
# mylog.log('I\'m alive!!') | ||
# self.log_message('hello global!', target='global') | ||
# self.log_message('that\'s not good', target='error') | ||
|
||
# ------------------------------------------------------------------------------ | ||
|
||
import random | ||
|
||
|
||
class %NODE_TITLE%_NodeInstance(NodeInstance): | ||
def __init__(self, parent_node: Node, flow, configuration=None): | ||
super(%NODE_TITLE%_NodeInstance, self).__init__(parent_node, flow, configuration) | ||
|
||
|
||
self.special_actions['make executable'] = {'method': M(self.action_make_executable)} | ||
self.active = False | ||
|
||
self.initialized() | ||
|
||
def action_make_executable(self): | ||
del self.special_actions['make executable'] | ||
self.special_actions['make passve'] = {'method': M(self.action_make_passive)} | ||
self.create_new_input('exec', '', pos=0) | ||
self.create_new_output('exec', '', pos=0) | ||
self.active = True | ||
|
||
def action_make_passive(self): | ||
del self.special_actions['make passve'] | ||
self.special_actions['make executable'] = {'method': M(self.action_make_executable)} | ||
self.delete_input(0) | ||
self.delete_output(0) | ||
self.active = False | ||
|
||
def update_event(self, input_called=-1): | ||
if self.active and input_called==0: | ||
self.set_output_val(1, [random.randint(self.input(2), self.input(3)) for i in range(self.input(1))]) | ||
self.exec_output(0) | ||
else: | ||
self.set_output_val(0, [random.randint(self.input(1), self.input(2)) for i in range(self.input(0))]) | ||
|
||
def get_data(self): | ||
data = {'active': self.active} | ||
return data | ||
|
||
def set_data(self, data): | ||
self.active = data['active'] | ||
|
||
def removing(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"type": "vyScriptFP nodes package", "nodes": [{"title": "Rand Seed", "description": "Initializes the random number generator.", "type": "", "module name": "random___RandSeed0", "class name": "RandSeed", "design style": "extended", "color": "#a2de98", "has main widget": false, "custom input widgets": [], "inputs": [{"type": "exec", "label": ""}, {"type": "data", "label": "seed", "has widget": true, "widget name": "std line edit m", "widget position": "besides"}], "outputs": [{"type": "exec", "label": ""}]}, {"title": "rand int", "description": "Generates a random integer N in a given range a <= N <= b.", "type": "", "module name": "random___RandInt0", "class name": "RandInt", "design style": "extended", "color": "#a2de98", "has main widget": false, "custom input widgets": [], "inputs": [{"type": "data", "label": "a", "has widget": true, "widget name": "std line edit m r nb", "widget position": "besides"}, {"type": "data", "label": "b", "has widget": true, "widget name": "std line edit m r nb", "widget position": "besides"}], "outputs": [{"type": "data", "label": ""}]}, {"title": "random", "description": "Generates a random float between 0.0 and 1.0.", "type": "", "module name": "random___Random0", "class name": "Random", "design style": "extended", "color": "#a2de98", "has main widget": false, "custom input widgets": [], "inputs": [], "outputs": [{"type": "data", "label": ""}]}]} | ||
{"type": "vyScriptFP nodes package", "nodes": [{"title": "Rand Seed", "description": "Initializes the random number generator.", "type": "", "module name": "random___RandSeed0", "class name": "RandSeed", "design style": "extended", "color": "#a2de98", "has main widget": false, "custom input widgets": [], "inputs": [{"type": "exec", "label": ""}, {"type": "data", "label": "seed", "has widget": true, "widget name": "std line edit m", "widget position": "besides"}], "outputs": [{"type": "exec", "label": ""}]}, {"title": "rand int", "description": "Generates a random integer N in a given range a <= N <= b.", "type": "", "module name": "random___RandInt0", "class name": "RandInt", "design style": "extended", "color": "#a2de98", "has main widget": false, "custom input widgets": [], "inputs": [{"type": "data", "label": "a", "has widget": true, "widget name": "std line edit m r nb", "widget position": "besides"}, {"type": "data", "label": "b", "has widget": true, "widget name": "std line edit m r nb", "widget position": "besides"}], "outputs": [{"type": "data", "label": ""}]}, {"title": "random", "description": "Generates a random float between 0.0 and 1.0.", "type": "", "module name": "random___Random0", "class name": "Random", "design style": "extended", "color": "#a2de98", "has main widget": false, "custom input widgets": [], "inputs": [], "outputs": [{"type": "data", "label": ""}]}, {"title": "rand ints", "description": "Generates a number of random integers N in a range a <= N <= b.", "type": "", "module name": "random___RandInts0", "class name": "RandInts", "design style": "extended", "color": "#a2de98", "has main widget": false, "custom input widgets": [], "inputs": [{"type": "data", "label": "cnt", "has widget": true, "widget name": "std line edit m r nb", "widget position": "besides"}, {"type": "data", "label": "a", "has widget": true, "widget name": "std line edit m r nb", "widget position": "besides"}, {"type": "data", "label": "b", "has widget": true, "widget name": "std line edit m r nb", "widget position": "besides"}], "outputs": [{"type": "data", "label": ""}]}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
from custom_src.NodeInstance import NodeInstance | ||
from custom_src.Node import Node | ||
from custom_src.retain import M | ||
|
||
|
||
# API METHODS | ||
|
||
# self.main_widget <- access to main widget | ||
# self.update_shape() <- recomputes the whole shape and content positions | ||
|
||
# Ports | ||
# self.input(index) <- access to input data | ||
# self.set_output_val(index, val) <- set output data port value | ||
# self.exec_output(index) <- executes an execution output | ||
|
||
# self.create_new_input(type_, label, widget_name=None, widget_pos='under', pos=-1) | ||
# self.delete_input(index) | ||
# self.create_new_output(type_, label, pos=-1) | ||
# self.delete_output(index) | ||
|
||
|
||
# Logging | ||
# mylog = self.new_log('Example Log') | ||
# mylog.log('I\'m alive!!') | ||
# self.log_message('hello global!', target='global') | ||
# self.log_message('that\'s not good', target='error') | ||
|
||
# ------------------------------------------------------------------------------ | ||
|
||
|
||
class Checkpoint_NodeInstance(NodeInstance): | ||
def __init__(self, parent_node: Node, flow, configuration=None): | ||
super(Checkpoint_NodeInstance, self).__init__(parent_node, flow, configuration) | ||
|
||
self.special_actions['make exec'] = {'method': M(self.action_make_exec)} | ||
self.passive = True | ||
self.num_exec_outputs = 0 | ||
|
||
self.initialized() | ||
|
||
def action_make_exec(self): | ||
self.passive = False | ||
self.delete_input(0) | ||
self.delete_output(0) | ||
self.create_new_input('exec', '') | ||
del self.special_actions['make exec'] | ||
self.special_actions['make data'] = {'method': M(self.action_make_data)} | ||
self.special_actions['add sequence output'] = {'method': M(self.action_add_sequence_output)} | ||
self.action_add_sequence_output() | ||
|
||
def action_add_sequence_output(self): | ||
self.create_new_output('exec', '') | ||
self.num_exec_outputs += 1 | ||
self.special_actions['remove output '+str(self.num_exec_outputs)] = {'method': M(self.action_remove_sequence_output), | ||
'data': self.num_exec_outputs-1} # -1 because index | ||
def action_remove_sequence_output(self, index): | ||
self.delete_output(index) | ||
|
||
# rebuilding special actions | ||
for i in range(self.num_exec_outputs): | ||
del self.special_actions['remove output '+str(i+1)] | ||
self.num_exec_outputs -= 1 | ||
for i in range(self.num_exec_outputs): | ||
self.special_actions['remove output '+str(i+1)] = {'method': M(self.action_remove_sequence_output), | ||
'data': i} | ||
|
||
def action_make_data(self): | ||
self.delete_input(0) | ||
for i in range(self.num_exec_outputs): | ||
self.delete_output(0) | ||
del self.special_actions['remove output '+str(i+1)] | ||
self.num_exec_outputs = 0 | ||
self.create_new_input('data', '') | ||
self.create_new_output('data', '') | ||
del self.special_actions['make data'] | ||
del self.special_actions['add sequence output'] | ||
self.special_actions['make exec'] = {'method': M(self.action_make_exec)} | ||
|
||
def update_event(self, input_called=-1): | ||
if self.passive: | ||
self.set_output_val(0, self.input(0)) | ||
else: | ||
if input_called==0: | ||
for i in range(self.num_exec_outputs): | ||
self.exec_output(i) | ||
|
||
def get_data(self): | ||
data = {'passive': self.passive, | ||
'num exec outputs': self.num_exec_outputs} | ||
return data | ||
|
||
def set_data(self, data): | ||
self.passive = data['passive'] | ||
self.num_exec_outputs = data['num exec outputs'] | ||
|
||
def removing(self): | ||
pass |
97 changes: 97 additions & 0 deletions
97
packages/std/nodes/std___Checkpoint0/std___Checkpoint0___METACODE.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
from custom_src.NodeInstance import NodeInstance | ||
from custom_src.Node import Node | ||
from custom_src.retain import M | ||
|
||
|
||
# API METHODS | ||
|
||
# self.main_widget <- access to main widget | ||
# self.update_shape() <- recomputes the whole shape and content positions | ||
|
||
# Ports | ||
# self.input(index) <- access to input data | ||
# self.set_output_val(index, val) <- set output data port value | ||
# self.exec_output(index) <- executes an execution output | ||
|
||
# self.create_new_input(type_, label, widget_name=None, widget_pos='under', pos=-1) | ||
# self.delete_input(index) | ||
# self.create_new_output(type_, label, pos=-1) | ||
# self.delete_output(index) | ||
|
||
|
||
# Logging | ||
# mylog = self.new_log('Example Log') | ||
# mylog.log('I\'m alive!!') | ||
# self.log_message('hello global!', target='global') | ||
# self.log_message('that\'s not good', target='error') | ||
|
||
# ------------------------------------------------------------------------------ | ||
|
||
|
||
class %NODE_TITLE%_NodeInstance(NodeInstance): | ||
def __init__(self, parent_node: Node, flow, configuration=None): | ||
super(%NODE_TITLE%_NodeInstance, self).__init__(parent_node, flow, configuration) | ||
|
||
self.special_actions['make exec'] = {'method': M(self.action_make_exec)} | ||
self.passive = True | ||
self.num_exec_outputs = 0 | ||
|
||
self.initialized() | ||
|
||
def action_make_exec(self): | ||
self.passive = False | ||
self.delete_input(0) | ||
self.delete_output(0) | ||
self.create_new_input('exec', '') | ||
del self.special_actions['make exec'] | ||
self.special_actions['make data'] = {'method': M(self.action_make_data)} | ||
self.special_actions['add sequence output'] = {'method': M(self.action_add_sequence_output)} | ||
self.action_add_sequence_output() | ||
|
||
def action_add_sequence_output(self): | ||
self.create_new_output('exec', '') | ||
self.num_exec_outputs += 1 | ||
self.special_actions['remove output '+str(self.num_exec_outputs)] = {'method': M(self.action_remove_sequence_output), | ||
'data': self.num_exec_outputs-1} # -1 because index | ||
def action_remove_sequence_output(self, index): | ||
self.delete_output(index) | ||
|
||
# rebuilding special actions | ||
for i in range(self.num_exec_outputs): | ||
del self.special_actions['remove output '+str(i+1)] | ||
self.num_exec_outputs -= 1 | ||
for i in range(self.num_exec_outputs): | ||
self.special_actions['remove output '+str(i+1)] = {'method': M(self.action_remove_sequence_output), | ||
'data': i} | ||
|
||
def action_make_data(self): | ||
self.delete_input(0) | ||
for i in range(self.num_exec_outputs): | ||
self.delete_output(0) | ||
del self.special_actions['remove output '+str(i+1)] | ||
self.num_exec_outputs = 0 | ||
self.create_new_input('data', '') | ||
self.create_new_output('data', '') | ||
del self.special_actions['make data'] | ||
del self.special_actions['add sequence output'] | ||
self.special_actions['make exec'] = {'method': M(self.action_make_exec)} | ||
|
||
def update_event(self, input_called=-1): | ||
if self.passive: | ||
self.set_output_val(0, self.input(0)) | ||
else: | ||
if input_called==0: | ||
for i in range(self.num_exec_outputs): | ||
self.exec_output(i) | ||
|
||
def get_data(self): | ||
data = {'passive': self.passive, | ||
'num exec outputs': self.num_exec_outputs} | ||
return data | ||
|
||
def set_data(self, data): | ||
self.passive = data['passive'] | ||
self.num_exec_outputs = data['num exec outputs'] | ||
|
||
def removing(self): | ||
pass |
Oops, something went wrong.