Commit 9e1e532619cbd016be742e14b789fa702a869699

Authored by Renan
Committed by Thiago Franco de Moraes
1 parent 50f903c2
Exists in master

create polydata from the imported stl (#210)

invesalius/data/viewer_volume.py
@@ -184,6 +184,7 @@ class Viewer(wx.Panel): @@ -184,6 +184,7 @@ class Viewer(wx.Panel):
184 self.aim_actor = None 184 self.aim_actor = None
185 self.dummy_coil_actor = None 185 self.dummy_coil_actor = None
186 self.target_mode = False 186 self.target_mode = False
  187 + self.polydata = None
187 self.anglethreshold = const.COIL_ANGLES_THRESHOLD 188 self.anglethreshold = const.COIL_ANGLES_THRESHOLD
188 self.distthreshold = const.COIL_COORD_THRESHOLD 189 self.distthreshold = const.COIL_COORD_THRESHOLD
189 190
@@ -916,7 +917,10 @@ class Viewer(wx.Panel): @@ -916,7 +917,10 @@ class Viewer(wx.Panel):
916 self.aim_actor = aim_actor 917 self.aim_actor = aim_actor
917 self.ren.AddActor(aim_actor) 918 self.ren.AddActor(aim_actor)
918 919
919 - obj_polydata = self.CreateObjectPolyData(os.path.join(inv_paths.OBJ_DIR, "magstim_fig8_coil_no_handle.stl")) 920 + if self.polydata:
  921 + obj_polydata = self.polydata
  922 + else:
  923 + obj_polydata = self.CreateObjectPolyData(os.path.join(inv_paths.OBJ_DIR, "magstim_fig8_coil_no_handle.stl"))
920 924
921 transform = vtk.vtkTransform() 925 transform = vtk.vtkTransform()
922 transform.RotateZ(90) 926 transform.RotateZ(90)
@@ -1254,9 +1258,10 @@ class Viewer(wx.Panel): @@ -1254,9 +1258,10 @@ class Viewer(wx.Panel):
1254 1258
1255 self.Refresh() 1259 self.Refresh()
1256 1260
1257 - def UpdateTrackObjectState(self, evt=None, flag=None, obj_name=None): 1261 + def UpdateTrackObjectState(self, evt=None, flag=None, obj_name=None, polydata=None):
1258 if flag: 1262 if flag:
1259 self.obj_name = obj_name 1263 self.obj_name = obj_name
  1264 + self.polydata = polydata
1260 if not self.obj_actor: 1265 if not self.obj_actor:
1261 self.AddObjectActor(self.obj_name) 1266 self.AddObjectActor(self.obj_name)
1262 else: 1267 else:
invesalius/gui/dialogs.py
@@ -3328,6 +3328,7 @@ class ObjectCalibrationDialog(wx.Dialog): @@ -3328,6 +3328,7 @@ class ObjectCalibrationDialog(wx.Dialog):
3328 self.trk_init = nav_prop[1] 3328 self.trk_init = nav_prop[1]
3329 self.obj_ref_id = 2 3329 self.obj_ref_id = 2
3330 self.obj_name = None 3330 self.obj_name = None
  3331 + self.polydata = None
3331 3332
3332 self.obj_fiducials = np.full([5, 3], np.nan) 3333 self.obj_fiducials = np.full([5, 3], np.nan)
3333 self.obj_orients = np.full([5, 3], np.nan) 3334 self.obj_orients = np.full([5, 3], np.nan)
@@ -3471,6 +3472,7 @@ class ObjectCalibrationDialog(wx.Dialog): @@ -3471,6 +3472,7 @@ class ObjectCalibrationDialog(wx.Dialog):
3471 reader.SetFileName(self.obj_name) 3472 reader.SetFileName(self.obj_name)
3472 reader.Update() 3473 reader.Update()
3473 polydata = reader.GetOutput() 3474 polydata = reader.GetOutput()
  3475 + self.polydata = polydata
3474 3476
3475 if polydata.GetNumberOfPoints() == 0: 3477 if polydata.GetNumberOfPoints() == 0:
3476 wx.MessageBox(_("InVesalius was not able to import this surface"), _("Import surface error")) 3478 wx.MessageBox(_("InVesalius was not able to import this surface"), _("Import surface error"))
@@ -3588,7 +3590,7 @@ class ObjectCalibrationDialog(wx.Dialog): @@ -3588,7 +3590,7 @@ class ObjectCalibrationDialog(wx.Dialog):
3588 self.obj_ref_id = 0 3590 self.obj_ref_id = 0
3589 3591
3590 def GetValue(self): 3592 def GetValue(self):
3591 - return self.obj_fiducials, self.obj_orients, self.obj_ref_id, self.obj_name 3593 + return self.obj_fiducials, self.obj_orients, self.obj_ref_id, self.obj_name, self.polydata
3592 3594
3593 3595
3594 class SurfaceProgressWindow(object): 3596 class SurfaceProgressWindow(object):
invesalius/gui/task_navigator.py
@@ -251,7 +251,7 @@ class InnerFoldPanel(wx.Panel): @@ -251,7 +251,7 @@ class InnerFoldPanel(wx.Panel):
251 def OnExternalTrigger(self, evt, ctrl): 251 def OnExternalTrigger(self, evt, ctrl):
252 Publisher.sendMessage('Update trigger state', trigger_state=ctrl.GetValue()) 252 Publisher.sendMessage('Update trigger state', trigger_state=ctrl.GetValue())
253 253
254 - def OnShowObject(self, evt=None, flag=None, obj_name=None): 254 + def OnShowObject(self, evt=None, flag=None, obj_name=None, polydata=None):
255 if not evt: 255 if not evt:
256 if flag: 256 if flag:
257 self.checkobj.Enable(True) 257 self.checkobj.Enable(True)
@@ -436,7 +436,7 @@ class NeuronavigationPanel(wx.Panel): @@ -436,7 +436,7 @@ class NeuronavigationPanel(wx.Panel):
436 self.obj_reg = None 436 self.obj_reg = None
437 self.obj_reg_status = False 437 self.obj_reg_status = False
438 438
439 - def UpdateTrackObjectState(self, evt=None, flag=None, obj_name=None): 439 + def UpdateTrackObjectState(self, evt=None, flag=None, obj_name=None, polydata=None):
440 self.track_obj = flag 440 self.track_obj = flag
441 441
442 def UpdateTriggerState(self, trigger_state): 442 def UpdateTriggerState(self, trigger_state):
@@ -882,7 +882,7 @@ class ObjectRegistrationPanel(wx.Panel): @@ -882,7 +882,7 @@ class ObjectRegistrationPanel(wx.Panel):
882 dialog = dlg.ObjectCalibrationDialog(self.nav_prop) 882 dialog = dlg.ObjectCalibrationDialog(self.nav_prop)
883 try: 883 try:
884 if dialog.ShowModal() == wx.ID_OK: 884 if dialog.ShowModal() == wx.ID_OK:
885 - self.obj_fiducials, self.obj_orients, self.obj_ref_mode, self.obj_name = dialog.GetValue() 885 + self.obj_fiducials, self.obj_orients, self.obj_ref_mode, self.obj_name, polydata = dialog.GetValue()
886 if np.isfinite(self.obj_fiducials).all() and np.isfinite(self.obj_orients).all(): 886 if np.isfinite(self.obj_fiducials).all() and np.isfinite(self.obj_orients).all():
887 self.checktrack.Enable(1) 887 self.checktrack.Enable(1)
888 Publisher.sendMessage('Update object registration', 888 Publisher.sendMessage('Update object registration',
@@ -891,7 +891,7 @@ class ObjectRegistrationPanel(wx.Panel): @@ -891,7 +891,7 @@ class ObjectRegistrationPanel(wx.Panel):
891 label=_("Ready")) 891 label=_("Ready"))
892 # Enable automatically Track object, Show coil and disable Vol. Camera 892 # Enable automatically Track object, Show coil and disable Vol. Camera
893 self.checktrack.SetValue(True) 893 self.checktrack.SetValue(True)
894 - Publisher.sendMessage('Update track object state', flag=True, obj_name=self.obj_name) 894 + Publisher.sendMessage('Update track object state', flag=True, obj_name=self.obj_name, polydata=polydata)
895 Publisher.sendMessage('Change camera checkbox', status=False) 895 Publisher.sendMessage('Change camera checkbox', status=False)
896 896
897 except wx._core.PyAssertionError: # TODO FIX: win64 897 except wx._core.PyAssertionError: # TODO FIX: win64