diff --git a/fsl/fsleyes/controls/__init__.py b/fsl/fsleyes/controls/__init__.py index c665ec3e224a6ead64ec2708e13d2766e86587f2..633a11b191f8935b94cf4045784c66c9f77ab8de 100644 --- a/fsl/fsleyes/controls/__init__.py +++ b/fsl/fsleyes/controls/__init__.py @@ -38,3 +38,40 @@ The following control panels currently exist: ~fsl.fsleyes.controls.shellpanel.ShellPanel ~fsl.fsleyes.controls.timeseriescontrolpanel.TimeSeriesControlPanel """ + +import atlaspanel +import canvassettingspanel +import clusterpanel +import histogramcontrolpanel +import lightboxtoolbar +import locationpanel +import lookuptablepanel +import melodicclassificationpanel +import orthoedittoolbar +import orthotoolbar +import overlaydisplaypanel +import overlaydisplaytoolbar +import overlayinfopanel +import plotlistpanel +import powerspectrumcontrolpanel +import shellpanel +import timeseriescontrolpanel + + +AtlasPanel = atlaspanel.AtlasPanel +CanvasSettingsPanel = canvassettingspanel.CanvasSettingsPanel +ClusterPanel = clusterpanel.ClusterPanel +HistogramControlPanel = histogramcontrolpanel.HistogramControlPanel +LightBoxToolBar = lightboxtoolbar.LightBoxToolBar +LocationPanel = locationpanel.LocationPanel +LookupTablePanel = lookuptablepanel.LookupTablePanel +MelodicClassificationPanel = melodicclassificationpanel.MelodicClassificationPanel +OrthoEditToolBar = orthoedittoolbar.OrthoEditToolBar +OrthoToolBar = orthotoolbar.OrthoToolBar +OverlayDisplayPanel = overlaydisplaypanel.OverlayDisplayPanel +OverlayDisplayToolBar = overlaydisplaytoolbar.OverlayDisplayToolBar +OverlayInfoPanel = overlayinfopanel.OverlayInfoPanel +PlotListPanel = plotlistpanel.PlotListPanel +PowerSpectrumControlPanel = powerspectrumcontrolpanel.PowerSpectrumControlPanel +ShellPanel = shellpanel.ShellPanel +TimeSeriesControlPanel = timeseriescontrolpanel.TimeSeriesControlPanel diff --git a/fsl/fsleyes/controls/atlaspanel.py b/fsl/fsleyes/controls/atlaspanel.py index e56be01fb06a13c0e685431c1c3e97739546c284..03e3fb1668c04df7bbf09d3c96367332793a424d 100644 --- a/fsl/fsleyes/controls/atlaspanel.py +++ b/fsl/fsleyes/controls/atlaspanel.py @@ -24,8 +24,8 @@ import fsl.data.atlases as atlases import fsl.data.strings as strings import fsl.utils.dialog as fsldlg import fsl.fsleyes.panel as fslpanel -import fsl.fsleyes.controls.atlasoverlaypanel as atlasoverlaypanel -import fsl.fsleyes.controls.atlasinfopanel as atlasinfopanel +import atlasoverlaypanel +import atlasinfopanel log = logging.getLogger(__name__) diff --git a/fsl/fsleyes/controls/histogramcontrolpanel.py b/fsl/fsleyes/controls/histogramcontrolpanel.py index 041588b0e64b26293a1520d235baf1cfdb6a3455..7920ba1bafc75d8ab35c9d726bbf2e061473a3f8 100644 --- a/fsl/fsleyes/controls/histogramcontrolpanel.py +++ b/fsl/fsleyes/controls/histogramcontrolpanel.py @@ -9,11 +9,11 @@ control* panel which allows a :class:`.HistogramPanel` to be configured. """ -import props +import props -import fsl.fsleyes.tooltips as fsltooltips -import fsl.fsleyes.controls.plotcontrolpanel as plotcontrolpanel -import fsl.data.strings as strings +import fsl.fsleyes.tooltips as fsltooltips +import plotcontrolpanel +import fsl.data.strings as strings class HistogramControlPanel(plotcontrolpanel.PlotControlPanel): diff --git a/fsl/fsleyes/controls/powerspectrumcontrolpanel.py b/fsl/fsleyes/controls/powerspectrumcontrolpanel.py index 271db2355860140a333218b705d2ed1abd59e1e0..d8fe87a728da8b6e7498ca9f1b8176ba62534270 100644 --- a/fsl/fsleyes/controls/powerspectrumcontrolpanel.py +++ b/fsl/fsleyes/controls/powerspectrumcontrolpanel.py @@ -11,7 +11,7 @@ import props -import fsl.fsleyes.controls.plotcontrolpanel as plotcontrolpanel +import plotcontrolpanel import fsl.fsleyes.tooltips as fsltooltips import fsl.fsleyes.plotting.powerspectrumseries as powerspectrumseries import fsl.data.strings as strings diff --git a/fsl/fsleyes/frame.py b/fsl/fsleyes/frame.py index 6f3c2b146eb35f76557b1b97f9baa78c0f8a67f2..4fed7b08782178482a987f9fe450995312319b98 100644 --- a/fsl/fsleyes/frame.py +++ b/fsl/fsleyes/frame.py @@ -80,7 +80,10 @@ class FSLEyesFrame(wx.Frame): :nosignatures: getViewPanels + getViewPanelInfo addViewPanel + removeViewPanel + getAuiManager """ @@ -151,6 +154,29 @@ class FSLEyesFrame(wx.Frame): return self.__viewPanels.values() + def getViewPanelInfo(self, viewPanel): + """Returns the ``AuiPaneInfo`` class which contains layout information + about the given :class:`.ViewPanel`. + """ + return self.__auiManager.GetPane(viewPanel) + + + def getAuiManager(self): + """Returns the ``wx.lib.agw.aui.AuiManager` object which is managing + the layout of this ``FSLEyesFrame``. + """ + return self.__auiManager + + + def removeViewPanel(self, viewPanel): + """Removes the given :class:`.ViewPanel` from this ``FSLEyesFrame``. + """ + paneInfo = self.__auiManager.GetPane(viewPanel) + self.__onViewPanelClose( paneInfo=paneInfo) + self.__auiManager.ClosePane(paneInfo) + self.__auiManager.Update() + + def addViewPanel(self, panelCls): """Adds a new :class:`.ViewPanel` to the centre of the frame, and a menu item allowing the user to configure the view. @@ -191,8 +217,11 @@ class FSLEyesFrame(wx.Frame): id(panel), id(childDC))) + # The PaneInfo Name is the panel class + # name - this is used for saving and + # restoring perspectives paneInfo = (aui.AuiPaneInfo() - .Name(title) + .Name(panelCls.__name__) .Caption(title) .CloseButton() .Dockable() @@ -287,6 +316,7 @@ class FSLEyesFrame(wx.Frame): if len(regularActions) > 0 and len(toggleActions) > 0: menu.AppendSeparator() + # Toggle actions for actionName, actionObj in toggleActions: menuItem = menu.Append( @@ -299,10 +329,7 @@ class FSLEyesFrame(wx.Frame): # Add a 'Close' action to # the menu for every panel def closeViewPanel(ev): - paneInfo = self.__auiManager.GetPane(panel) - self.__onViewPanelClose( paneInfo=paneInfo) - self.__auiManager.ClosePane(paneInfo) - self.__auiManager.Update() + self.removeViewPanel(panel) # But put another separator before it if len(regularActions) > 0 or len(toggleActions) > 0: diff --git a/fsl/fsleyes/views/viewpanel.py b/fsl/fsleyes/views/viewpanel.py index cae61fed247702661a4e1b42aa4d2487f69b169c..e7a216d0ba33246e298564f61dbba748df369fe6 100644 --- a/fsl/fsleyes/views/viewpanel.py +++ b/fsl/fsleyes/views/viewpanel.py @@ -65,6 +65,24 @@ class ViewPanel(fslpanel.FSLEyesPanel): profile can be changed with the :attr:`profile` property, and can be accessed with the :meth:`getCurrentProfile` method. See the :mod:`.profiles` package for more information on interaction profiles. + + + **Programming interface** + + + The following methods are available on a ``Viewpanel` for programmatically + controlling its display and layout: + + + .. autosummary:: + :nosignatures: + + togglePanel + isPanelOpen + getPanel + getPanels + getPanelInfo + getAuiManager """ @@ -188,7 +206,11 @@ class ViewPanel(fslpanel.FSLEyesPanel): """Set the primary centre panel for this ``ViewPanel``. """ panel.Reparent(self) - self.__auiMgr.AddPane(panel, wx.CENTRE) + paneInfo = (aui.AuiPaneInfo() + .Name(type(panel).__name__) + .CentrePane()) + + self.__auiMgr.AddPane(panel, paneInfo) self.__auiMgrUpdate() @@ -251,8 +273,10 @@ class ViewPanel(fslpanel.FSLEyesPanel): self.__onPaneClose(None, window) return - # Otherwise, create a new panel of the specified type - paneInfo = aui.AuiPaneInfo() + # Otherwise, create a new panel of the specified type. + # The PaneInfo Name is the control panel class name - + # this is used for saving and restoring perspectives. + paneInfo = aui.AuiPaneInfo().Name(panelType.__name__) window = panelType( self, self._overlayList, self._displayCtx, *args, **kwargs) @@ -341,6 +365,27 @@ class ViewPanel(fslpanel.FSLEyesPanel): """ if panelType in self.__panels: return self.__panels[panelType] else: return None + + + def getPanels(self): + """Returns a list containing all control panels currently shown in this + ``ViewPanel``. + """ + return list(self.__panels.values()) + + + def getPanelInfo(self, panel): + """Returns the ``AuiPaneInfo`` object which contains information about + the given control panel. + """ + return self.__auiMgr.GetPane(panel) + + + def getAuiManager(self): + """Returns the ``wx.lib.agw.aui.AuiManager`` object which manages the + layout of this ``ViewPanel``. + """ + return self.__auiMgr def __selectedOverlayChanged(self, *a):