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:
objectThe
RenderTextureStackclass creates and maintains a collection ofRenderTextureinstances, each of which is used to display a single slice of aGLObjectalong a specific display axis.The purpose of the
RenderTextureStackis to pre-generate 2D slices of aGLObjectso that they do not have to be rendered on-demand. Rendering aGLObjectslices from a pre-generated off-screen texture provides better performance than rendering theGLObjectslice in real time.The
RenderTexturetextures are updated in an idle loop, via theidle.idle()function.Note
A
RenderTextureStackinstance must be manually updated whenever itsGLObjectchanges, via theonGLObjectUpdate()method.RenderTextureStackinstances do not explicitly listen forGLObjectchanges 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 theGLObject, so that the textures can be refreshed whenever it changes.- Parameters
globj – The
GLObjectinstance.
-
destroy()[source]¶ Must be called when this
RenderTextureStackis no longer needed. Calls the__destroyTextures()method.
-
draw(zpos, xform=None)[source]¶ Draws the pre-generated
RenderTexturewhich 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
GLObjectchanges. It destroys and re-creates allRenderTextureinstances.
-
__destroyTextures()¶ Destroys all
RenderTextureinstances. This is performed asynchronously, via theidle.idlefunction.
-
onGLObjectUpdate()[source]¶ Must be called called when the
GLObjectdisplay is updated. Re-calculates the display space Z-axis range, and marks all render textures as dirty.
-
__refreshAllTextures(*a)¶ Marks all
RenderTextureinstances as dirty, so that they will be refreshed by the__textureUpdateLoop().
-
__textureUpdateLoop()¶ This method is called via the
idle.idle()function. It loops through allRenderTextureinstances, and refreshes any that have been marked as dirty.Each call to this method causes one
RenderTextureto be refreshed. After aRenderTexturehas been refreshed, if there are dirty moreRenderTextureinstances, this method re-schedules itself to be called again viaidle.idle().
-
__refreshTexture(tex, idx)¶ Refreshes the given
RenderTexture.- Parameters
tex – The
RenderTextureto refresh.idx – Index of the
RenderTexture.
-
__zposToIndex(zpos)¶ Converts a Z location in the display coordinate system into a
RenderTextureindex.
-
__indexToZpos(index)¶ Converts a
RenderTextureindex 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)
-