Skip to content

Commit

Permalink
RUFF
Browse files Browse the repository at this point in the history
  • Loading branch information
rmatsuda committed Feb 11, 2025
1 parent ca50dc9 commit 5fcfe36
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 34 deletions.
27 changes: 9 additions & 18 deletions invesalius/data/viewer_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,8 @@ def __bind_events(self):
self.OnUpdateRobotStatus, "Robot to Neuronavigation: Update robot status"
)
Publisher.subscribe(
self.UpdateForceCompensation, "Robot to Neuronavigation: Update force compensation displacement"
self.UpdateForceCompensation,
"Robot to Neuronavigation: Update force compensation displacement",
)
Publisher.subscribe(self.GetCoilPosition, "Calculate position and rotation")
Publisher.subscribe(
Expand Down Expand Up @@ -1007,9 +1008,6 @@ def EnableTargetMode(self):
# force_compensate_arrow_up = self.CreateCompensateArrowUp()
# self.ren.AddActor(force_compensate_arrow_up)




# Store the object for 'distance' text so it can be modified when distance changes.
self.distance_text = distance_text

Expand Down Expand Up @@ -1106,7 +1104,6 @@ def UpdateForceCompensation(self, displacement):
# if self.force_compensate_text is not None:
# self.force_compensate_text.SetValue(formatted_force_compensate)


def OnUpdateCoilPose(self, m_img, coord):
# vtk_colors = vtkNamedColors()
if self.target_coord and self.target_mode:
Expand Down Expand Up @@ -1186,17 +1183,12 @@ def OnUpdateCoilPose(self, m_img, coord):

# print("creating force_compensate_arrow_up")
# force_compensate_arrow_up = self.actor_factory.CreateArrow([0, 0, 0], [0, 0, 50])
force_compensate_arrow_up = self.actor_factory.CreateArrow(
[0, 0, 0], [0, -50, 0]
)
force_compensate_arrow_up = self.actor_factory.CreateArrow([0, 0, 0], [0, -50, 0])
force_compensate_arrow_up.SetPosition(0, -575, 0)
force_compensate_arrow_up.RotateY(90)
force_compensate_arrow_up.RotateZ(180)
force_compensate_arrow_up.GetProperty().SetColor(1, 1, 1)




# print("Adding the actor force_compensate_arrow_up")
self.target_guide_renderer.AddActor(force_compensate_arrow_up)
########
Expand Down Expand Up @@ -1376,15 +1368,14 @@ def CreateDistanceText(self):
# force_compensate_arrow_up.RotateZ(180)
# return force_compensate_arrow_up


# def CreateForceCompensateText(self):
# up_arrow_actor = vtku.vtkTextActor()
# up_arrow_actor.SetInput("TESTTEST") # Unicode for up arrow
# up_arrow_actor.GetTextProperty().SetFontSize(24)
# up_arrow_actor.GetTextProperty().SetColor(1.0, 1.0, 1.0)
# up_arrow_actor.SetPosition(100, 100) #### Might wanna change
# up_arrow_actor = vtku.vtkTextActor()
# up_arrow_actor.SetInput("TESTTEST") # Unicode for up arrow
# up_arrow_actor.GetTextProperty().SetFontSize(24)
# up_arrow_actor.GetTextProperty().SetColor(1.0, 1.0, 1.0)
# up_arrow_actor.SetPosition(100, 100) #### Might wanna change

# return up_arrow_actor
# return up_arrow_actor

# def CreateForceCompensateText(self):
# force_compensate_text = vtku.Text()
Expand Down
37 changes: 23 additions & 14 deletions invesalius/gui/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ def __init__(self, parent):
border = wx.BoxSizer(wx.VERTICAL)
border.Add(bsizer_logging, 1, wx.EXPAND | wx.ALL, 10) # | wx.FIXED_MINSIZE, 10)
border.Add(bsizer_console_logging, 1, wx.EXPAND | wx.ALL, 10) # | wx.FIXED_MINSIZE, 10)

self.SetSizerAndFit(border)

self.Layout()
Expand Down Expand Up @@ -861,21 +861,24 @@ def __init__(self, parent, navigation):
choices=["No", "Yes"],
majorDimension=2,
style=wx.RA_SPECIFY_COLS | wx.NO_BORDER | wx.FIXED_MINSIZE,
)
)

min_force_threshold = wx.StaticText(self, -1, _("Min force (N):"))
min_force_threshold_spin = self.force_adjust_distance_spin = wx.SpinCtrlDouble(self, -1, "", size=wx.Size(50, 23), inc=0.01)
min_force_threshold_spin = self.force_adjust_distance_spin = wx.SpinCtrlDouble(
self, -1, "", size=wx.Size(50, 23), inc=0.01
)
min_force_threshold_spin.Enable(1)
min_force_threshold_spin.SetRange(2.0, 10.0)
min_force_threshold_spin.SetValue(self.min_force_threshold)
# spin_nav_move.Bind(wx.EVT_TEXT, partial(self.OnSelectNavSleep, ctrl=spin_nav_sleep))
# spin_nav_move.Bind(wx.EVT_SPINCTRL, partial(self.OnSelectNavSleep, ctrl=spin_nav_sleep))


# Add this variable into a legit variable lol
self.max_force_threshold = 10.0
max_force_threshold = wx.StaticText(self, -1, _("Max force (N):"))
max_force_threshold_spin = self.force_adjust_distance_spin = wx.SpinCtrlDouble(self, -1, "", size=wx.Size(50, 23), inc=0.01)
max_force_threshold_spin = self.force_adjust_distance_spin = wx.SpinCtrlDouble(
self, -1, "", size=wx.Size(50, 23), inc=0.01
)
max_force_threshold_spin.Enable(1)
max_force_threshold_spin.SetRange(2.0, 20.0)
max_force_threshold_spin.SetValue(self.max_force_threshold)
Expand All @@ -902,7 +905,7 @@ def __init__(self, parent, navigation):

bsizer_force_centering = wx.BoxSizer(wx.HORIZONTAL)
bsizer_force_centering_threshold = wx.BoxSizer(wx.HORIZONTAL)

##### ADD ANOTHER rb_force_adjust
rb_force_centering = self.rb_force_centering = wx.RadioBox(
self,
Expand All @@ -916,7 +919,9 @@ def __init__(self, parent, navigation):
bsizer_force_centering.Add(rb_force_centering, 0, wx.TOP | wx.LEFT | wx.FIXED_MINSIZE, 5)

distance_threshold = wx.StaticText(self, -1, _("Distance threshold (mm):"))
distance_threshold_spin = self.force_adjust_distance_spin = wx.SpinCtrlDouble(self, -1, "", size=wx.Size(50, 23), inc=0.01)
distance_threshold_spin = self.force_adjust_distance_spin = wx.SpinCtrlDouble(
self, -1, "", size=wx.Size(50, 23), inc=0.01
)
distance_threshold_spin.Enable(1)
distance_threshold_spin.SetRange(1.0, 10.0)
distance_threshold_spin.SetValue(self.min_force_threshold)
Expand All @@ -929,15 +934,19 @@ def __init__(self, parent, navigation):
(distance_threshold_spin, 0, wx.ALL | wx.EXPAND | wx.GROW, 5),
]
)



bsizer_force.Add(bsizer_force_centering, 0, wx.TOP | wx.LEFT | wx.EXPAND, 0)
bsizer_force.Add(bsizer_force_centering_threshold, 0, wx.GROW | wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 5)
bsizer_force.Add(
bsizer_force_centering_threshold,
0,
wx.GROW | wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP,
5,
)

main_sizer = wx.BoxSizer(wx.VERTICAL)
main_sizer.Add(conf_sizer, 0, wx.ALL | wx.EXPAND, 10)
main_sizer.Add(bsizer_force, 1, wx.EXPAND | wx.ALL | wx.FIXED_MINSIZE, 10)

self.SetSizerAndFit(main_sizer)
self.Layout()

Expand All @@ -951,7 +960,9 @@ def OnSelectCoordSleep(self, evt, ctrl):
self.sleep_coord = ctrl.GetValue()
Publisher.sendMessage("Update coord sleep", data=self.sleep_coord)

self.session.SetConfig("sleep_coord", self.sleep_nav) # I presume this is wrong and should be self.sleep_coord, come back to it.
self.session.SetConfig(
"sleep_coord", self.sleep_nav
) # I presume this is wrong and should be self.sleep_coord, come back to it.

def LoadConfig(self):
sleep_nav = self.session.GetConfig("sleep_nav")
Expand All @@ -968,7 +979,6 @@ def LoadConfig(self):
if force_adjust_distance is not None:
self.min_force_threshold = force_adjust_distance


def GetSelection(self):
options = {
const.EXCESSIVE_FORCE_ADJUST: self.rb_force_adjust.GetSelection(),
Expand All @@ -987,7 +997,6 @@ def LoadSelection(self, values):
self.force_adjust_distance_spin.SetValue(force_adjust_distance)



class ObjectTab(wx.Panel):
def __init__(self, parent, navigation, tracker, pedal_connector):
wx.Panel.__init__(self, parent)
Expand Down
11 changes: 9 additions & 2 deletions invesalius/navigation/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,15 @@ def SelectCoil(self, coil_name, coil_registration):

def UpdateExcessiveForceAdjust(self):
session = ses.Session()
excessive_force_adjust = [session.GetConfig("excessive_force_adjust"), session.GetConfig("excessive_force_adjust_value"), session.GetConfig("force_centering_on")]
Publisher.sendMessage('Neuronavigation to Robot: Update excessive force adjustment', data=excessive_force_adjust)
excessive_force_adjust = [
session.GetConfig("excessive_force_adjust"),
session.GetConfig("excessive_force_adjust_value"),
session.GetConfig("force_centering_on"),
]
Publisher.sendMessage(
"Neuronavigation to Robot: Update excessive force adjustment",
data=excessive_force_adjust,
)

def CoilAtTarget(self, state):
self.coil_at_target = state
Expand Down

0 comments on commit 5fcfe36

Please sign in to comment.