Skip to content

Commit

Permalink
Refactor interactor.py and molecular.py
Browse files Browse the repository at this point in the history
  • Loading branch information
WassCodeur committed Jun 6, 2024
1 parent 64fa7ad commit 6b00d92
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 53 deletions.
59 changes: 7 additions & 52 deletions fury/interactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import numpy as np

from fury.decorators import keyword_only
from fury.decorators import keyword_only
from fury.lib import (
Command,
Expand Down Expand Up @@ -119,18 +118,7 @@ def get_prop_at_event_position(self):
# TODO: return a list of items (i.e. each level of the assembly path).
event_pos = self.GetInteractor().GetEventPosition()

self.picker.Pick(
event_pos[0],
event_pos[1],
0,
self.GetCurrentRenderer(),
)
self.picker.Pick(
event_pos[0],
event_pos[1],
0,
self.GetCurrentRenderer(),
)
self.picker.Pick(event_pos[0], event_pos[1], 0, self.GetCurrentRenderer())

path = self.picker.GetPath()
if path is None:
Expand Down Expand Up @@ -186,8 +174,6 @@ def _process_event(self, obj, evt):

self.event.reset() # Event fully processed.

@keyword_only
def _button_clicked(self, button, *, last_event=-1, before_last_event=-2):
@keyword_only
def _button_clicked(self, button, *, last_event=-1, before_last_event=-2):
if len(self.history) < abs(before_last_event):
Expand All @@ -196,23 +182,15 @@ def _button_clicked(self, button, *, last_event=-1, before_last_event=-2):
if self.history[last_event]["event"] != button + "ButtonReleaseEvent":
return False

if (self.history[before_last_event]["event"]) != (button + "ButtonPressEvent"): # noqa
if (self.history[before_last_event]["event"]) != (button + "ButtonPressEvent"): # noqa
if self.history[before_last_event]["event"] != button + "ButtonPressEvent":
return False

return True

def _button_double_clicked(self, button):
if not (
(self._button_clicked(button))
and (
self._button_clicked(
button,
-3,
-4,
)
)
):
if not (self._button_clicked(button) and self._button_clicked(button,
last_event=-3,
before_last_event=-4)):
return False

return True
Expand Down Expand Up @@ -410,25 +388,7 @@ def force_render(self):
self.GetInteractor().GetRenderWindow().Render()

@keyword_only
def add_callback(
self,
prop,
event_type,
callback,
*,
priority=0,
args=None,
):
@keyword_only
def add_callback(
self,
prop,
event_type,
callback,
*,
priority=0,
args=None,
):
def add_callback(self, prop, event_type, callback, *, priority=0, args=None):
"""Add a callback associated to a specific event for a VTK prop.
Parameters
Expand Down Expand Up @@ -457,12 +417,7 @@ def _callback(_obj, event_name):
if event_type not in self.event2id:
# If the event type was not previously defined,
# then create an extra user defined event.
self.event2id[event_type] = (Command.UserEvent) + (
len(self.event2id) + 1
)
self.event2id[event_type] = (Command.UserEvent) + (
len(self.event2id) + 1
)
self.event2id[event_type] = Command.UserEvent + len(self.event2id) + 1

event_type = self.event2id[event_type]

Expand Down
2 changes: 1 addition & 1 deletion fury/molecular.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ def ribbon(molecule):

for i in range(num_total_atoms):
radii[i] = np.repeat(
table.atomic_radius(all_atomic_numbers[i], "VDW"),
table.atomic_radius(all_atomic_numbers[i], radius_type="VDW"),
3,
)
rgb[i] = table.atom_color(all_atomic_numbers[i])
Expand Down

0 comments on commit 6b00d92

Please sign in to comment.