Panel#
The cdl.core.gui.panel
package provides the panel objects
for signals and images.
Three types of panels are available:
cdl.core.gui.panel.signal.SignalPanel
: Signal panelcdl.core.gui.panel.image.ImagePanel
: Image panelcdl.core.gui.panel.macro.MacroPanel
: Macro panel
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:
cdl.core.gui.actionhandler
: Application actions (menus, toolbars, context menu)cdl.core.gui.objectview
: Widgets to display object (signal/image) treescdl.core.gui.plothandler
: PlotPy items for representing signals and imagescdl.core.gui.processor
: Processor (computation)cdl.core.gui.panel.roieditor
: ROI editor
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 [source]#
Return True if plot item is serializable
- class cdl.core.gui.panel.base.ObjectProp(panel: BaseDataPanel, paramclass: SignalObj | ImageObj)[source]#
Object handling panel properties
- class cdl.core.gui.panel.base.AbstractPanelMeta(name, bases, namespace, /, **kwargs)[source]#
Mixed metaclass to avoid conflicts
- class cdl.core.gui.panel.base.AbstractPanel(parent)[source]#
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- serialize_object_to_hdf5(obj: ObjItf, writer: NativeH5Writer) None [source]#
Serialize object to HDF5 file
- deserialize_object_from_hdf5(reader: NativeH5Reader, name: str) ObjItf [source]#
Deserialize object from a HDF5 file
- abstract serialize_to_hdf5(writer: NativeH5Writer) None [source]#
Serialize whole panel to a HDF5 file
- class cdl.core.gui.panel.base.ResultData(results: list[ResultShape | ResultProperties] = None, xlabels: list[str] = None, ylabels: list[str] = None)[source]#
Result data associated to a shapetype
- cdl.core.gui.panel.base.create_resultdata_dict(objs: list[SignalObj | ImageObj]) dict[str, ResultData] [source]#
Return result data dictionary
- Parameters:
objs – List of objects
- Returns:
keys are result categories, values are ResultData
- Return type:
Result data dictionary
- class cdl.core.gui.panel.base.BaseDataPanel(parent: QWidget)[source]#
Object handling the item list, the selected item properties and plot
- plot_item_parameters_changed(item: CurveItem | MaskedImageItem | LabelItem) None [source]#
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 [source]#
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: TypeObj, writer: NativeH5Writer) None [source]#
Serialize object to HDF5 file
- deserialize_from_hdf5(reader: NativeH5Reader) None [source]#
Deserialize whole panel from a HDF5 file
- create_object() TypeObj [source]#
Create object (signal or image)
- Returns:
SignalObj or ImageObj object
- add_object(obj: TypeObj, group_id: str | None = None, set_current: bool = True) None [source]#
Add object
- Parameters:
obj – SignalObj or ImageObj object
group_id – group id
set_current – if True, set the added object as current
- get_category_actions(category: ActionCategory) list[QAction] [source]#
Return actions for category
Update and return context menu
- remove_object(force: bool = False) None [source]#
Remove signal/image object
- Parameters:
force – if True, remove object without confirmation. Defaults to False.
- delete_metadata(refresh_plot: bool = True, keep_roi: bool | None = None) None [source]#
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 [source]#
Add object annotations (annotation plot items).
- Parameters:
items – annotation plot items
refresh_plot – refresh plot. Defaults to True.
- rename_group(new_name: str | None = None) None [source]#
Rename a group
- Parameters:
new_name – new group name. Defaults to None (ask user).
- abstract get_newparam_from_current(newparam: NewSignalParam | NewImageParam | None = None) NewSignalParam | NewImageParam | None [source]#
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) TypeObj | None [source]#
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
- load_from_files(filenames: list[str] | None = None) list[TypeObj] [source]#
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 [source]#
Save selected objects to files (signal/image).
- Parameters:
filenames – File names
- handle_dropped_files(filenames: list[str] | None = None) None [source]#
Handle dropped files
- Parameters:
filenames – File names
- Returns:
None
- import_metadata_from_file(filename: str | None = None) None [source]#
Import metadata from file (JSON).
- Parameters:
filename – File name
- export_metadata_from_file(filename: str | None = None) None [source]#
Export metadata to file (JSON).
- Parameters:
filename – File name
- selection_changed(update_items: bool = False) None [source]#
Object selection changed: update object properties, refresh plot and update object view.
- Parameters:
update_items – Update plot items (default: False)
- properties_changed() None [source]#
The properties ‘Apply’ button was clicked: update object properties, refresh plot and update object view.
- add_plot_items_to_dialog(dlg: PlotDialog, oids: list[str]) None [source]#
Add plot items to dialog
- Parameters:
dlg – Dialog
oids – Object IDs
- open_separate_view(oids: list[str] | None = None, edit_annotations: bool = False) PlotDialog | None [source]#
Open separate view for visualizing selected objects
- Parameters:
oids – Object IDs (default: None)
edit_annotations – Edit annotations (default: False)
- Returns:
Instance of PlotDialog
- create_new_dialog(edit: bool = False, toolbar: bool = True, title: str | None = None, name: str | None = None, options: dict | None = None) PlotDialog | None [source]#
Create new pop-up signal/image plot dialog.
- Parameters:
edit – Edit mode
toolbar – Show toolbar
title – Dialog title
name – Dialog object name
options – Plot options
- Returns:
Plot dialog instance
- get_roi_editor_output(extract: bool) tuple[TypeROI, bool] | None [source]#
Get ROI data (array) from specific dialog box.
- Parameters:
extract – Extract ROI from data
- Returns:
A tuple containing the ROI object and a boolean indicating whether the dialog was accepted or not.
- get_objects_with_dialog(title: str, comment: str = '', nb_objects: int = 1, parent: QWidget | None = None) TypeObj | None [source]#
Get object with dialog box.
- Parameters:
title – Dialog title
comment – Optional dialog comment
nb_objects – Number of objects to select
parent – Parent widget
- Returns:
Object(s) (signal(s) or image(s), or None if dialog was canceled)
Signal panel#
- class cdl.core.gui.panel.signal.SignalPanel(parent: QW.QWidget, dockableplotwidget: DockablePlotWidget, panel_toolbar: QW.QToolBar)[source]#
Object handling the item list, the selected item properties and plot, specialized for Signal objects
- PARAMCLASS#
Signal object
- uuid#
Default: None.
- xydata#
Default: None.
- metadata#
Default: {}.
- title#
Signal title. Default: ‘Untitled’.
- xlabel#
Title. Default: ‘’.
- xunit#
Default: ‘’.
- ylabel#
Title. Default: ‘’.
- yunit#
Default: ‘’.
- autoscale#
Default: True.
- xscalelog#
Default: False.
- xscalemin#
Lower bound. Default: None.
- xscalemax#
Upper bound. Default: None.
- yscalelog#
Default: False.
- yscalemin#
Lower bound. Default: None.
- yscalemax#
Upper bound. Default: None.
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
- static get_roieditor_class() Type[SignalROIEditor] [source]#
Return ROI editor class
- get_newparam_from_current(newparam: NewSignalParam | None = None, title: str | None = None) NewSignalParam | None [source]#
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 [source]#
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
Image panel#
- class cdl.core.gui.panel.image.ImagePanel(parent: QW.QWidget, dockableplotwidget: DockablePlotWidget, panel_toolbar: QW.QToolBar)[source]#
Object handling the item list, the selected item properties and plot, specialized for Image objects
- PARAMCLASS#
Image object
- uuid#
Default: None.
- data#
Default: None.
- metadata#
Default: {}.
- x0#
X0. Default: 0.0.
- y0#
Y0. Default: 0.0.
- dx#
Δx. Float, non zero. Default: 1.0.
- dy#
Δy. Float, non zero. Default: 1.0.
- title#
Image title. Default: ‘Untitled’.
- xlabel#
Title. Default: ‘’.
- xunit#
Default: ‘’.
- ylabel#
Title. Default: ‘’.
- yunit#
Default: ‘’.
- zlabel#
Title. Default: ‘’.
- zunit#
Default: ‘’.
- autoscale#
Default: True.
- xscalelog#
Default: False.
- xscalemin#
Lower bound. Default: None.
- xscalemax#
Upper bound. Default: None.
- yscalelog#
Default: False.
- yscalemin#
Lower bound. Default: None.
- yscalemax#
Upper bound. Default: None.
- zscalemin#
Lower bound. Default: None.
- zscalemax#
Upper bound. Default: None.
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
- static get_roieditor_class() Type[ImageROIEditor] [source]#
Return ROI editor class
- plot_lut_changed(plot: BasePlot) None [source]#
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 [source]#
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 [source]#
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
Macro panel#
- class cdl.core.gui.panel.macro.MacroTabs(parent=None)[source]#
Macro tabwidget
- Parameters:
parent (QWidget) – Parent widget
- add_tab(macro: Macro) int [source]#
Add tab
- Parameters:
macro – Macro object
- Returns:
Number of the tab (starting at 1)
- Return type:
- remove_tab(number: int) None [source]#
Remove tab
- Parameters:
number – Number of the tab (starting at 1)
- get_widget(number: int) CodeEditor [source]#
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 [source]#
Set current tab number
- Parameters:
number – Number of the tab (starting at 1)
- class cdl.core.gui.panel.macro.MacroPanel(parent: QWidget | None = None)[source]#
Macro Panel widget
- Parameters:
parent (QWidget) – Parent widget
- serialize_to_hdf5(writer: NativeH5Writer) None [source]#
Serialize whole panel to a HDF5 file
- Parameters:
writer – HDF5 writer
- deserialize_from_hdf5(reader: NativeH5Reader) None [source]#
Deserialize whole panel from a HDF5 file
- Parameters:
reader – HDF5 reader
- get_macro(number_or_title: int | str | None = None) Macro | None [source]#
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 [source]#
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 [source]#
Return macro number from macro object
- Parameters:
macro – Macro object
- Returns:
Number of the macro (starting at 1) or None (if not found)
- run_macro(number_or_title: int | str | None = None) None [source]#
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 [source]#
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 [source]#
Macro state has changed (True: started, False: stopped)
- Parameters:
orig_macro – Macro object
state – State of the macro
- macro_name_changed(name: str) None [source]#
Macro name has been changed
- Parameters:
name – New name of the macro
- rename_macro(number: int | None = None, title: str | None = None) None [source]#
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 [source]#
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