fsleyes.frame
¶
This module provides the FSLeyesFrame
which is the top level frame
for FSLeyes.
-
class
fsleyes.frame.
FSLeyesFrame
(parent, overlayList, displayCtx, restore=False, save=True, fontSize=None, menu=True)¶ Bases:
__main__.MockClass
A
FSLeyesFrame
is a simplewx.Frame
which acts as a container forViewPanel
instances.A
wx.lib.agw.aui.AuiManager
is used so thatViewPanel
panels can be dynamically laid out and reconfigured by the user.Menus
The
FSLeyesFrame
has the following menus:FSLeyes General actions, such as help, quit, about. File File actions such as adding a new overlay. Overlay Actions for working with overlays. View Options to open a new ViewPanel
.Settings Options which are specific to the currently visible ViewPanel
instances. A separate sub-menu is added for each visibleViewPanel
. AllViewPanel
classes inherit from theActionProvider
class - any actions that have been defined are added as menu items here.Tools Options which invoke some sort of tool - some global tools are added to this menu, along with tools that are specific to each active view. Saving/restoring state
When a
FSLeyesFrame
is closed, it saves some display settings so that they can be restored the next time aFSLeyesFrame
is opened. The settings are saved using thesettings
module. Currently, the frame position, size, and layout (see thelayout
module) are saved.Programming interface
The
FSLeyesFrame
provides the following properties and methods for programmatically configuring the display:overlayList
Returns the OverlayList
which contains the overlays being displayed by thisFSLeyesFrame
.displayCtx
Returns the top-level DisplayContext
associated with thisFSLeyesFrame
.viewPanels
Returns a list of all ViewPanel
instances that are currenlty displayed in thisFSLeyesFrame
.focusedViewPanel
Returns the ViewPanel
which currently has focus, orNone
if noViewPanel
has focus.auiManager
Returns the wx.lib.agw.aui.AuiManager` object which is managing the layout of this ``FSLeyesFrame
.getViewPanelInfo
Returns the AuiPaneInfo
class which contains layout information about the givenViewPanel
.getViewPanelID
Returns the ID that was assigned to the given ViewPanel
.getViewPanelTitle
Returns the ID that was assigned to the given ViewPanel
.addViewPanel
Adds a new ViewPanel
to the centre of the frame, and a menu item allowing the user to configure the view.viewPanelDefaultLayout
After a ViewPanel
is added via the view menu, this method is called to perform some basic initialisation on the panel.removeViewPanel
Removes the given ViewPanel
from thisFSLeyesFrame
.removeAllViewPanels
Removes all view panels from this FSLeyesFrame
.refreshViewMenu
Re-creates the View menu. refreshLayoutMenu
Re-creates the View -> Layouts sub-menu. refreshSettingsMenu
Re-creates the Settings menu. refreshToolsMenu
Re-creates the Tools menu. populateMenu
Creates menu items for every Action
available on the giventarget
, or for every named action in theactionNames
list.Close
Closes this FSLeyesFrame
.Actions
The
fsleyes.actions.frameactions
module contains someactions
which are monkey-patched into theFSLeyesFrame
class. These actions are made available to the user via menu items and/or keyboard shortcuts.Note
All of the functions defined in the
fsleyes.actions.frameactions
module are treated as first-class methods of theFSLeyesFrame
class (i.e. they are assumed to be present). They are only in a separate module to keep file sizes down.-
__init__
(parent, overlayList, displayCtx, restore=False, save=True, fontSize=None, menu=True)¶ Create a
FSLeyesFrame
.Parameters: - parent – The
wx
parent object. - overlayList – The
OverlayList
. - displayCtx – The master
DisplayContext
. - restore – Restores previous saved layout. If
False
, no view panels will be displayed. - save – Save current layout when closed.
- fontSize – Application-wide font size to use. Defaults to 10.
- menu – Whether or not to create a menu bar.
- parent – The
-
overlayList
¶ Returns the
OverlayList
which contains the overlays being displayed by thisFSLeyesFrame
.
-
displayCtx
¶ Returns the top-level
DisplayContext
associated with thisFSLeyesFrame
.
-
viewPanels
¶ Returns a list of all
ViewPanel
instances that are currenlty displayed in thisFSLeyesFrame
.
-
focusedViewPanel
¶ Returns the
ViewPanel
which currently has focus, orNone
if noViewPanel
has focus.
Returns a dictionary containing all global
Action
objects that are bound to menu items.
-
getOverlayList
= <MagicMock name='mock.deprecated()()' id='4123138092'>¶
-
getDisplayContext
= <MagicMock name='mock.deprecated()()' id='4123138092'>¶
-
getViewPanels
= <MagicMock name='mock.deprecated()()' id='4123138092'>¶
-
getFocusedViewPanel
= <MagicMock name='mock.deprecated()()' id='4123138092'>¶
-
getViewPanelID
(viewPanel)¶ Returns the ID that was assigned to the given
ViewPanel
. This is a sequentially increasing integer, starting from 1.
-
getViewPanelTitle
(viewPanel)¶ Returns the ID that was assigned to the given
ViewPanel
. This is a sequentially increasing integer, starting from 1.
-
getViewPanelInfo
(viewPanel)¶ Returns the
AuiPaneInfo
class which contains layout information about the givenViewPanel
.
-
auiManager
¶ Returns the
wx.lib.agw.aui.AuiManager` object which is managing the layout of this ``FSLeyesFrame
.
-
getAuiManager
= <MagicMock name='mock.deprecated()()' id='4123138092'>¶
-
removeAllViewPanels
()¶ Removes all view panels from this
FSLeyesFrame
.Note
This method should be used to clear the frame, rather than removing each
ViewPanel
individually viaremoveViewPanel()
. This is because when oneViewPanel
is closed, the display settings of the remainingViewPanel
instances may be modified. If these remainingViewPanels
are then immediately closed, thay may not have had enough time to reconfigure themselves (e.g.GLVolume
instances re-creating theirImageTexture
instance due to a change inDisplayContext.syncOverlayDisplay
), and ugly things will happen (e.g. anImageTexture
trying to configure itself after it has already been destroyed).So just use this method instead.
-
addViewPanel
(panelCls, title=None, **kwargs)¶ Adds a new
ViewPanel
to the centre of the frame, and a menu item allowing the user to configure the view.Parameters: - panelCls – The
ViewPanel
type to be added. - title – Title to give the view. If not provided, it is assumed
that a name is present for the view type in
strings.titles
.
Returns: The newly created
ViewPanel
.All other arguments are passed to the
__init__
method of the childDisplayContext
that is created for the new view.- panelCls – The
-
viewPanelDefaultLayout
(viewPanel)¶ After a
ViewPanel
is added via the view menu, this method is called to perform some basic initialisation on the panel. This basically amounts to adding toolbars.
-
refreshViewMenu
()¶ Re-creates the View menu.
-
refreshLayoutMenu
()¶ Re-creates the View -> Layouts sub-menu.
-
refreshSettingsMenu
()¶ Re-creates the Settings menu.
-
refreshToolsMenu
()¶ Re-creates the Tools menu.
-
refreshPerspectiveMenu
= <MagicMock name='mock.deprecated()()' id='4123138092'>¶
-
populateMenu
(menu, target, actionNames=None, actionTitles=None, **kwargs)¶ Creates menu items for every
Action
available on the giventarget
, or for every named action in theactionNames
list.Called by the
__addViewPanelMenu()
method to generate a menu for newViewPanel
instances, but can also be called for other purposes.Parameters: - menu – The
wx.Menu
to be populated. - target – The object which has actions to be bound to the menu items.
- actionNames – If provided, only menu items for the actions named
in this list will be created. May contain
None
, which indicates that a menu separator should be added at that point. - actionTitles – Optional dict containing
{name : title}
mappings for some actions. If not provided, it is assumed that a name for the action exists instrings.actions
.
All other keyword arguments are passed through to the
__onViewPanelMenuItem()
method.Returns: A list containing the (Action, wx.MenuItem)
pairs that were added to the menu.- menu – The
-
Close
(**kwargs)¶ Closes this
FSLeyesFrame
. See__onClose()
.Parameters: - askUnsaved – Defaults to
True
. IfFalse
, the user is not asked whether they want to save any unsaved overlays. - askLayout – Defaults to the
save
value passed to__init__()
. Controls whether the user is asked if they want to save the current layout.
- askUnsaved – Defaults to
-
_FSLeyesFrame__addViewPanelMenu
(panel, title)¶ Called by
addViewPanel()
. Adds a menu item for the newly createdViewPanel
instance, and adds any tools for the view panel to the tools menu.Parameters: - panel – The newly created
ViewPanel
instance. - title – The name given to the
panel
.
- panel – The newly created
-
_FSLeyesFrame__configDisplaySync
(newPanel=None)¶ Called by
addViewPanel()
and__onViewPanelClose()
.This method ensures that the display properties, overlay order, and selected overlay for the
DisplayContext
of at least least oneCanvasPanel
is synced to the masterDisplayContext
.Parameters: newPanel – If this method has been called as a result of a new ViewPanel
being added, a reference to the new panel.
-
_FSLeyesFrame__makeFSLeyesMenu
(menu)¶ Called by
__makeMenuBar()
. Creates the FSLeyes menu.
-
_FSLeyesFrame__makeFileMenu
()¶ Called by
__makeMenuBar()
. Creates the File menu.
-
_FSLeyesFrame__makeLayoutMenu
()¶ Called by
refreshLayoutMenu()
. Re-creates the View->Layouts menu.
-
_FSLeyesFrame__makeMenuBar
()¶ Constructs a bunch of menu items for this
FSLeyesFrame
.
-
_FSLeyesFrame__makeOverlayMenu
()¶ Called by
__makeMenuBar()
. Creates/configures the Overlay menu.
-
_FSLeyesFrame__makeRecentPathsMenu
(*a)¶ Populates the “File -> Recent files” menu. This method is called by the
__makeFileMenu()
, and also by theRecentPathManager
when paths are added.
-
_FSLeyesFrame__makeToolsMenu
()¶ Called by
refreshToolsMenu()
. Populates the Tools menu with tools that are not bound to a specificViewPanel
(and which are always present).
-
_FSLeyesFrame__makeViewMenu
()¶ Called by
refreshViewMenu()
. Creates the view panel menu.Returns: A list containing the (Action, wx.MenuItem)
pairs that were added to the menu.
-
_FSLeyesFrame__makeViewPanelTools
()¶ Called when a view panel is added or removed. Refreshes the Tools menu.
-
_FSLeyesFrame__onClose
(ev)¶ Called when the user closes this
FSLeyesFrame
.Saves the frame position, size, and layout, so it may be preserved the next time it is opened. See the
_restoreState()
method.
-
_FSLeyesFrame__onRecentPath
(ev)¶ Called when a recent path is selected from the “File -> Recent files” menu item. Loads the path. See the
__makeRecentPathsMenu()
method.
-
_FSLeyesFrame__onViewPanelClose
(ev=None, panel=None, displaySync=True)¶ Called when the user closes a
ViewPanel
. May also be called programmatically via theremoveViewPanel()
or :removeAllViewPanels` :method.The
__addViewPanelMenu()
method adds a Close menu item for every view panel, and binds it to this method.This method does the following:
- Makes sure that the
ViewPanel
: is destroyed correctly - Removes the Settings sub-menu corresponding to the
ViewPanel
. - Makes sure that any remaining
ViewPanel
panels are arranged nicely. - If the
displaySync
parameter isTrue
, calls__configDisplaySync()
.
Parameters: - ev –
wx
event, passed when aViewPanel
is closed by the user: - panel – If called programmatically, the
ViewPanel
to close. - displaySync – If
True
(the default), and only oneViewPanel
remains after this one is removed, that remainingViewPanel
is synchronised to the masterDisplayContext
.
- Makes sure that the
-
_FSLeyesFrame__onViewPanelMenuItem
(target, actionName, shortcut, ignoreFocus=False, runOnIdle=False)¶ Called when a menu item from a
ViewPanel
menu, or a menu otherwise created viacreateMenu()
, is selected, either via menu selection, or from a bound keyboard shortcut. This callback is configured in thecreateMenu()
method.Parameters: - target – The target instance for the action, most often a
ViewPanel
. - actionName – The name of the
Action
which is associated with the menu item. - shortcut – The keyboard shortcut code (see
wx.AcceleratorEntry.ToString
) associated with the menu item, ofNone
if there is no shortcut. - ignoreFocus – If
True
, the action is executed on thetarget
. Otherwise (the default), the action is executed on the currently focusedViewPanel
. - runOnIdle – If
True
, the action is executed on theidle.idle
loop. Otherwise (the default), the action is executed on the calling thread.
- target – The target instance for the action, most often a
-
_FSLeyesFrame__restoreState
(restore)¶ Called by
__init__()
.If any frame size/layout properties have previously been saved via the
settings
module, they are read in, and applied to this frame.Parameters: restore – If False
, any saved layout state is ignored.
-
_FSLeyesFrame__selectedOverlayChanged
(*a)¶ Called when the
DisplayContext.selectedOverlay
, or when theDisplay.name
property of the currently selected overlay changes. Updates the overlay name item in the Overlay menu*.
-
__module__
= 'fsleyes.frame'¶
-
addHistogramPanel
(*args, **kwargs)¶ Adds a new
HistogramPanel
.
-
addLightBoxPanel
(*args, **kwargs)¶ Adds a new
LightBoxPanel
.
-
addOrthoPanel
(*args, **kwargs)¶ Adds a new
OrthoPanel
.
-
addPowerSpectrumPanel
(*args, **kwargs)¶ Adds a new
PowerSpectrumPanel
.
-
addScene3DPanel
(*args, **kwargs)¶ Adds a new
Scene3DPanel
.
-
addShellPanel
(*args, **kwargs)¶ Adds a new
ShellPanel
.
-
addTimeSeriesPanel
(*args, **kwargs)¶ Adds a new
TimeSeriesPanel
.
-
closeFSLeyes
(*args, **kwargs)¶ Closes FSLeyes.
-
openHelp
(*args, **kwargs)¶ Opens FSLeyes help in a web browser.
-
selectNextOverlay
(*args, **kwargs)¶ Increments the
DisplayContext.selectedOverlay
.
-
selectPreviousOverlay
(*args, **kwargs)¶ Decrements the
DisplayContext.selectedOverlay
.
-
toggleOverlayVisibility
(*args, **kwargs)¶ Shows/hides the currently selected overlay.
-