Skip to content

Commit

Permalink
created link nodes, renamed special_actions to actions
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-thomm committed Jun 6, 2021
1 parent e18f9f9 commit 0060724
Show file tree
Hide file tree
Showing 11 changed files with 404 additions and 292 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ __pycache__/
venv/
temp/
tests/
code_gen/
code_gen/
__own__/
10 changes: 5 additions & 5 deletions Ryven/packages/OpenCV/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(self, params):

self.active = False
self.file_path = ''
self.special_actions['make executable'] = {'method': self.action_make_executable}
self.actions['make executable'] = {'method': self.action_make_executable}

def view_place_event(self):
self.input_widget(1).path_chosen.connect(self.path_chosen)
Expand All @@ -94,15 +94,15 @@ def action_make_executable(self):
self.create_input(type_='exec', insert=0)
self.active = True

del self.special_actions['make executable']
self.special_actions['make passive'] = {'method': self.action_make_passive}
del self.actions['make executable']
self.actions['make passive'] = {'method': self.action_make_passive}

def action_make_passive(self):
self.delete_input(0)
self.active = False

del self.special_actions['make passive']
self.special_actions['make executable'] = {'method': self.action_make_executable}
del self.actions['make passive']
self.actions['make executable'] = {'method': self.action_make_executable}

def update_event(self, inp=-1):
if not self.active or (self.active and inp == 0):
Expand Down
2 changes: 1 addition & 1 deletion Ryven/packages/doc_examples/mypackage/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def __init__(self, params):
super().__init__(params)

# here we could add some stuff for all nodes below...
self.special_actions['asdf'] = {'method': self.asdf}
self.actions['asdf'] = {'method': self.asdf}

def asdf(self):
self.create_input_dt(dtype=dtypes.Integer(default=1, bounds=(1, 100)),
Expand Down
10 changes: 5 additions & 5 deletions Ryven/packages/linalg/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Matrix_Node(Node):
def __init__(self, params):
super(Matrix_Node, self).__init__(params)

self.special_actions['hide preview'] = {'method': self.action_hide_mw}
self.actions['hide preview'] = {'method': self.action_hide_mw}
self.main_widget_hidden = False
self.expression_matrix = None
self.evaluated_matrix = None
Expand Down Expand Up @@ -128,15 +128,15 @@ def var_val_updated(self, name, val):

def action_hide_mw(self):
self.main_widget().hide()
del self.special_actions['hide preview']
self.special_actions['show preview'] = {'method': self.action_show_mw}
del self.actions['hide preview']
self.actions['show preview'] = {'method': self.action_show_mw}
self.main_widget_hidden = True
self.update_shape()

def action_show_mw(self):
self.main_widget().show()
del self.special_actions['show preview']
self.special_actions['hide preview'] = {'method': self.action_hide_mw}
del self.actions['show preview']
self.actions['hide preview'] = {'method': self.action_hide_mw}
self.main_widget_hidden = False
self.update_shape()

Expand Down
12 changes: 6 additions & 6 deletions Ryven/packages/std/basic_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, params):
super().__init__(params)

self.num_inputs = 0
self.special_actions['add input'] = {'method': self.add_operand_input}
self.actions['add input'] = {'method': self.add_operand_input}

def place_event(self):
for i in range(len(self.inputs)):
Expand All @@ -34,12 +34,12 @@ def add_operand_input(self):
def remove_operand_input(self, index):
self.delete_input(index)
self.num_inputs -= 1
# del self.special_actions[f'remove input {index}']
# del self.actions[f'remove input {index}']
self.rebuild_remove_actions()
self.update()

def register_new_operand_input(self, index):
self.special_actions[f'remove input {index}'] = {
self.actions[f'remove input {index}'] = {
'method': self.remove_operand_input,
'data': index
}
Expand All @@ -48,15 +48,15 @@ def register_new_operand_input(self, index):
def rebuild_remove_actions(self):

remove_keys = []
for k, v in self.special_actions.items():
for k, v in self.actions.items():
if k.startswith('remove input'):
remove_keys.append(k)

for k in remove_keys:
del self.special_actions[k]
del self.actions[k]

for i in range(self.num_inputs):
self.special_actions[f'remove input {i}'] = {'method': self.remove_operand_input, 'data': i}
self.actions[f'remove input {i}'] = {'method': self.remove_operand_input, 'data': i}

def update_event(self, inp=-1):
self.set_output_val(0, self.apply_op([self.input(i) for i in range(len(self.inputs))]))
Expand Down
12 changes: 6 additions & 6 deletions Ryven/packages/std/control_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ForLoop_Node(CSNodeBase):
def __init__(self, params):
super().__init__(params)

self.special_actions['add dimension'] = {'method': self.add_dimension}
self.actions['add dimension'] = {'method': self.add_dimension}

self.dims = 1

Expand All @@ -55,7 +55,7 @@ def add_dimension(self):
self.create_output(f'i {new_dim}', 'data', insert=-1)
self.dims += 1

self.special_actions[f'remove dimension {new_dim}'] = {
self.actions[f'remove dimension {new_dim}'] = {
'method': self.remove_dimension,
'data': new_dim
}
Expand All @@ -68,21 +68,21 @@ def remove_dimension(self, dim):
self.delete_output(out_index)
self.delete_output(out_index)
self.dims -= 1
# del self.special_actions[f'remove dimension {dim}']
# del self.actions[f'remove dimension {dim}']
self.rebuild_remove_actions()

def rebuild_remove_actions(self):

remove_keys = []
for k, v in self.special_actions.items():
for k, v in self.actions.items():
if k.startswith('remove dimension'):
remove_keys.append(k)

for k in remove_keys:
del self.special_actions[k]
del self.actions[k]

for i in range(1, self.dims):
self.special_actions[f'remove dimension {i+1}'] = {'method': self.remove_dimension, 'data': i+1}
self.actions[f'remove dimension {i+1}'] = {'method': self.remove_dimension, 'data': i+1}

def input_from_dim(self, dim):
return 1 + 2*(dim-1)
Expand Down
Loading

0 comments on commit 0060724

Please sign in to comment.