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__.MockClassA
FSLeyesFrameis a simplewx.Framewhich acts as a container forViewPanelinstances.A
wx.lib.agw.aui.AuiManageris used so thatViewPanelpanels can be dynamically laid out and reconfigured by the user.Menus
The
FSLeyesFramehas 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 ViewPanelinstances. A separate sub-menu is added for each visibleViewPanel. AllViewPanelclasses inherit from theActionProviderclass - 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
FSLeyesFrameis closed, it saves some display settings so that they can be restored the next time aFSLeyesFrameis opened. The settings are saved using thesettingsmodule. Currently, the frame position, size, and layout (see thelayoutmodule) are saved.Programming interface
The
FSLeyesFrameprovides the following properties and methods for programmatically configuring the display:overlayListReturns the OverlayListwhich contains the overlays being displayed by thisFSLeyesFrame.displayCtxReturns the top-level DisplayContextassociated with thisFSLeyesFrame.viewPanelsReturns a list of all ViewPanelinstances that are currenlty displayed in thisFSLeyesFrame.focusedViewPanelReturns the ViewPanelwhich currently has focus, orNoneif noViewPanelhas focus.auiManagerReturns the wx.lib.agw.aui.AuiManager` object which is managing the layout of this ``FSLeyesFrame.getViewPanelInfoReturns the AuiPaneInfoclass which contains layout information about the givenViewPanel.getViewPanelIDReturns the ID that was assigned to the given ViewPanel.getViewPanelTitleReturns the ID that was assigned to the given ViewPanel.addViewPanelAdds a new ViewPanelto the centre of the frame, and a menu item allowing the user to configure the view.viewPanelDefaultLayoutAfter a ViewPanelis added via the view menu, this method is called to perform some basic initialisation on the panel.removeViewPanelRemoves the given ViewPanelfrom thisFSLeyesFrame.removeAllViewPanelsRemoves all view panels from this FSLeyesFrame.refreshViewMenuRe-creates the View menu. refreshLayoutMenuRe-creates the View -> Layouts sub-menu. refreshSettingsMenuRe-creates the Settings menu. refreshToolsMenuRe-creates the Tools menu. populateMenuCreates menu items for every Actionavailable on the giventarget, or for every named action in theactionNameslist.CloseCloses this FSLeyesFrame.Actions
The
fsleyes.actions.frameactionsmodule contains someactionswhich are monkey-patched into theFSLeyesFrameclass. 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.frameactionsmodule are treated as first-class methods of theFSLeyesFrameclass (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
wxparent 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
OverlayListwhich contains the overlays being displayed by thisFSLeyesFrame.
-
displayCtx¶ Returns the top-level
DisplayContextassociated with thisFSLeyesFrame.
-
viewPanels¶ Returns a list of all
ViewPanelinstances that are currenlty displayed in thisFSLeyesFrame.
-
focusedViewPanel¶ Returns the
ViewPanelwhich currently has focus, orNoneif noViewPanelhas focus.
Returns a dictionary containing all global
Actionobjects that are bound to menu items.
-
getOverlayList= <MagicMock name='mock.deprecated()()' id='139845843667040'>¶
-
getDisplayContext= <MagicMock name='mock.deprecated()()' id='139845843667040'>¶
-
getViewPanels= <MagicMock name='mock.deprecated()()' id='139845843667040'>¶
-
getFocusedViewPanel= <MagicMock name='mock.deprecated()()' id='139845843667040'>¶
-
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
AuiPaneInfoclass 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='139845843667040'>¶
-
removeAllViewPanels()¶ Removes all view panels from this
FSLeyesFrame.Note
This method should be used to clear the frame, rather than removing each
ViewPanelindividually viaremoveViewPanel(). This is because when oneViewPanelis closed, the display settings of the remainingViewPanelinstances may be modified. If these remainingViewPanelsare then immediately closed, thay may not have had enough time to reconfigure themselves (e.g.GLVolumeinstances re-creating theirImageTextureinstance due to a change inDisplayContext.syncOverlayDisplay), and ugly things will happen (e.g. anImageTexturetrying to configure itself after it has already been destroyed).So just use this method instead.
-
addViewPanel(panelCls, title=None, **kwargs)¶ Adds a new
ViewPanelto the centre of the frame, and a menu item allowing the user to configure the view.Parameters: - panelCls – The
ViewPaneltype 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 childDisplayContextthat is created for the new view.- panelCls – The
-
viewPanelDefaultLayout(viewPanel)¶ After a
ViewPanelis 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='139845843667040'>¶
-
populateMenu(menu, target, actionNames=None, actionTitles=None, **kwargs)¶ Creates menu items for every
Actionavailable on the giventarget, or for every named action in theactionNameslist.Called by the
__addViewPanelMenu()method to generate a menu for newViewPanelinstances, but can also be called for other purposes.Parameters: - menu – The
wx.Menuto 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
savevalue 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 createdViewPanelinstance, and adds any tools for the view panel to the tools menu.Parameters: - panel – The newly created
ViewPanelinstance. - 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
DisplayContextof at least least oneCanvasPanelis synced to the masterDisplayContext.Parameters: newPanel – If this method has been called as a result of a new ViewPanelbeing 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 theRecentPathManagerwhen 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
ViewPanelpanels are arranged nicely. - If the
displaySyncparameter isTrue, calls__configDisplaySync().
Parameters: - ev –
wxevent, passed when aViewPanelis closed by the user: - panel – If called programmatically, the
ViewPanelto close. - displaySync – If
True(the default), and only oneViewPanelremains after this one is removed, that remainingViewPanelis synchronised to the masterDisplayContext.
- Makes sure that the
-
_FSLeyesFrame__onViewPanelMenuItem(target, actionName, shortcut, ignoreFocus=False, runOnIdle=False)¶ Called when a menu item from a
ViewPanelmenu, 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
Actionwhich is associated with the menu item. - shortcut – The keyboard shortcut code (see
wx.AcceleratorEntry.ToString) associated with the menu item, ofNoneif 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.idleloop. 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
settingsmodule, 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.nameproperty 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.
-