Commit 6d9e7e2a0d9af53effd7dd900e5a6a4afe18f5f5

Authored by Paulo Henrique Junqueira Amorim
1 parent a6335464
Exists in master

ENH: Added shortcut to create new mask

invesalius/constants.py
... ... @@ -545,6 +545,7 @@ ID_THRESHOLD_SEGMENTATION = wx.NewId()
545 545 ID_FLOODFILL_SEGMENTATION = wx.NewId()
546 546 ID_CROP_MASK = wx.NewId()
547 547 ID_CREATE_SURFACE = wx.NewId()
  548 +ID_CREATE_MASK = wx.NewId()
548 549  
549 550 #---------------------------------------------------------
550 551 STATE_DEFAULT = 1000
... ...
invesalius/gui/frame.py
... ... @@ -496,6 +496,9 @@ class Frame(wx.Frame):
496 496 elif id == const.ID_CREATE_SURFACE:
497 497 Publisher.sendMessage('Open create surface dialog')
498 498  
  499 + elif id == const.ID_CREATE_MASK:
  500 + Publisher.sendMessage('New mask from shortcut')
  501 +
499 502 def OnInterpolatedSlices(self, status):
500 503 Publisher.sendMessage('Set interpolated slices', status)
501 504  
... ... @@ -693,7 +696,8 @@ class MenuBar(wx.MenuBar):
693 696 const.ID_WATERSHED_SEGMENTATION,
694 697 const.ID_THRESHOLD_SEGMENTATION,
695 698 const.ID_FLOODFILL_SEGMENTATION,
696   - const.ID_CREATE_SURFACE,]
  699 + const.ID_CREATE_SURFACE,
  700 + const.ID_CREATE_MASK]
697 701 self.__init_items()
698 702 self.__bind_events()
699 703  
... ... @@ -784,7 +788,11 @@ class MenuBar(wx.MenuBar):
784 788  
785 789 # Mask Menu
786 790 mask_menu = wx.Menu()
787   - self.bool_op_menu = mask_menu.Append(const.ID_BOOLEAN_MASK, _(u"Boolean operations"))
  791 +
  792 + self.new_mask_menu = mask_menu.Append(const.ID_CREATE_MASK, _(u"New\tCtrl+Shift+M"))
  793 + self.new_mask_menu.Enable(False)
  794 +
  795 + self.bool_op_menu = mask_menu.Append(const.ID_BOOLEAN_MASK, _(u"Boolean operations\tCtrl+Shift+B"))
788 796 self.bool_op_menu.Enable(False)
789 797  
790 798 self.clean_mask_menu = mask_menu.Append(const.ID_CLEAN_MASK, _(u"Clean Mask\tCtrl+Shift+A"))
... ... @@ -814,14 +822,14 @@ class MenuBar(wx.MenuBar):
814 822 # Segmentation Menu
815 823 segmentation_menu = wx.Menu()
816 824 self.threshold_segmentation = segmentation_menu.Append(const.ID_THRESHOLD_SEGMENTATION, _(u"Threshold\tCtrl+Shift+T"))
817   - self.manual_segmentation = segmentation_menu.Append(const.ID_MANUAL_SEGMENTATION, _(u"Manual segmentation\tCtrl+Shift+M"))
  825 + self.manual_segmentation = segmentation_menu.Append(const.ID_MANUAL_SEGMENTATION, _(u"Manual segmentation\tCtrl+Shift+E"))
818 826 self.watershed_segmentation = segmentation_menu.Append(const.ID_WATERSHED_SEGMENTATION, _(u"Watershed\tCtrl+Shift+W"))
819 827 self.ffill_segmentation = segmentation_menu.Append(const.ID_FLOODFILL_SEGMENTATION, _(u"Region growing\tCtrl+Shift+G"))
820 828 self.ffill_segmentation.Enable(False)
821 829  
822 830 # Surface Menu
823 831 surface_menu = wx.Menu()
824   - self.create_surface = surface_menu.Append(const.ID_CREATE_SURFACE, (u"Create surface\tCtrl+Shift+C"))
  832 + self.create_surface = surface_menu.Append(const.ID_CREATE_SURFACE, (u"New\tCtrl+Shift+C"))
825 833 self.create_surface.Enable(False)
826 834  
827 835 # Image menu
... ...
invesalius/gui/task_slice.py
... ... @@ -93,6 +93,8 @@ class InnerTaskPanel(wx.Panel):
93 93 link_new_mask.AutoBrowse(False)
94 94 link_new_mask.UpdateLink()
95 95 link_new_mask.Bind(hl.EVT_HYPERLINK_LEFT, self.OnLinkNewMask)
  96 +
  97 + Publisher.subscribe(self.OnLinkNewMask, 'New mask from shortcut')
96 98  
97 99 # Create horizontal sizers to represent lines in the panel
98 100 line_new = wx.BoxSizer(wx.HORIZONTAL)
... ... @@ -186,6 +188,13 @@ class InnerTaskPanel(wx.Panel):
186 188 dlg.InexistentMask()
187 189  
188 190 def OnLinkNewMask(self, evt=None):
  191 +
  192 + try:
  193 + evt.data
  194 + evt = None
  195 + except:
  196 + pass
  197 +
189 198 dialog = dlg.NewMask()
190 199  
191 200 try:
... ...