Commit d1c7184d73ce217583ac403e421a81a7ab7c73b6

Authored by Thiago Franco de Moraes
1 parent 8b278a92
Exists in segmentation_menu

Working ...

invesalius/constants.py
@@ -521,6 +521,9 @@ ID_FLOODFILL_MASK = wx.NewId() @@ -521,6 +521,9 @@ ID_FLOODFILL_MASK = wx.NewId()
521 ID_FILL_HOLE_AUTO = wx.NewId() 521 ID_FILL_HOLE_AUTO = wx.NewId()
522 ID_REMOVE_MASK_PART = wx.NewId() 522 ID_REMOVE_MASK_PART = wx.NewId()
523 ID_SELECT_MASK_PART = wx.NewId() 523 ID_SELECT_MASK_PART = wx.NewId()
  524 +ID_MANUAL_SEGMENTATION = wx.NewId()
  525 +ID_WATERSHED_SEGMENTATION = wx.NewId()
  526 +ID_THRESHOLD_SEGMENTATION = wx.NewId()
524 ID_FLOODFILL_SEGMENTATION = wx.NewId() 527 ID_FLOODFILL_SEGMENTATION = wx.NewId()
525 ID_CROP_MASK = wx.NewId() 528 ID_CROP_MASK = wx.NewId()
526 529
invesalius/data/slice_.py
@@ -184,6 +184,7 @@ class Slice(object): @@ -184,6 +184,7 @@ class Slice(object):
184 184
185 Publisher.subscribe(self.OnEnableStyle, 'Enable style') 185 Publisher.subscribe(self.OnEnableStyle, 'Enable style')
186 Publisher.subscribe(self.OnDisableStyle, 'Disable style') 186 Publisher.subscribe(self.OnDisableStyle, 'Disable style')
  187 + Publisher.subscribe(self.OnDisableActualStyle, 'Disable actual style')
187 188
188 Publisher.subscribe(self.OnRemoveMasks, 'Remove masks') 189 Publisher.subscribe(self.OnRemoveMasks, 'Remove masks')
189 Publisher.subscribe(self.OnDuplicateMasks, 'Duplicate masks') 190 Publisher.subscribe(self.OnDuplicateMasks, 'Duplicate masks')
@@ -263,6 +264,9 @@ class Slice(object): @@ -263,6 +264,9 @@ class Slice(object):
263 Publisher.sendMessage('Set interactor default cursor') 264 Publisher.sendMessage('Set interactor default cursor')
264 self.state = new_state 265 self.state = new_state
265 266
  267 + def OnDisableActualStyle(self, pubsub_evt):
  268 + self.interaction_style.Reset()
  269 +
266 def OnCloseProject(self, pubsub_evt): 270 def OnCloseProject(self, pubsub_evt):
267 self.CloseProject() 271 self.CloseProject()
268 272
invesalius/gui/frame.py
@@ -446,6 +446,21 @@ class Frame(wx.Frame): @@ -446,6 +446,21 @@ class Frame(wx.Frame):
446 elif id == const.ID_REORIENT_IMG: 446 elif id == const.ID_REORIENT_IMG:
447 self.OnReorientImg() 447 self.OnReorientImg()
448 448
  449 + elif id == const.ID_THRESHOLD_SEGMENTATION:
  450 + Publisher.sendMessage("Show panel", const.ID_THRESHOLD_SEGMENTATION)
  451 + Publisher.sendMessage('Disable actual style')
  452 + Publisher.sendMessage('Enable style', const.STATE_DEFAULT)
  453 +
  454 + elif id == const.ID_MANUAL_SEGMENTATION:
  455 + Publisher.sendMessage("Show panel", const.ID_MANUAL_SEGMENTATION)
  456 + Publisher.sendMessage('Disable actual style')
  457 + Publisher.sendMessage('Enable style', const.SLICE_STATE_EDITOR)
  458 +
  459 + elif id == const.ID_WATERSHED_SEGMENTATION:
  460 + Publisher.sendMessage("Show panel", const.ID_WATERSHED_SEGMENTATION)
  461 + Publisher.sendMessage('Disable actual style')
  462 + Publisher.sendMessage('Enable style', const.SLICE_STATE_WATERSHED)
  463 +
449 elif id == const.ID_FLOODFILL_MASK: 464 elif id == const.ID_FLOODFILL_MASK:
450 self.OnFillHolesManually() 465 self.OnFillHolesManually()
451 466
@@ -642,6 +657,10 @@ class MenuBar(wx.MenuBar): @@ -642,6 +657,10 @@ class MenuBar(wx.MenuBar):
642 const.ID_FILL_HOLE_AUTO, 657 const.ID_FILL_HOLE_AUTO,
643 const.ID_REMOVE_MASK_PART, 658 const.ID_REMOVE_MASK_PART,
644 const.ID_SELECT_MASK_PART, 659 const.ID_SELECT_MASK_PART,
  660 + const.ID_THRESHOLD_SEGMENTATION,
  661 + const.ID_MANUAL_SEGMENTATION,
  662 + const.ID_WATERSHED_SEGMENTATION,
  663 + const.ID_THRESHOLD_SEGMENTATION,
645 const.ID_FLOODFILL_SEGMENTATION,] 664 const.ID_FLOODFILL_SEGMENTATION,]
646 self.__init_items() 665 self.__init_items()
647 self.__bind_events() 666 self.__bind_events()
@@ -781,6 +800,9 @@ class MenuBar(wx.MenuBar): @@ -781,6 +800,9 @@ class MenuBar(wx.MenuBar):
781 800
782 # Segmentation Menu 801 # Segmentation Menu
783 segmentation_menu = wx.Menu() 802 segmentation_menu = wx.Menu()
  803 + self.threshold_segmentation = segmentation_menu.Append(const.ID_THRESHOLD_SEGMENTATION, _(u"Threshold"))
  804 + self.manual_segmentation = segmentation_menu.Append(const.ID_MANUAL_SEGMENTATION, _(u"Manual segmentation"))
  805 + self.watershed_segmentation = segmentation_menu.Append(const.ID_WATERSHED_SEGMENTATION, _(u"Watershed"))
784 self.ffill_segmentation = segmentation_menu.Append(const.ID_FLOODFILL_SEGMENTATION, _(u"Region growing")) 806 self.ffill_segmentation = segmentation_menu.Append(const.ID_FLOODFILL_SEGMENTATION, _(u"Region growing"))
785 self.ffill_segmentation.Enable(False) 807 self.ffill_segmentation.Enable(False)
786 808
invesalius/gui/task_slice.py
@@ -342,6 +342,7 @@ class InnerFoldPanel(wx.Panel): @@ -342,6 +342,7 @@ class InnerFoldPanel(wx.Panel):
342 Publisher.subscribe(self.OnRetrieveStyle, 'Retrieve task slice style') 342 Publisher.subscribe(self.OnRetrieveStyle, 'Retrieve task slice style')
343 Publisher.subscribe(self.OnDisableStyle, 'Disable task slice style') 343 Publisher.subscribe(self.OnDisableStyle, 'Disable task slice style')
344 Publisher.subscribe(self.OnCloseProject, 'Close project data') 344 Publisher.subscribe(self.OnCloseProject, 'Close project data')
  345 + Publisher.subscribe(self.OnColapsePanel, 'Show panel')
345 346
346 def OnFoldPressCaption(self, evt): 347 def OnFoldPressCaption(self, evt):
347 id = evt.GetTag().GetId() 348 id = evt.GetTag().GetId()
@@ -388,6 +389,19 @@ class InnerFoldPanel(wx.Panel): @@ -388,6 +389,19 @@ class InnerFoldPanel(wx.Panel):
388 def OnCloseProject(self, pubsub_evt): 389 def OnCloseProject(self, pubsub_evt):
389 self.fold_panel.Expand(self.fold_panel.GetFoldPanel(0)) 390 self.fold_panel.Expand(self.fold_panel.GetFoldPanel(0))
390 391
  392 + def OnColapsePanel(self, pubsub_evt):
  393 + panel_seg_id = {
  394 + const.ID_THRESHOLD_SEGMENTATION: 0,
  395 + const.ID_MANUAL_SEGMENTATION: 1,
  396 + const.ID_WATERSHED_SEGMENTATION: 2
  397 + }
  398 +
  399 + try:
  400 + _id = panel_seg_id[pubsub_evt.data]
  401 + self.fold_panel.Expand(self.fold_panel.GetFoldPanel(_id))
  402 + except KeyError:
  403 + pass
  404 +
391 def GetMaskSelected(self): 405 def GetMaskSelected(self):
392 x= self.mask_prop_panel.GetMaskSelected() 406 x= self.mask_prop_panel.GetMaskSelected()
393 return self.mask_prop_panel.GetMaskSelected() 407 return self.mask_prop_panel.GetMaskSelected()
invesalius/style.py
@@ -78,10 +78,10 @@ class StyleStateManager(object): @@ -78,10 +78,10 @@ class StyleStateManager(object):
78 const.STATE_DEFAULT 78 const.STATE_DEFAULT
79 79
80 def AddState(self, state): 80 def AddState(self, state):
81 - 81 +
82 level = const.STYLE_LEVEL[state] 82 level = const.STYLE_LEVEL[state]
83 max_level = max(self.stack.keys()) 83 max_level = max(self.stack.keys())
84 - 84 +
85 # Insert new state into stack 85 # Insert new state into stack
86 self.stack[level] = state 86 self.stack[level] = state
87 87
@@ -93,7 +93,7 @@ class StyleStateManager(object): @@ -93,7 +93,7 @@ class StyleStateManager(object):
93 level = const.STYLE_LEVEL[state] 93 level = const.STYLE_LEVEL[state]
94 if level in self.stack.keys(): 94 if level in self.stack.keys():
95 max_level = max(self.stack.keys()) 95 max_level = max(self.stack.keys())
96 - 96 +
97 # Remove item from stack 97 # Remove item from stack
98 self.stack.pop(level) 98 self.stack.pop(level)
99 99
@@ -104,9 +104,12 @@ class StyleStateManager(object): @@ -104,9 +104,12 @@ class StyleStateManager(object):
104 # level in stack has been removed 104 # level in stack has been removed
105 if level == max_level: 105 if level == max_level:
106 new_state = self.stack[new_max_level] 106 new_state = self.stack[new_max_level]
107 - 107 +
108 return self.stack[new_max_level] 108 return self.stack[new_max_level]
109 - 109 +
110 max_level = max(self.stack.keys()) 110 max_level = max(self.stack.keys())
111 return self.stack[max_level] 111 return self.stack[max_level]
112 - 112 +
  113 + def Reset(self):
  114 + self.stack[const.STYLE_LEVEL[const.STATE_DEFAULT]] = \
  115 + const.STATE_DEFAULT