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
in certain rendering situations - specifically, 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)¶ Bases:
fsleyes.gl.glvector.GLVector
The
GLLineVector
class encapsulates the logic required to render anImage
instance 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 theGLRGBVector
are coloured. TheGLLineVector
class assumes that theDisplay
instance associated with theImage
overlay holds a reference to aLineVectorOpts
instance, which containsGLLineVector
-specific display settings. TheGLLineVector
class is a sub-class of theGLVector
class, and uses the functionality provided byGLVector
.In a similar manner to the
GLRGBVector
, theGLLineVector
uses two OpenGL version-specific modules, thegl14.gllinevector_funcs
andgl21.gllinevector_funcs
modules. It is assumed that these modules define the same functions that are defined by theGLRGBVector
version specific modules.A
GLLineVector
instance 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)¶ Create a
GLLineVector
instance.- Parameters
image – An
Image
orDTIFitTensor
instance.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
GLLineVector
is no longer needed. Removes some property listeners from theLineVectorOpts
instance, calls the OpenGL version-specificdestroy
function, and calls theGLVector.destroy()
method.
-
getDataResolution
(xax, yax)¶ Overrides
GLImageObject.getDataResolution()
. Returns a pixel resolution suitable for rendering thisGLLineVector
.
-
compileShaders
()¶ Overrides
GLVector.compileShaders()
. Calls the OpenGL version-specificcompileShaders
function.
-
updateShaderState
()¶ Overrides
GLVector.updateShaderState()
. Calls the OpenGL version-specificupdateShaderState
function.
-
preDraw
(xform=None, bbox=None)¶ Overrides
GLVector.preDraw()
. Calls the base class implementation, and then calls the OpenGL version-specificpreDraw
function.
-
draw2D
(*args, **kwargs)¶ Overrides
GLObject.draw2D()
. Calls the OpenGL version-specificdraw2D
function.
-
draw3D
(*args, **kwargs)¶ Overrides
GLObject.draw3D()
. Calls the OpenGL version-specificdraw3D
function.
-
drawAll
(*args, **kwargs)¶ Overrides
GLObject.drawAll()
. Calls the OpenGL version-specificdrawAll
function.
-
postDraw
(xform=None, bbox=None)¶ Overrides
GLVector.postDraw()
. Calls the base class implementation, and then calls the OpenGL version-specificpostDraw
function.
-
__module__
= 'fsleyes.gl.gllinevector'¶
-
-
class
fsleyes.gl.gllinevector.
GLLineVertices
(glvec)¶ Bases:
object
The
GLLineVertices
class is used in some cases when rendering aGLLineVector
. It contains logic to generate vertices for every vector in the vectorImage
that is being displayed by aGLLineVector
instance.After a
GLLineVertices
instance 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 theGLLineVertices
instance.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
GLLineVertices
instance is not associated with a specificGLLineVector
instance. This is so that a singleGLLineVertices
instance can be shared between more than oneGLLineVector
, avoiding the need to store multiple copies of the vertices and voxel coordinates. This means that aGLLineVector
instance needs to be passed to most of the methods of aGLLineVertices
instance.-
__init__
(glvec)¶ Create a
GLLineVertices
. Vertices are calculated for the givenGLLineVector
instance.- Parameters
glvec – A
GLLineVector
which is using thisGLLineVertices
instance.
-
destroy
()¶ Should be called when this
GLLineVertices
instance is no longer needed. Clears references to cached vertices/coordinates.
-
__hash__
()¶ Returns a hash of this
GLLineVertices
instance. The hash value is calculated and cached on every call torefresh()
, using thecalculateHash()
method. This method returns that cached value.
-
calculateHash
(glvec)¶ Calculates and returns a hash value that can be used to determine whether the vertices of this this
GLLineVertices
instance need to be recalculated. The hash value is based on some properties of theLineVectorOpts
instance, associated with the givenGLLineVector
.For a
GLLineVertices
instance 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)¶ (Re-)calculates the vertices of this
GLLineVertices
instance.For each voxel, in the
Image
overlay being displayed by theGLLineVector
associated with thisGLLineVertices
instance, 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\)
numpy
array, as an attribute of this instance, calledvertices
.
-
getVertices2D
(glvec, zpos, axes, bbox=None)¶ 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 in some cases when rendering a\n :class:`GLLineVector`. It contains logic to generate vertices for every\n vector in the vector :class:`.Image` that is being displayed by a\n ``GLLineVector`` instance.\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>})¶
-
__module__
= 'fsleyes.gl.gllinevector'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-