fsleyes.controls.lookuptablepanel

This module provides the LookupTablePanel, a FSLeyes control panel which allows the user to manage lookup tables. See the colourmaps module for more details on lookup tables.

A few other classes and functions are defined in this module, all for use by the LookupTablePanel:

promptForLutName Prompts the user to enter a name for a newly created LookupTable.
LabelWidget A LabelWidget is shown for each label of the LookupTable which is currently displayed on a LookupTablePanel.
LutLabelDialog A dialog which is displayed when the user adds a new label to the LookupTable currently displayed in the LookupTablePanel.
class fsleyes.controls.lookuptablepanel.LookupTablePanel(parent, overlayList, displayCtx, frame)

Bases: fsleyes.controls.controlpanel.ControlPanel

A LookupTablePanel is a ControlPanel which allows users to manage LookupTable instances. A LookupTablePanel looks something like this:

_images/lookuptablepanel.png

A LookupTablePanel allows the user to do the following:

  • Add/remove labels to/from a LookupTable.
  • Change the colour, name, and visibility of a label in a LookupTable.
  • Create a new LookupTable, or copy an existing one.
  • Save/load a LookupTable to/from a file.

The LookupTablePanel keeps track of the currently selected overlay (see the DisplayContext.selectedOverlay property). If the overlay is associated with a LabelOpts instance, its Labelopts.lut property will be updated when the LookupTable is changed through the LookupTablePanel, and vice versa.

__init__(parent, overlayList, displayCtx, frame)

Create a LookupTablePanel.

Parameters:
destroy()

Must be called when this LookupTablePanel is no longer needed. Removes some property listeners, and calls the ControlPanel.destroy() method.

_LookupTablePanel__createLabelList()

Refreshes the contents of the class:.LookupTable label list, from the currently selected LookupTable.

_LookupTablePanel__lutChanged(*a)

Called when the LabelOpts.lut property associated with the currently selected overlay changes. Changes the LookupTable displayed on this LookupTablePanel (see the __setLut() method).

_LookupTablePanel__lutLabelAdded(lut, topic, label)

Called when the current LookupTable sends an 'added' notification, indicating that a label has been added. Updates the list of displayed labels.

_LookupTablePanel__lutLabelRemoved(lut, topic, label)

Called when the current LookupTable sends a 'removed' notification, indicating that a label has been removed. Updates the list of displayed labels.

_LookupTablePanel__lutSaveStateChanged(*a)

Called when the LookupTable.saved property of the current LookupTable instance changes. Sets the state of the save button accordingly.

_LookupTablePanel__onCopyLut(ev)

Called when the user presses the Copy LUT button.

Prompts the user to enter a name (via promptForLutName()), and then creates and registers a new LookupTable instance which is initialised with the same labels as the previously selected LookupTable. Updates this LookupTablePanel via the __updateLutChoices() and __setLut() methods.

_LookupTablePanel__onLabelAdd(ev)

Called when the user pushes the add button on the lookup table label list. Displays a LutLabelDialog, prompting the user to select a name, value and colour, and then adds a new label to the current LookupTable instance.

_LookupTablePanel__onLabelRemove(ev)

Called when the user pushes the remove button on the lookup table label list. Removes the selected label from the current LookupTable.

_LookupTablePanel__onLoadLut(ev)

Called when the user presses the Load LUT button. Does the following:

  • Prompts the user to select a LUT file with a wx.FileDialog
  • Prompts the user to enter a name for the LUT via the promptForLutName() function.
  • Creates and registers a new LookupTable instance, initialising it with the selected file.
  • Updates this LookupTablePanel via the __updateLutChoices() and __setLut() methods.
_LookupTablePanel__onLutChoice(ev)

Called when the user changes the selected LookupTable via the lookup table drop down box. See the __setLut() method..

_LookupTablePanel__onNewLut(ev)

Called when the user presses the New LUT button.

Prompts the user to enter a name (via promptForLutName()), and then creates and registers a new LookupTable instance. Updates this LookupTablePanel via the __updateLutChoices() and __setLut() methods.

_LookupTablePanel__onSaveLut(ev)

Called when the user presses the Save LUT button. Makes sure that the current LookupTable is saved (see the colourmaps.installLookupTable() function).

_LookupTablePanel__onSelectAll(ev)

Called when the user pushes the Select all button. Enables every label on the current LUT.

_LookupTablePanel__onSelectNone(ev)

Called when the user pushes the Select none button. Disables every label on the current LUT.

_LookupTablePanel__overlayTypeChanged(*a)

Called when the Display.overlayType property of the currently selected overlay changes. If the DisplayOpts instance associated with the new overlay type is a LabelOpts, a listener is addd to its lut property.

_LookupTablePanel__selectedOverlayChanged(*a)

Called when the OverlayList or DisplayContext.selectedOverlay changes. Refreshes the LookupTablePanel accordingly.

_LookupTablePanel__setLut(lut)

Updates this LookupTablePanel to display the labels for the given lut (assumed to be a LookupTable instance).

If the currently selected overlay is associated with a LabelOpts instance, its LabelOpts.lut property is set to the new LookupTable.

_LookupTablePanel__updateLutChoices()

Refreshes the contents of the lookup table drop down box, using the LookupTable instances returned by the colourmaps.getLookupTables() function.

__module__ = 'fsleyes.controls.lookuptablepanel'
fsleyes.controls.lookuptablepanel.promptForLutName(initial=None)

Prompts the user to enter a name for a newly created LookupTable.

class fsleyes.controls.lookuptablepanel.LabelWidget(lutPanel, lut, label)

Bases: __main__.MockClass

A LabelWidget is shown for each label of the LookupTable which is currently displayed on a LookupTablePanel. A LabelWidget allows the user to change the colour and visibility of the label value.

__init__(lutPanel, lut, label)

Create a LabelWidget.

Parameters:
  • lutPanel – The LookupTablePanel that is displaying this LabelWidget.
  • lut – The LookupTable currently being displayed.
  • label – The LutLabel that this LabelWidget is associated with.
__module__ = 'fsleyes.controls.lookuptablepanel'
class fsleyes.controls.lookuptablepanel.LutLabelDialog(parent, value, name, colour)

Bases: __main__.MockClass

A dialog which is displayed when the user adds a new label to the LookupTable currently displayed in the LookupTablePanel.

Prompts the user to enter a label value, name, and colour. After the dialog is dismissed, the entered information is available via the following methods:

GetValue Returns the value that was entered by the user.
GetName Returns the name that was entered by the user.
GetColour Returns the colour that was entered by the user.
__init__(parent, value, name, colour)

Create a LutLabelDialog.

Parameters:parent – The wx parent object.
GetValue()

Returns the value that was entered by the user. Or, returns None if the user cancelled the dialog, or the dialog has not yet been closed.

GetName()

Returns the name that was entered by the user. Or, returns None if the user cancelled the dialog, or the dialog has not yet been closed.

GetColour()

Returns the colour that was entered by the user. Or, returns None if the user cancelled the dialog, or the dialog has not yet been closed.

_LutLabelDialog__onCancel(ev)

Called when the user cancells the dialog. Closes the dialog.

_LutLabelDialog__onOk(ev)

Called when the user confirms the dialog. Saves the name, colour, and value that were entered, and closes the dialog.

__module__ = 'fsleyes.controls.lookuptablepanel'