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

No control panels are shown by default anymore - perspectives will fix

this. Some other minor fixes/tweaks.
parent 4c4c8750
No related branches found
No related tags found
No related merge requests found
...@@ -52,6 +52,9 @@ messages = TypeDict({ ...@@ -52,6 +52,9 @@ messages = TypeDict({
'ProcessingDialog.error' : 'An error has occurred: {}' 'ProcessingDialog.error' : 'An error has occurred: {}'
'\n\nDetails: {}', '\n\nDetails: {}',
'perspectives.savePerspective' : 'Enter a name for the perspective',
'perspectives.applyingPerspective' : 'Applying {} perspective ...',
'overlay.loadOverlays.loading' : 'Loading {} ...', 'overlay.loadOverlays.loading' : 'Loading {} ...',
'overlay.loadOverlays.error' : 'An error occurred loading the image ' 'overlay.loadOverlays.error' : 'An error occurred loading the image '
'{}\n\nDetails: {}', '{}\n\nDetails: {}',
......
...@@ -7,7 +7,9 @@ ...@@ -7,7 +7,9 @@
""" """
""" """
import wx
import fsl.data.strings as strings
import fsl.fsleyes.actions as actions import fsl.fsleyes.actions as actions
import fsl.fsleyes.perspectives as perspectives import fsl.fsleyes.perspectives as perspectives
...@@ -29,7 +31,16 @@ class SavePerspectiveAction(actions.Action): ...@@ -29,7 +31,16 @@ class SavePerspectiveAction(actions.Action):
""" """
""" """
# TODO prompt for name dlg = wx.TextEntryDialog(
name = 'blah' self.__frame,
message=strings.messages['perspectives.savePerspective'])
if dlg.ShowModal() != wx.ID_OK:
return
name = dlg.GetValue()
if name.strip() == '':
return
perspectives.savePerspective(self.__frame, name) perspectives.savePerspective(self.__frame, name)
...@@ -52,6 +52,7 @@ import orthotoolbar ...@@ -52,6 +52,7 @@ import orthotoolbar
import overlaydisplaypanel import overlaydisplaypanel
import overlaydisplaytoolbar import overlaydisplaytoolbar
import overlayinfopanel import overlayinfopanel
import overlaylistpanel
import plotlistpanel import plotlistpanel
import powerspectrumcontrolpanel import powerspectrumcontrolpanel
import shellpanel import shellpanel
...@@ -71,6 +72,7 @@ OrthoToolBar = orthotoolbar.OrthoToolBar ...@@ -71,6 +72,7 @@ OrthoToolBar = orthotoolbar.OrthoToolBar
OverlayDisplayPanel = overlaydisplaypanel.OverlayDisplayPanel OverlayDisplayPanel = overlaydisplaypanel.OverlayDisplayPanel
OverlayDisplayToolBar = overlaydisplaytoolbar.OverlayDisplayToolBar OverlayDisplayToolBar = overlaydisplaytoolbar.OverlayDisplayToolBar
OverlayInfoPanel = overlayinfopanel.OverlayInfoPanel OverlayInfoPanel = overlayinfopanel.OverlayInfoPanel
OverlayListPanel = overlaylistpanel.OverlayListPanel
PlotListPanel = plotlistpanel.PlotListPanel PlotListPanel = plotlistpanel.PlotListPanel
PowerSpectrumControlPanel = powerspectrumcontrolpanel.PowerSpectrumControlPanel PowerSpectrumControlPanel = powerspectrumcontrolpanel.PowerSpectrumControlPanel
ShellPanel = shellpanel.ShellPanel ShellPanel = shellpanel.ShellPanel
......
...@@ -26,7 +26,7 @@ class ShellPanel(fslpanel.FSLEyesPanel): ...@@ -26,7 +26,7 @@ class ShellPanel(fslpanel.FSLEyesPanel):
that owns this ``ShellPanel``. that owns this ``ShellPanel``.
""" """
def __init__(self, parent, overlayList, displayCtx, sceneOpts): def __init__(self, parent, overlayList, displayCtx, canvasPanel):
"""Create a ``ShellPanel``. """Create a ``ShellPanel``.
:arg parent: The :mod:`wx` parent object, assumed to be the :arg parent: The :mod:`wx` parent object, assumed to be the
...@@ -37,15 +37,15 @@ class ShellPanel(fslpanel.FSLEyesPanel): ...@@ -37,15 +37,15 @@ class ShellPanel(fslpanel.FSLEyesPanel):
:arg displayCtx: The :class:`.DisplayContext` of the :arg displayCtx: The :class:`.DisplayContext` of the
:class:`.CanvasPanel` that owns this ``ShellPanel``. :class:`.CanvasPanel` that owns this ``ShellPanel``.
:arg sceneOpts: The :class:`.SceneOpts` of the :arg canvasPanel: The :class:`.CanvasPanel` that owns this
:class:`.CanvasPanel` that owns this ``ShellPanel``. ``ShellPanel``.
""" """
fslpanel.FSLEyesPanel.__init__(self, parent, overlayList, displayCtx) fslpanel.FSLEyesPanel.__init__(self, parent, overlayList, displayCtx)
lcls = { lcls = {
'displayCtx' : displayCtx, 'displayCtx' : displayCtx,
'overlayList' : overlayList, 'overlayList' : overlayList,
'sceneOpts' : sceneOpts, 'sceneOpts' : canvasPanel.getSceneOptions(),
'viewPanel' : parent, 'viewPanel' : parent,
} }
......
...@@ -151,7 +151,7 @@ class FSLEyesFrame(wx.Frame): ...@@ -151,7 +151,7 @@ class FSLEyesFrame(wx.Frame):
"""Returns a list of all :class:`.ViewPanel` instances that are """Returns a list of all :class:`.ViewPanel` instances that are
currenlty displayed in this ``FSLEyesFrame``. currenlty displayed in this ``FSLEyesFrame``.
""" """
return self.__viewPanels.values() return list(self.__viewPanels.values())
def getViewPanelInfo(self, viewPanel): def getViewPanelInfo(self, viewPanel):
...@@ -564,16 +564,8 @@ class FSLEyesFrame(wx.Frame): ...@@ -564,16 +564,8 @@ class FSLEyesFrame(wx.Frame):
# TODO Restore the previous view panel layout. # TODO Restore the previous view panel layout.
# Currently, we just display an OrthoPanel. # Currently, we just display an OrthoPanel.
if restore: if restore:
self.addViewPanel(views.OrthoPanel) self.addViewPanel(views.OrthoPanel)
viewPanel = self.getViewPanels()[0]
# Set up a default for ortho views
# layout (this will hopefully eventually
# be restored from a saved state)
viewPanel.toggleOverlayList()
viewPanel.toggleLocationPanel()
def __makeMenuBar(self): def __makeMenuBar(self):
...@@ -624,12 +616,13 @@ class FSLEyesFrame(wx.Frame): ...@@ -624,12 +616,13 @@ class FSLEyesFrame(wx.Frame):
viewMenu.AppendSubMenu(perspectiveMenu, 'Perspectives') viewMenu.AppendSubMenu(perspectiveMenu, 'Perspectives')
for persp in perspectives.getAllPerspectives(): for persp in perspectives.getAllPerspectives():
menuItem = perspectiveMenu.Append(wx.ID_ANY, menuItem = perspectiveMenu.Append(
strings.perspectives[persp]) wx.ID_ANY, strings.perspectives.get(persp, persp))
actionObj = loadperspective.LoadPerspectiveAction(self, persp) actionObj = loadperspective.LoadPerspectiveAction(self, persp)
actionObj.bindToWidget(self, wx.EVT_MENU, menuItem) actionObj.bindToWidget(self, wx.EVT_MENU, menuItem)
# Save perspective # Save perspective
perspectiveMenu.AppendSeparator()
savePerspAction = saveperspective.SavePerspectiveAction(self) savePerspAction = saveperspective.SavePerspectiveAction(self)
savePerspMenuItem = perspectiveMenu.Append( savePerspMenuItem = perspectiveMenu.Append(
wx.ID_ANY, strings.actions[savePerspAction]) wx.ID_ANY, strings.actions[savePerspAction])
......
...@@ -375,7 +375,7 @@ class CanvasPanel(viewpanel.ViewPanel): ...@@ -375,7 +375,7 @@ class CanvasPanel(viewpanel.ViewPanel):
:meth:`.ViewPanel.togglePanel`. :meth:`.ViewPanel.togglePanel`.
""" """
self.togglePanel(lookuptablepanel.LookupTablePanel, self.togglePanel(lookuptablepanel.LookupTablePanel,
location=wx.TO, location=wx.TOP,
action=self.toggleLookupTablePanel) action=self.toggleLookupTablePanel)
@actions.toggleAction @actions.toggleAction
...@@ -394,7 +394,7 @@ class CanvasPanel(viewpanel.ViewPanel): ...@@ -394,7 +394,7 @@ class CanvasPanel(viewpanel.ViewPanel):
:meth:`.ViewPanel.togglePanel`. :meth:`.ViewPanel.togglePanel`.
""" """
self.togglePanel(shellpanel.ShellPanel, self.togglePanel(shellpanel.ShellPanel,
self.getSceneOptions(), self,
location=wx.BOTTOM, location=wx.BOTTOM,
action=self.toggleShell) action=self.toggleShell)
......
...@@ -61,10 +61,6 @@ class HistogramPanel(plotpanel.OverlayPlotPanel): ...@@ -61,10 +61,6 @@ class HistogramPanel(plotpanel.OverlayPlotPanel):
toggleHistogramList toggleHistogramList
toggleHistogramControl toggleHistogramControl
The ``PlotListPanel`` and ``HistogramControlPanel`` are both shown
by default when a new ``HistogramPanel`` is created.
""" """
...@@ -93,12 +89,6 @@ class HistogramPanel(plotpanel.OverlayPlotPanel): ...@@ -93,12 +89,6 @@ class HistogramPanel(plotpanel.OverlayPlotPanel):
self.addListener('histType', self._name, self.draw) self.addListener('histType', self._name, self.draw)
def addPanels():
self.toggleHistogramControl()
self.toggleHistogramList()
wx.CallAfter(addPanels)
def destroy(self): def destroy(self):
"""Removes some property listeners, and calls """Removes some property listeners, and calls
......
...@@ -51,16 +51,6 @@ class LightBoxPanel(canvaspanel.CanvasPanel): ...@@ -51,16 +51,6 @@ class LightBoxPanel(canvaspanel.CanvasPanel):
:nosignatures: :nosignatures:
toggleLightBoxToolBar toggleLightBoxToolBar
When a ``LightBoxPanel`` is created, it will automatically add the
following control panels:
.. autosummary::
:nosignatures:
~fsl.fsleyes.controls.lightboxtoolbar.LightBoxToolBar
~fsl.fsleyes.controls.overlaydisplaytoolbar.OverlayDisplayToolBar
""" """
...@@ -160,15 +150,6 @@ class LightBoxPanel(canvaspanel.CanvasPanel): ...@@ -160,15 +150,6 @@ class LightBoxPanel(canvaspanel.CanvasPanel):
self.centrePanelLayout() self.centrePanelLayout()
self.initProfile() self.initProfile()
# The ViewPanel AuiManager seems to
# struggle if we add these toolbars
# immediately, so we'll do it asynchronously
def addToolbars():
self.toggleDisplayProperties()
self.toggleLightBoxToolBar()
wx.CallAfter(addToolbars)
def destroy(self): def destroy(self):
"""Must be called when this ``LightBoxPanel`` is closed. """Must be called when this ``LightBoxPanel`` is closed.
......
...@@ -108,27 +108,15 @@ class OrthoPanel(canvaspanel.CanvasPanel): ...@@ -108,27 +108,15 @@ class OrthoPanel(canvaspanel.CanvasPanel):
toggleOrthoToolBar toggleOrthoToolBar
toggleEditToolBar toggleEditToolBar
When an ``OrthoPanel`` is created, it will automatically add the
following control panels:
.. autosummary::
:nosignatures:
~fsl.fsleyes.controls.orthotoolbar.OrthoToolBar
~fsl.fsleyes.controls.overlaydisplaytoolbar.OverlayDisplayToolBar
""" """
def __init__(self, parent, overlayList, displayCtx, addToolbars=True): def __init__(self, parent, overlayList, displayCtx):
"""Create an ``OrthoPanel``. """Create an ``OrthoPanel``.
:arg parent: The :mod:`wx` parent. :arg parent: The :mod:`wx` parent.
:arg overlayList: An :class:`.OverlayList` instance. :arg overlayList: An :class:`.OverlayList` instance.
:arg displayCtx: A :class:`.DisplayContext` instance. :arg displayCtx: A :class:`.DisplayContext` instance.
:arg addToolbars: If ``False``, the toolbars (listed above) are not
added. Defaults to ``True``.
""" """
sceneOpts = orthoopts.OrthoOpts() sceneOpts = orthoopts.OrthoOpts()
...@@ -233,16 +221,6 @@ class OrthoPanel(canvaspanel.CanvasPanel): ...@@ -233,16 +221,6 @@ class OrthoPanel(canvaspanel.CanvasPanel):
self.centrePanelLayout() self.centrePanelLayout()
self.initProfile() self.initProfile()
# The ViewPanel AuiManager seems to
# struggle if we add these toolbars
# immediately, so we'll do it asynchronously
def _addToolbars():
self.toggleDisplayProperties()
self.toggleOrthoToolBar()
if addToolbars:
wx.CallAfter(_addToolbars)
def destroy(self): def destroy(self):
"""Must be called when this ``OrthoPanel`` is closed. """Must be called when this ``OrthoPanel`` is closed.
...@@ -833,10 +811,7 @@ class OrthoFrame(wx.Frame): ...@@ -833,10 +811,7 @@ class OrthoFrame(wx.Frame):
ctx, dummyCanvas = fslgl.getWXGLContext() ctx, dummyCanvas = fslgl.getWXGLContext()
fslgl.bootstrap() fslgl.bootstrap()
self.panel = OrthoPanel(self, self.panel = OrthoPanel(self, overlayList, displayCtx)
overlayList,
displayCtx,
addToolbars=False)
self.Layout() self.Layout()
if dummyCanvas is not None: if dummyCanvas is not None:
...@@ -876,10 +851,7 @@ class OrthoDialog(wx.Dialog): ...@@ -876,10 +851,7 @@ class OrthoDialog(wx.Dialog):
ctx, dummyCanvas = fslgl.getWXGLContext() ctx, dummyCanvas = fslgl.getWXGLContext()
fslgl.bootstrap() fslgl.bootstrap()
self.panel = OrthoPanel(self, self.panel = OrthoPanel(self, overlayList, displayCtx)
overlayList,
displayCtx,
addToolbars=False)
self.Layout() self.Layout()
if dummyCanvas is not None: if dummyCanvas is not None:
......
...@@ -55,10 +55,6 @@ class PowerSpectrumPanel(plotpanel.OverlayPlotPanel): ...@@ -55,10 +55,6 @@ class PowerSpectrumPanel(plotpanel.OverlayPlotPanel):
togglePowerSpectrumControl togglePowerSpectrumControl
The ``PlotListPanel`` and ``PowerSpectrumControlPanel`` are both shown
by default when a new ``PowerSpectrumPanel`` is created.
**Melodic images** **Melodic images**
...@@ -101,13 +97,6 @@ class PowerSpectrumPanel(plotpanel.OverlayPlotPanel): ...@@ -101,13 +97,6 @@ class PowerSpectrumPanel(plotpanel.OverlayPlotPanel):
self._name, self._name,
self.__plotMelodicICsChanged) self.__plotMelodicICsChanged)
def addPanels():
self.togglePowerSpectrumControl()
self.togglePowerSpectrumList()
wx.CallAfter(addPanels)
self.draw()
def destroy(self): def destroy(self):
"""Must be called when this ``PowerSpectrumPanel` is no longer """Must be called when this ``PowerSpectrumPanel` is no longer
......
...@@ -75,9 +75,6 @@ class TimeSeriesPanel(plotpanel.OverlayPlotPanel): ...@@ -75,9 +75,6 @@ class TimeSeriesPanel(plotpanel.OverlayPlotPanel):
toggleTimeSeriesList toggleTimeSeriesList
toggleTimeSeriesControl toggleTimeSeriesControl
New ``TimeSeriesPanel`` instances will display a ``PlotListPanel``
and a ``TimeSeriesControlPanel`` by default.
**FEATures** **FEATures**
...@@ -146,13 +143,6 @@ class TimeSeriesPanel(plotpanel.OverlayPlotPanel): ...@@ -146,13 +143,6 @@ class TimeSeriesPanel(plotpanel.OverlayPlotPanel):
self._name, self._name,
self.__plotMelodicICsChanged) self.__plotMelodicICsChanged)
def addPanels():
self.toggleTimeSeriesControl()
self.toggleTimeSeriesList()
wx.CallAfter(addPanels)
self.draw()
def destroy(self): def destroy(self):
"""Removes some listeners, and calls the :meth:`.PlotPanel.destroy` """Removes some listeners, and calls the :meth:`.PlotPanel.destroy`
......
...@@ -100,14 +100,21 @@ class ViewPanel(fslpanel.FSLEyesPanel): ...@@ -100,14 +100,21 @@ class ViewPanel(fslpanel.FSLEyesPanel):
self.__profileManager = profiles.ProfileManager( self.__profileManager = profiles.ProfileManager(
self, overlayList, displayCtx) self, overlayList, displayCtx)
# The centrePanel attribute stores a reference
# to the main (centre) panel on this ViewPanel.
# It is set by sub-class implementations via
# the setCentrePanel method.
#
# The panels dictionary stores a collection # The panels dictionary stores a collection
# of {type : instance} mappings of active # of {type : instance} mappings of active
# FSLeyes control panels that are contained # FSLeyes control panels that are contained
# in this view panel. The panelActions dict # in this view panel.
# contains a collection of {type : Action} #
# mappings, but only if the control panel # The panelActions dict contains a collection
# was opened as a result of an Action on # of {type : Action} mappings, but only if the
# this view panel. # control panel was opened as a result of an
# Action on this view panel.
self.__centrePanel = None
self.__panels = {} self.__panels = {}
self.__panelActions = {} self.__panelActions = {}
...@@ -185,6 +192,7 @@ class ViewPanel(fslpanel.FSLEyesPanel): ...@@ -185,6 +192,7 @@ class ViewPanel(fslpanel.FSLEyesPanel):
self.__profileManager = None self.__profileManager = None
self.__auiMgr = None self.__auiMgr = None
self.__panels = None self.__panels = None
self.__centrePanel = None
fslpanel.FSLEyesPanel.destroy(self) fslpanel.FSLEyesPanel.destroy(self)
...@@ -203,15 +211,18 @@ class ViewPanel(fslpanel.FSLEyesPanel): ...@@ -203,15 +211,18 @@ class ViewPanel(fslpanel.FSLEyesPanel):
def setCentrePanel(self, panel): def setCentrePanel(self, panel):
"""Set the primary centre panel for this ``ViewPanel``. """ """Set the primary centre panel for this ``ViewPanel``. This method
is only intended to be called by sub-classes.
"""
panel.Reparent(self) panel.Reparent(self)
paneInfo = (aui.AuiPaneInfo() paneInfo = (aui.AuiPaneInfo()
.Name(type(panel).__name__) .Name(type(panel).__name__)
.CentrePane()) .CentrePane())
self.__auiMgr.AddPane(panel, paneInfo) self.__auiMgr.AddPane(panel, paneInfo)
self.__auiMgrUpdate() self.__auiMgrUpdate()
self.__centrePanel = panel
def togglePanel(self, panelType, *args, **kwargs): def togglePanel(self, panelType, *args, **kwargs):
...@@ -367,6 +378,12 @@ class ViewPanel(fslpanel.FSLEyesPanel): ...@@ -367,6 +378,12 @@ class ViewPanel(fslpanel.FSLEyesPanel):
else: return None else: return None
def getCentrePanel(self):
"""Returns the primary (centre) panel on this ``ViewPanel``.
"""
return self.__centrePanel
def getPanels(self): def getPanels(self):
"""Returns a list containing all control panels currently shown in this """Returns a list containing all control panels currently shown in this
``ViewPanel``. ``ViewPanel``.
......
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