From 1e33187cd660f1783acd43a248dcfcc6d29c4e1b Mon Sep 17 00:00:00 2001 From: Thiago Franco de Moraes Date: Thu, 18 Aug 2016 14:22:32 -0300 Subject: [PATCH] Not opening more than one ffill dlg when clickin 2x in ffill menu --- invesalius/constants.py | 1 + invesalius/data/styles.py | 5 +++-- invesalius/gui/dialogs.py | 12 ++++++------ invesalius/gui/frame.py | 12 +++++++++++- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/invesalius/constants.py b/invesalius/constants.py index f690254..8e70ef7 100644 --- a/invesalius/constants.py +++ b/invesalius/constants.py @@ -482,6 +482,7 @@ ID_CLEAN_MASK = wx.NewId() ID_REORIENT_IMG = wx.NewId() ID_FLOODFILL_MASK = wx.NewId() +ID_REMOVE_MASK_PART = wx.NewId() #--------------------------------------------------------- STATE_DEFAULT = 1000 diff --git a/invesalius/data/styles.py b/invesalius/data/styles.py index cad8b16..4428a2e 100644 --- a/invesalius/data/styles.py +++ b/invesalius/data/styles.py @@ -1783,9 +1783,10 @@ class FloodFillMaskInteractorStyle(DefaultInteractorStyle): self.dlg_ffill.Show() def CleanUp(self): - self.config.dlg_visible = False - if self.dlg_ffill is not None: + if (self.dlg_ffill is not None) and (self.config.dlg_visible): + self.config.dlg_visible = False self.dlg_ffill.Destroy() + self.dlg_ffill = None def OnFFClick(self, obj, evt): if (self.viewer.slice_.buffer_slices[self.orientation].mask is None): diff --git a/invesalius/gui/dialogs.py b/invesalius/gui/dialogs.py index 779559e..1f2abc3 100644 --- a/invesalius/gui/dialogs.py +++ b/invesalius/gui/dialogs.py @@ -1851,7 +1851,7 @@ class FFillOptionsDialog(wx.Dialog): self._init_gui() def _init_gui(self): - sizer = wx.GridBagSizer(3, 1) + sizer = wx.GridBagSizer(3, 3) flag_labels = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL @@ -1883,9 +1883,9 @@ class FFillOptionsDialog(wx.Dialog): self.conect3D.SetSelection(0) self.config.con_3d = 6 - sizer.Add(self.target, (0, 0)) - sizer.Add(self.conect2D, (1, 0)) - sizer.Add(self.conect3D, (2, 0)) + sizer.Add(self.target, (0, 0), (1, 3), flag=wx.EXPAND, border=5) + sizer.Add(self.conect2D, (1, 0), flag=wx.EXPAND, border=5) + sizer.Add(self.conect3D, (2, 0), flag=wx.EXPAND, border=5) self.SetSizer(sizer) sizer.Fit(self) @@ -1911,7 +1911,7 @@ class FFillOptionsDialog(wx.Dialog): print self.config.con_3d def OnClose(self, evt): - Publisher.sendMessage('Disable style', const.SLICE_STATE_MASK_FFILL) - self.config.dlg_visible = False + if self.config.dlg_visible: + Publisher.sendMessage('Disable style', const.SLICE_STATE_MASK_FFILL) evt.Skip() self.Destroy() diff --git a/invesalius/gui/frame.py b/invesalius/gui/frame.py index 842c5fc..37c9428 100644 --- a/invesalius/gui/frame.py +++ b/invesalius/gui/frame.py @@ -442,6 +442,9 @@ class Frame(wx.Frame): elif id == const.ID_FLOODFILL_MASK: self.OnFillHolesManually() + elif id == const.ID_REMOVE_MASK_PART: + self.OnRemoveMaskParts() + def OnSize(self, evt): """ Refresh GUI when frame is resized. @@ -565,6 +568,9 @@ class Frame(wx.Frame): def OnFillHolesManually(self): Publisher.sendMessage('Enable style', const.SLICE_STATE_MASK_FFILL) + def OnRemoveMaskParts(self): + Publisher.sendMessage('Enable style', const.SLICE_STATE_MASK_FFILL) + # ------------------------------------------------------------------ # ------------------------------------------------------------------ # ------------------------------------------------------------------ @@ -585,7 +591,8 @@ class MenuBar(wx.MenuBar): const.ID_PROJECT_SAVE_AS, const.ID_PROJECT_CLOSE, const.ID_REORIENT_IMG, - const.ID_FLOODFILL_MASK] + const.ID_FLOODFILL_MASK, + const.ID_REMOVE_MASK_PART,] self.__init_items() self.__bind_events() @@ -699,6 +706,9 @@ class MenuBar(wx.MenuBar): self.fill_hole_mask_menu = mask_menu.Append(const.ID_FLOODFILL_MASK, _(u"Fill mask holes manually")) self.fill_hole_mask_menu.Enable(False) + self.remove_mask_part_menu = mask_menu.Append(const.ID_REMOVE_MASK_PART, _(u"Remove parts")) + self.remove_mask_part_menu.Enable(False) + tools_menu.AppendMenu(-1, _(u"Mask"), mask_menu) # Image menu -- libgit2 0.21.2