From 7bcf6df2af5ddefdd8c03128163fbedf60e01f0d Mon Sep 17 00:00:00 2001 From: Thiago Franco de Moraes Date: Wed, 4 Sep 2013 15:27:21 -0300 Subject: [PATCH] When user shows a mask, MIP is deactivated --- invesalius/data/slice_.py | 13 +++++++++++-- invesalius/data/viewer_slice.py | 22 +++++++++++++--------- invesalius/gui/data_notebook.py | 5 +++++ 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/invesalius/data/slice_.py b/invesalius/data/slice_.py index 3b65a0c..4f962f7 100644 --- a/invesalius/data/slice_.py +++ b/invesalius/data/slice_.py @@ -352,11 +352,15 @@ class Slice(object): if not value: Publisher.sendMessage('Select mask name in combo', -1) + if self._type_projection != const.PROJECTION_NORMAL: + self.SetTypeProjection(const.PROJECTION_NORMAL) + Publisher.sendMessage('Reload actual slice') + def __hide_current_mask(self, pubsub_evt): if self.current_mask: index = self.current_mask.index value = False - self.ShowMask(index, value) + Publisher.sendMessage('Show mask', (index, value)) def edit_mask_pixel(self, operation, index, position, radius, orientation): mask = self.buffer_slices[orientation].mask @@ -823,7 +827,12 @@ class Slice(object): def SetTypeProjection(self, tprojection): if self._type_projection != tprojection: if self._type_projection == const.PROJECTION_NORMAL: - self.__hide_current_mask(None) + Publisher.sendMessage('Hide current mask') + + if tprojection == const.PROJECTION_NORMAL: + Publisher.sendMessage('Show MIP interface', False) + else: + Publisher.sendMessage('Show MIP interface', True) self._type_projection = tprojection for buffer_ in self.buffer_slices.values(): diff --git a/invesalius/data/viewer_slice.py b/invesalius/data/viewer_slice.py index 359a733..71fb3ef 100755 --- a/invesalius/data/viewer_slice.py +++ b/invesalius/data/viewer_slice.py @@ -715,6 +715,7 @@ class Viewer(wx.Panel): Publisher.subscribe(self.OnSetMIPSize, 'Set MIP size %s' % self.orientation) Publisher.subscribe(self.OnSetMIPBorder, 'Set MIP border %s' % self.orientation) Publisher.subscribe(self.OnSetMIPInvert, 'Set MIP Invert %s' % self.orientation) + Publisher.subscribe(self.OnShowMIPInterface, 'Show MIP interface') def SetDefaultCursor(self, pusub_evt): self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) @@ -1136,15 +1137,6 @@ class Viewer(wx.Panel): elif evt.GetKeyCode() in projections: print "PROJECTION MANOLO!" - if evt.GetKeyCode() != wx.WXK_NUMPAD0 and self.slice_._type_projection == const.PROJECTION_NORMAL: - self.mip_ctrls.Show() - self.GetSizer().Add(self.mip_ctrls, 0, wx.EXPAND|wx.GROW|wx.ALL, 2) - self.Layout() - elif evt.GetKeyCode() == wx.WXK_NUMPAD0 and self.slice_._type_projection != const.PROJECTION_NORMAL: - self.mip_ctrls.Hide() - self.GetSizer().Remove(self.mip_ctrls) - self.Layout() - self.slice_.SetTypeProjection(projections[evt.GetKeyCode()]) self.ReloadActualSlice() @@ -1203,6 +1195,18 @@ class Viewer(wx.Panel): buffer_.discard_buffer() self.ReloadActualSlice() + def OnShowMIPInterface(self, pubsub_evt): + value = pubsub_evt.data + if value: + self.mip_ctrls.Show() + self.GetSizer().Add(self.mip_ctrls, 0, wx.EXPAND|wx.GROW|wx.ALL, 2) + self.Layout() + else: + self.mip_ctrls.Hide() + self.GetSizer().Remove(self.mip_ctrls) + self.Layout() + + def set_slice_number(self, index): inverted = self.mip_ctrls.inverted.GetValue() image = self.slice_.GetSlices(self.orientation, index, diff --git a/invesalius/gui/data_notebook.py b/invesalius/gui/data_notebook.py index c0c0890..dc37d1f 100644 --- a/invesalius/gui/data_notebook.py +++ b/invesalius/gui/data_notebook.py @@ -365,6 +365,7 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): 'Change mask colour in notebook') Publisher.subscribe(self.OnChangeCurrentMask, 'Change mask selected') + Publisher.subscribe(self.__hide_current_mask, 'Hide current mask') Publisher.subscribe(self.OnCloseProject, 'Close project data') def OnKeyEvent(self, event): @@ -432,6 +433,10 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): if key != mask_index: self.SetItemImage(key, 0) + def __hide_current_mask(self, pubsub_evt): + print self.mask_list_index.keys() + self.SetItemImage(self.current_index, 0) + def __init_columns(self): self.InsertColumn(0, "", wx.LIST_FORMAT_CENTER) -- libgit2 0.21.2