Commit 096a9b8f33c2d49b5f87405b455d637c0a92ba7a
1 parent
187f57e2
Exists in
master
and in
68 other branches
FIX: Raycasting cut plane enable and disable
Showing
2 changed files
with
19 additions
and
6 deletions
Show diff stats
invesalius/data/volume.py
... | ... | @@ -486,16 +486,20 @@ class Volume(): |
486 | 486 | (volume, colour, (self.ww, self.wl))) |
487 | 487 | |
488 | 488 | def OnEnableTool(self, pubsub_evt): |
489 | + print "OnEnableTool" | |
489 | 490 | tool_name, enable = pubsub_evt.data |
490 | 491 | if tool_name == "Cut plane": |
491 | 492 | if self.plane: |
492 | 493 | if enable: |
494 | + print "Enable" | |
493 | 495 | self.plane_on = True |
494 | 496 | self.plane.Enable() |
495 | 497 | else: |
498 | + print "Disable" | |
496 | 499 | self.plane_on = False |
497 | 500 | self.plane.Disable() |
498 | 501 | else: |
502 | + print "Enable" | |
499 | 503 | self.plane_on = True |
500 | 504 | self.plane = CutPlane(self.final_imagedata, |
501 | 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 | 266 | ID_TO_NAME = {} |
267 | 267 | ID_TO_TOOL = {} |
268 | 268 | ID_TO_TOOL_ITEM = {} |
269 | +TOOL_STATE = {} | |
269 | 270 | |
270 | 271 | class VolumeViewerCover(wx.Panel): |
271 | 272 | def __init__(self, parent): |
... | ... | @@ -366,6 +367,7 @@ class VolumeToolPanel(wx.Panel): |
366 | 367 | submenu.AppendItem(item) |
367 | 368 | ID_TO_TOOL[id] = name |
368 | 369 | ID_TO_TOOL_ITEM[id] = item |
370 | + TOOL_STATE[id] = False | |
369 | 371 | self.submenu_raycasting_tools = submenu |
370 | 372 | menu.AppendMenu(RAYCASTING_TOOLS, "Tools", submenu) |
371 | 373 | menu.Enable(RAYCASTING_TOOLS, 0) |
... | ... | @@ -393,11 +395,12 @@ class VolumeToolPanel(wx.Panel): |
393 | 395 | def OnMenuRaycasting(self, evt): |
394 | 396 | """Events from raycasting menu.""" |
395 | 397 | id = evt.GetId() |
398 | + evt.Skip() | |
396 | 399 | if id in ID_TO_NAME.keys(): |
397 | 400 | # Raycassting type was selected |
398 | - name = ID_TO_NAME[evt.GetId()] | |
401 | + name = ID_TO_NAME[id] | |
399 | 402 | ps.Publisher().sendMessage('Load raycasting preset', |
400 | - ID_TO_NAME[evt.GetId()]) | |
403 | + ID_TO_NAME[id]) | |
401 | 404 | # Enable or disable tools |
402 | 405 | if name != const.RAYCASTING_OFF_LABEL: |
403 | 406 | self.menu_raycasting.Enable(RAYCASTING_TOOLS, 1) |
... | ... | @@ -407,17 +410,23 @@ class VolumeToolPanel(wx.Panel): |
407 | 410 | else: |
408 | 411 | # Raycasting tool |
409 | 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 | 414 | #if not item.IsChecked(): |
412 | 415 | # for i in ID_TO_TOOL_ITEM.values(): |
413 | 416 | # if i is not item: |
414 | 417 | # i.Check(0) |
415 | - if item.IsChecked(): | |
418 | + if not TOOL_STATE[id]: | |
419 | + print "item is checked" | |
416 | 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 | 424 | else: |
425 | + print "item is not checked" | |
419 | 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 | 432 | def OnMenuView(self, evt): | ... | ... |