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

BF: Make sure clipping range is updated when colourMode changes whilst

clipMode is unset (and thus delegates to colourMode). Fix issue with image
texture notification - only one callback (1/3 canvases) is called when texture
data is ready, so shader uniforms were not being set for 2/3 ortho
canvases. Rely on notifier callback instead.
parent e7cbc417
......@@ -235,7 +235,7 @@ class TractogramOpts(fsldisplay.DisplayOpts,
:meth:`.ColourMapOpts.updateDataRange`, to ensure that the display
and clipping ranges are up to date.
"""
self.updateDataRange(resetCR=False)
self.updateDataRange(resetCR=(self.clipMode is None))
def __clipModeChanged(self, *_):
......
......@@ -439,31 +439,55 @@ class GLTractogram(globject.GLObject):
# When the texture has been prepared,
# we need to tell the shader programs
# how to use it.
def shader(texture):
opts = self.displayCtx.getOpts(image)
w2tXform = opts.getTransform('world', 'texture')
voxXform = texture.voxValXform
voxScale = voxXform[0, 0]
voxOffset = voxXform[0, 3]
if which == 'colour':
for shader in self.iterShaders('imageData'):
with shader.loaded():
shader.set('imageTexture', 2)
shader.set('texCoordXform', w2tXform)
shader.set('voxScale', voxScale)
shader.set('voxOffset', voxOffset)
elif which == 'clip':
for shader in self.iterShaders([], ['imageData']):
with shader.loaded():
shader.set('clipTexture', 3)
shader.set('clipTexCoordXform', w2tXform)
shader.set('clipValScale', voxScale)
shader.set('clipValOffset', voxOffset)
self.imageTextures.registerAuxImage(which, image, callback=shader)
self.imageTextures.texture(which).register(
self.name, self.updateShaderState)
if which == 'colour': callback = self.colourImageTextureChanged
else: callback = self.clipImageTextureChanged
self.imageTextures.registerAuxImage(
which, image, callback=callback, notify=True)
self.imageTextures.texture(which).register(self.name, callback)
def colourImageTextureChanged(self, *_):
"""Calls :meth:`imageTextureChanged`. """
self.imageTextureChanged('colour')
def clipImageTextureChanged(self, *_):
"""Calls :meth:`imageTextureChanged`. """
self.imageTextureChanged('clip')
def imageTextureChanged(self, which):
"""Called when :attr:`.TractogramOpts.colourMode` or
:attr:`.TractogramOpts.clipMode` is set to an image, and the
underlying :class:`.ImageTexture` changes. Sets some shader uniforms
accordingly.
"""
if which == 'colour': image = self.opts.colourMode
else: image = self.opts.clipMode
texture = self.imageTextures.texture(which)
opts = self.displayCtx.getOpts(image)
w2tXform = opts.getTransform('world', 'texture')
voxXform = texture.voxValXform
voxScale = voxXform[0, 0]
voxOffset = voxXform[0, 3]
if which == 'colour':
for shader in self.iterShaders('imageData'):
with shader.loaded():
shader.set('imageTexture', 2)
shader.set('texCoordXform', w2tXform)
shader.set('voxScale', voxScale)
shader.set('voxOffset', voxOffset)
elif which == 'clip':
for shader in self.iterShaders([], ['imageData']):
with shader.loaded():
shader.set('clipTexture', 3)
shader.set('clipTexCoordXform', w2tXform)
shader.set('clipValScale', voxScale)
shader.set('clipValOffset', voxOffset)
def refreshCmapTextures(self):
......
......@@ -717,6 +717,8 @@ class AuxImageTextureManager:
if opts is not None: volume = opts.index()[3:]
else: volume = 0
kwargs['notify'] = kwargs.get('notify', False)
tex = glresources.get(
texName,
ImageTexture,
......@@ -724,7 +726,6 @@ class AuxImageTextureManager:
image,
normaliseRange=norm,
volume=volume,
notify=False,
**kwargs)
self.__auxtextures[which] = tex
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