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.GLImageObjectThe
GLLabelclass is aGLImageObjectwhich encapsulates the logic required to render anImageoverlay 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
GLLabelinstance assumes that the providedImageinstance has aDisplay.overlayTypeoflabel, and that its associatedDisplayinstance contains aLabelOptsinstance, containing label-specific display properties.An
ImageTextureis used to store theImagedata, and aLookupTableTextureused to store theLookupTable(defined by theLabelOpts.lutproperty). OpenGL version-specific modules (gl14.gllabel_funcsandgl21.gllabel_funcs) are used to configure the vertex/fragment shader programs used for rendering.The
GLLabelclass is modelled upon theGLVolumeclass, and the version specific modules for theGLLabelclass must provide the same set of functions that are required by theGLVolumeclass.-
__init__(image, overlayList, displayCtx, canvas, threedee)[source]¶ Create a
GLLabel.- Parameters
image – The
Imageinstance.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
GLLabelis no longer needed. Destroys theImageTextureandLookupTableTexture.
-
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 theDisplayandLabelOptsinstances, 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 theImagedata, is up to date.
-
refreshLutTexture(*a)[source]¶ Refreshes the
LookupTableTexturewhich stores theLookupTableused to colour the overlay.
-
registerLut()[source]¶ Registers a listener on the current
LookupTableinstance.
-
preDraw(xform=None, bbox=None)[source]¶ Binds the
ImageTextureandLookupTableTexture, and calls the version-dependentpreDrawfunction.
-
postDraw(xform=None, bbox=None)[source]¶ Unbinds the
ImageTextureandLookupTableTexture, and calls the version-dependentpostDrawfunction.
-
_GLLabel__colourPropChanged(*a)¶ Called when a
Displayproperty changes (e.g.alpha). Refreshes the LUT texture.
-
_GLLabel__imagePropChanged(*a)¶ Called when the
NiftiOpts.volumeproperty changes. Updates theimageTextureand callsupdateShaderState().
-
_GLLabel__imageSyncChanged(*a)¶ Called when the
NiftiOpts.volumeproperty is synchronised or un-synchronised. CallsrefreshImageTexture()andupdateShaderState().
-
_GLLabel__imageTextureChanged(*a)¶ Called when the
ImageTexturecontaining the image data changes. CallsupdateShaderState().
-
_GLLabel__lutChanged(*a)¶ Called when the
LabelOpts.lutproperty changes. Re-creates theLookupTableTexture.
-
__module__= 'fsleyes.gl.gllabel'¶
-