Skip to content

Commit

Permalink
ADD: progress dialog to enable brain mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
rmatsuda committed Sep 29, 2024
1 parent 128673f commit 85df02f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
7 changes: 6 additions & 1 deletion invesalius/data/visualization/mep_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

import invesalius.constants as const
import invesalius.data.transformations as transformations
import invesalius.gui.dialogs as dialogs
import invesalius.session as ses
from invesalius.data.markers.marker import Marker, MarkerType
from invesalius.navigation.markers import MarkersControl
Expand Down Expand Up @@ -142,7 +143,7 @@ def DisplayMotorMap(self, show: bool):
self._SaveUserParameters()
Publisher.sendMessage("Open preferences menu", page=0)
return False

progress_dialog = dialogs.BrainSurfaceLoadingProgressWindow()
if self.colorBarActor:
Publisher.sendMessage("Remove surface actor from viewer", actor=self.colorBarActor)
Publisher.sendMessage("Remove surface actor from viewer", actor=self.surface)
Expand All @@ -161,8 +162,12 @@ def DisplayMotorMap(self, show: bool):
)
Publisher.sendMessage("Get visible surface actor")
self.first_load = False
progress_dialog.Update(
value=50, msg="Preparing brain surface..."
)
self.UpdateVisualization()
self.UpdateMEPPoints()
progress_dialog.Close()
else:
self._config_params["mep_enabled"] = False
self._CleanupVisualization()
Expand Down
22 changes: 22 additions & 0 deletions invesalius/gui/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5972,6 +5972,28 @@ def Close(self) -> None:
self.dlg.Destroy()


class BrainSurfaceLoadingProgressWindow:
def __init__(self):
title = "InVesalius 3"
message = _("Loading brain surface...")
style = wx.PD_APP_MODAL | wx.PD_CAN_ABORT
parent = wx.GetApp().GetTopWindow()

self.dlg = wx.ProgressDialog(title, message, parent=parent, style=style)
self.dlg.Show()

def Update(self, msg: Optional[str] = None, value=None) -> None:
if value:
self.dlg.Update(int(value), msg)
elif msg:
self.dlg.Pulse(msg)
else:
self.dlg.Pulse()

def Close(self) -> None:
self.dlg.Destroy()


class SurfaceSmoothingProgressWindow:
def __init__(self):
title = "InVesalius 3"
Expand Down

0 comments on commit 85df02f

Please sign in to comment.