Commit 8e640588bfb11491c75ddf4b868f5b5f3d71aa4b

Authored by Paulo Henrique Junqueira Amorim
1 parent dab3ed36

FIX: Close project and open other project the raycast cut plane not removed #126

invesalius/data/viewer_volume.py
... ... @@ -127,8 +127,11 @@ class Viewer(wx.Panel):
127 127 ps.Publisher().subscribe(self.OnShowText,
128 128 'Show text actors on viewers')
129 129 ps.Publisher().subscribe(self.OnCloseProject, 'Close project data')
130   - ps.Publisher().subscribe(self.OnExportPicture,'Export picture to file')
  130 +
  131 + ps.Publisher().subscribe(self.RemoveAllActor, 'Remove all volume actors')
131 132  
  133 + ps.Publisher().subscribe(self.OnExportPicture,'Export picture to file')
  134 +
132 135  
133 136  
134 137 def OnExportPicture(self, pubsub_evt):
... ... @@ -420,12 +423,16 @@ class Viewer(wx.Panel):
420 423 def RemoveActor(self, pubsub_evt):
421 424 print "RemoveActor"
422 425 actor = pubsub_evt.data
423   -
424 426 ren = self.ren
425 427 ren.RemoveActor(actor)
426   -
427 428 self.interactor.Render()
  429 +
  430 + def RemoveAllActor(self, pubsub_evt):
  431 + print "RemoveAllActor"
  432 + self.ren.RemoveAllProps()
  433 + ps.Publisher().sendMessage('Render volume viewer')
428 434  
  435 +
429 436 def LoadSlicePlane(self, pubsub_evt):
430 437 self.slice_plane = SlicePlane()
431 438  
... ...
invesalius/data/volume.py
... ... @@ -107,12 +107,23 @@ class Volume():
107 107 self.CloseProject()
108 108  
109 109 def CloseProject(self):
  110 + #if self.plane:
  111 + # self.plane = None
  112 + # ps.Publisher().sendMessage('Remove surface actor from viewer', self.plane_actor)
110 113 if self.plane:
111   - self.plane = None
112   - ps.Publisher().sendMessage('Remove surface actor from viewer', self.plane_actor)
  114 + print "======================================================================================================"
  115 + #ps.Publisher().sendMessage('Remove surface actor from viewer', self.plane.plane_actor)
  116 + #self.plane.Disable()
  117 + self.plane.DestroyObjs()
  118 + del self.plane
  119 + #del self.final_imagedata
  120 + self.plane = 0
  121 +
  122 +
113 123 if self.exist:
114 124 self.exist = None
115 125 ps.Publisher().sendMessage('Remove surface actor from viewer', self.volume)
  126 + ps.Publisher().sendMessage('Disable volume cut menu')
116 127  
117 128 def OnLoadVolume(self, pubsub_evt):
118 129 label = pubsub_evt.data
... ... @@ -559,6 +570,7 @@ class Volume():
559 570 self.plane.Disable()
560 571 else:
561 572 print "Enable"
  573 + self.final_imagedata.Update()
562 574 self.plane_on = True
563 575 self.plane = CutPlane(self.final_imagedata,
564 576 self.volume_mapper)
... ... @@ -618,7 +630,7 @@ class CutPlane:
618 630 plane_source.SetPoint1(plane_widget.GetPoint1())
619 631 plane_source.SetPoint2(plane_widget.GetPoint2())
620 632 plane_source.SetNormal(plane_widget.GetNormal())
621   - plane_mapper = vtk.vtkPolyDataMapper()
  633 + plane_mapper = self.plane_mapper = vtk.vtkPolyDataMapper()
622 634 plane_mapper.SetInput(plane_source.GetOutput())
623 635 self.plane_actor = plane_actor = vtk.vtkActor()
624 636 plane_actor.SetMapper(plane_mapper)
... ... @@ -673,5 +685,15 @@ class CutPlane:
673 685 self.plane_actor.VisibilityOn()
674 686 self.plane.SetNormal(self.normal)
675 687 self.plane.SetOrigin(self.origin)
676   - ps.Publisher().sendMessage('Render volume viewer', None)
677   -
  688 + ps.Publisher().sendMessage('Render volume viewer', None)
  689 +
  690 + def DestroyObjs(self):
  691 + ps.Publisher().sendMessage('Remove surface actor from viewer', self.plane_actor)
  692 +
  693 + del self.plane_widget
  694 + del self.plane_source
  695 + del self.plane_actor
  696 + del self.normal
  697 + del self.plane
  698 + ps.Publisher().sendMessage('Remove all volume actors')
  699 +
678 700 \ No newline at end of file
... ...
invesalius/gui/default_viewers.py
... ... @@ -392,6 +392,7 @@ class VolumeToolPanel(wx.Panel):
392 392 'Change volume viewer gui colour')
393 393 ps.Publisher().subscribe(self.DisablePreset, 'Close project data')
394 394 ps.Publisher().subscribe(self.Uncheck, 'Uncheck image plane menu')
  395 + ps.Publisher().subscribe(self.DisableVolumeCutMenu, 'Disable volume cut menu')
395 396  
396 397 def DisablePreset(self, pubsub_evt):
397 398 self.off_item.Check(1)
... ... @@ -422,7 +423,7 @@ class VolumeToolPanel(wx.Panel):
422 423  
423 424 def __init_menus(self, pubsub_evt=None):
424 425 # MENU RELATED TO RAYCASTING TYPES
425   - menu = wx.Menu()
  426 + menu = self.menu = wx.Menu()
426 427 for name in const.RAYCASTING_TYPES:
427 428 id = wx.NewId()
428 429 item = wx.MenuItem(menu, id, name, kind=wx.ITEM_RADIO)
... ... @@ -434,9 +435,13 @@ class VolumeToolPanel(wx.Panel):
434 435  
435 436 menu.AppendSeparator()
436 437 # MENU RELATED TO RAYCASTING TOOLS
  438 + self.id_cutplane = None
437 439 submenu = wx.Menu()
438 440 for name in const.RAYCASTING_TOOLS:
439 441 id = wx.NewId()
  442 + if not(self.id_cutplane):
  443 + self.id_cutplane = id
  444 +
440 445 item = wx.MenuItem(submenu, id, name, kind=wx.ITEM_CHECK)
441 446 submenu.AppendItem(item)
442 447 ID_TO_TOOL[id] = name
... ... @@ -480,6 +485,11 @@ class VolumeToolPanel(wx.Panel):
480 485  
481 486 self.Fit()
482 487 self.Update()
  488 +
  489 + def DisableVolumeCutMenu(self, pusub_evt):
  490 + self.menu.Enable(RAYCASTING_TOOLS, 0)
  491 + item = ID_TO_TOOL_ITEM[self.id_cutplane]
  492 + item.Check(0)
483 493  
484 494 def BuildRaycastingMenu(self):
485 495 presets = []
... ...