fsleyes.plugins.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.plugins.controls.lookuptablepanel.LookupTablePanel(parent, overlayList, displayCtx, viewPanel)[source]

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.

static supportedViews()[source]

The LookupTablePanel is restricted for use with OrthoPanel, LightBoxPanel and Scene3DPanel views.

static defaultLayout()[source]

Returns a dictionary containing layout settings to be passed to ViewPanel.togglePanel.

__init__(parent, overlayList, displayCtx, viewPanel)[source]

Create a LookupTablePanel.

Parameters
destroy()[source]

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

__updateLutChoices()

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

__createLabelList()

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

__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.

__lutSaveStateChanged(*a)

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

__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.

__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.

__onLutChoice(ev)

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

__onSelectAll(ev)

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

__onSelectNone(ev)

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

__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.

__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.

__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.

__onSaveLut(ev)

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

__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.

__onLabelRemove(ev)

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

__selectedOverlayChanged(*a)

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

__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.

__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).

__module__ = 'fsleyes.plugins.controls.lookuptablepanel'
fsleyes.plugins.controls.lookuptablepanel.promptForLutName(initial=None)[source]

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

class fsleyes.plugins.controls.lookuptablepanel.LabelWidget(lutPanel, lut, label)[source]

Bases: __main__.docbuilder.run.<locals>.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)[source]

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.plugins.controls.lookuptablepanel'
class fsleyes.plugins.controls.lookuptablepanel.LutLabelDialog(parent, value, name, colour)[source]

Bases: __main__.docbuilder.run.<locals>.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)[source]

Create a LutLabelDialog.

Parameters

parent – The wx parent object.

GetValue()[source]

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()[source]

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()[source]

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.

__onOk(ev)

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

__onCancel(ev)

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

__module__ = 'fsleyes.plugins.controls.lookuptablepanel'