fsleyes.gl.gltensor

This module provides the GLTensor class, for displaying tensor ellipsoids in a DTIFitTensor overlay, or compatible Image overlay.

See gl21.gltensor_funcs.

class fsleyes.gl.gltensor.GLTensor(image, overlayList, displayCtx, canvas, threedee)

Bases: fsleyes.gl.glvector.GLVector

The GLTensor class encapsulates the logic required to render TensorImage overlays. Most of the functionality is in the gl21.gltensor_funcs module.

Note

The GLTensor is not currently supported on versions of OpenGL older than 2.1 (and probably never will be).

The eigenvalues and eigenvectors of the overlay are stored as 3D ImageTexture instances, using the gl.resources module. These textures are added as attributes of a GLTensor instance - this is in addition to the textures that are used for GLVector instances (of which the GLTensor is a sub-class):

Attribute name Description Texture unit
v1Texture First eigenvector gl.GL_TEXTURE8
v2Texture Second eigenvector gl.GL_TEXTURE9
v3Texture Third eigenvector gl.GL_TEXTURE10
l1Texture First eigenvalue gl.GL_TEXTURE11
l2Texture Second eigenvalue gl.GL_TEXTURE12
l3Texture Third eigenvalue gl.GL_TEXTURE13
__init__(image, overlayList, displayCtx, canvas, threedee)

Create a GLTensor. Prepares the eigenvalue and eigenvector textures, and calls the gl21.gltensor_funcs.init() function.

Parameters:
  • image – A DTIFitTensor or compatible Image overlay.
  • overlayList – The OverlayList
  • displayCtx – The DisplayContext managing the scene.
  • canvas – The canvas doing the drawing.
  • threedee – 2D or 3D rendering.
destroy()

Must be called when this GLTensor is no longer needed. Performs cleanup tasks.

texturesReady()

Overrides GLVector.texturesReady(). Returns True if all of the textures are ready, False otherwise.

addListeners()

Overrides GLVector.addListeners(). Calls the base class implementation, and adds some property listeners to the TensorOpts instance associated with the overlay being displayed.

removeListeners()

Overrides GLVector.removeListeners(). Calls the base class implementation, and removes some property listeners.

getDataResolution(xax, yax)

Overrides GLVector.getDataResolution(). Returns a pixel resolution suitable for off-screen rendering of this GLTensor.

compileShaders()

Overrides GLVector.compileShaders(). Calls the gl21.gltensor_funcs.compileShaders() function.

updateShaderState()

Overrides GLVector.updateShaderState(). Calls the gl21.gltensor_funcs.updateShaderState() function.

preDraw(xform=None, bbox=None)

Overrides GLVector.preDraw(). Binds the eigenvalue and eigenvector textures, calls the GLVector.preDraw() method, and the gl21.gltensor_funcs.preDraw() function.

draw2D(*args, **kwargs)

Overrides GLVector.draw2D(). Calls the gl21.gltensor_funcs.draw2D() function.

draw3D(*args, **kwargs)

Overrides GLVector.draw3D(). Calls the gl21.gltensor_funcs.draw3D() function.

postDraw(xform=None, bbox=None)

Overrides GLVector.postDraw(). Unbinds the eigenvalue and eigenvector textures, calls the GLVector.postDraw() method, and the gl21.gltensor_funcs.postDraw() function.

_GLTensor__tensorResolutionChanged(*a)

Called when the TensorOpts.tensorResolution property changes. Calls asyncUpdateShaderState().

__module__ = 'fsleyes.gl.gltensor'