From a7745c44b1f2ce1709e79fd86c678fc863e9d3d1 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauld.mccarthy@gmail.com> Date: Fri, 13 Nov 2015 15:12:15 +0000 Subject: [PATCH] Bugfix to RenderTextureStack - Z axis range was not being updated when GLObject was being updated. --- fsl/fsleyes/gl/textures/rendertexturestack.py | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/fsl/fsleyes/gl/textures/rendertexturestack.py b/fsl/fsleyes/gl/textures/rendertexturestack.py index b332ad265..f47d47363 100644 --- a/fsl/fsleyes/gl/textures/rendertexturestack.py +++ b/fsl/fsleyes/gl/textures/rendertexturestack.py @@ -68,7 +68,7 @@ class RenderTextureStack(object): self.__globj.addUpdateListener( '{}_{}'.format(type(self).__name__, id(self)), - self.__refreshAllTextures) + self.__onGLObjectUpdate) import wx wx.GetApp().Bind(wx.EVT_IDLE, self.__textureUpdateLoop) @@ -134,8 +134,7 @@ class RenderTextureStack(object): self.__yax = yax self.__zax = zax - lo, hi = self.__globj.getDisplayBounds() - res = self.__globj.getDataResolution(xax, yax) + res = self.__globj.getDataResolution(xax, yax) if res is not None: numTextures = res[zax] else: numTextures = self.__defaultNumTextures @@ -143,9 +142,6 @@ class RenderTextureStack(object): if numTextures > self.__maxNumTextures: numTextures = self.__maxNumTextures - self.__zmin = lo[zax] - self.__zmax = hi[zax] - self.__destroyTextures() for i in range(numTextures): @@ -153,7 +149,7 @@ class RenderTextureStack(object): rendertexture.RenderTexture('{}_{}'.format(self.name, i))) self.__textureDirty = [True] * numTextures - self.__refreshAllTextures() + self.__onGLObjectUpdate() def __destroyTextures(self): @@ -167,6 +163,18 @@ class RenderTextureStack(object): for tex in texes: wx.CallLater(50, tex.destroy) + + def __onGLObjectUpdate(self, *a): + """Called when the :class:`.GLObject` display is updated. Re-calculates + the display space Z-axis range, and marks all render textures as dirty. + """ + + lo, hi = self.__globj.getDisplayBounds() + self.__zmin = lo[self.__zax] + self.__zmax = hi[self.__zax] + + self.__refreshAllTextures() + def __refreshAllTextures(self, *a): """Marks all :class:`.RenderTexture` instances as *dirty*, so that -- GitLab