From 102faa25184697409ffd6980f1d53090b18ef2fe Mon Sep 17 00:00:00 2001 From: paulojamorim Date: Mon, 23 Nov 2009 17:36:14 +0000 Subject: [PATCH] ADD: Restructuring of the ways to bring the tools --- invesalius/constants.py | 6 +++++- invesalius/data/viewer_slice.py | 32 ++++++++++++++++++++++++++------ invesalius/mode.py | 45 ++++++++++++++++++++------------------------- 3 files changed, 51 insertions(+), 32 deletions(-) diff --git a/invesalius/constants.py b/invesalius/constants.py index 0a152f9..fe5a0a8 100644 --- a/invesalius/constants.py +++ b/invesalius/constants.py @@ -328,10 +328,14 @@ SLICE_STATE_WL = 2 SLICE_STATE_SPIN = 3 SLICE_STATE_ZOOM = 4 SLICE_STATE_ZOOM_SL = 5 +SLICE_STATE_CROSS = 6 +SLICE_STATE_SCROLL = 7 LEVEL = {SLICE_STATE_DEFAULT: 0, SLICE_STATE_EDITOR: 1, SLICE_STATE_WL: 2, SLICE_STATE_SPIN: 2, SLICE_STATE_ZOOM: 2, - SLICE_STATE_ZOOM_SL: 2} + SLICE_STATE_ZOOM_SL: 2, + SLICE_STATE_CROSS: 2, + SLICE_STATE_SCROLL: 2} diff --git a/invesalius/data/viewer_slice.py b/invesalius/data/viewer_slice.py index 99ed574..aaa28eb 100755 --- a/invesalius/data/viewer_slice.py +++ b/invesalius/data/viewer_slice.py @@ -33,6 +33,7 @@ import constants as const import cursor_actors as ca import data.slice_ as sl import data.vtk_utils as vtku +import mode as md import project from slice_data import SliceData @@ -74,7 +75,8 @@ class Viewer(wx.Panel): self.__bind_events() self.__bind_events_wx() - + + md.SliceMode() def __init_gui(self): @@ -227,12 +229,17 @@ class Viewer(wx.Panel): self.append_mode('EDITOR') self.mouse_pressed = 0 self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_BLANK)) - + #------------------------------------------ + ps.Publisher().sendMessage('Enable mode', const.SLICE_STATE_EDITOR) + def __set_mode_spin(self, pubsub_evt): self.append_mode('SPIN') self.mouse_pressed = 0 self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZING)) - + #------------------------------------------ + ps.Publisher().sendMessage('Enable mode', const.SLICE_STATE_SPIN) + + def __set_mode_zoom(self, pubsub_evt): #print "Zoom" self.append_mode('ZOOM') @@ -240,33 +247,46 @@ class Viewer(wx.Panel): ICON_IMAGE = wx.Image(os.path.join(const.ICON_DIR, "tool_zoom.png"),wx.BITMAP_TYPE_PNG) self.interactor.SetCursor(wx.CursorFromImage(ICON_IMAGE)) - + #------------------------------------------ + ps.Publisher().sendMessage('Enable mode', const.SLICE_STATE_ZOOM) + def __set_mode_pan(self, pubsub_evt): self.append_mode('PAN') self.mouse_pressed = 0 self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZING)) - + #------------------------------------------ + ps.Publisher().sendMessage('Enable mode', const.SLICE_STATE_PAN) + def __set_mode_zoom_select(self, pubsub_evt): self.append_mode('ZOOMSELECT') ICON_IMAGE = wx.Image(os.path.join(const.ICON_DIR, "tool_zoom.png"),wx.BITMAP_TYPE_PNG) self.interactor.SetCursor(wx.CursorFromImage(ICON_IMAGE)) - + #------------------------------------------ + ps.Publisher().sendMessage('Enable mode', const.SLICE_STATE_SL) + def __set_mode_window_level(self, pubsub_evt): self.append_mode('WINDOWLEVEL') self.mouse_pressed = 0 self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZING)) self.interactor.Render() + #------------------------------------------ + ps.Publisher().sendMessage('Enable mode', const.SLICE_STATE_WL) + def __set_mode_slice_scroll(self, pubsub_evt): self.append_mode('CHANGESLICE') self.mouse_pressed = 0 self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZENS)) + #------------------------------------------ + ps.Publisher().sendMessage('Enable mode', const.SLICE_STATE_SCROLL) def __set_mode_cross(self, pubsub_evt): self.append_mode('CROSS') self.mouse_pressed = 0 self.cross_actor.VisibilityOn() + #------------------------------------------ + ps.Publisher().sendMessage('Enable mode', const.SLICE_STATE_CROSS) def OnWindowLevelMove(self, evt, obj): if self.mouse_pressed: diff --git a/invesalius/mode.py b/invesalius/mode.py index 39312fe..ba83061 100644 --- a/invesalius/mode.py +++ b/invesalius/mode.py @@ -17,19 +17,14 @@ # detalhes. #-------------------------------------------------------------------------- +import wx.lib.pubsub as ps + + # mode.py # to be instanced inside Controller (control.py) -# TODO: Add to constants.py: -#-------------------- -# SLICE MODE -SLICE_STATE_DEFAULT = 0 -SLICE_STATE_EDITOR = 1 -SLICE_STATE_WL = 2 -SLICE_STATE_SPIN = 3 -SLICE_STATE_ZOOM = 4 -SLICE_STATE_ZOOM_SL = 5 + # IMPORTANT: When adding a new state, remember o insert it into LEVEL # dictionary @@ -38,19 +33,19 @@ SLICE_STATE_ZOOM_SL = 5 # default is the only level 0 # states controlled somehow by taskmenu are level 1 # states controlled by toolbar are level 2 -LEVEL = {SLICE_STATE_DEFAULT: 0, - SLICE_STATE_EDITOR: 1, - SLICE_STATE_WL: 2, - SLICE_STATE_SPIN: 2, - SLICE_STATE_ZOOM: 2, - SLICE_STATE_ZOOM_SL: 2} +#LEVEL = {SLICE_STATE_DEFAULT: 0, +# SLICE_STATE_EDITOR: 1, +# SLICE_STATE_WL: 2, +# SLICE_STATE_SPIN: 2, +# SLICE_STATE_ZOOM: 2, +# SLICE_STATE_ZOOM_SL: 2} #---------------------- # TODO: Add to viewer_slice.py: - ps.Publisher().subscribe(self.OnSetMode, 'Set slice mode') +#ps.Publisher().subscribe(self.OnSetMode, 'Set slice mode') -def OnSetMode(self, pubsub_evt): - mode = pubsub_evt.data +#def OnSetMode(self, pubsub_evt): +# mode = pubsub_evt.data # according to mode, set cursor, interaction, etc #---------------------- # TODO: Add GUI classes (frame, tasks related to slice, toolbar): @@ -59,11 +54,11 @@ def OnSetMode(self, pubsub_evt): # viewer_slice directly # example - pseudo code -def OnToggleButtonSpin(self, evt) - if evt.toggle: # doesn't exist, just to illustrate - ps.Publisher().sendMessage('Enable mode', const.SLICE_STATE_ZOOM) - else: - ps.Publisher().subscribe('Disable mode', const.SLICE_STATE_ZOOM) +#def OnToggleButtonSpin(self, evt) +# if evt.toggle: # doesn't exist, just to illustrate +# ps.Publisher().sendMessage('Enable mode', const.SLICE_STATE_ZOOM) +# else: +# ps.Publisher().subscribe('Disable mode', const.SLICE_STATE_ZOOM) #---------------------- @@ -83,9 +78,9 @@ class SliceMode(object): const.SLICE_STATE_DEFAULT # bind pubsub evt - self.bind_events() + self.__bind_events() - def _bind_events(self): + def __bind_events(self): ps.Publisher().subscribe(self.OnEnableState, 'Enable mode') ps.Publisher().subscribe(self.OnDisableState, 'Disable mode') -- libgit2 0.21.2