Skip to content
Snippets Groups Projects
Commit f346b002 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

FSLEyes tool documentation

parent 720e733d
No related branches found
No related tags found
No related merge requests found
...@@ -47,7 +47,7 @@ class FSLEyesFrame(wx.Frame): ...@@ -47,7 +47,7 @@ class FSLEyesFrame(wx.Frame):
be displayed. be displayed.
""" """
wx.Frame.__init__(self, parent, title='FSLEyes') wx.Frame.__init__(self, parent, title='FSLeyes')
# Default application font - this is # Default application font - this is
# inherited by all child controls. # inherited by all child controls.
......
...@@ -4,11 +4,23 @@ ...@@ -4,11 +4,23 @@
# #
# Author: Paul McCarthy <pauldmccarthy@gmail.com> # Author: Paul McCarthy <pauldmccarthy@gmail.com>
# #
"""A 3D image viewer. See the :mod:`.frame` module for more details. The """*FSLeyes* - a 3D image viewer.
command line interface is defined (and parsed) by the :mod:`fsleyes_parseargs`
module. .. image:: images/fsleyes.png
:scale: 50%
:align: center
This module provides the front-end to *FSLeyes*, the FSL image viewer. Nearly
all of the ``fsleyes`` functionality is located in the :mod:`fsl.fsleyes`
package. This module just parses command line arguments (via the
:mod:`.fsleyes_parseargs` module) and does some GUI bootstrapping necessities.
See the :mod:`~fsl.fsleyes` package documentation for more details on
``fsleyes``.
""" """
import logging import logging
import argparse import argparse
...@@ -19,72 +31,13 @@ import fsl.fsleyes.overlay as fsloverlay ...@@ -19,72 +31,13 @@ import fsl.fsleyes.overlay as fsloverlay
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
def interface(parent, args, ctx):
import wx
import fsl.fsleyes.frame as fsleyesframe
import fsl.fsleyes.views as views
overlayList, displayCtx, splashFrame = ctx
# If a scene has not been specified, the default
# behaviour is to restore the previous frame layout
if args.scene is None: restore = True
else: restore = False
frame = fsleyesframe.FSLEyesFrame(
parent, overlayList, displayCtx, restore)
# Otherwise, we add the scene
# specified by the user
if args.scene == 'ortho': frame.addViewPanel(views.OrthoPanel)
elif args.scene == 'lightbox': frame.addViewPanel(views.LightBoxPanel)
# The viewPanel is assumed to be a CanvasPanel
# (i.e. either OrthoPanel or LightBoxPanel)
viewPanel = frame.getViewPanels()[0]
viewOpts = viewPanel.getSceneOptions()
fsleyes_parseargs.applySceneArgs(args, overlayList, displayCtx, viewOpts)
if args.scene == 'ortho':
xcentre = args.xcentre
ycentre = args.ycentre
zcentre = args.zcentre
if xcentre is None: xcentre = displayCtx.location.yz
if ycentre is None: ycentre = displayCtx.location.xz
if zcentre is None: zcentre = displayCtx.location.xy
viewPanel._xcanvas.centreDisplayAt(*xcentre)
viewPanel._ycanvas.centreDisplayAt(*ycentre)
viewPanel._zcanvas.centreDisplayAt(*zcentre)
# Make sure the new frame is shown
# before destroying the splash screen
frame.Show(True)
frame.Refresh()
frame.Update()
# Closing the splash screen immediately
# can cause a crash under linux/GTK, so
# we'll do it a bit later.
def closeSplash():
splashFrame.Close()
wx.CallLater(500, closeSplash)
return frame
def parseArgs(argv): def parseArgs(argv):
""" """Parses the given ``fsleyes`` command line arguments. See the
Parses the given command line arguments. Parameters: :mod:`.fsleyes_parseargs` module for details on the ``fsleyes`` command
line interface.
- argv: command line arguments for fsleyes. :arg argv: command line arguments for ``fsleyes``.
""" """
parser = argparse.ArgumentParser(add_help=False) parser = argparse.ArgumentParser(add_help=False)
...@@ -101,7 +54,30 @@ def parseArgs(argv): ...@@ -101,7 +54,30 @@ def parseArgs(argv):
'fsleyes', 'fsleyes',
'Image viewer') 'Image viewer')
def context(args): def context(args):
"""Creates the ``fsleyes`` context.
This function does a few things:
1. Displays the ``fsleyes`` splash screen (see
:class:`.FSLEyesSplash`). The splash screen is destroyed later on by
the :func:`interface` function.
2. Initialises OpenGL (see the :mod:`fsl.fsleyes.gl` package).
3. Creates the :class:`.OverlayList` and the top level
:class:`.DisplayContext`.
4. Loads all of the overlays which were passed in on the command line.
:arg args: Parsed command line arguments (see :func:`parseArgs`).
:returns: a tuple containing:
- the :class:`.OverlayList`
- the master :class:`.DisplayContext`
- the :class:`.FSLEyesSplash` frame
"""
import wx import wx
import fsl.fsleyes.splash as fslsplash import fsl.fsleyes.splash as fslsplash
...@@ -147,7 +123,6 @@ def context(args): ...@@ -147,7 +123,6 @@ def context(args):
overlayList = fsloverlay.OverlayList() overlayList = fsloverlay.OverlayList()
displayCtx = displaycontext.DisplayContext(overlayList) displayCtx = displaycontext.DisplayContext(overlayList)
# While the DisplayContext may refer to # While the DisplayContext may refer to
# multiple overlay groups, we are currently # multiple overlay groups, we are currently
# using just one, allowing the user to specify # using just one, allowing the user to specify
...@@ -167,7 +142,94 @@ def context(args): ...@@ -167,7 +142,94 @@ def context(args):
return overlayList, displayCtx, frame return overlayList, displayCtx, frame
FSL_TOOLNAME = 'FSLEyes' def interface(parent, args, ctx):
"""Creates the ``fsleyes`` interface.
This function does the following:
1. Creates the :class:`.FSLEyesFrame` the top-level frame for ``fsleyes``.
2. Configures the frame according to the command line arguments (e.g.
ortho or lightbox view).
3. Destroys the splash screen that was created by the :func:`context`
function.
:arg parent: :mod:`wx` parent object.
:arg args: Parsed command line arguments, as returned by
:func:`parseArgs`.
:arg ctx: The :class:`.OverlayList`, :class:`.DisplayContext`, and
:class:`.FSLEyesSplash`, as created and returned by
:func:`context`.
:returns: the :class:`.FSLEyesFrame` that was created.
"""
import wx
import fsl.fsleyes.frame as fsleyesframe
import fsl.fsleyes.views as views
overlayList, displayCtx, splashFrame = ctx
# If a scene has not been specified, the default
# behaviour is to restore the previous frame layout
if args.scene is None: restore = True
else: restore = False
frame = fsleyesframe.FSLEyesFrame(
parent, overlayList, displayCtx, restore)
# Otherwise, we add the scene
# specified by the user
if args.scene == 'ortho': frame.addViewPanel(views.OrthoPanel)
elif args.scene == 'lightbox': frame.addViewPanel(views.LightBoxPanel)
# The viewPanel is assumed to be a CanvasPanel
# (i.e. either OrthoPanel or LightBoxPanel)
viewPanel = frame.getViewPanels()[0]
viewOpts = viewPanel.getSceneOptions()
fsleyes_parseargs.applySceneArgs(args, overlayList, displayCtx, viewOpts)
if args.scene == 'ortho':
xcentre = args.xcentre
ycentre = args.ycentre
zcentre = args.zcentre
if xcentre is None: xcentre = displayCtx.location.yz
if ycentre is None: ycentre = displayCtx.location.xz
if zcentre is None: zcentre = displayCtx.location.xy
viewPanel._xcanvas.centreDisplayAt(*xcentre)
viewPanel._ycanvas.centreDisplayAt(*ycentre)
viewPanel._zcanvas.centreDisplayAt(*zcentre)
# Make sure the new frame is shown
# before destroying the splash screen
frame.Show(True)
frame.Refresh()
frame.Update()
# Closing the splash screen immediately
# can cause a crash under linux/GTK, so
# we'll do it a bit later.
def closeSplash():
splashFrame.Close()
wx.CallLater(500, closeSplash)
return frame
#########################################
# See the fsl.tools package documentation
#########################################
FSL_TOOLNAME = 'FSLeyes'
FSL_INTERFACE = interface FSL_INTERFACE = interface
FSL_CONTEXT = context FSL_CONTEXT = context
FSL_PARSEARGS = parseArgs FSL_PARSEARGS = parseArgs
...@@ -41,7 +41,8 @@ respective horizontal/vertical display axes, are maintained, and that the ...@@ -41,7 +41,8 @@ respective horizontal/vertical display axes, are maintained, and that the
canvases are sized proportionally with respect to each other. These functions canvases are sized proportionally with respect to each other. These functions
are used both by :mod:`.render`, and also by the :class:`.OrthoPanel` and are used both by :mod:`.render`, and also by the :class:`.OrthoPanel` and
:class:`.LightBoxPanel`, for calculating canvas sizes when they are displayed :class:`.LightBoxPanel`, for calculating canvas sizes when they are displayed
in :mod:`.fsleyes`. The following size calculation functions are available: in :mod:`~.tools.fsleyes`. The following size calculation functions are
available:
.. autosummary:: .. autosummary::
:nosignatures: :nosignatures:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment