Commit 56932482 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

Merge branch 'rel/0.33.11' into 'v0.33'

Rel/0.33.11

See merge request fsl/fsleyes/fsleyes!201
parents e8d1d14c 85933e77
......@@ -9,6 +9,17 @@ This document contains the ``fsleyes`` release history in reverse
chronological order.
0.33.1 (Monday 8th June 2020)
-----------------------------
Changed
^^^^^^^
* Changed the :func:`.embed` function so that a parent ``wx`` object is
not required.
0.33.0 (Tuesday 26th May 2020)
------------------------------
......
......@@ -489,9 +489,9 @@ class GLContext(object):
A ``wx.glcanvas.GLContext`` may only be created once a
``wx.glcanvas.GLCanvas`` has been created, and is visible on screen.
The ``GLContext`` class therefore creates a dummy ``GLCanvas``, and
displays it, before creating the ``wx`` GL context.
``wx.glcanvas.GLCanvas`` has been created, and is visible on screen. The
``GLContext`` class therefore creates a dummy ``wx.Frame`` and
``GLCanvas``, and displays it, before creating the ``wx`` GL context.
Because ``wx`` contexts may be used even when an off-screen rendering
......@@ -521,7 +521,6 @@ class GLContext(object):
def __init__(self,
offscreen=False,
parent=None,
other=None,
target=None,
createApp=False,
......@@ -531,8 +530,6 @@ class GLContext(object):
:arg offscreen: On-screen or off-screen context?
:arg parent: Parent ``wx`` GUI object
:arg other: Another ``GLContext`` instance with which GL state
should be shared.
......@@ -560,7 +557,6 @@ class GLContext(object):
self.__offscreen = offscreen
self.__ownApp = False
self.__ownParent = False
self.__context = None
self.__canvas = None
self.__parent = None
......@@ -575,97 +571,86 @@ class GLContext(object):
raise ValueError('On-screen GL contexts must be '
'created on the wx.MainLoop')
# For off-screen, only use
# OSMesa if we have no cnoice
# For off-screen, only use OSMesa
# if we have no cnoice. Otherewise
# we use wx if possible
if offscreen and not canHaveGui:
self.__createOSMesaContext()
ready()
return
# Use wx if possible
else:
self.__ownApp = (not haveGui) and createApp
self.__ownParent = parent is None
if other is not None:
self.__createWXGLContext(other=other.__context, target=target)
return
self.__ownApp = (not haveGui) and createApp
# Create a wx.App if we've been
# given permission to do so
# (via the createApp argument)
if self.__ownApp:
log.debug('Creating temporary wx.App')
import fsleyes.main as fm
self.__app = fm.FSLeyesApp()
# Create a parent for the
# canvas if necessary
if self.__ownParent: self.__createWXGLParent()
else: self.__parent = parent
# Create the GL canvas
self.__createWXGLCanvas()
# This function creates the context
# and does some clean-up afterwards.
# It gets scheduled on the wx idle
# loop.
def create():
self.__createWXGLContext()
if ready is not None:
try:
ready()
except Exception as e:
log.warning('GLContext callback function raised '
'{}: {}'.format(type(e).__name__,
str(e)),
exc_info=True)
if raiseErrors:
raise e
# Destroying the dummy canvas
# can be dangerous on GTK, so we
# just permanently hide it instead.
self.__canvas.Hide()
# We can hide the parent as well
# if we were the one who created
# it.
if self.__ownParent:
self.__parent.Hide()
# If we've created and started
# our own loop, kill it
if self.__ownApp:
log.debug('Exiting temporary wx.MainLoop')
self.__app.ExitMainLoop()
# If we've created our own wx.App, run its
# main loop - we need to run the loop
# in order to display the GL canvas and
# context. But we can kill the loop as soon
# as this is done (in the create function
# above). If an existing wx.App is running,
# we just schedule the context creation
# routine on it.
idle.idle(create, alwaysQueue=True)
# A context already exists - we don't
# need to create a GL canvas to create
# another one.
if other is not None:
self.__createWXGLContext(other=other.__context, target=target)
ready()
return
# Create a wx.App if we've been
# given permission to do so
# (via the createApp argument)
if self.__ownApp:
log.debug('Creating temporary wx.App')
import fsleyes.main as fm
self.__app = fm.FSLeyesApp()
# Create a parent for the GL
# canvas, and the canvas itself
self.__createWXGLParent()
self.__createWXGLCanvas()
# This function creates the context
# and does some clean-up afterwards.
# It gets scheduled on the wx idle
# loop.
def create():
self.__createWXGLContext()
# Once the GL context has been
# created, we no longer need
# references to the wx objects
app = self.__app
self.__parent = None
self.__canvas = None
self.__app = None
# If we've created and started
# our own loop, kill it
if self.__ownApp:
log.debug('Starting temporary wx.MainLoop')
self.__app.MainLoop()
# Once the GL context has been
# created, we no longer need
# references to the wx objects
self.__parent = None
self.__canvas = None
self.__app = None
log.debug('Exiting temporary wx.MainLoop')
app.ExitMainLoop()
if ready is not None:
try:
ready()
except Exception as e:
log.warning('GLContext callback function raised '
'{}: {}'.format(type(e).__name__,
str(e)),
exc_info=True)
if raiseErrors:
raise e
# If we've created our own wx.App, run its
# main loop - we need to run the loop
# in order to display the GL canvas and
# context. But we can kill the loop as soon
# as this is done (in the create function
# above). If an existing wx.App is running,
# we just schedule the context creation
# routine on it.
idle.idle(create, alwaysQueue=True)
if self.__ownApp:
log.debug('Starting temporary wx.MainLoop')
self.__app.MainLoop()
def setTarget(self, target):
......
......@@ -428,13 +428,12 @@ def main(args=None):
return exitCode[0]
def embed(parent=None, mkFrame=True, **kwargs):
def embed(mkFrame=True, **kwargs):
"""Initialise FSLeyes and create a :class:`.FSLeyesFrame`, when
running within another application.
.. note:: If a ``wx.App`` does not exist, one is created.
:arg parent: ``wx`` parent object
.. note:: In most cases, this function must be called from the
``wx.MainLoop``.
:arg mkFrame: Defaults to ``True``. If ``False``, FSLeyes is
initialised, but a :class:`.FSLeyesFrame` is not created.
......@@ -465,8 +464,8 @@ def embed(parent=None, mkFrame=True, **kwargs):
app = wx.GetApp()
ownapp = app is None
if ownapp and (makeFrame is False):
raise RuntimeError('If makeFrame is False, you '
if ownapp and (mkFrame is False):
raise RuntimeError('If mkFrame is False, you '
'must create a wx.App before '
'calling fsleyes.main.embed')
if ownapp:
......@@ -489,7 +488,7 @@ def embed(parent=None, mkFrame=True, **kwargs):
if mkFrame:
frame = fslframe.FSLeyesFrame(
parent, overlayList, displayCtx, **kwargs)
None, overlayList, displayCtx, **kwargs)
else:
frame = None
......@@ -501,7 +500,7 @@ def embed(parent=None, mkFrame=True, **kwargs):
called[0] = True
ret[0] = (overlayList, displayCtx, frame)
fslgl.getGLContext(parent=parent, ready=ready, raiseErrors=True)
fslgl.getGLContext(ready=ready, raiseErrors=True)
idle.block(10, until=until)
if ret[0] is None:
......@@ -583,9 +582,7 @@ def initialise(splash, namespace, callback):
try:
# Force the creation of a wx.glcanvas.GLContext object,
# and initialise OpenGL version-specific module loads.
# The splash screen is used as the parent of the dummy
# canvas created by the gl.getWXGLContext function.
fslgl.getGLContext(parent=splash, ready=realCallback)
fslgl.getGLContext(ready=realCallback)
except Exception:
log.error('Unable to initialise OpenGL!', exc_info=True)
......
......@@ -14,7 +14,7 @@ version number. See also the :mod:`fsl.version` module.
"""
__version__ = '0.33.0'
__version__ = '0.33.1'
"""Current version number, as a string. The FSLeyes version number consists
of three numbers, separated by a period, which roughly obeys the Semantic
Versioning conventions (http://semver.org/).
......
......@@ -319,7 +319,6 @@ def run_with_fsleyes(func, *args, **kwargs):
else:
wx.CallLater(startingDelay,
fslgl.getGLContext,
parent=state.panel,
ready=init,
raiseErrors=True)
else:
......
......@@ -38,7 +38,7 @@ def test_embed():
print('Embedded call', ncalls[0])
overlayList, displayCtx, fframe = fslmain.embed(
frame[0], menu=False, save=False)
menu=False, save=False)
img = fslimage.Image(op.join(datadir, '3d'))
fframe.addOrthoPanel()
......@@ -92,7 +92,7 @@ def test_embed_ownFrame():
print('Embedded call', ncalls[0])
overlayList, displayCtx, fframe = fslmain.embed(
frame[0], mkFrame=False, menu=False, save=False)
mkFrame=False, menu=False, save=False)
assert fframe is None
......
......@@ -70,30 +70,6 @@ install FSLeyes into it like so::
conda install -c conda-forge fsleyes
Install standalone build (recommended)
--------------------------------------
If you wish to install FSLeyes independently of FSL, you can download and
install a standalone version from the |fsleyes_homepage|_ home page, using
these instructions.
1. Download the ``zip`` or ``tar.gz`` file for your platform.
2. Unzip/untar the downloaded file to a location of your choice.
3. Call FSLeyes like this (you may wish to put the directory containing
the ``fsleyes`` command on your ``$PATH`` environment variable):
======== ==========================================================
Platform Command to run FSLeyes
======== ==========================================================
Linux ``/path/to/downloaded/FSLeyes/fsleyes``
macOS ``/path/to/downloaded/FSLeyes.app/Contents/MacOS/fsleyes``
======== ==========================================================
Install from PyPi (advanced)
----------------------------
......@@ -160,6 +136,34 @@ Under Ubuntu, run the following::
Then you should be able to run ``pip install fsleyes``.
Install standalone build (no longer updated)
--------------------------------------------
.. note:: FSLeyes 0.32.3 is the last version for which standalone builds are
provided. From FSLeyes 0.33.0 onwards, ``conda`` is the recommended
installation method.
If you wish to install FSLeyes independently of FSL, you can download and
install a standalone version from the |fsleyes_homepage|_ home page, using
these instructions.
1. Download the ``zip`` or ``tar.gz`` file for your platform.
2. Unzip/untar the downloaded file to a location of your choice.
3. Call FSLeyes like this (you may wish to put the directory containing
the ``fsleyes`` command on your ``$PATH`` environment variable):
======== ==========================================================
Platform Command to run FSLeyes
======== ==========================================================
Linux ``/path/to/downloaded/FSLeyes/fsleyes``
macOS ``/path/to/downloaded/FSLeyes.app/Contents/MacOS/fsleyes``
======== ==========================================================
Install into a Singularity image
--------------------------------
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment