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

RF: Use wx query routines from fsleyes_widgets, use new GL info properties in

fsleyes.gl. More to come.
parent bc2e3fcc
......@@ -203,9 +203,9 @@ import sys
import logging
import warnings
from fsl.utils.platform import platform as fslplatform
import fsl.utils.settings as fslsettings
import fsleyes.version as version
import fsl.utils.settings as fslsettings
import fsleyes_widgets as fwidgets
import fsleyes.version as version
# The logger is assigned in
......@@ -214,7 +214,7 @@ log = None
# If set to True, logging will not be configured
disableLogging = fslplatform.frozen
disableLogging = fwidgets.frozen()
__version__ = version.__version__
......@@ -277,7 +277,7 @@ def initialise():
# application, we'll guess at the
# location, which will differ depending
# on the platform
if fslplatform.frozen:
if fwidgets.frozen():
mac = op.join(fsleyesDir, '..', '..', '..', '..', 'Resources')
lnx = op.join(fsleyesDir, '..', 'share', 'FSLeyes')
options.append(op.normpath(mac))
......@@ -328,7 +328,7 @@ def _hacksAndWorkarounds():
# n.b. This will cause issues if building FSLeyes
# with the pyinstaller '--onefile' option, as
# discussed in the above pyinstaller file.
if fslplatform.frozen:
if fwidgets.frozen():
os.environ.pop('MPLCONFIGDIR', None)
# nibabel rejects NIfTI images where the
......@@ -357,7 +357,7 @@ def _hacksAndWorkarounds():
# Add the current directory to the python
# path, so that modules can be imported
# from within notebook/shell environments
if fslplatform.frozen:
if fwidgets.frozen():
sys.path.insert(0, '')
......@@ -383,7 +383,7 @@ def configLogging(verbose=0, noisy=None):
noisy = []
# Show deprecations if running from code
if fslplatform.frozen:
if fwidgets.frozen():
warnings.filterwarnings('ignore', category=DeprecationWarning)
else:
warnings.filterwarnings('default', category=DeprecationWarning)
......
......@@ -13,8 +13,8 @@ import os.path as op
import wx
import fsleyes_widgets.imagepanel as imagepanel
from fsl.utils.platform import platform as fslplatform
import fsleyes_widgets.imagepanel as imagepanel
import fsleyes.gl as fslgl
import fsleyes.strings as strings
import fsleyes.splash as splash
......@@ -57,8 +57,9 @@ class AboutDialog(wx.Dialog):
# Create / retrieve all the content
verStr = version.__version__
glVerStr = fslplatform.glVersion
glRenStr = fslplatform.glRenderer
glVerStr = fslgl.GL_VERSION
glRenStr = fslgl.GL_RENDERER
glCompat = fslgl.GL_COMPATIBILITY
swlibs = strings.about['libs']
swVersions = []
......@@ -84,7 +85,7 @@ class AboutDialog(wx.Dialog):
fslVer = strings.about['fslVersion'].format(fslplatform.fslVersion)
fslDir = strings.about['fslPath'] .format(fslplatform.fsldir)
glVerStr = strings.about['glVersion'] .format(glVerStr)
glCompat = strings.about['glCompat'] .format(fslgl.GL_VERSION)
glCompat = strings.about['glCompat'] .format(glCompat)
glRenStr = strings.about['glRenderer'].format(glRenStr)
swStr = strings.about['software'] .format(*swVersions)
......
......@@ -11,7 +11,7 @@ displays an about dialog for *FSLeyes*.
from . import base
from fsl.utils.platform import platform as fslplatform
import fsleyes_widgets as fwidgets
class AboutAction(base.Action):
......@@ -41,5 +41,5 @@ class AboutAction(base.Action):
# When running over X11/SSH, CentreOnParent
# causes the dialog to be moved way off.
if not fslplatform.inSSHSession:
if not fwidgets.inSSHSession():
dlg.CentreOnParent()
......@@ -16,11 +16,10 @@ import logging
import platform
from collections import OrderedDict
from fsl.utils.platform import platform as fslplatform
import fsleyes_widgets.utils.status as status
import fsleyes.strings as strings
import fsleyes.state as fslstate
from . import base
import fsleyes_widgets.utils.status as status
import fsleyes.strings as strings
import fsleyes.state as fslstate
from . import base
log = logging.getLogger(__name__)
......@@ -135,18 +134,17 @@ class DiagnosticReportAction(base.Action):
OpenGL platform.
"""
import OpenGL.GL as gl
import fsleyes.gl as fslgl
import OpenGL.GL as gl
report = OrderedDict()
version = gl.glGetString( gl.GL_VERSION) .decode('ascii')
renderer = gl.glGetString( gl.GL_RENDERER) .decode('ascii')
texsize = str(gl.glGetInteger(gl.GL_MAX_TEXTURE_SIZE))
extensions = gl.glGetString( gl.GL_EXTENSIONS).decode('ascii')
report['Version'] = version
report['Compatibility'] = fslplatform.glVersion
report['Renderer'] = renderer
report['Texture size'] = str(gl.glGetInteger(gl.GL_MAX_TEXTURE_SIZE))
report = OrderedDict()
report['Version'] = fslgl.GL_VERSION
report['Compatibility'] = fslgl.GL_COMPATIBILITY
report['Renderer'] = fslgl.GL_RENDERER
report['Texture size'] = texsize
report['Extensions'] = extensions.split(' ')
return report
......
......@@ -28,20 +28,20 @@ import webbrowser
import wx
import jinja2 as j2
import fsleyes_widgets.utils.progress as progress
import fsleyes_widgets.utils.status as status
import fsl.utils.settings as settings
from fsl.utils.platform import platform as fslplatform
import fsl.utils.tempdir as tempdir
import fsl.utils.idle as idle
import fsleyes_widgets as fwidgets
import fsleyes_widgets.utils.progress as progress
import fsleyes_widgets.utils.status as status
import fsl.utils.settings as settings
import fsl.utils.tempdir as tempdir
import fsl.utils.idle as idle
import fsleyes
import fsleyes.main as fsleyes_main
import fsleyes.strings as strings
import fsleyes.actions.screenshot as screenshot
import fsleyes
import fsleyes.main as fsleyes_main
import fsleyes.strings as strings
import fsleyes.actions.screenshot as screenshot
from . import base
from . import runscript
from . import base
from . import runscript
try:
import zmq
......@@ -602,7 +602,7 @@ class NotebookServer(threading.Thread):
# can't just call a python interpreter,
# so we use a hook in fsleyes.main to
# call actions.notebook_main.main.
if fslplatform.frozen:
if fwidgets.frozen():
cmd = [op.join(op.dirname(sys.executable), 'fsleyes')]
else:
cmd = [sys.executable, fsleyes_main.__file__]
......
......@@ -31,6 +31,7 @@ import matplotlib.image as mplimg
from fsl.utils.platform import platform as fslplatform
import fsl.utils.idle as idle
import fsleyes_widgets as fwidgets
import fsleyes_widgets.utils.status as status
import fsl.utils.settings as fslsettings
import fsleyes.views.canvaspanel as canvaspanel
......@@ -181,7 +182,7 @@ def canvasPanelScreenshot(panel, filename):
windowDC = wx.WindowDC(panel)
memoryDC = wx.MemoryDC()
if fslplatform.wxFlavour == fslplatform.WX_PHOENIX:
if fwidgets.wxFlavour() == fwidgets.WX_PHOENIX:
bmp = wx.Bitmap(width, height)
else:
bmp = wx.EmptyBitmap(width, height)
......@@ -205,7 +206,7 @@ def canvasPanelScreenshot(panel, filename):
data[:, :, :3] = rgb.reshape(height, width, 3)
# OSX and SSh/X11 both have complications
inSSH = fslplatform.inSSHSession and not fslplatform.inVNCSession
inSSH = fwidgets.inSSHSession() and not fwidgets.inVNCSession()
if inSSH or fslplatform.os == 'Darwin':
data = _patchInCanvases(cpanel, panel, data, bgColour)
......
......@@ -12,10 +12,10 @@ for displaying an :class:`.Image` overlay as a binary mask.
import copy
import logging
import fsleyes_props as props
from fsl.utils.platform import platform as fslplatform
from . import volumeopts
from . import niftiopts
import fsleyes_props as props
import fsleyes.gl as fslgl
from . import volumeopts
from . import niftiopts
log = logging.getLogger(__name__)
......@@ -65,7 +65,7 @@ class MaskOpts(niftiopts.NiftiOpts):
# We need GL >= 2.1 for
# spline interpolation
if float(fslplatform.glVersion) < 2.1:
if float(fslgl.GL_COMPATIBILITY) < 2.1:
interp = self.getProp('interpolation')
interp.removeChoice('spline', instance=self)
interp.updateChoice('linear', instance=self, newAlt=['spline'])
......
......@@ -15,12 +15,12 @@ MIP overlays are rendered via the :class:`.GLMIP` class.
import numpy as np
from fsl.utils.platform import platform as fslplatform
import fsl.transform.affine as affine
import fsleyes_props as props
import fsl.transform.affine as affine
import fsleyes_props as props
import fsleyes.gl as fslgl
from . import colourmapopts as cmapopts
from . import niftiopts
from . import colourmapopts as cmapopts
from . import niftiopts
class MIPOpts(cmapopts.ColourMapOpts, niftiopts.NiftiOpts):
......@@ -61,7 +61,7 @@ class MIPOpts(cmapopts.ColourMapOpts, niftiopts.NiftiOpts):
# We need GL >= 2.1 for
# spline interpolation
if float(fslplatform.glVersion) < 2.1:
if float(fslgl.GL_COMPATIBILITY) < 2.1:
interp = self.getProp('interpolation')
interp.removeChoice('spline', instance=self)
interp.updateChoice('linear', instance=self, newAlt=['spline'])
......
......@@ -12,9 +12,9 @@ settings used by :class:`.CanvasPanel` instances.
import copy
import logging
from fsl.utils.platform import platform as fslplatform
import fsleyes_props as props
import fsleyes.colourmaps as fslcm
import fsleyes_props as props
import fsleyes.gl as fslgl
import fsleyes.colourmaps as fslcm
from . import canvasopts
......@@ -121,22 +121,16 @@ class SceneOpts(props.HasProperties):
@property
def defaultMovieSyncRefresh(self):
"""In movie mode, the canvas refreshes are performed by the
__syncMovieRefresh or __unsyncMovieRefresh methods of the CanvasPanel
class. Some platforms/GL drivers/environments seem to have a problem
with separate renders/buffer swaps, so we have to use a shitty
unsynchronised update routine.
These heuristics are not perfect - the movieSyncRefresh property can
therefore be overridden by the user.
"""
# In movie mode, the canvas refreshes are
# performed by the __syncMovieRefresh or
# __unsyncMovieRefresh methods of the
# CanvasPanel class. Some platforms/GL
# drivers/environments seem to have a
# problem with separate renders/buffer
# swaps, so we have to use a shitty
# unsynchronised update routine.
#
# These heuristics are not perfect - the
# movieSyncRefresh property can therefore
# be overridden by the user.
"""
renderer = fslplatform.glRenderer.lower()
renderer = fslgl.GL_RENDERER.lower()
unsyncRenderers = ['gallium', 'mesa dri intel(r)']
unsync = any([r in renderer for r in unsyncRenderers])
......
......@@ -12,11 +12,11 @@ vector images.
import copy
import fsleyes_props as props
import fsl.data.image as fslimage
from fsl.utils.platform import platform as fslplatform
from . import niftiopts
from . import volumeopts
import fsleyes_props as props
import fsl.data.image as fslimage
import fsleyes.gl as fslgl
from . import niftiopts
from . import volumeopts
class VectorOpts(niftiopts.NiftiOpts):
......@@ -337,7 +337,7 @@ class RGBVectorOpts(VectorOpts):
# We need GL >= 2.1 for
# spline interpolation
if float(fslplatform.glVersion) < 2.1:
if float(fslgl.GL_COMPATIBILITY) < 2.1:
interp = self.getProp('interpolation')
interp.removeChoice('spline', instance=self)
interp.updateChoice('linear', instance=self, newAlt=['spline'])
......
......@@ -10,10 +10,11 @@ use with :class:`.DisplayOpts` classes.
import numpy as np
from fsl.utils.platform import platform as fslplatform
import fsl.transform.affine as affine
import fsl.utils.deprecated as deprecated
import fsleyes_props as props
import fsl.transform.affine as affine
import fsl.utils.deprecated as deprecated
import fsleyes_props as props
import fsleyes_widgets as fwidgets
import fsleyes.gl as fslgl
class Volume3DOpts(object):
......@@ -131,7 +132,7 @@ class Volume3DOpts(object):
# If we're in an X11/SSh session,
# step down the quality so it's
# a bit faster.
if fslplatform.inSSHSession:
if fwidgets.inSSHSession():
self.numSteps = 60
self.resolution = 70
self.blendFactor = 0.3
......@@ -143,7 +144,7 @@ class Volume3DOpts(object):
#
# Also disable blendByIntensity,
# as it is not implemented on gl14
if float(fslplatform.glVersion) < 2.1:
if float(fslgl.GL_COMPATIBILITY) < 2.1:
smooth = self.getProp('smoothing')
smooth.setAttribute(self, 'maxval', 6)
self.disableProperty('blendByIntensity')
......@@ -182,7 +183,7 @@ class Volume3DOpts(object):
See the :class:`.GLVolume` class for more details.
"""
if float(fslplatform.glVersion) >= 2.1:
if float(fslgl.GL_COMPATIBILITY) >= 2.1:
return self.numSteps
outer = self.getNumOuterSteps()
......
......@@ -12,9 +12,9 @@ import logging
import numpy as np
import fsl.data.image as fslimage
from fsl.utils.platform import platform as fslplatform
import fsleyes_props as props
import fsl.data.image as fslimage
import fsleyes_props as props
import fsleyes.gl as fslgl
import fsleyes.colourmaps as fslcm
from . import colourmapopts as cmapopts
......@@ -118,7 +118,7 @@ class VolumeOpts(cmapopts.ColourMapOpts,
# We need GL >= 2.1 for
# spline interpolation
if float(fslplatform.glVersion) < 2.1:
if float(fslgl.GL_COMPATIBILITY) < 2.1:
interp = self.getProp('interpolation')
interp.removeChoice('spline', instance=self)
interp.updateChoice('linear', instance=self, newAlt=['spline'])
......@@ -494,7 +494,7 @@ class VolumeRGBOpts(niftiopts.NiftiOpts):
# We need GL >= 2.1 for
# spline interpolation
if float(fslplatform.glVersion) < 2.1:
if float(fslgl.GL_COMPATIBILITY) < 2.1:
interp = self.getProp('interpolation')
interp.removeChoice('spline', instance=self)
interp.updateChoice('linear', instance=self, newAlt=['spline'])
......
......@@ -20,19 +20,19 @@ import logging
import six
import wx
import wx.lib.agw.aui as aui
import wx.lib.agw.aui as aui
import fsl.utils.idle as idle
import fsl.utils.settings as fslsettings
import fsl.utils.deprecated as deprecated
from fsl.utils.platform import platform as fslplatform
import fsleyes_widgets.dialog as fsldlg
import fsleyes_widgets.utils.status as status
import fsl.utils.idle as idle
import fsl.utils.settings as fslsettings
import fsl.utils.deprecated as deprecated
import fsleyes_widgets as fwidgets
import fsleyes_widgets.dialog as fsldlg
import fsleyes_widgets.utils.status as status
import fsleyes.strings as strings
import fsleyes.plugins as plugins
import fsleyes.autodisplay as autodisplay
import fsleyes.profiles.shortcuts as shortcuts
import fsleyes.strings as strings
import fsleyes.plugins as plugins
import fsleyes.autodisplay as autodisplay
import fsleyes.profiles.shortcuts as shortcuts
from . import actions
from . import tooltips
......@@ -1515,10 +1515,10 @@ class FSLeyesFrame(wx.Frame):
# than the menu bar on OSX/wxPhoenix, or on Linux.
# This is because under OSX/wxPython, we can't get
# access to the built-in application menu.
onOSX = fslplatform.wxPlatform in (fslplatform.WX_MAC_CARBON,
fslplatform.WX_MAC_COCOA)
onOSX = fwidgets.wxPlatform() in (fwidgets.WX_MAC_CARBON,
fwidgets.WX_MAC_COCOA)
haveAppMenu = (onOSX and
fslplatform.wxFlavour == fslplatform.WX_PHOENIX)
fwidgets.wxFlavour() == fwidgets.WX_PHOENIX)
locationOffset = 0
# On linux, we create a FSLeyes menu
......@@ -1725,7 +1725,7 @@ class FSLeyesFrame(wx.Frame):
for path in self.__recentPathsMenu.GetMenuItems():
# RemoveItem is deprecated in phoenix
if fslplatform.wxFlavour == fslplatform.WX_PHOENIX:
if fwidgets.wxFlavour() == fwidgets.WX_PHOENIX:
self.__recentPathsMenu.Remove(path)
else:
self.__recentPathsMenu.RemoveItem(path)
......
......@@ -12,18 +12,17 @@ encapsulates the data and logic required to render 2D slice of an
import logging
import numpy as np
import OpenGL.GL as gl
import numpy as np
import OpenGL.GL as gl
from fsl.utils.platform import platform as fslplatform
import fsl.utils.idle as idle
import fsl.transform.affine as affine
import fsleyes.gl as fslgl
import fsleyes.gl.routines as glroutines
import fsleyes.gl.shaders.filter as glfilter
from . import textures
from . import glimageobject
from . import resources as glresources
import fsl.utils.idle as idle
import fsl.transform.affine as affine
import fsleyes.gl as fslgl
import fsleyes.gl.routines as glroutines
import fsleyes.gl.shaders.filter as glfilter
from . import textures
from . import glimageobject
from . import resources as glresources
log = logging.getLogger(__name__)
......@@ -1051,7 +1050,7 @@ class GLVolume(glimageobject.GLImageObject):
"""Called when the :attr:`.Volume3DOpts.numClipPlanes` property
changes.
"""
if float(fslplatform.glVersion) == 1.4:
if float(fslgl.GL_COMPATIBILITY) == 1.4:
fslgl.glvolume_funcs.compileShaders(self)
self.updateShaderState(alwaysNotify=True)
......@@ -1060,7 +1059,7 @@ class GLVolume(glimageobject.GLImageObject):
"""Called when the :attr:`.Volume3DOpts.clipMode` property
changes.
"""
if float(fslplatform.glVersion) == 1.4:
if float(fslgl.GL_COMPATIBILITY) == 1.4:
fslgl.glvolume_funcs.compileShaders(self)
self.updateShaderState(alwaysNotify=True)
......
......@@ -12,11 +12,10 @@ to loading and running simple filter shader programs, which require a
import collections
import OpenGL.GL as gl
import OpenGL.GL as gl
from fsl.utils.platform import platform as fslplatform
import fsleyes.gl.shaders as shaders
import fsleyes.gl as fslgl
import fsleyes.gl.shaders as shaders
GL14_CONSTANTS = collections.defaultdict(dict, {
......@@ -74,7 +73,7 @@ class Filter(object):
self.__texture = texture
self.__basename = basename
if float(fslplatform.glVersion) >= 2.1:
if float(fslgl.GL_COMPATIBILITY) >= 2.1:
self.__shader = shaders.GLSLShader(vertSrc, fragSrc)
else:
constants = {n : 1 for n in GL14_CONSTANTS[basename]}
......@@ -110,7 +109,7 @@ class Filter(object):
shader.load()
kwargs = dict(kwargs)
glver = float(fslplatform.glVersion)
glver = float(fslgl.GL_COMPATIBILITY)
needRecompile = False
if glver >= 2.1:
......@@ -172,7 +171,7 @@ class Filter(object):
shader.loadAtts()
shader.setAtt('texCoord', texCoords)
if float(fslplatform.glVersion) >= 2.1:
if float(fslgl.GL_COMPATIBILITY) >= 2.1:
shader.setAtt('vertex', vertices)
source.draw(**kwargs)
else:
......
......@@ -16,12 +16,12 @@ import collections.abc as abc
import numpy as np
import fsl.transform.affine as affine
import fsl.data.imagewrapper as imagewrapper
from fsl.utils.platform import platform as fslplatform
from . import data as texdata
from . import texture2d
from . import texture3d
import fsl.transform.affine as affine
import fsl.data.imagewrapper as imagewrapper
import fsleyes_widgets as fwidgets
from . import data as texdata
from . import texture2d
from . import texture3d
log = logging.getLogger(__name__)
......@@ -349,7 +349,7 @@ class ImageTexture(ImageTextureBase, texture3d.Texture3D):
threadedDefault = None
"""Default value used for the ``threaded`` argument passed to
:meth:`__init__`. When this is set to ``None``, the default value will be
the value of :attr:`.fsl.utils.platform.Platform.haveGui`.
the value of :func:`.fsleyes_widgets.haveGui`.
"""
......@@ -401,7 +401,7 @@ class ImageTexture(ImageTextureBase, texture3d.Texture3D):
ImageTexture.threadedDefault)
if kwargs['threaded'] is None:
kwargs['threaded'] = fslplatform.haveGui
kwargs['threaded'] = fwidgets.haveGui()
ImageTextureBase .__init__(self, image, nvals, 3)
texture3d.Texture3D.__init__(self, name, **kwargs)
......
......@@ -23,10 +23,10 @@ import OpenGL.GL as gl
import OpenGL.raw.GL._types as gltypes
import OpenGL.GL.EXT.framebuffer_object as glfbo
from fsl.utils.platform import platform as fslplatform
import fsleyes.gl.routines as glroutines
import fsleyes.gl.shaders as shaders
from . import texture2d
import fsleyes.gl as fslgl
import fsleyes.gl.routines as glroutines
import fsleyes.gl.shaders as shaders
from . import texture2d
log = logging.getLogger(__name__)
......@@ -163,7 +163,7 @@ class RenderTexture(texture2d.Texture2D):
fragSrc = shaders.getFragmentShader('rendertexture')