Commit 096a9b8f33c2d49b5f87405b455d637c0a92ba7a

Authored by tatiana
1 parent 187f57e2

FIX: Raycasting cut plane enable and disable

invesalius/data/volume.py
@@ -486,16 +486,20 @@ class Volume(): @@ -486,16 +486,20 @@ class Volume():
486 (volume, colour, (self.ww, self.wl))) 486 (volume, colour, (self.ww, self.wl)))
487 487
488 def OnEnableTool(self, pubsub_evt): 488 def OnEnableTool(self, pubsub_evt):
  489 + print "OnEnableTool"
489 tool_name, enable = pubsub_evt.data 490 tool_name, enable = pubsub_evt.data
490 if tool_name == "Cut plane": 491 if tool_name == "Cut plane":
491 if self.plane: 492 if self.plane:
492 if enable: 493 if enable:
  494 + print "Enable"
493 self.plane_on = True 495 self.plane_on = True
494 self.plane.Enable() 496 self.plane.Enable()
495 else: 497 else:
  498 + print "Disable"
496 self.plane_on = False 499 self.plane_on = False
497 self.plane.Disable() 500 self.plane.Disable()
498 else: 501 else:
  502 + print "Enable"
499 self.plane_on = True 503 self.plane_on = True
500 self.plane = CutPlane(self.final_imagedata, 504 self.plane = CutPlane(self.final_imagedata,
501 self.volume_mapper) 505 self.volume_mapper)
invesalius/gui/default_viewers.py
@@ -266,6 +266,7 @@ ID_TO_BMP = {const.VOL_FRONT: ["Front", "../icons/view_front.png"], @@ -266,6 +266,7 @@ ID_TO_BMP = {const.VOL_FRONT: ["Front", "../icons/view_front.png"],
266 ID_TO_NAME = {} 266 ID_TO_NAME = {}
267 ID_TO_TOOL = {} 267 ID_TO_TOOL = {}
268 ID_TO_TOOL_ITEM = {} 268 ID_TO_TOOL_ITEM = {}
  269 +TOOL_STATE = {}
269 270
270 class VolumeViewerCover(wx.Panel): 271 class VolumeViewerCover(wx.Panel):
271 def __init__(self, parent): 272 def __init__(self, parent):
@@ -366,6 +367,7 @@ class VolumeToolPanel(wx.Panel): @@ -366,6 +367,7 @@ class VolumeToolPanel(wx.Panel):
366 submenu.AppendItem(item) 367 submenu.AppendItem(item)
367 ID_TO_TOOL[id] = name 368 ID_TO_TOOL[id] = name
368 ID_TO_TOOL_ITEM[id] = item 369 ID_TO_TOOL_ITEM[id] = item
  370 + TOOL_STATE[id] = False
369 self.submenu_raycasting_tools = submenu 371 self.submenu_raycasting_tools = submenu
370 menu.AppendMenu(RAYCASTING_TOOLS, "Tools", submenu) 372 menu.AppendMenu(RAYCASTING_TOOLS, "Tools", submenu)
371 menu.Enable(RAYCASTING_TOOLS, 0) 373 menu.Enable(RAYCASTING_TOOLS, 0)
@@ -393,11 +395,12 @@ class VolumeToolPanel(wx.Panel): @@ -393,11 +395,12 @@ class VolumeToolPanel(wx.Panel):
393 def OnMenuRaycasting(self, evt): 395 def OnMenuRaycasting(self, evt):
394 """Events from raycasting menu.""" 396 """Events from raycasting menu."""
395 id = evt.GetId() 397 id = evt.GetId()
  398 + evt.Skip()
396 if id in ID_TO_NAME.keys(): 399 if id in ID_TO_NAME.keys():
397 # Raycassting type was selected 400 # Raycassting type was selected
398 - name = ID_TO_NAME[evt.GetId()] 401 + name = ID_TO_NAME[id]
399 ps.Publisher().sendMessage('Load raycasting preset', 402 ps.Publisher().sendMessage('Load raycasting preset',
400 - ID_TO_NAME[evt.GetId()]) 403 + ID_TO_NAME[id])
401 # Enable or disable tools 404 # Enable or disable tools
402 if name != const.RAYCASTING_OFF_LABEL: 405 if name != const.RAYCASTING_OFF_LABEL:
403 self.menu_raycasting.Enable(RAYCASTING_TOOLS, 1) 406 self.menu_raycasting.Enable(RAYCASTING_TOOLS, 1)
@@ -407,17 +410,23 @@ class VolumeToolPanel(wx.Panel): @@ -407,17 +410,23 @@ class VolumeToolPanel(wx.Panel):
407 else: 410 else:
408 # Raycasting tool 411 # Raycasting tool
409 # TODO: In future, when more tools are available 412 # TODO: In future, when more tools are available
410 - item = ID_TO_TOOL_ITEM[evt.GetId()] 413 + item = ID_TO_TOOL_ITEM[id]
411 #if not item.IsChecked(): 414 #if not item.IsChecked():
412 # for i in ID_TO_TOOL_ITEM.values(): 415 # for i in ID_TO_TOOL_ITEM.values():
413 # if i is not item: 416 # if i is not item:
414 # i.Check(0) 417 # i.Check(0)
415 - if item.IsChecked(): 418 + if not TOOL_STATE[id]:
  419 + print "item is checked"
416 ps.Publisher().sendMessage('Enable raycasting tool', 420 ps.Publisher().sendMessage('Enable raycasting tool',
417 - [ID_TO_TOOL[evt.GetId()],1]) 421 + [ID_TO_TOOL[id],1])
  422 + TOOL_STATE[id] = True
  423 + item.Check(1)
418 else: 424 else:
  425 + print "item is not checked"
419 ps.Publisher().sendMessage('Enable raycasting tool', 426 ps.Publisher().sendMessage('Enable raycasting tool',
420 - [ID_TO_TOOL[evt.GetId()],0]) 427 + [ID_TO_TOOL[id],0])
  428 + TOOL_STATE[id] = False
  429 + item.Check(0)
421 430
422 431
423 def OnMenuView(self, evt): 432 def OnMenuView(self, evt):