fsleyes.gl.gllinevector¶
This module provides the GLLineVector class, for displaying 3D
vector Image overlays in line mode.
The GLLineVertices class is also defined in this module, and is used
when running in OpenGL 1.4. See the gl14.gllinevector_funcs and
gl21.gllinevector_funcs modules for more details.
-
class
fsleyes.gl.gllinevector.GLLineVector(image, overlayList, displayCtx, canvas, threedee)[source]¶ Bases:
fsleyes.gl.glvector.GLVectorThe
GLLineVectorclass encapsulates the logic required to render anImageinstance of shapex*y*z*3, or typeNIFTI_TYPE_RGB24, as a vector image, where the vector at each voxel is drawn as a line, and coloured in the same way that voxels in theGLRGBVectorare coloured. TheGLLineVectorclass assumes that theDisplayinstance associated with theImageoverlay holds a reference to aLineVectorOptsinstance, which containsGLLineVector-specific display settings. TheGLLineVectorclass is a sub-class of theGLVectorclass, and uses the functionality provided byGLVector.In a similar manner to the
GLRGBVector, theGLLineVectoruses two OpenGL version-specific modules, thegl14.gllinevector_funcsandgl21.gllinevector_funcsmodules. It is assumed that these modules define the same functions that are defined by theGLRGBVectorversion specific modules.A
GLLineVectorinstance is rendered in different ways depending upon the rendering environment (GL 1.4 vs GL 2.1), so most of the rendering functionality is implemented in the version-specific modules mentioned above.-
__init__(image, overlayList, displayCtx, canvas, threedee)[source]¶ Create a
GLLineVectorinstance.- Parameters
image – An
ImageorDTIFitTensorinstance.overlayList – The
OverlayListdisplayCtx – The
DisplayContextmanaging the scene.canvas – The canvas doing the drawing.
threedee – 2D or 3D rendering.
-
destroy()[source]¶ Must be called when this
GLLineVectoris no longer needed. Removes some property listeners from theLineVectorOptsinstance, calls the OpenGL version-specificdestroyfunction, and calls theGLVector.destroy()method.
-
getDataResolution(xax, yax)[source]¶ Overrides
GLImageObject.getDataResolution(). Returns a pixel resolution suitable for rendering thisGLLineVector.
-
compileShaders()[source]¶ Overrides
GLVector.compileShaders(). Calls the OpenGL version-specificcompileShadersfunction.
-
updateShaderState()[source]¶ Overrides
GLVector.updateShaderState(). Calls the OpenGL version-specificupdateShaderStatefunction.
-
preDraw(xform=None, bbox=None)[source]¶ Overrides
GLVector.preDraw(). Calls the base class implementation, and then calls the OpenGL version-specificpreDrawfunction.
-
draw2D(*args, **kwargs)[source]¶ Overrides
GLObject.draw2D(). Calls the OpenGL version-specificdraw2Dfunction.
-
draw3D(*args, **kwargs)[source]¶ Overrides
GLObject.draw3D(). Calls the OpenGL version-specificdraw3Dfunction.
-
drawAll(*args, **kwargs)[source]¶ Overrides
GLObject.drawAll(). Calls the OpenGL version-specificdrawAllfunction.
-
postDraw(xform=None, bbox=None)[source]¶ Overrides
GLVector.postDraw(). Calls the base class implementation, and then calls the OpenGL version-specificpostDrawfunction.
-
__unitLengthChanged(*a)¶ Called when the
LineVectorOptsunitLengthproperty changes. Refreshes the vector image texture data.
-
__module__= 'fsleyes.gl.gllinevector'¶
-
-
class
fsleyes.gl.gllinevector.GLLineVertices(glvec)[source]¶ Bases:
objectThe
GLLineVerticesclass is used when rendering aGLLineVectorwith OpenGL 1.4. It contains logic to generate vertices for every vector in the vectorImagethat is being displayed by aGLLineVectorinstance.This class is used by the OpenGL 1.4 implementation - when using OpenGL 2.1, the logic encoded in this class is implemented in the line vector vertex shader. This is because OpenGL 1.4 vertex programs (using the ARB_vertex_program extension) are unable to perform texture lookups, so cannot retrieve the vector data.
After a
GLLineVerticesinstance has been created, therefresh()method can be used to generate line vector vertices and voxel coordinates for every voxel in theImage. These vertices and coordinates are stored as attributes of theGLLineVerticesinstance.Later, when the line vectors from a 2D slice of the image need to be displayed, the
getVertices2D()method can be used to extract the vertices and coordinates from the slice.A
GLLineVerticesinstance is not associated with a specificGLLineVectorinstance. This is so that a singleGLLineVerticesinstance can be shared between more than oneGLLineVector, avoiding the need to store multiple copies of the vertices and voxel coordinates. This means that aGLLineVectorinstance needs to be passed to most of the methods of aGLLineVerticesinstance.-
__init__(glvec)[source]¶ Create a
GLLineVertices. Vertices are calculated for the givenGLLineVectorinstance.- Parameters
glvec – A
GLLineVectorwhich is using thisGLLineVerticesinstance.
-
destroy()[source]¶ Should be called when this
GLLineVerticesinstance is no longer needed. Clears references to cached vertices/coordinates.
-
__hash__()[source]¶ Returns a hash of this
GLLineVerticesinstance. The hash value is calculated and cached on every call torefresh(), using thecalculateHash()method. This method returns that cached value.
-
calculateHash(glvec)[source]¶ Calculates and returns a hash value that can be used to determine whether the vertices of this this
GLLineVerticesinstance need to be recalculated. The hash value is based on some properties of theLineVectorOptsinstance, associated with the givenGLLineVector.For a
GLLineVerticesinstance calledverts, if the following test:hash(verts) != verts.calculateHash(glvec)
evaluates to
False, the vertices need to be refreshed (via a call torefresh()).
-
refresh(glvec)[source]¶ (Re-)calculates the vertices of this
GLLineVerticesinstance.For each voxel, in the
Imageoverlay being displayed by theGLLineVectorassociated with thisGLLineVerticesinstance, two vertices are generated, which define a line that represents the vector at the voxel.The vertices are stored as a \(X\times Y\times Z\times 2\times 3\)
numpyarray, as an attribute of this instance, calledvertices.
-
getVertices2D(glvec, zpos, axes, bbox=None)[source]¶ Extracts and returns a slice of line vertices, and the associated voxel coordinates, which are in a plane located at the given Z position (in display coordinates).
This method assumes that the
refresh()method has already been called.
-
__dict__= mappingproxy({'__module__': 'fsleyes.gl.gllinevector', '__doc__': 'The ``GLLineVertices`` class is used when rendering a\n :class:`GLLineVector` with OpenGL 1.4. It contains logic to generate\n vertices for every vector in the vector :class:`.Image` that is being\n displayed by a ``GLLineVector`` instance.\n\n\n This class is used by the OpenGL 1.4 implementation - when using OpenGL\n 2.1, the logic encoded in this class is implemented in the line vector\n vertex shader. This is because OpenGL 1.4 vertex programs (using the\n ARB_vertex_program extension) are unable to perform texture lookups,\n so cannot retrieve the vector data.\n\n\n After a ``GLLineVertices`` instance has been created, the :meth:`refresh`\n method can be used to generate line vector vertices and voxel\n coordinates for every voxel in the :class:`Image`. These vertices and\n coordinates are stored as attributes of the ``GLLineVertices`` instance.\n\n\n Later, when the line vectors from a 2D slice of the image need to be\n displayed, the :meth:`getVertices2D` method can be used to extract the\n vertices and coordinates from the slice.\n\n\n A ``GLLineVertices`` instance is not associated with a specific\n ``GLLineVector`` instance. This is so that a single ``GLLineVertices``\n instance can be shared between more than one ``GLLineVector``, avoiding\n the need to store multiple copies of the vertices and voxel\n coordinates. This means that a ``GLLineVector`` instance needs to be\n passed to most of the methods of a ``GLLineVertices`` instance.\n ', '__init__': <function GLLineVertices.__init__>, 'destroy': <function GLLineVertices.destroy>, '__hash__': <function GLLineVertices.__hash__>, 'calculateHash': <function GLLineVertices.calculateHash>, 'refresh': <function GLLineVertices.refresh>, 'getVertices2D': <function GLLineVertices.getVertices2D>, '__dict__': <attribute '__dict__' of 'GLLineVertices' objects>, '__weakref__': <attribute '__weakref__' of 'GLLineVertices' objects>, '__annotations__': {}})¶
-
__module__= 'fsleyes.gl.gllinevector'¶
-
__weakref__¶ list of weak references to the object (if defined)
-