From 69661eb1d393d54a12489689bf89e6c617b9ab5d Mon Sep 17 00:00:00 2001 From: paulojamorim Date: Wed, 25 Nov 2009 17:18:59 +0000 Subject: [PATCH] ENH: Modes and SafeYield --- invesalius/data/viewer_slice.py | 2 +- invesalius/gui/dicom_preview_panel.py | 2 +- invesalius/gui/frame.py | 2 +- invesalius/gui/task_slice.py | 19 +++++++++++++++++++ invesalius/mode.py | 1 + 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/invesalius/data/viewer_slice.py b/invesalius/data/viewer_slice.py index 6df4130..60ab424 100755 --- a/invesalius/data/viewer_slice.py +++ b/invesalius/data/viewer_slice.py @@ -937,7 +937,7 @@ class Viewer(wx.Panel): self.EnableText() # Insert cursor - self.SetState(const.SLICE_STATE_EDITOR) + self.SetState(const.STATE_DEFAULT) self.__build_cross_lines() diff --git a/invesalius/gui/dicom_preview_panel.py b/invesalius/gui/dicom_preview_panel.py index 2755fd7..e157783 100755 --- a/invesalius/gui/dicom_preview_panel.py +++ b/invesalius/gui/dicom_preview_panel.py @@ -165,7 +165,7 @@ class SingleImagePreview(wx.Panel): self.ShowSlice(pos) time.sleep(0.2) if self.ischecked: - wx.Yield() + wx.SafeYield() wx.CallAfter(self.OnRun) def SetDicomGroup(self, group): diff --git a/invesalius/gui/frame.py b/invesalius/gui/frame.py index 177ea4e..d9b3b6f 100755 --- a/invesalius/gui/frame.py +++ b/invesalius/gui/frame.py @@ -423,7 +423,7 @@ class StatusBar(wx.StatusBar): if (int(value) >= 99): self.SetStatusText("",0) if sys.platform != 'linux2': - wx.Yield() + wx.SafeYield() def UpdateStatusLabel(self, pubsub_evt): diff --git a/invesalius/gui/task_slice.py b/invesalius/gui/task_slice.py index 4a9dfb7..b62e6c6 100644 --- a/invesalius/gui/task_slice.py +++ b/invesalius/gui/task_slice.py @@ -205,6 +205,9 @@ class InnerFoldPanel(wx.Panel): fold_panel.ApplyCaptionStyle(item, style) fold_panel.AddFoldPanelWindow(item, EditionTools(item), Spacing= 0, leftSpacing=0, rightSpacing=0) + self.editor_panel_id = item.GetId() + self.last_panel_opened = None + #fold_panel.Expand(fold_panel.GetFoldPanel(1)) # Panel sizer to expand fold panel @@ -214,6 +217,22 @@ class InnerFoldPanel(wx.Panel): self.SetSizer(sizer) self.Update() self.SetAutoLayout(1) + fold_panel.Bind(fpb.EVT_CAPTIONBAR, self.OnFoldPressCaption) + + def OnFoldPressCaption(self, evt): + + if (self.editor_panel_id == evt.GetTag().GetId()): + if not(evt.GetFoldStatus()): + ps.Publisher().sendMessage('Enable mode', const.SLICE_STATE_EDITOR) + else: + ps.Publisher().sendMessage('Disable mode', const.SLICE_STATE_EDITOR) + else: + if(self.last_panel_opened == self.editor_panel_id): + ps.Publisher().sendMessage('Disable mode', const.SLICE_STATE_EDITOR) + + self.last_panel_opened = evt.GetTag().GetId() + + evt.Skip() def GetMaskSelected(self): x= self.mask_prop_panel.GetMaskSelected() diff --git a/invesalius/mode.py b/invesalius/mode.py index 67a113d..75f75b7 100644 --- a/invesalius/mode.py +++ b/invesalius/mode.py @@ -108,6 +108,7 @@ class SliceMode(object): max_level = max(self.stack.keys()) # Remove item from stack + self.stack.pop(level) # New max level -- libgit2 0.21.2