Skip to content
Snippets Groups Projects
Commit bf3ff977 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

All profile/canvaspael props/actions are available on the UI. Action

methods now accept any number of arguments.
parent 01dea82e
No related branches found
No related tags found
No related merge requests found
...@@ -94,7 +94,7 @@ class Action(props.HasProperties): ...@@ -94,7 +94,7 @@ class Action(props.HasProperties):
self._boundWidgets.append(widget) self._boundWidgets.append(widget)
def _enabledChanged(self, *a): def _enabledChanged(self, *args):
"""Internal method which is called when the :attr:`enabled` property """Internal method which is called when the :attr:`enabled` property
changes. Enables/disables the action, and any bound widgets. changes. Enables/disables the action, and any bound widgets.
""" """
...@@ -105,18 +105,18 @@ class Action(props.HasProperties): ...@@ -105,18 +105,18 @@ class Action(props.HasProperties):
widget.Enable(self.enabled) widget.Enable(self.enabled)
def __disabledDoAction(self): def __disabledDoAction(self, *args):
"""This method gets called when the action is disabled.""" """This method gets called when the action is disabled."""
raise RuntimeError('{} is disabled'.format(self.__class__.__name__)) 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 """This method is set in :meth:`__init__`; it gets called when the
action is enabled.""" action is enabled."""
pass pass
def doAction(self): def doAction(self, *args):
"""This method must be overridden by subclasses. """This method must be overridden by subclasses.
It performs the action, or raises a ``RuntimeError`` if the action It performs the action, or raises a ``RuntimeError`` if the action
...@@ -200,6 +200,6 @@ class ActionProvider(props.HasProperties): ...@@ -200,6 +200,6 @@ class ActionProvider(props.HasProperties):
self.__actions[name].enabled = not self.__actions[name].enabled self.__actions[name].enabled = not self.__actions[name].enabled
def run(self, name): def run(self, name, *args):
"""Performs the named action.""" """Performs the named action."""
self.__actions[name].doAction() self.__actions[name].doAction(*args)
...@@ -32,17 +32,35 @@ OrthoEditProfileLayout = props.HGroup( ...@@ -32,17 +32,35 @@ OrthoEditProfileLayout = props.HGroup(
vertLabels=True, 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( CanvasPanelActionLayout = props.HGroup(
(props.Button('screenshot', text=strings.labels[CanvasPanel, 'screenshot'], callback=CanvasPanel.screenshot), (props.Widget('profile', label=strings.labels[CanvasPanel, 'profile']),
props.Button('toggleColourBar', text=strings.labels[CanvasPanel, 'toggleColourBar'], callback=CanvasPanel.toggleColourBar), props.Button('screenshot', text=strings.labels[CanvasPanel, 'screenshot'], callback=CanvasPanel.screenshot),
props.Button('toggleImageList', text=strings.labels[CanvasPanel, 'toggleImageList'], callback=CanvasPanel.toggleImageList), props.Button('toggleColourBar', text=strings.labels[CanvasPanel, 'toggleColourBar'], callback=CanvasPanel.toggleColourBar),
props.Button('toggleDisplayProperties', text=strings.labels[CanvasPanel, 'toggleDisplayProperties'], callback=CanvasPanel.toggleDisplayProperties), props.Button('toggleImageList', text=strings.labels[CanvasPanel, 'toggleImageList'], callback=CanvasPanel.toggleImageList),
props.Button('toggleLocationPanel', text=strings.labels[CanvasPanel, 'toggleLocationPanel'], callback=CanvasPanel.toggleLocationPanel), props.Button('toggleDisplayProperties', text=strings.labels[CanvasPanel, 'toggleDisplayProperties'], callback=CanvasPanel.toggleDisplayProperties),
props.Button('toggleCanvasProperties', text=strings.labels[CanvasPanel, 'toggleCanvasProperties'], callback=CanvasPanel.toggleCanvasProperties)), props.Button('toggleLocationPanel', text=strings.labels[CanvasPanel, 'toggleLocationPanel'], callback=CanvasPanel.toggleLocationPanel),
props.Button('toggleCanvasProperties', text=strings.labels[CanvasPanel, 'toggleCanvasProperties'], callback=CanvasPanel.toggleCanvasProperties)),
wrap=True, wrap=True,
showLabels=False) showLabels=False)
...@@ -51,9 +69,10 @@ CanvasPanelActionLayout = props.HGroup( ...@@ -51,9 +69,10 @@ CanvasPanelActionLayout = props.HGroup(
layouts = td.TypeDict({ layouts = td.TypeDict({
'OrthoViewProfile' : OrthoViewProfileLayout, ('OrthoViewProfile', 'props') : OrthoViewProfileLayout,
'OrthoEditProfile' : OrthoEditProfileLayout, ('OrthoEditProfile', 'props') : OrthoEditProfileLayout,
('OrthoViewProfile', 'actions') : OrthoViewProfileActionLayout,
('OrthoEditProfile', 'actions') : OrthoEditProfileActionLayout,
('CanvasPanel', 'actions') : CanvasPanelActionLayout, ('CanvasPanel', 'actions') : CanvasPanelActionLayout,
# ('CanvasPanel', 'props') : CanvasPanelTopLayout,
}) })
...@@ -42,19 +42,19 @@ class OrthoEditProfile(orthoviewprofile.OrthoViewProfile): ...@@ -42,19 +42,19 @@ class OrthoEditProfile(orthoviewprofile.OrthoViewProfile):
('subtract', 'Subtract from current selection')))) ('subtract', 'Subtract from current selection'))))
def clearSelection(self): def clearSelection(self, *a):
self._editor.getSelection().clearSelection() self._editor.getSelection().clearSelection()
def fillSelection(self): def fillSelection(self, *a):
self._editor.fillSelection(self.fillValue) self._editor.fillSelection(self.fillValue)
def undo(self): def undo(self, *a):
self._editor.undo() self._editor.undo()
def redo(self): def redo(self, *a):
self._editor.redo() self._editor.redo()
......
...@@ -77,7 +77,7 @@ class OrthoViewProfile(profiles.Profile): ...@@ -77,7 +77,7 @@ class OrthoViewProfile(profiles.Profile):
return [self._xcanvas, self._ycanvas, self._zcanvas] return [self._xcanvas, self._ycanvas, self._zcanvas]
def resetZoom(self): def resetZoom(self, *a):
self._canvasPanel.zoom = 100 self._canvasPanel.zoom = 100
self._canvasPanel.xzoom = 100 self._canvasPanel.xzoom = 100
...@@ -85,7 +85,7 @@ class OrthoViewProfile(profiles.Profile): ...@@ -85,7 +85,7 @@ class OrthoViewProfile(profiles.Profile):
self._canvasPanel.zzoom = 100 self._canvasPanel.zzoom = 100
def centreCursor(self): def centreCursor(self, *a):
bounds = self._displayCtx.bounds bounds = self._displayCtx.bounds
......
...@@ -282,17 +282,26 @@ class CanvasPanel(fslpanel.FSLViewPanel): ...@@ -282,17 +282,26 @@ class CanvasPanel(fslpanel.FSLViewPanel):
def __profileChanged(self, *a): def __profileChanged(self, *a):
self.__profileManager.changeProfile(self.profile)
if self.__profilePanel is not None: import fsl.fslview.layouts as layouts
self.__profilePanel.DestroyChildren()
self.__profileManager.changeProfile(self.profile)
self.__profilePanel.DestroyChildren()
realProfilePanel = fslpanel.ConfigPanel( profile = self.getCurrentProfile()
self.__profilePanel, 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.__profilePanel.SetSizer(sizer)
self.__layout() self.__layout()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment