From bf3ff9772dd5f893915887e57b1a02fd8fccd695 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauld.mccarthy@gmail.com> Date: Mon, 5 Jan 2015 10:33:49 +0000 Subject: [PATCH] All profile/canvaspael props/actions are available on the UI. Action methods now accept any number of arguments. --- fsl/fslview/actions/__init__.py | 12 ++++---- fsl/fslview/layouts.py | 39 ++++++++++++++++++------ fsl/fslview/profiles/orthoeditprofile.py | 8 ++--- fsl/fslview/profiles/orthoviewprofile.py | 4 +-- fsl/fslview/views/canvaspanel.py | 23 +++++++++----- 5 files changed, 57 insertions(+), 29 deletions(-) diff --git a/fsl/fslview/actions/__init__.py b/fsl/fslview/actions/__init__.py index 7e356a69b..00399d9ce 100644 --- a/fsl/fslview/actions/__init__.py +++ b/fsl/fslview/actions/__init__.py @@ -94,7 +94,7 @@ class Action(props.HasProperties): self._boundWidgets.append(widget) - def _enabledChanged(self, *a): + def _enabledChanged(self, *args): """Internal method which is called when the :attr:`enabled` property changes. Enables/disables the action, and any bound widgets. """ @@ -105,18 +105,18 @@ class Action(props.HasProperties): widget.Enable(self.enabled) - def __disabledDoAction(self): + def __disabledDoAction(self, *args): """This method gets called when the action is disabled.""" raise RuntimeError('{} is disabled'.format(self.__class__.__name__)) - def __enabledDoAction(self): + def __enabledDoAction(self, *args): """This method is set in :meth:`__init__`; it gets called when the action is enabled.""" pass - def doAction(self): + def doAction(self, *args): """This method must be overridden by subclasses. It performs the action, or raises a ``RuntimeError`` if the action @@ -200,6 +200,6 @@ class ActionProvider(props.HasProperties): self.__actions[name].enabled = not self.__actions[name].enabled - def run(self, name): + def run(self, name, *args): """Performs the named action.""" - self.__actions[name].doAction() + self.__actions[name].doAction(*args) diff --git a/fsl/fslview/layouts.py b/fsl/fslview/layouts.py index c6e55cc06..6446760de 100644 --- a/fsl/fslview/layouts.py +++ b/fsl/fslview/layouts.py @@ -32,17 +32,35 @@ OrthoEditProfileLayout = props.HGroup( vertLabels=True, ) -OrthoViewProfileLayout = props.HGroup(('mode', )) +OrthoViewProfileLayout = props.HGroup( + (props.Widget('mode', label=strings.labels[OrthoViewProfile, 'mode']), ), + wrap=True, + vertLabels=True) +OrthoViewProfileActionLayout = props.HGroup( + (props.Button('resetZoom', text=strings.labels[OrthoViewProfile, 'resetZoom'], callback=OrthoViewProfile.resetZoom), + props.Button('centreCursor', text=strings.labels[OrthoViewProfile, 'centreCursor'], callback=OrthoViewProfile.centreCursor)), + wrap=True, + showLabels=False) +OrthoEditProfileActionLayout = props.HGroup( + (props.Button('resetZoom', text=strings.labels[OrthoEditProfile, 'resetZoom'], callback=OrthoEditProfile.resetZoom), + props.Button('centreCursor', text=strings.labels[OrthoEditProfile, 'centreCursor'], callback=OrthoEditProfile.centreCursor), + props.Button('clearSelection', text=strings.labels[OrthoEditProfile, 'clearSelection'], callback=OrthoEditProfile.clearSelection), + props.Button('fillSelection', text=strings.labels[OrthoEditProfile, 'fillSelection'], callback=OrthoEditProfile.fillSelection), + props.Button('undo', text=strings.labels[OrthoEditProfile, 'undo'], callback=OrthoEditProfile.undo), + props.Button('redo', text=strings.labels[OrthoEditProfile, 'redo'], callback=OrthoEditProfile.redo)), + wrap=True, + showLabels=False) CanvasPanelActionLayout = props.HGroup( - (props.Button('screenshot', text=strings.labels[CanvasPanel, 'screenshot'], callback=CanvasPanel.screenshot), - props.Button('toggleColourBar', text=strings.labels[CanvasPanel, 'toggleColourBar'], callback=CanvasPanel.toggleColourBar), - props.Button('toggleImageList', text=strings.labels[CanvasPanel, 'toggleImageList'], callback=CanvasPanel.toggleImageList), - props.Button('toggleDisplayProperties', text=strings.labels[CanvasPanel, 'toggleDisplayProperties'], callback=CanvasPanel.toggleDisplayProperties), - props.Button('toggleLocationPanel', text=strings.labels[CanvasPanel, 'toggleLocationPanel'], callback=CanvasPanel.toggleLocationPanel), - props.Button('toggleCanvasProperties', text=strings.labels[CanvasPanel, 'toggleCanvasProperties'], callback=CanvasPanel.toggleCanvasProperties)), + (props.Widget('profile', label=strings.labels[CanvasPanel, 'profile']), + props.Button('screenshot', text=strings.labels[CanvasPanel, 'screenshot'], callback=CanvasPanel.screenshot), + props.Button('toggleColourBar', text=strings.labels[CanvasPanel, 'toggleColourBar'], callback=CanvasPanel.toggleColourBar), + props.Button('toggleImageList', text=strings.labels[CanvasPanel, 'toggleImageList'], callback=CanvasPanel.toggleImageList), + props.Button('toggleDisplayProperties', text=strings.labels[CanvasPanel, 'toggleDisplayProperties'], callback=CanvasPanel.toggleDisplayProperties), + props.Button('toggleLocationPanel', text=strings.labels[CanvasPanel, 'toggleLocationPanel'], callback=CanvasPanel.toggleLocationPanel), + props.Button('toggleCanvasProperties', text=strings.labels[CanvasPanel, 'toggleCanvasProperties'], callback=CanvasPanel.toggleCanvasProperties)), wrap=True, showLabels=False) @@ -51,9 +69,10 @@ CanvasPanelActionLayout = props.HGroup( layouts = td.TypeDict({ - 'OrthoViewProfile' : OrthoViewProfileLayout, - 'OrthoEditProfile' : OrthoEditProfileLayout, + ('OrthoViewProfile', 'props') : OrthoViewProfileLayout, + ('OrthoEditProfile', 'props') : OrthoEditProfileLayout, + ('OrthoViewProfile', 'actions') : OrthoViewProfileActionLayout, + ('OrthoEditProfile', 'actions') : OrthoEditProfileActionLayout, ('CanvasPanel', 'actions') : CanvasPanelActionLayout, -# ('CanvasPanel', 'props') : CanvasPanelTopLayout, }) diff --git a/fsl/fslview/profiles/orthoeditprofile.py b/fsl/fslview/profiles/orthoeditprofile.py index aa0c6d7d7..6f291b6e2 100644 --- a/fsl/fslview/profiles/orthoeditprofile.py +++ b/fsl/fslview/profiles/orthoeditprofile.py @@ -42,19 +42,19 @@ class OrthoEditProfile(orthoviewprofile.OrthoViewProfile): ('subtract', 'Subtract from current selection')))) - def clearSelection(self): + def clearSelection(self, *a): self._editor.getSelection().clearSelection() - def fillSelection(self): + def fillSelection(self, *a): self._editor.fillSelection(self.fillValue) - def undo(self): + def undo(self, *a): self._editor.undo() - def redo(self): + def redo(self, *a): self._editor.redo() diff --git a/fsl/fslview/profiles/orthoviewprofile.py b/fsl/fslview/profiles/orthoviewprofile.py index 2cffa2ce1..2d5aa7cc9 100644 --- a/fsl/fslview/profiles/orthoviewprofile.py +++ b/fsl/fslview/profiles/orthoviewprofile.py @@ -77,7 +77,7 @@ class OrthoViewProfile(profiles.Profile): return [self._xcanvas, self._ycanvas, self._zcanvas] - def resetZoom(self): + def resetZoom(self, *a): self._canvasPanel.zoom = 100 self._canvasPanel.xzoom = 100 @@ -85,7 +85,7 @@ class OrthoViewProfile(profiles.Profile): self._canvasPanel.zzoom = 100 - def centreCursor(self): + def centreCursor(self, *a): bounds = self._displayCtx.bounds diff --git a/fsl/fslview/views/canvaspanel.py b/fsl/fslview/views/canvaspanel.py index 3363c1e45..9b19dbdf7 100644 --- a/fsl/fslview/views/canvaspanel.py +++ b/fsl/fslview/views/canvaspanel.py @@ -282,17 +282,26 @@ class CanvasPanel(fslpanel.FSLViewPanel): def __profileChanged(self, *a): - self.__profileManager.changeProfile(self.profile) - if self.__profilePanel is not None: - self.__profilePanel.DestroyChildren() + import fsl.fslview.layouts as layouts + + self.__profileManager.changeProfile(self.profile) + self.__profilePanel.DestroyChildren() - realProfilePanel = fslpanel.ConfigPanel( - self.__profilePanel, self.getCurrentProfile()) + profile = self.getCurrentProfile() + + profilePropPanel = fslpanel.ConfigPanel( + self.__profilePanel, profile, + layout=layouts.layouts[type(profile), 'props']) - sizer = wx.BoxSizer(wx.HORIZONTAL) + profileActionPanel = fslpanel.ConfigPanel( + self.__profilePanel, profile, + layout=layouts.layouts[type(profile), 'actions']) + + sizer = wx.BoxSizer(wx.VERTICAL) - sizer.Add(realProfilePanel, flag=wx.EXPAND, proportion=1) + sizer.Add(profilePropPanel, flag=wx.EXPAND) + sizer.Add(profileActionPanel, flag=wx.EXPAND) self.__profilePanel.SetSizer(sizer) self.__layout() -- GitLab