diff --git a/invesalius/constants.py b/invesalius/constants.py index 70218e4..47d882a 100644 --- a/invesalius/constants.py +++ b/invesalius/constants.py @@ -521,6 +521,9 @@ ID_FLOODFILL_MASK = wx.NewId() ID_FILL_HOLE_AUTO = wx.NewId() ID_REMOVE_MASK_PART = wx.NewId() ID_SELECT_MASK_PART = wx.NewId() +ID_MANUAL_SEGMENTATION = wx.NewId() +ID_WATERSHED_SEGMENTATION = wx.NewId() +ID_THRESHOLD_SEGMENTATION = wx.NewId() ID_FLOODFILL_SEGMENTATION = wx.NewId() ID_CROP_MASK = wx.NewId() diff --git a/invesalius/data/slice_.py b/invesalius/data/slice_.py index af70f59..d773c6f 100644 --- a/invesalius/data/slice_.py +++ b/invesalius/data/slice_.py @@ -184,6 +184,7 @@ class Slice(object): Publisher.subscribe(self.OnEnableStyle, 'Enable style') Publisher.subscribe(self.OnDisableStyle, 'Disable style') + Publisher.subscribe(self.OnDisableActualStyle, 'Disable actual style') Publisher.subscribe(self.OnRemoveMasks, 'Remove masks') Publisher.subscribe(self.OnDuplicateMasks, 'Duplicate masks') @@ -263,6 +264,9 @@ class Slice(object): Publisher.sendMessage('Set interactor default cursor') self.state = new_state + def OnDisableActualStyle(self, pubsub_evt): + self.interaction_style.Reset() + def OnCloseProject(self, pubsub_evt): self.CloseProject() diff --git a/invesalius/gui/frame.py b/invesalius/gui/frame.py index 11c2f57..436720d 100644 --- a/invesalius/gui/frame.py +++ b/invesalius/gui/frame.py @@ -446,6 +446,21 @@ class Frame(wx.Frame): elif id == const.ID_REORIENT_IMG: self.OnReorientImg() + elif id == const.ID_THRESHOLD_SEGMENTATION: + Publisher.sendMessage("Show panel", const.ID_THRESHOLD_SEGMENTATION) + Publisher.sendMessage('Disable actual style') + Publisher.sendMessage('Enable style', const.STATE_DEFAULT) + + elif id == const.ID_MANUAL_SEGMENTATION: + Publisher.sendMessage("Show panel", const.ID_MANUAL_SEGMENTATION) + Publisher.sendMessage('Disable actual style') + Publisher.sendMessage('Enable style', const.SLICE_STATE_EDITOR) + + elif id == const.ID_WATERSHED_SEGMENTATION: + Publisher.sendMessage("Show panel", const.ID_WATERSHED_SEGMENTATION) + Publisher.sendMessage('Disable actual style') + Publisher.sendMessage('Enable style', const.SLICE_STATE_WATERSHED) + elif id == const.ID_FLOODFILL_MASK: self.OnFillHolesManually() @@ -642,6 +657,10 @@ class MenuBar(wx.MenuBar): const.ID_FILL_HOLE_AUTO, const.ID_REMOVE_MASK_PART, const.ID_SELECT_MASK_PART, + const.ID_THRESHOLD_SEGMENTATION, + const.ID_MANUAL_SEGMENTATION, + const.ID_WATERSHED_SEGMENTATION, + const.ID_THRESHOLD_SEGMENTATION, const.ID_FLOODFILL_SEGMENTATION,] self.__init_items() self.__bind_events() @@ -781,6 +800,9 @@ class MenuBar(wx.MenuBar): # Segmentation Menu segmentation_menu = wx.Menu() + self.threshold_segmentation = segmentation_menu.Append(const.ID_THRESHOLD_SEGMENTATION, _(u"Threshold")) + self.manual_segmentation = segmentation_menu.Append(const.ID_MANUAL_SEGMENTATION, _(u"Manual segmentation")) + self.watershed_segmentation = segmentation_menu.Append(const.ID_WATERSHED_SEGMENTATION, _(u"Watershed")) self.ffill_segmentation = segmentation_menu.Append(const.ID_FLOODFILL_SEGMENTATION, _(u"Region growing")) self.ffill_segmentation.Enable(False) diff --git a/invesalius/gui/task_slice.py b/invesalius/gui/task_slice.py index 03d5bac..fd2706d 100644 --- a/invesalius/gui/task_slice.py +++ b/invesalius/gui/task_slice.py @@ -342,6 +342,7 @@ class InnerFoldPanel(wx.Panel): Publisher.subscribe(self.OnRetrieveStyle, 'Retrieve task slice style') Publisher.subscribe(self.OnDisableStyle, 'Disable task slice style') Publisher.subscribe(self.OnCloseProject, 'Close project data') + Publisher.subscribe(self.OnColapsePanel, 'Show panel') def OnFoldPressCaption(self, evt): id = evt.GetTag().GetId() @@ -388,6 +389,19 @@ class InnerFoldPanel(wx.Panel): def OnCloseProject(self, pubsub_evt): self.fold_panel.Expand(self.fold_panel.GetFoldPanel(0)) + def OnColapsePanel(self, pubsub_evt): + panel_seg_id = { + const.ID_THRESHOLD_SEGMENTATION: 0, + const.ID_MANUAL_SEGMENTATION: 1, + const.ID_WATERSHED_SEGMENTATION: 2 + } + + try: + _id = panel_seg_id[pubsub_evt.data] + self.fold_panel.Expand(self.fold_panel.GetFoldPanel(_id)) + except KeyError: + pass + def GetMaskSelected(self): x= self.mask_prop_panel.GetMaskSelected() return self.mask_prop_panel.GetMaskSelected() diff --git a/invesalius/style.py b/invesalius/style.py index 29d3369..2319a27 100644 --- a/invesalius/style.py +++ b/invesalius/style.py @@ -78,10 +78,10 @@ class StyleStateManager(object): const.STATE_DEFAULT def AddState(self, state): - + level = const.STYLE_LEVEL[state] max_level = max(self.stack.keys()) - + # Insert new state into stack self.stack[level] = state @@ -93,7 +93,7 @@ class StyleStateManager(object): level = const.STYLE_LEVEL[state] if level in self.stack.keys(): max_level = max(self.stack.keys()) - + # Remove item from stack self.stack.pop(level) @@ -104,9 +104,12 @@ class StyleStateManager(object): # level in stack has been removed if level == max_level: new_state = self.stack[new_max_level] - + return self.stack[new_max_level] - + max_level = max(self.stack.keys()) return self.stack[max_level] - + + def Reset(self): + self.stack[const.STYLE_LEVEL[const.STATE_DEFAULT]] = \ + const.STATE_DEFAULT -- libgit2 0.21.2