fsleyes.gl.textures.rendertexturestack

This module provides the RenderTextureStack class, which is used by the SliceCanvas class to store a collection of off-screen RenderTexture instances containing rendered slices of GLObject instances.

class fsleyes.gl.textures.rendertexturestack.RenderTextureStack(globj)[source]

Bases: object

The RenderTextureStack class creates and maintains a collection of RenderTexture instances, each of which is used to display a single slice of a GLObject along a specific display axis.

The purpose of the RenderTextureStack is to pre-generate 2D slices of a GLObject so that they do not have to be rendered on-demand. Rendering a GLObject slices from a pre-generated off-screen texture provides better performance than rendering the GLObject slice in real time.

The RenderTexture textures are updated in an idle loop, via the idle.idle() function.

Note

A RenderTextureStack instance must be manually updated whenever its GLObject changes, via the onGLObjectUpdate() method. RenderTextureStack instances do not explicitly listen for GLObject changes themselves, because there is no guarantee that the textures will be refreshed before they need to be drawn.

__init__(globj)[source]

Create a RenderTextureStack. An update listener is registered on the GLObject, so that the textures can be refreshed whenever it changes.

Parameters

globj – The GLObject instance.

__del__()[source]

Prints a log message.

destroy()[source]

Must be called when this RenderTextureStack is no longer needed. Calls the __destroyTextures() method.

getGLObject()[source]

Returns the GLObject associated with this RenderTextureStack.

draw(zpos, xform=None)[source]

Draws the pre-generated RenderTexture which corresponds to the specified Z position.

Parameters
  • zpos – Position of slice to render.

  • xform – Transformation matrix to apply to rendered slice vertices.

setAxes(xax, yax)[source]

This method must be called when the display orientation of the GLObject changes. It destroys and re-creates all RenderTexture instances.

__destroyTextures()

Destroys all RenderTexture instances. This is performed asynchronously, via the idle.idle function.

onGLObjectUpdate()[source]

Must be called called when the GLObject display is updated. Re-calculates the display space Z-axis range, and marks all render textures as dirty.

__refreshAllTextures(*a)

Marks all RenderTexture instances as dirty, so that they will be refreshed by the __textureUpdateLoop().

__textureUpdateLoop()

This method is called via the idle.idle() function. It loops through all RenderTexture instances, and refreshes any that have been marked as dirty.

Each call to this method causes one RenderTexture to be refreshed. After a RenderTexture has been refreshed, if there are dirty more RenderTexture instances, this method re-schedules itself to be called again via idle.idle().

__refreshTexture(tex, idx)

Refreshes the given RenderTexture.

Parameters
  • tex – The RenderTexture to refresh.

  • idx – Index of the RenderTexture.

__zposToIndex(zpos)

Converts a Z location in the display coordinate system into a RenderTexture index.

__indexToZpos(index)

Converts a RenderTexture index into a Z location in the display coordinate system.

__dict__ = mappingproxy({'__module__': 'fsleyes.gl.textures.rendertexturestack', '__doc__': 'The ``RenderTextureStack`` class creates and maintains a collection of\n    :class:`.RenderTexture` instances, each of which is used to display a\n    single slice of a :class:`.GLObject` along a specific display axis.\n\n    The purpose of the ``RenderTextureStack`` is to pre-generate 2D slices of\n    a :class:`.GLObject` so that they do not have to be rendered on-demand.\n    Rendering a ``GLObject`` slices from a pre-generated off-screen texture\n    provides better performance than rendering the ``GLObject`` slice\n    in real time.\n\n    The :class:`.RenderTexture` textures are updated in an idle loop, via the\n    :func:`.idle.idle` function.\n\n\n    .. note:: A ``RenderTextureStack`` instance must be manually updated\n              whenever its ``GLObject`` changes, via the\n              :meth:`onGLObjectUpdate` method. ``RenderTextureStack``\n              instances do not explicitly listen for ``GLObject`` changes\n              themselves, because there is no guarantee that the textures\n              will be refreshed before they need to be drawn.\n    ', '__init__': <function RenderTextureStack.__init__>, '__del__': <function RenderTextureStack.__del__>, 'destroy': <function RenderTextureStack.destroy>, 'getGLObject': <function RenderTextureStack.getGLObject>, 'draw': <function RenderTextureStack.draw>, 'setAxes': <function RenderTextureStack.setAxes>, '_RenderTextureStack__destroyTextures': <function RenderTextureStack.__destroyTextures>, 'onGLObjectUpdate': <function RenderTextureStack.onGLObjectUpdate>, '_RenderTextureStack__refreshAllTextures': <function RenderTextureStack.__refreshAllTextures>, '_RenderTextureStack__textureUpdateLoop': <function RenderTextureStack.__textureUpdateLoop>, '_RenderTextureStack__refreshTexture': <function RenderTextureStack.__refreshTexture>, '_RenderTextureStack__zposToIndex': <function RenderTextureStack.__zposToIndex>, '_RenderTextureStack__indexToZpos': <function RenderTextureStack.__indexToZpos>, '__dict__': <attribute '__dict__' of 'RenderTextureStack' objects>, '__weakref__': <attribute '__weakref__' of 'RenderTextureStack' objects>, '__annotations__': {}})
__module__ = 'fsleyes.gl.textures.rendertexturestack'
__weakref__

list of weak references to the object (if defined)