From 8a9fbe91d89699862d72033ef3cb36e927902053 Mon Sep 17 00:00:00 2001 From: Rakhesis <119945837+Rakhesis@users.noreply.github.com> Date: Fri, 5 Jul 2024 23:19:34 +0300 Subject: [PATCH 1/6] FIX: AssertionError when closing InVesalius Caused by tracker thread left running after destroying wx.App --- invesalius/navigation/tracker.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/invesalius/navigation/tracker.py b/invesalius/navigation/tracker.py index b5d290711..46facc1e0 100644 --- a/invesalius/navigation/tracker.py +++ b/invesalius/navigation/tracker.py @@ -51,8 +51,13 @@ def __init__(self): self.TrackerCoordinates = dco.TrackerCoordinates() + self.__bind_events() + self.LoadState() + def __bind_events(self): + Publisher.subscribe(self.DisconnectTracker, 'Disconnect tracker') + def SaveState(self): tracker_id = self.tracker_id tracker_fiducials = self.tracker_fiducials.tolist() From 4b96b7d8bb264fdb4f8493c69ee0b8f25e75c771 Mon Sep 17 00:00:00 2001 From: Rakhesis <119945837+Rakhesis@users.noreply.github.com> Date: Wed, 4 Sep 2024 23:44:51 +0300 Subject: [PATCH 2/6] MOD: Switching TMS-mode closes project Switching TMS-mode on/off now always tries to close the project. Previous functionality was buggy. --- invesalius/gui/default_tasks.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/invesalius/gui/default_tasks.py b/invesalius/gui/default_tasks.py index 1d28ee52f..a7cd6ba62 100644 --- a/invesalius/gui/default_tasks.py +++ b/invesalius/gui/default_tasks.py @@ -145,17 +145,14 @@ def SetNavigationMode(self, status): else: Publisher.sendMessage("Hide target button") session.SetConfig("mode", const.MODE_RP) + Publisher.sendMessage("Close Project") + Publisher.sendMessage("Disconnect tracker") self.gbs.Hide(self.uppertaskpanel) self.uppertaskpanel.Destroy() self.uppertaskpanel = UpperTaskPanel(self) self.gbs.Add(self.uppertaskpanel, (0, 0), flag=wx.EXPAND) self.Layout() self.Refresh() - project_status = session.GetConfig("project_status") - if project_status != const.PROJECT_STATUS_CLOSED: - Publisher.sendMessage("Load project data") - Publisher.sendMessage("Enable state project", state=True) - # Lower fold panel class LowerTaskPanel(wx.Panel): From 1272990fd2a06ab00c253226fc77ee288d460381 Mon Sep 17 00:00:00 2001 From: Rakhesis <119945837+Rakhesis@users.noreply.github.com> Date: Wed, 4 Sep 2024 23:47:19 +0300 Subject: [PATCH 3/6] FIX: RuntimeError on switching off TMS-mode --- invesalius/gui/default_tasks.py | 1 + 1 file changed, 1 insertion(+) diff --git a/invesalius/gui/default_tasks.py b/invesalius/gui/default_tasks.py index a7cd6ba62..d1b821790 100644 --- a/invesalius/gui/default_tasks.py +++ b/invesalius/gui/default_tasks.py @@ -148,6 +148,7 @@ def SetNavigationMode(self, status): Publisher.sendMessage("Close Project") Publisher.sendMessage("Disconnect tracker") self.gbs.Hide(self.uppertaskpanel) + wx.GetApp().ProcessPendingEvents() self.uppertaskpanel.Destroy() self.uppertaskpanel = UpperTaskPanel(self) self.gbs.Add(self.uppertaskpanel, (0, 0), flag=wx.EXPAND) From 9b465fd85b7a6f7e4b77ed4598fff612564bb042 Mon Sep 17 00:00:00 2001 From: Rakhesis <119945837+Rakhesis@users.noreply.github.com> Date: Thu, 5 Sep 2024 17:40:23 +0300 Subject: [PATCH 4/6] CLN: Unused code related to TMS-mode switching --- invesalius/control.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/invesalius/control.py b/invesalius/control.py index e81fe446a..98ee89366 100644 --- a/invesalius/control.py +++ b/invesalius/control.py @@ -122,8 +122,6 @@ def __bind_events(self) -> None: Publisher.subscribe(self.disable_mask_preview, "Disable mask 3D preview") Publisher.subscribe(self.update_mask_preview, "Update mask 3D preview") - Publisher.subscribe(self.LoadProject, "Load project data") - def SetBitmapSpacing(self, spacing: Tuple[float, float, float]) -> None: proj = prj.Project() proj.spacing = spacing From 2b5d84b0f97ff1e84873ecc166da4267c05f5d65 Mon Sep 17 00:00:00 2001 From: Rakhesis <119945837+Rakhesis@users.noreply.github.com> Date: Thu, 5 Sep 2024 23:59:41 +0300 Subject: [PATCH 5/6] FIX: Canceling TMS-mode change Canceling TMS-mode change due to unsaved project now works. Removed a line of commented code. --- invesalius/gui/default_tasks.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/invesalius/gui/default_tasks.py b/invesalius/gui/default_tasks.py index d1b821790..ea3f057dc 100644 --- a/invesalius/gui/default_tasks.py +++ b/invesalius/gui/default_tasks.py @@ -138,15 +138,19 @@ def __bind_events(self): Publisher.subscribe(self.SetNavigationMode, "Set navigation mode") def SetNavigationMode(self, status): - self.navigation_mode_status = status session = ses.Session() + Publisher.sendMessage("Close Project") + project_status = session.GetConfig("project_status") + if project_status != const.PROJECT_STATUS_CLOSED: + return + if status: session.SetConfig("mode", const.MODE_NAVIGATOR) else: Publisher.sendMessage("Hide target button") session.SetConfig("mode", const.MODE_RP) - Publisher.sendMessage("Close Project") Publisher.sendMessage("Disconnect tracker") + self.gbs.Hide(self.uppertaskpanel) wx.GetApp().ProcessPendingEvents() self.uppertaskpanel.Destroy() @@ -353,7 +357,6 @@ def __bind_events(self): Publisher.subscribe(self.OnFoldSurface, "Fold surface task") Publisher.subscribe(self.OnFoldExport, "Fold export task") Publisher.subscribe(self.OnEnableState, "Enable state project") - # Publisher.subscribe(self.SetNavigationMode, "Set navigation mode") def OnOverwrite(self, surface_parameters): self.overwrite = surface_parameters["options"]["overwrite"] From a3fb16b0408387a362ea422d7cdda535e6b4030a Mon Sep 17 00:00:00 2001 From: Rakhesis <119945837+Rakhesis@users.noreply.github.com> Date: Mon, 9 Sep 2024 20:14:29 +0300 Subject: [PATCH 6/6] FIX: TMS-mode menu item updating Fix TMS-mode menu item changing even when canceling mode switch. --- invesalius/gui/default_tasks.py | 1 + 1 file changed, 1 insertion(+) diff --git a/invesalius/gui/default_tasks.py b/invesalius/gui/default_tasks.py index ea3f057dc..7495de522 100644 --- a/invesalius/gui/default_tasks.py +++ b/invesalius/gui/default_tasks.py @@ -142,6 +142,7 @@ def SetNavigationMode(self, status): Publisher.sendMessage("Close Project") project_status = session.GetConfig("project_status") if project_status != const.PROJECT_STATUS_CLOSED: + Publisher.sendMessage("Update Navigation Mode MenuBar") return if status: