fsleyes.views.viewpanel
This module provides the ViewPanel
class, which is the base-class
for all of the FSLeyes view panels. See the fsleyes
package
documentation for more details.
- class fsleyes.views.viewpanel.ViewPanel(parent, overlayList, displayCtx, frame)[source]
Bases:
fsleyes.panel.FSLeyesPanel
The
ViewPanel
class is the base-class for all FSLeyes views.A
ViewPanel
displays some sort of view of the overlays in anOverlayList
. The settings for aViewPanel
are defined by aDisplayContext
instance.Panels and controls
A
ViewPanel
class uses awx.lib.agw.aui.AuiManager
to lay out its children. AViewPanel
has one central panel, which contains the primary view; and may have one or more secondary panels, which contain controls - see thecontrols
package. The centre panel can be set via thecentrePanel()
property, and secondary panels can be added/removed to/from with thetogglePanel()
method. The current state of a secondary panel (i.e. whether one is open or not) can be queried with theisPanelOpen()
method, and existing secondary panels can be accessed via thegetPanel()
method. Secondary panels must be derived from either theControlPanel
orControlToolBar
base-classes.Profiles
The logic which defines the way that a user interacts with a view panel is defined by a
Profile
object, which contains mouse and keyboard event handlers for reacting to user input.Sub-classes must call the
initProfile()
method to initialise their default profile. Other profiles may be associated with a particular control panel - these profiles can be temporarily activated and deactivated when the control panel is toggled via thetogglePanel()
method.The currently active interaction profile can be accessed with the
currentProfile()
method. See theprofiles
package for more information on interaction profiles.Programming interface
The following methods are available on a
Viewpanel
for programmatically controlling its display and layout:Add/remove the secondary control panel of the specified type to/from this
ViewPanel
.Returns
True
if a panel of typepanelType
is open,False
otherwise.If an instance of
panelType
exists, it is returned.Returns a list containing all control panels currently shown in this
ViewPanel
.This method should be overridden by sub-classes (if necessary), and should return any
action
methods which should be added to theFSLeyesFrame
Tools menu.Remove this
ViewPanel
from theFSLeyesFrame
.Remove all control panels from this
ViewPanel
.Returns the
AuiPaneInfo
object which contains information about the given control panel.Returns the
wx.lib.agw.aui.AuiManager
object which manages the layout of thisViewPanel
.- controlOptions(cpType)[source]
May be overridden by sub-classes. Given a control panel type, may return a dictionary containing arguments to be passed to the
__init__
method when the control panel is created.
- static title()[source]
May be overridden by sub-classes. Returns a title for this
ViewPanel
, to be used in menus and window title bars.
- static controlOrder()[source]
May be overridden by sub-classes. Returns a list of names of control panel types, specifying a suggested order for the settings menu for views of this type.
- static toolOrder()[source]
May be overridden by sub-classes. Returns a list of names of tools, specifying a suggested order for the corresponding entries in the FSLeyes tools menu. Note that the ordering of tools returned by the
getTools()
method is honoured - the ordering returned by this method relates to tools which are implemented as plugins.
- static defaultLayout()[source]
May be overridden by sub-classes. Should return a list of names of FSLeyes
ControlPanel
types which form the default layout for this view.
- __init__(parent, overlayList, displayCtx, frame)[source]
Create a
ViewPanel
.- Parameters
parent –
wx
parent objectoverlayList – The
OverlayList
displayCtx – A
DisplayContext
object unique to thisViewPanel
frame – The
FSLeyesFrame
- reloadPlugins()[source]
Called by
__init__()
, and by theLoadPluginAction
when new plugins are registered.This is a bit of a hack, but less hacky than it used to be. All plugin-provided control panels and tools which support this
ViewPanel
are looked up via theplugins.
module. Then, for each control, we create aToggleControlPanelAction
, and add it as an attribute on thisViewPanel
.Similarly, all plugin-provided tools which support this
ViewPanel
are created and added as attributes.In both cases, the class name of the control/tool is used as the attribute name.
This is done so that these actions will work with the
ActionProvider
interface, and hence theFSLEeyesFrame.populateMenu()
method.This implementation may change in the future if it becomes problematic (e.g. due to naming conflicts).
- destroy()[source]
Removes some property listeners, destroys all child panels, destroys the
ProfileManager
, andAuiManager
, and callsFSLeyesPanel.destroy()
.
- property events: __main__.docbuilder.run.<locals>.MockClass
Return a reference to a
Notifier
instance which can be used to be notified when certain events occur. Currently the following events are emitted:'profile'
, when the current interaction profile changes. Callbacks which are registered with the'profile'
topic will be passed a tuple containing the types (Profile
sub-classes) of the de-registered and newly registered profiles.'aui_perspective'
, when the AUI-managed layout changes, e.g. sash resizes, control panels added/removed, etc. This event is emitted whenever theAuiManager
emits aEVT_AUI_PERSPECTIVE_CHANGED
event. It is re-emitted via theNotifer
interface so that non-wx entities can be notified (see e.g. theToggleControlPanelAction
).
- initProfile(defaultProfile)[source]
Must be called by subclasses, after they have initialised all of the attributes which may be needed by their associated
Profile
instances.- Parameters
defaultProfile – Default profile type
- property profileManager
Returns a reference to the
ProfileManager
used by thisViewPanel
.
- property centrePanel
Returns the primary (centre) panel on this
ViewPanel
.
- togglePanel(panelType, *args, **kwargs)[source]
Add/remove the secondary control panel of the specified type to/from this
ViewPanel
.If no keyword argunents are specified, the arguments returned by the
ControlMixin.defaultLayout()
method are returned.- Parameters
panelType – Type of the secondary panel.
args – All positional arguments are passed to the
panelType
constructor.floatPane – If
True
, the secondary panel is initially floated. Defaults toFalse
.floatOnly – If
True
, andfloatPane=True
, the panel will be permanently floated (i.e. it will not be dockable).floatPos – If provided, and
floatPane
isTrue
, specifies the location of the floating panel as(w, h)
proportions between 0 and 1, relative to this view panel.closeable – If
False
, andfloatPane=True
, the panel will not have a close button when it is floated.location – If
floatPane=False
, the initial dock position of the panel - eitherwx.TOP
,wx.BOTTOM
,wx.LEFT
, orwx.RIGHT. Defaults to ``wx.BOTTOM
.title – Title to give the control. If not provided, it is assumed that a title for
panelType
is instrings.titles
.kwargs – All other keyword arguments, are passed to the
panelType
constructor.
- Returns
The newly created control panel.
Note
The
panelType
type must be a sub-class ofControlPanel
orControlToolBar
, which can be created like so:panel = panelType(parent, overlayList, displayCtx, frame, *args, **kwargs)
Warning
Do not define a control (a.k.a. secondary) panel constructor to accept arguments with the names
floatPane
,floatOnly
,floatPos
,closeable
, orlocation
, as arguments with those names will get eaten by this method before they can be passed to the constructor.
- __layoutNewPanel(panel, title, location, floatPane, floatPos, floatOnly, closeable)
Sub-method of
togglePanel()
. Creates and returns anAuiPaneInfo
instance describing the initial layout of a new control panel. SeetogglePanel
for an explanation of the arguments.
- getPanel(panelType)[source]
If an instance of
panelType
exists, it is returned. OtherwiseNone
is returned.
- removeFromFrame()[source]
Remove this
ViewPanel
from theFSLeyesFrame
.Will raise an error if this
ViewPanel
is not in aFSLeyesFrame
.
- getPanels()[source]
Returns a list containing all control panels currently shown in this
ViewPanel
.
- getPanelInfo(panel)[source]
Returns the
AuiPaneInfo
object which contains information about the given control panel.
- property auiManager
Returns the
wx.lib.agw.aui.AuiManager
object which manages the layout of thisViewPanel
.
- getTools()[source]
This method should be overridden by sub-classes (if necessary), and should return any
action
methods which should be added to theFSLeyesFrame
Tools menu.See also the
ActionProvider.getActions()
method, which can also be overridden, and controls the actions which get added to the FSLeyes settings menu.
- __auiMgrUpdate(*args, **kwargs)
Called whenever a panel is added/removed to/from this
ViewPanel
.Calls the
Update
method on theAuiManager
instance that is managing this panel.- Parameters
newPanel – Must be passed as a keyword argument. When a new panel is added, it should be passed here.
- __onPaneClose(ev=None, panel=None)
Called when the user closes a control (a.k.a. secondary) panel. Calls the
ControlPanel.destroy
/ControlToolBar.destroy
method on the panel.
- __onPerspectiveChange(ev)
Called on
EVT_AUI_PERSPECTIVE_CHANGED
events. Re-emits the event via theevents()
notifier, with topic'aui_perspective'
. This is performed for the benefit of non-wx entities which need to know about layout changes.
- __annotations__ = {}
- __module__ = 'fsleyes.views.viewpanel'
- fsleyes.views.viewpanel._AuiDockingGuide_init(self, *args, **kwargs)[source]
I am also monkey-patching the
wx.lib.agw.aui.AuiDockingGuide.__init__
method, because in this instance, when running over SSH/X11, thewx.FRAME_TOOL_WINDOW
style seems to result in the docking guide frames being given title bars, which is quite undesirable.I cannot patch the entire class in the aui package, because it is used as part of a class hierarchy. So I am just patching the method.