fsleyes.gl.gllabel
This module provides the GLLabel
class, which implements
functionality to render an Image
overlay as a label/atlas image.
- class fsleyes.gl.gllabel.GLLabel(image, overlayList, displayCtx, canvas, threedee)[source]
Bases:
fsleyes.gl.glimageobject.GLImageObject
The
GLLabel
class is aGLImageObject
which encapsulates the logic required to render anImage
overlay as a label image. Within the image, each contiguous region with the same label value is rendered in the same colour. Regions may be shown either with a filled colour, or with a border around them.When created, a
GLLabel
instance assumes that the providedImage
instance has aDisplay.overlayType
oflabel
, and that its associatedDisplay
instance contains aLabelOpts
instance, containing label-specific display properties.An
ImageTexture
is used to store theImage
data, and aLookupTableTexture
used to store theLookupTable
(defined by theLabelOpts.lut
property). OpenGL version-specific modules (gl14.gllabel_funcs
andgl21.gllabel_funcs
) are used to configure the vertex/fragment shader programs used for rendering.The
GLLabel
class is modelled upon theGLVolume
class, and the version specific modules for theGLLabel
class must provide the same set of functions that are required by theGLVolume
class.- __init__(image, overlayList, displayCtx, canvas, threedee)[source]
Create a
GLLabel
.- Parameters
image – The
Image
instance.overlayList – The
OverlayList
displayCtx – The
DisplayContext
managing the scene.canvas – The canvas doing the drawing.
threedee – 2D or 3D rendering
- destroy()[source]
Must be called when this
GLLabel
is no longer needed. Destroys theImageTexture
andLookupTableTexture
.
- updateShaderState(*args, **kwargs)[source]
Calls
gl14.gllabel_funcs.updateShaderState()
orgl21.gllabel_funcs.updateShaderState()
, andNotifier.notify()
. Usesidle.idleWhen()
to ensure that they don’t get called untilready()
returnsTrue
.
- addListeners()[source]
Called by
__init__()
. Adds listeners to several properties of theDisplay
andLabelOpts
instances, so the OpenGL representation can be updated when they change.
- removeListeners()[source]
Called by
destroy()
. Removes all of the listeners that were added byaddListeners()
.
- refreshImageTexture()[source]
Makes sure that the
ImageTexture
, used to store theImage
data, is up to date.
- refreshLutTexture(*a)[source]
Refreshes the
LookupTableTexture
which stores theLookupTable
used to colour the overlay.
- registerLut()[source]
Registers a listener on the current
LookupTable
instance.
- preDraw(xform=None, bbox=None)[source]
Binds the
ImageTexture
andLookupTableTexture
, and calls the version-dependentpreDraw
function.
- postDraw(xform=None, bbox=None)[source]
Unbinds the
ImageTexture
andLookupTableTexture
, and calls the version-dependentpostDraw
function.
- __lutChanged(*a)
Called when the
LabelOpts.lut
property changes. Re-creates theLookupTableTexture
.
- __colourPropChanged(*a)
Called when a
Display
property changes (e.g.alpha
). Refreshes the LUT texture.
- __imagePropChanged(*a)
Called when the
NiftiOpts.volume
property changes. Updates theimageTexture
and callsupdateShaderState()
.
- __imageSyncChanged(*a)
Called when the
NiftiOpts.volume
property is synchronised or un-synchronised. CallsrefreshImageTexture()
andupdateShaderState()
.
- __imageTextureChanged(*a)
Called when the
ImageTexture
containing the image data changes. CallsupdateShaderState()
.
- __annotations__ = {}
- __module__ = 'fsleyes.gl.gllabel'