Panel#

The cdl.core.gui.panel package provides the panel objects for signals and images.

Three types of panels are available:

Signal and Image Panels are called Data Panels and are used to display and handle signals and images in the main window of DataLab.

Data Panels rely on the cdl.core.gui.panel.base.ObjectProp class (managing the object properties) and a set of modules to handle the GUI features:

The Macro Panel is used to display and run macros. It relies on the cdl.core.gui.macroeditor module to handle the macro edition and execution.

Base features#

cdl.core.gui.panel.base.is_plot_item_serializable(item: ShapeTypes) bool#

Return True if plot item is serializable

class cdl.core.gui.panel.base.ObjectProp(panel: BaseDataPanel, paramclass: SignalObj | ImageObj)#

Object handling panel properties

add_button(button)#

Add additional button on bottom of properties panel

set_param_label(param: SignalObj | ImageObj)#

Set computing parameters label

update_properties_from(param: SignalObj | ImageObj | None = None)#

Update properties from signal/image dataset

class cdl.core.gui.panel.base.AbstractPanelMeta(name, bases, namespace, /, **kwargs)#

Mixed metaclass to avoid conflicts

class cdl.core.gui.panel.base.AbstractPanel(parent)#

Object defining DataLab panel interface, based on a vertical QSplitter widget

A panel handle an object list (objects are signals, images, macros, …). Each object must implement cdl.core.gui.ObjItf interface

get_serializable_name(obj: ObjItf) str#

Return serializable name of object

serialize_object_to_hdf5(obj: ObjItf, writer: NativeH5Writer) None#

Serialize object to HDF5 file

deserialize_object_from_hdf5(reader: NativeH5Reader, name: str) ObjItf#

Deserialize object from a HDF5 file

abstract serialize_to_hdf5(writer: NativeH5Writer) None#

Serialize whole panel to a HDF5 file

abstract deserialize_from_hdf5(reader: NativeH5Reader) None#

Deserialize whole panel from a HDF5 file

abstract create_object() ObjItf#

Create and return object

abstract add_object(obj: ObjItf) None#

Add object to panel

abstract remove_all_objects()#

Remove all objects

class cdl.core.gui.panel.base.ResultData(results: list[ResultShape | ResultProperties] = None, xlabels: list[str] = None, ylabels: list[str] = None)#

Result data associated to a shapetype

class cdl.core.gui.panel.base.BaseDataPanel(parent: QWidget)#

Object handling the item list, the selected item properties and plot

closeEvent(event)#

Reimplement QMainWindow method

plot_item_parameters_changed(item: CurveItem | MaskedImageItem | LabelItem) None#

Plot items changed: update metadata of all objects from plot items

plot_item_moved(item: LabelItem, x0: float, y0: float, x1: float, y1: float) None#

Plot item moved: update metadata of all objects from plot items

Parameters:
  • item – Plot item

  • x0 – new x0 coordinate

  • y0 – new y0 coordinate

  • x1 – new x1 coordinate

  • y1 – new y1 coordinate

serialize_object_to_hdf5(obj: SignalObj | ImageObj, writer: NativeH5Writer) None#

Serialize object to HDF5 file

serialize_to_hdf5(writer: NativeH5Writer) None#

Serialize whole panel to a HDF5 file

deserialize_from_hdf5(reader: NativeH5Reader) None#

Deserialize whole panel from a HDF5 file

create_object() SignalObj | ImageObj#

Create object (signal or image)

Returns:

SignalObj or ImageObj object

add_object(obj: SignalObj | ImageObj, group_id: str | None = None, set_current: bool = True) None#

Add object

Parameters:
  • obj – SignalObj or ImageObj object

  • group_id – group id

  • set_current – if True, set the added object as current

remove_all_objects() None#

Remove all objects

setup_panel() None#

Setup panel

get_category_actions(category: ActionCategory) list[QAction]#

Return actions for category

get_context_menu() QMenu#

Update and return context menu

add_group(title: str) ObjectGroup#

Add group

duplicate_object() None#

Duplication signal/image object

copy_metadata() None#

Copy object metadata

paste_metadata() None#

Paste metadata to selected object(s)

remove_object() None#

Remove signal/image object

delete_all_objects() None#

Confirm before removing all objects

delete_metadata(refresh_plot: bool = True, keep_roi: bool | None = None) None#

Delete metadata of selected objects

Parameters:
  • refresh_plot – Refresh plot. Defaults to True.

  • keep_roi – Keep regions of interest, if any. Defaults to None (ask user).

add_annotations_from_items(items: list, refresh_plot: bool = True) None#

Add object annotations (annotation plot items).

Parameters:
  • items – annotation plot items

  • refresh_plot – refresh plot. Defaults to True.

update_metadata_view_settings() None#

Update metadata view settings

copy_titles_to_clipboard() None#

Copy object titles to clipboard (for reproducibility)

new_group() None#

Create a new group

rename_group() None#

Rename a group

abstract get_newparam_from_current(newparam: NewSignalParam | NewImageParam | None = None) NewSignalParam | NewImageParam | None#

Get new object parameters from the current object.

Parameters:

newparam – new object parameters. If None, create a new one.

Returns:

New object parameters

abstract new_object(newparam: NewSignalParam | NewImageParam | None = None, addparam: gds.DataSet | None = None, edit: bool = True, add_to_panel: bool = True) SignalObj | ImageObj | None#

Create a new object (signal/image).

Parameters:
  • newparam – new object parameters

  • addparam – additional parameters

  • edit – Open a dialog box to edit parameters (default: True)

  • add_to_panel – Add object to panel (default: True)

Returns:

New object

set_current_object_title(title: str) None#

Set current object title

load_from_files(filenames: list[str] | None = None) list[SignalObj | ImageObj]#

Open objects from file (signals/images), add them to DataLab and return them.

Parameters:

filenames – File names

Returns:

list of new objects

save_to_files(filenames: list[str] | str | None = None) None#

Save selected objects to files (signal/image).

Parameters:

filenames – File names

handle_dropped_files(filenames: list[str] | None = None) None#

Handle dropped files

Parameters:

filenames – File names

Returns:

None

exec_import_wizard() None#

Execute import wizard

import_metadata_from_file(filename: str | None = None) None#

Import metadata from file (JSON).

Parameters:

filename – File name

export_metadata_from_file(filename: str | None = None) None#

Export metadata to file (JSON).

Parameters:

filename – File name

selection_changed(update_items: bool = False) None#

Object selection changed: update object properties, refresh plot and update object view.

Parameters:

update_items – Update plot items (default: False)

properties_changed() None#

The properties β€˜Apply’ button was clicked: update object properties, refresh plot and update object view.

open_separate_view(oids: list[str] | None = None, edit_annotations: bool = False) PlotDialog | None#

Open separate view for visualizing selected objects

Parameters:
  • oids – Object IDs (default: None)

  • edit_annotations – Edit annotations (default: False)

Returns:

Instance of PlotDialog

manual_refresh() None#

Manual refresh

create_new_dialog(oids: list[str], edit: bool = False, toolbar: bool = True, title: str | None = None, tools: list[GuiTool] | None = None, name: str | None = None, options: dict | None = None) PlotDialog | None#

Create new pop-up signal/image plot dialog.

Parameters:
  • oids – Object IDs

  • edit – Edit mode

  • toolbar – Show toolbar

  • title – Dialog title

  • tools – list of tools to add to the toolbar

  • name – Dialog name

  • options – Plot options

Returns:

QDialog instance

create_new_dialog_for_selection(title: str, name: str, options: dict[str, any] = None, toolbar: bool = False, tools: list[GuiTool] = None) tuple[PlotDialog | None, SignalObj | ImageObj]#

Create new pop-up dialog for the currently selected signal/image.

Parameters:
  • title – Dialog title

  • name – Dialog name

  • options – Plot options

  • toolbar – Show toolbar

  • tools – list of tools to add to the toolbar

Returns:

QDialog instance, selected object

get_roi_dialog(extract: bool, singleobj: bool, add_roi: bool = False) tuple[ROIDataParam, bool] | None#

Get ROI data (array) from specific dialog box.

Parameters:
  • extract – Extract ROI from data

  • singleobj – Single object

  • add_roi – Add ROI immediately after opening the dialog (default: False)

Returns:

ROI data

get_object_with_dialog(title: str, parent: QW.QWidget | None = None) SignalObj | ImageObj | None#

Get object with dialog box.

Parameters:
  • title – Dialog title

  • parent – Parent widget

Returns:

Object (signal or image, or None if dialog was canceled)

add_objprop_buttons() None#

Insert additional buttons in object properties panel

show_results() None#

Show results

plot_results() None#

Plot results

delete_results() None#

Delete results

add_label_with_title(title: str | None = None) None#

Add a label with object title on the associated plot

Parameters:

title – Label title. Defaults to None. If None, the title is the object title.

Signal panel#

class cdl.core.gui.panel.signal.SignalPanel(parent: QW.QWidget, dockableplotwidget: DockablePlotWidget, panel_toolbar: QW.QToolBar)#

Object handling the item list, the selected item properties and plot, specialized for Signal objects

PARAMCLASS#

Signal object

uuid#

Default: None.

Type:

guidata.dataset.dataitems.StringItem

xydata#

Default: None.

Type:

guidata.dataset.dataitems.FloatArrayItem

metadata#

Default: {}.

Type:

guidata.dataset.dataitems.DictItem

title#

Signal title. Default: β€˜Untitled’.

Type:

guidata.dataset.dataitems.StringItem

xlabel#

Title. Default: β€˜β€™.

Type:

guidata.dataset.dataitems.StringItem

xunit#

Default: β€˜β€™.

Type:

guidata.dataset.dataitems.StringItem

ylabel#

Title. Default: β€˜β€™.

Type:

guidata.dataset.dataitems.StringItem

yunit#

Default: β€˜β€™.

Type:

guidata.dataset.dataitems.StringItem

autoscale#

Default: True.

Type:

guidata.dataset.dataitems.BoolItem

xscalelog#

Default: False.

Type:

guidata.dataset.dataitems.BoolItem

xscalemin#

Lower bound. Default: None.

Type:

guidata.dataset.dataitems.FloatItem

xscalemax#

Upper bound. Default: None.

Type:

guidata.dataset.dataitems.FloatItem

yscalelog#

Default: False.

Type:

guidata.dataset.dataitems.BoolItem

yscalemin#

Lower bound. Default: None.

Type:

guidata.dataset.dataitems.FloatItem

yscalemax#

Upper bound. Default: None.

Type:

guidata.dataset.dataitems.FloatItem

alias of SignalObj

classmethod PARAMCLASS.create(uuid: str, xydata: numpy.ndarray, metadata: dict, title: str, xlabel: str, xunit: str, ylabel: str, yunit: str, autoscale: bool, xscalelog: bool, xscalemin: float, xscalemax: float, yscalelog: bool, yscalemin: float, yscalemax: float) cdl.core.model.signal.SignalObj#

Returns a new instance of SignalObj with the fields set to the given values.

Parameters:
  • uuid (str) – Default: None.

  • xydata (numpy.ndarray) – Default: None.

  • metadata (dict) – Default: {}.

  • title (str) – Signal title. Default: β€˜Untitled’.

  • xlabel (str) – Title. Default: β€˜β€™.

  • xunit (str) – Default: β€˜β€™.

  • ylabel (str) – Title. Default: β€˜β€™.

  • yunit (str) – Default: β€˜β€™.

  • autoscale (bool) – Default: True.

  • xscalelog (bool) – Default: False.

  • xscalemin (float) – Lower bound. Default: None.

  • xscalemax (float) – Upper bound. Default: None.

  • yscalelog (bool) – Default: False.

  • yscalemin (float) – Lower bound. Default: None.

  • yscalemax (float) – Upper bound. Default: None.

Returns:

New instance of SignalObj.

IO_REGISTRY#

alias of SignalIORegistry

ROIDIALOGCLASS#

alias of SignalROIEditor

get_newparam_from_current(newparam: NewSignalParam | None = None, title: str | None = None) NewSignalParam | None#

Get new object parameters from the current object.

Parameters:
  • newparam (guidata.dataset.DataSet) – new object parameters. If None, create a new one.

  • title – new object title. If None, use the current object title, or the default title.

Returns:

New object parameters

new_object(newparam: NewSignalParam | None = None, addparam: gds.DataSet | None = None, edit: bool = True, add_to_panel: bool = True) SignalObj | None#

Create a new object (signal).

Parameters:
  • newparam (guidata.dataset.DataSet) – new object parameters

  • addparam (guidata.dataset.DataSet) – additional parameters

  • edit (bool) – Open a dialog box to edit parameters (default: True)

  • add_to_panel (bool) – Add the new object to the panel (default: True)

Returns:

New object

toggle_anti_aliasing(state: bool) None#

Toggle anti-aliasing on/off

Parameters:

state – state of the anti-aliasing

reset_curve_styles() None#

Reset curve styles

Image panel#

class cdl.core.gui.panel.image.ImagePanel(parent: QW.QWidget, dockableplotwidget: DockablePlotWidget, panel_toolbar: QW.QToolBar)#

Object handling the item list, the selected item properties and plot, specialized for Image objects

PARAMCLASS#

Image object

uuid#

Default: None.

Type:

guidata.dataset.dataitems.StringItem

data#

Default: None.

Type:

guidata.dataset.dataitems.FloatArrayItem

metadata#

Default: {}.

Type:

guidata.dataset.dataitems.DictItem

x0#

X0. Default: 0.0.

Type:

guidata.dataset.dataitems.FloatItem

y0#

Y0. Default: 0.0.

Type:

guidata.dataset.dataitems.FloatItem

dx#

Ξ”x. Float, non zero. Default: 1.0.

Type:

guidata.dataset.dataitems.FloatItem

dy#

Ξ”y. Float, non zero. Default: 1.0.

Type:

guidata.dataset.dataitems.FloatItem

title#

Image title. Default: β€˜Untitled’.

Type:

guidata.dataset.dataitems.StringItem

xlabel#

Title. Default: β€˜β€™.

Type:

guidata.dataset.dataitems.StringItem

xunit#

Default: β€˜β€™.

Type:

guidata.dataset.dataitems.StringItem

ylabel#

Title. Default: β€˜β€™.

Type:

guidata.dataset.dataitems.StringItem

yunit#

Default: β€˜β€™.

Type:

guidata.dataset.dataitems.StringItem

zlabel#

Title. Default: β€˜β€™.

Type:

guidata.dataset.dataitems.StringItem

zunit#

Default: β€˜β€™.

Type:

guidata.dataset.dataitems.StringItem

autoscale#

Default: True.

Type:

guidata.dataset.dataitems.BoolItem

xscalelog#

Default: False.

Type:

guidata.dataset.dataitems.BoolItem

xscalemin#

Lower bound. Default: None.

Type:

guidata.dataset.dataitems.FloatItem

xscalemax#

Upper bound. Default: None.

Type:

guidata.dataset.dataitems.FloatItem

yscalelog#

Default: False.

Type:

guidata.dataset.dataitems.BoolItem

yscalemin#

Lower bound. Default: None.

Type:

guidata.dataset.dataitems.FloatItem

yscalemax#

Upper bound. Default: None.

Type:

guidata.dataset.dataitems.FloatItem

zscalemin#

Lower bound. Default: None.

Type:

guidata.dataset.dataitems.FloatItem

zscalemax#

Upper bound. Default: None.

Type:

guidata.dataset.dataitems.FloatItem

alias of ImageObj

classmethod PARAMCLASS.create(uuid: str, data: numpy.ndarray, metadata: dict, x0: float, y0: float, dx: float, dy: float, title: str, xlabel: str, xunit: str, ylabel: str, yunit: str, zlabel: str, zunit: str, autoscale: bool, xscalelog: bool, xscalemin: float, xscalemax: float, yscalelog: bool, yscalemin: float, yscalemax: float, zscalemin: float, zscalemax: float) cdl.core.model.image.ImageObj#

Returns a new instance of ImageObj with the fields set to the given values.

Parameters:
  • uuid (str) – Default: None.

  • data (numpy.ndarray) – Default: None.

  • metadata (dict) – Default: {}.

  • x0 (float) – X0. Default: 0.0.

  • y0 (float) – Y0. Default: 0.0.

  • dx (float) – Ξ”x. Float, non zero. Default: 1.0.

  • dy (float) – Ξ”y. Float, non zero. Default: 1.0.

  • title (str) – Image title. Default: β€˜Untitled’.

  • xlabel (str) – Title. Default: β€˜β€™.

  • xunit (str) – Default: β€˜β€™.

  • ylabel (str) – Title. Default: β€˜β€™.

  • yunit (str) – Default: β€˜β€™.

  • zlabel (str) – Title. Default: β€˜β€™.

  • zunit (str) – Default: β€˜β€™.

  • autoscale (bool) – Default: True.

  • xscalelog (bool) – Default: False.

  • xscalemin (float) – Lower bound. Default: None.

  • xscalemax (float) – Upper bound. Default: None.

  • yscalelog (bool) – Default: False.

  • yscalemin (float) – Lower bound. Default: None.

  • yscalemax (float) – Upper bound. Default: None.

  • zscalemin (float) – Lower bound. Default: None.

  • zscalemax (float) – Upper bound. Default: None.

Returns:

New instance of ImageObj.

IO_REGISTRY#

alias of ImageIORegistry

ROIDIALOGCLASS#

alias of ImageROIEditor

properties_changed() None#

The properties β€˜Apply’ button was clicked: updating signal

plot_lut_changed(plot: BasePlot) None#

The LUT of the plot has changed: updating image objects accordingly

Parameters:

plot – Plot object

get_newparam_from_current(newparam: NewImageParam | None = None, title: str | None = None) NewImageParam | None#

Get new object parameters from the current object.

Parameters:
  • newparam (guidata.dataset.DataSet) – new object parameters. If None, create a new one.

  • title – new object title. If None, use the current object title, or the default title.

Returns:

New object parameters

new_object(newparam: NewImageParam | None = None, addparam: gds.DataSet | None = None, edit: bool = True, add_to_panel: bool = True) ImageObj | None#

Create a new object (image).

Parameters:
  • newparam (Daguidata.dataset.datatypes.DataSettaSet) – new object parameters

  • addparam (guidata.dataset.DataSet) – additional parameters

  • edit (bool) – Open a dialog box to edit parameters (default: True)

  • add_to_panel (bool) – Add the object to the panel (default: True)

Returns:

New object

delete_metadata(refresh_plot: bool = True, keep_roi: bool | None = None) None#

Delete metadata of selected objects

Parameters:
  • refresh_plot – Refresh plot. Defaults to True.

  • keep_roi – Keep regions of interest, if any. Defaults to None (ask user).

toggle_show_contrast(state: bool) None#

Toggle show contrast option

Macro panel#

class cdl.core.gui.panel.macro.MacroTabs(parent=None)#

Macro tabwidget

Parameters:

parent (QWidget) – Parent widget

clear() None#

Override Qt method

contextMenuEvent(event)#

Override Qt method

add_tab(macro: Macro) int#

Add tab

Parameters:

macro – Macro object

Returns:

Number of the tab (starting at 1)

Return type:

int

remove_tab(number: int) None#

Remove tab

Parameters:

number – Number of the tab (starting at 1)

get_widget(number: int) CodeEditor#

Return macro editor widget at number

Parameters:

number – Number of the tab (starting at 1)

Returns:

Macro editor widget

set_current_number(number: int) None#

Set current tab number

Parameters:

number – Number of the tab (starting at 1)

get_current_number() int#

Return current tab number

Returns:

Number of the tab (starting at 1)

Return type:

int

set_tab_title(number: int, name: str) None#

Set tab title

Parameters:
  • number – Number of the tab (starting at 1)

  • name – Macro name

class cdl.core.gui.panel.macro.MacroPanel(parent: QWidget | None = None)#

Macro Panel widget

Parameters:

parent (QWidget) – Parent widget

get_serializable_name(obj: Macro) str#

Return serializable name of object

serialize_to_hdf5(writer: NativeH5Writer) None#

Serialize whole panel to a HDF5 file

Parameters:

writer – HDF5 writer

deserialize_from_hdf5(reader: NativeH5Reader) None#

Deserialize whole panel from a HDF5 file

Parameters:

reader – HDF5 reader

create_object() Macro#

Create object.

Returns:

Macro object

add_object(obj: Macro) None#

Add object.

Parameters:

obj – Macro object

remove_all_objects() None#

Remove all objects

setup_actions() None#

Setup macro menu actions

get_macro(number_or_title: int | str | None = None) Macro | None#

Return macro at number (if number is None, return current macro)

Parameters:

number – Number of the macro (starting at 1) or title of the macro. Defaults to None (current macro).

Returns:

Macro object or None (if not found)

get_number_from_title(title: str) int | None#

Return macro number from title

Parameters:

title – Title of the macro

Returns:

Number of the macro (starting at 1) or None (if not found)

get_number_from_macro(macro: Macro) int | None#

Return macro number from macro object

Parameters:

macro – Macro object

Returns:

Number of the macro (starting at 1) or None (if not found)

get_macro_titles() list[str]#

Return list of macro titles

macro_contents_changed() None#

One of the macro contents has changed

run_macro(number_or_title: int | str | None = None) None#

Run current macro

Parameters:

number – Number of the macro (starting at 1). Defaults to None (run current macro, or does nothing if there is no macro).

stop_macro(number_or_title: int | str | None = None) None#

Stop current macro

Parameters:

number – Number of the macro (starting at 1). Defaults to None (run current macro, or does nothing if there is no macro).

macro_state_changed(orig_macro: Macro, state: bool) None#

Macro state has changed (True: started, False: stopped)

Parameters:
  • orig_macro – Macro object

  • state – State of the macro

add_macro() Macro#

Add macro, optionally with name

Returns:

Macro object

macro_name_changed(name: str) None#

Macro name has been changed

Parameters:

name – New name of the macro

rename_macro(number: int | None = None, title: str | None = None) None#

Rename macro

Parameters:
  • number – Number of the macro (starting at 1). Defaults to None.

  • title – Title of the macro. Defaults to None.

export_macro_to_file(number_or_title: int | str | None = None, filename: str | None = None) None#

Export macro to file

Parameters:
  • number_or_title – Number of the macro (starting at 1) or title of the macro. Defaults to None.

  • filename – Filename. Defaults to None.

Raises:

ValueError – If title is not found

import_macro_from_file(filename: str | None = None) int#

Import macro from file

Parameters:

filename – Filename. Defaults to None.

Returns:

Number of the macro (starting at 1)

remove_macro(number_or_title: int | str | None = None) None#

Remove macro

Parameters:

number_or_title – Number of the macro (starting at 1) or title of the macro. Defaults to None.