示例#1
0
def _test_custom(frame, overlayList, displayCtx):

    ortho = frame.addViewPanel(OrthoPanel)
    ps = frame.addViewPanel(PowerSpectrumPanel)

    ortho.toggleAtlasPanel()
    ortho.toggleLookupTablePanel()

    ps.togglePlotList()
    ps.togglePowerSpectrumControl()

    realYield(50)
    layouts.saveLayout(frame, 'custom_custom')
    frame.removeAllViewPanels()
    realYield(50)

    layouts.loadLayout(frame, 'custom_custom')

    realYield(50)

    ortho, ps = frame.viewPanels

    assert isinstance(ortho, OrthoPanel)
    assert isinstance(ps, PowerSpectrumPanel)

    orthoctrls = ortho.getPanels()
    psctrls = ps.getPanels()

    assert len(orthoctrls) == 2
    assert len(psctrls) == 2

    assert AtlasPanel in [type(p) for p in orthoctrls]
    assert LookupTablePanel in [type(p) for p in orthoctrls]
    assert PlotListPanel in [type(p) for p in psctrls]
    assert PowerSpectrumControlPanel in [type(p) for p in psctrls]
示例#2
0
def _test_custom(frame, overlayList, displayCtx):

    ortho = frame.addViewPanel(OrthoPanel)
    ps    = frame.addViewPanel(PowerSpectrumPanel)

    ortho.toggleAtlasPanel()
    ortho.toggleLookupTablePanel()
    ortho.sceneOpts.showColourBar = True

    ps.togglePlotList()
    ps.togglePowerSpectrumControl()

    realYield(50)
    layouts.saveLayout(frame, 'custom_custom')
    frame.removeAllViewPanels()
    realYield(50)

    layouts.loadLayout(frame, 'custom_custom')

    overlayList.append(fslimage.Image(op.join(datadir, '3d')))

    realYield(50)

    ortho, ps = frame.viewPanels

    assert isinstance(ortho, OrthoPanel)
    assert isinstance(ps,    PowerSpectrumPanel)

    orthoctrls = ortho.getPanels()
    psctrls    = ps   .getPanels()

    assert len(orthoctrls) == 2
    assert len(psctrls)    == 2

    assert AtlasPanel                in [type(p) for p in orthoctrls]
    assert LookupTablePanel          in [type(p) for p in orthoctrls]
    assert PlotListPanel             in [type(p) for p in psctrls]
    assert PowerSpectrumControlPanel in [type(p) for p in psctrls]

    assert ortho.sceneOpts.showColourBar
    assert ortho.colourBarCanvas is not None
示例#3
0
def makeFrame(namespace, displayCtx, overlayList, splash):
    """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 namespace:   Parsed command line arguments, as returned by
                      :func:`parseArgs`.

    :arg displayCtx:  The  :class:`.DisplayContext`, as created and returned
                      by :func:`makeDisplayContext`.

    :arg overlayList: The :class:`.OverlayList`, as created and returned by
                      :func:`makeDisplayContext`.

    :arg splash:      The :class:`.FSLeyesSplash` frame.

    :returns: the :class:`.FSLeyesFrame` that was created.
    """

    import fsl.utils.idle as idle
    import fsleyes_widgets.utils.status as status
    import fsleyes.parseargs as parseargs
    import fsleyes.frame as fsleyesframe
    import fsleyes.displaycontext as fsldisplay
    import fsleyes.layouts as layouts
    import fsleyes.views.canvaspanel as canvaspanel

    # Set up the frame scene (a.k.a. layout)
    # The scene argument can be:
    #
    #   - The name of a saved (or built-in) layout
    #
    #   - None, in which case the default or previous
    #     layout is restored, unless a custom script
    #     has been provided.
    script = namespace.runscript
    scene = namespace.scene

    # If a scene/layout or custom script
    # has not been specified, the default
    # behaviour is to restore the previous
    # frame layout.
    restore = (scene is None) and (script is None)

    status.update('Creating FSLeyes interface...')

    frame = fsleyesframe.FSLeyesFrame(None,
                                      overlayList,
                                      displayCtx,
                                      restore,
                                      True,
                                      fontSize=namespace.fontSize)

    # Allow files to be dropped
    # onto FSLeyes to open them
    dt = fsleyesframe.OverlayDropTarget(overlayList, displayCtx)
    frame.SetDropTarget(dt)

    # Make sure the new frame is shown
    # before destroying the splash screen
    frame.Show(True)
    frame.Refresh()
    frame.Update()

    # In certain instances under Linux/GTK,
    # closing the splash screen will crash
    # the application. No idea why. So we
    # leave the splash screen hidden, but
    # not closed, and close it when the main
    # frame is closed. This also works under
    # OSX.
    splash.Hide()
    splash.Refresh()
    splash.Update()

    def onFrameDestroy(ev):
        ev.Skip()

        # splash screen may already
        # have been destroyed
        try:
            splash.Close()
        except Exception:
            pass

    frame.Bind(wx.EVT_WINDOW_DESTROY, onFrameDestroy)

    status.update('Setting up scene...')

    # Set the default SceneOpts.performance
    # level so that all created SceneOpts
    # instances will default to it
    if namespace.performance is not None:
        fsldisplay.SceneOpts.performance.setAttribute(None, 'default',
                                                      namespace.performance)

    # If a layout has been specified,
    # we load the layout
    if namespace.scene is not None:
        layouts.loadLayout(frame, namespace.scene)

    # Apply any view-panel specific arguments
    viewPanels = frame.viewPanels
    for viewPanel in viewPanels:

        if not isinstance(viewPanel, canvaspanel.CanvasPanel):
            continue

        displayCtx = viewPanel.displayCtx
        viewOpts = viewPanel.sceneOpts

        parseargs.applySceneArgs(namespace, overlayList, displayCtx, viewOpts)

    # If a script has been specified, we run
    # the script. This has to be done on the
    # idle loop, because overlays specified
    # on the command line are loaded on the
    # idle loop. Therefore, if we schedule the
    # script on idle (which is a queue), the
    # script can assume that all overlays have
    # already been loaded.
    from fsleyes.actions.runscript import RunScriptAction
    if script is not None:
        idle.idle(frame.menuActions[RunScriptAction], script)

    return frame
示例#4
0
 def __loadLayout(self):
     """Load the layout specified in :meth:`__init__`. """
     layouts.loadLayout(self.__frame, self.__layout)
示例#5
0
def _test_layout(frame, overlayList, displayCtx, layout):
    img = fslimage.Image(op.join(datadir, '4d'))
    overlayList.append(img)
    layouts.loadLayout(frame, layout)
    realYield(100)