From b1e871551d5e47ca5f341f0f51d3edf06db819d2 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauld.mccarthy@gmail.com> Date: Fri, 22 Jan 2016 12:51:51 +0000 Subject: [PATCH] Oops, LightBoxCanvas fix from previous commit was bad. Separated out duplicate LBC/SC logic into a SC method. --- fsl/fsleyes/gl/lightboxcanvas.py | 14 ++------- fsl/fsleyes/gl/slicecanvas.py | 51 +++++++++++++++++++++----------- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/fsl/fsleyes/gl/lightboxcanvas.py b/fsl/fsleyes/gl/lightboxcanvas.py index b99431415..e03fd7877 100644 --- a/fsl/fsleyes/gl/lightboxcanvas.py +++ b/fsl/fsleyes/gl/lightboxcanvas.py @@ -741,18 +741,10 @@ class LightBoxCanvas(slicecanvas.SliceCanvas): if not self._setGLContext(): return - # See comments regarding this process in - # SliceCanvas.._draw. I guess I should - # put this in a method or something. - overlays = self.displayCtx.getOrderedOverlays() - globjs = [] + overlays, globjs = self._getGLObjects() - for ovl in overlays: - globj = self._glObjects.get(ovl, None) - - if globj is None: self.__genGLObject(ovl) - elif globj: globjs.append(globj) - + # See comment in SliceCanvas._draw + # regarding this test if any([not g.ready() for g in globjs]): return diff --git a/fsl/fsleyes/gl/slicecanvas.py b/fsl/fsleyes/gl/slicecanvas.py index 5b13152fb..12cc0801e 100644 --- a/fsl/fsleyes/gl/slicecanvas.py +++ b/fsl/fsleyes/gl/slicecanvas.py @@ -873,6 +873,37 @@ class SliceCanvas(props.HasProperties): async.idle(refresh) + def _getGLObjects(self): + """Called by :meth:`_draw`. Builds a list of all :class:`.GLObjects` + to be drawn. + + :returns: A list of overlays, and a list of corresponding + :class:`.GLObjects` to be drawn. + """ + + overlays = [] + globjs = [] + for ovl in self.displayCtx.getOrderedOverlays(): + + globj = self._glObjects.get(ovl, None) + + # If an overlay does not yet have a corresponding + # GLObject, we presume that it hasn't been created + # yet, so we'll tell genGLObject to create one for + # it. + if globj is None: self.__genGLObject(ovl) + + # If there is a value for this overlay in + # the globjects dictionary, but it evaluates + # to False, then GLObject creation has been + # scheduled for the overlay - see genGLObject. + elif globj: + overlays.append(ovl) + globjs .append(globj) + + return overlays, globjs + + def _overlayBoundsChanged(self, *a): """Called when the display bounds are changed. @@ -1225,24 +1256,8 @@ class SliceCanvas(props.HasProperties): if not self._setGLContext(): return - overlays = self.displayCtx.getOrderedOverlays() - globjs = [] - for ovl in overlays: - - globj = self._glObjects.get(ovl, None) - - # If an overlay does not yet have a corresponding - # GLObject, we presume that it hasn't been created - # yet, so we'll tell genGLObject to create one for - # it. - if globj is None: self.__genGLObject(ovl) - - # If there is a value for this overlay in - # the globjects dictionary, but it evaluates - # to False, then GLObject creation has been - # scheduled for the overlay - see genGLObject. - elif globj: globjs.append(globj) - + overlays, globjs = self._getGLObjects() + # Do not draw anything if some globjects # are not ready. This is because, if a # GLObject was drawn, but is now temporarily -- GitLab