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)[source]¶ Bases:
__main__.docbuilder.run.<locals>.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:Returns the
OverlayList
which contains the overlays being displayed by thisFSLeyesFrame
.Returns the top-level
DisplayContext
associated with thisFSLeyesFrame
.Returns a list of all
ViewPanel
instances that are currenlty displayed in thisFSLeyesFrame
.Returns the
ViewPanel
which currently has focus, the firstViewPanel
if none have focus, orNone
if there are noViewPanels
.Returns the
wx.lib.agw.aui.AuiManager` object which is managing the layout of this ``FSLeyesFrame
.Returns the
AuiPaneInfo
class which contains layout information about the givenViewPanel
.Returns the ID that was assigned to the given
ViewPanel
.Returns the ID that was assigned to the given
ViewPanel
.Adds a new
ViewPanel
to the centre of the frame, and a menu item allowing the user to configure the view.After a
ViewPanel
is added via the view menu, this method is called to perform some basic initialisation on the panel.Removes the given
ViewPanel
from thisFSLeyesFrame
.Removes all view panels from this
FSLeyesFrame
.Re-creates the View menu.
Re-creates the View -> Layouts sub-menu.
Re-creates the Settings menu.
Re-creates the Tools menu.
Creates menu items for every
Action
available on the giventarget
, or for every named action in theactionNames
list.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)[source]¶ 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.
-
property
overlayList
¶ Returns the
OverlayList
which contains the overlays being displayed by thisFSLeyesFrame
.
-
property
displayCtx
¶ Returns the top-level
DisplayContext
associated with thisFSLeyesFrame
.
-
property
viewPanels
¶ Returns a list of all
ViewPanel
instances that are currenlty displayed in thisFSLeyesFrame
.
-
property
focusedViewPanel
¶ Returns the
ViewPanel
which currently has focus, the firstViewPanel
if none have focus, orNone
if there are noViewPanels
.
Returns a dictionary containing all global
Action
objects that are bound to menu items.
-
getOverlayList
= <MagicMock name='mock.utils.deprecated.deprecated()()' id='139656530443808'>¶
-
getDisplayContext
= <MagicMock name='mock.utils.deprecated.deprecated()()' id='139656530443808'>¶
-
getViewPanels
= <MagicMock name='mock.utils.deprecated.deprecated()()' id='139656530443808'>¶
-
getFocusedViewPanel
= <MagicMock name='mock.utils.deprecated.deprecated()()' id='139656530443808'>¶
-
getViewPanelID
(viewPanel)[source]¶ Returns the ID that was assigned to the given
ViewPanel
. This is a sequentially increasing integer, starting from 1.
-
getViewPanelTitle
(viewPanel)[source]¶ Returns the ID that was assigned to the given
ViewPanel
. This is a sequentially increasing integer, starting from 1.
-
getViewPanelInfo
(viewPanel)[source]¶ Returns the
AuiPaneInfo
class which contains layout information about the givenViewPanel
.
-
property
auiManager
¶ Returns the
wx.lib.agw.aui.AuiManager` object which is managing the layout of this ``FSLeyesFrame
.
-
getAuiManager
= <MagicMock name='mock.utils.deprecated.deprecated()()' id='139656530443808'>¶
-
removeAllViewPanels
()[source]¶ 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)[source]¶ 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.
-
viewPanelDefaultLayout
(viewPanel)[source]¶ 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.
-
refreshPerspectiveMenu
= <MagicMock name='mock.utils.deprecated.deprecated()()' id='139656530443808'>¶
-
populateMenu
(menu, target, actionNames=None, actionTitles=None, **kwargs)[source]¶ 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.
-
__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
.
-
__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.
-
__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 correctlyRemoves 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
.
-
__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.
-
Close
(**kwargs)[source]¶ 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.
-
__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.
-
__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.
-
__makeMenuBar
()¶ Constructs a bunch of menu items for this
FSLeyesFrame
.
-
__enableMenus
(state)¶ Enables/disables some of the menus. Only the menus which are useless without any view panels open are affected.
-
__makeFSLeyesMenu
(menu)¶ Called by
__makeMenuBar()
. Creates the FSLeyes menu.
-
__makeFileMenu
()¶ Called by
__makeMenuBar()
. Creates the File menu.
-
__makeRecentPathsMenu
(*a)¶ Populates the “File -> Recent files” menu. This method is called by the
__makeFileMenu()
, and also by theRecentPathManager
when paths are added.
-
__onRecentPath
(ev)¶ Called when a recent path is selected from the “File -> Recent files” menu item. Loads the path. See the
__makeRecentPathsMenu()
method.
-
__makeViewMenu
()¶ Called by
refreshViewMenu()
. Creates the view panel menu.- Returns
A list containing the
(Action, wx.MenuItem)
pairs that were added to the menu.
-
__makeLayoutMenu
()¶ Called by
refreshLayoutMenu()
. Re-creates the View->Layouts menu.
-
__makeOverlayMenu
()¶ Called by
__makeMenuBar()
. Creates/configures the Overlay menu.
-
__makeToolsMenu
()¶ Called by
refreshToolsMenu()
. Populates the Tools menu with tools that are not bound to a specificViewPanel
(and which are always present).
-
__makeViewPanelTools
()¶ Called when a view panel is added or removed. Refreshes the Tools menu.
-
__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
.
-
setFSLDIR
(*args, **kwargs)¶ Opens a directory dialog allowing the user to select a value for
$FSLDIR
.
-
toggleOverlayVisibility
(*args, **kwargs)¶ Shows/hides the currently selected overlay.
-