diff --git a/invesalius/data/viewer_volume.py b/invesalius/data/viewer_volume.py index 1ed1b31..fa50150 100644 --- a/invesalius/data/viewer_volume.py +++ b/invesalius/data/viewer_volume.py @@ -184,6 +184,7 @@ class Viewer(wx.Panel): self.aim_actor = None self.dummy_coil_actor = None self.target_mode = False + self.polydata = None self.anglethreshold = const.COIL_ANGLES_THRESHOLD self.distthreshold = const.COIL_COORD_THRESHOLD @@ -916,7 +917,10 @@ class Viewer(wx.Panel): self.aim_actor = aim_actor self.ren.AddActor(aim_actor) - obj_polydata = self.CreateObjectPolyData(os.path.join(inv_paths.OBJ_DIR, "magstim_fig8_coil_no_handle.stl")) + if self.polydata: + obj_polydata = self.polydata + else: + obj_polydata = self.CreateObjectPolyData(os.path.join(inv_paths.OBJ_DIR, "magstim_fig8_coil_no_handle.stl")) transform = vtk.vtkTransform() transform.RotateZ(90) @@ -1254,9 +1258,10 @@ class Viewer(wx.Panel): self.Refresh() - def UpdateTrackObjectState(self, evt=None, flag=None, obj_name=None): + def UpdateTrackObjectState(self, evt=None, flag=None, obj_name=None, polydata=None): if flag: self.obj_name = obj_name + self.polydata = polydata if not self.obj_actor: self.AddObjectActor(self.obj_name) else: diff --git a/invesalius/gui/dialogs.py b/invesalius/gui/dialogs.py index 3063f67..c253c01 100644 --- a/invesalius/gui/dialogs.py +++ b/invesalius/gui/dialogs.py @@ -3328,6 +3328,7 @@ class ObjectCalibrationDialog(wx.Dialog): self.trk_init = nav_prop[1] self.obj_ref_id = 2 self.obj_name = None + self.polydata = None self.obj_fiducials = np.full([5, 3], np.nan) self.obj_orients = np.full([5, 3], np.nan) @@ -3471,6 +3472,7 @@ class ObjectCalibrationDialog(wx.Dialog): reader.SetFileName(self.obj_name) reader.Update() polydata = reader.GetOutput() + self.polydata = polydata if polydata.GetNumberOfPoints() == 0: wx.MessageBox(_("InVesalius was not able to import this surface"), _("Import surface error")) @@ -3588,7 +3590,7 @@ class ObjectCalibrationDialog(wx.Dialog): self.obj_ref_id = 0 def GetValue(self): - return self.obj_fiducials, self.obj_orients, self.obj_ref_id, self.obj_name + return self.obj_fiducials, self.obj_orients, self.obj_ref_id, self.obj_name, self.polydata class SurfaceProgressWindow(object): diff --git a/invesalius/gui/task_navigator.py b/invesalius/gui/task_navigator.py index 0a0d3c1..b7b57ef 100644 --- a/invesalius/gui/task_navigator.py +++ b/invesalius/gui/task_navigator.py @@ -251,7 +251,7 @@ class InnerFoldPanel(wx.Panel): def OnExternalTrigger(self, evt, ctrl): Publisher.sendMessage('Update trigger state', trigger_state=ctrl.GetValue()) - def OnShowObject(self, evt=None, flag=None, obj_name=None): + def OnShowObject(self, evt=None, flag=None, obj_name=None, polydata=None): if not evt: if flag: self.checkobj.Enable(True) @@ -436,7 +436,7 @@ class NeuronavigationPanel(wx.Panel): self.obj_reg = None self.obj_reg_status = False - def UpdateTrackObjectState(self, evt=None, flag=None, obj_name=None): + def UpdateTrackObjectState(self, evt=None, flag=None, obj_name=None, polydata=None): self.track_obj = flag def UpdateTriggerState(self, trigger_state): @@ -882,7 +882,7 @@ class ObjectRegistrationPanel(wx.Panel): dialog = dlg.ObjectCalibrationDialog(self.nav_prop) try: if dialog.ShowModal() == wx.ID_OK: - self.obj_fiducials, self.obj_orients, self.obj_ref_mode, self.obj_name = dialog.GetValue() + self.obj_fiducials, self.obj_orients, self.obj_ref_mode, self.obj_name, polydata = dialog.GetValue() if np.isfinite(self.obj_fiducials).all() and np.isfinite(self.obj_orients).all(): self.checktrack.Enable(1) Publisher.sendMessage('Update object registration', @@ -891,7 +891,7 @@ class ObjectRegistrationPanel(wx.Panel): label=_("Ready")) # Enable automatically Track object, Show coil and disable Vol. Camera self.checktrack.SetValue(True) - Publisher.sendMessage('Update track object state', flag=True, obj_name=self.obj_name) + Publisher.sendMessage('Update track object state', flag=True, obj_name=self.obj_name, polydata=polydata) Publisher.sendMessage('Change camera checkbox', status=False) except wx._core.PyAssertionError: # TODO FIX: win64 -- libgit2 0.21.2