Plot handler#

The datalab.gui.plothandler module provides plot handlers for signal and image panels, that is, classes handling PlotPy plot items for representing signals and images.

Signal plot handler#

class datalab.gui.plothandler.SignalPlotHandler(panel: BaseDataPanel, plotwidget: PlotWidget)[source]#

Object handling signal plot items, plot dialogs, plot options

toggle_anti_aliasing(state: bool) None[source]#

Toggle anti-aliasing

Parameters:

state – if True, enable anti-aliasing

get_plot_options() PlotOptions[source]#

Return standard signal/image plot options

refresh_plot(what: str, update_items: bool = True, force: bool = False, only_visible: bool = True, only_existing: bool = False) None[source]#

Refresh plot and configure datetime axis if needed.

This override adds automatic datetime axis configuration when at least one of the displayed signals has a datetime X-axis.

Parameters:
  • what – string describing the objects to refresh

  • update_items – if True, update the items

  • force – if True, force refresh even if auto refresh is disabled

  • only_visible – if True, only refresh visible items

  • only_existing – if True, only refresh existing items

add_shapes(oid: str, do_autoscale: bool = False) None#

Add geometric shape items associated to computed results and annotations, for the object with the given uuid

cleanup_dataview() None#

Clean up data view

clear() None#

Clear plot items

get(key: str, default: TypePlotItem | None = None) TypePlotItem | None#

Return item associated to object uuid. If the key is not found, default is returned if given, otherwise None is returned.

get_existing_oids() list[str]#

Get existing object uuids.

Returns:

List of object uuids that have a plot item associated to them.

get_obj_from_item(item: TypePlotItem) TypeObj | None#

Return object associated to plot item

Parameters:

item – plot item

Returns:

Object associated to plot item

reduce_shown_oids(oids: list[str]) list[str]#

Reduce the number of shown objects to visible items only. The base implementation is to show only the first selected item if the option “Show first only” is enabled.

Parameters:

oids – list of object uuids

Returns:

Reduced list of object uuids

refresh_all_shape_items() None#

Refresh all geometric shapes to apply new style parameters.

This method is called when shape/marker visualization settings are changed in the Settings dialog. It removes and recreates all shape items to apply the new parameters.

remove_all_shape_items() None#

Remove all geometric shapes associated to result items

remove_item(oid: str) None#

Remove plot item associated to object uuid

set_auto_refresh(auto_refresh: bool) None#

Set auto refresh mode.

Parameters:

auto_refresh – if True, refresh plot items automatically

set_show_first_only(show_first_only: bool) None#

Set show first only mode.

Parameters:

show_first_only – if True, show only the first selected item

toggle_result_label_visibility(show: bool) None#

Toggle the visibility of all merged result labels on the plot.

Parameters:

show – True to show the labels, False to hide them

update_resultproperty_from_plot_item(item: LabelItem) None#

Update result properties from merged label plot item.

When the merged results label is moved, update the stored position in the merged result adapter.

Parameters:

item – Merged results label item

Image plot handler#

class datalab.gui.plothandler.ImagePlotHandler(panel: BaseDataPanel, plotwidget: PlotWidget)[source]#

Object handling image plot items, plot dialogs, plot options

reduce_shown_oids(oids: list[str]) list[str][source]#

Reduce the number of shown objects to visible items only. The base implementation is to show only the first selected item if the option “Show first only” is enabled.

Parameters:

oids – list of object uuids

Returns:

Reduced list of object uuids

refresh_plot(what: str, update_items: bool = True, force: bool = False, only_visible: bool = True, only_existing: bool = False) None[source]#

Refresh plot.

Parameters:
  • what – string describing the objects to refresh. Valid values are “selected” (refresh the selected objects), “all” (refresh all objects), “existing” (refresh existing plot items), or an object uuid.

  • update_items – if True, update the items. If False, only show the items (do not update them). Defaults to True.

  • force – if True, force refresh even if auto refresh is disabled. Defaults to False.

  • only_visible – if True, only refresh visible items. Defaults to True. Visible items are the ones that are not hidden by other items or the items except the first one if the option “Show first only” is enabled. This is useful for images, where the last image is the one that is shown. If False, all items are refreshed.

  • only_existing – if True, only refresh existing items. Defaults to False. Existing items are the ones that have already been created and are associated to the object uuid. If False, create new items for the objects that do not have an item yet.

Raises:

ValueError – if what is not a valid value

cleanup_dataview() None[source]#

Clean up data view

get_plot_options() PlotOptions[source]#

Return standard signal/image plot options

add_shapes(oid: str, do_autoscale: bool = False) None#

Add geometric shape items associated to computed results and annotations, for the object with the given uuid

clear() None#

Clear plot items

get(key: str, default: TypePlotItem | None = None) TypePlotItem | None#

Return item associated to object uuid. If the key is not found, default is returned if given, otherwise None is returned.

get_existing_oids() list[str]#

Get existing object uuids.

Returns:

List of object uuids that have a plot item associated to them.

get_obj_from_item(item: TypePlotItem) TypeObj | None#

Return object associated to plot item

Parameters:

item – plot item

Returns:

Object associated to plot item

refresh_all_shape_items() None#

Refresh all geometric shapes to apply new style parameters.

This method is called when shape/marker visualization settings are changed in the Settings dialog. It removes and recreates all shape items to apply the new parameters.

remove_all_shape_items() None#

Remove all geometric shapes associated to result items

remove_item(oid: str) None#

Remove plot item associated to object uuid

set_auto_refresh(auto_refresh: bool) None#

Set auto refresh mode.

Parameters:

auto_refresh – if True, refresh plot items automatically

set_show_first_only(show_first_only: bool) None#

Set show first only mode.

Parameters:

show_first_only – if True, show only the first selected item

toggle_result_label_visibility(show: bool) None#

Toggle the visibility of all merged result labels on the plot.

Parameters:

show – True to show the labels, False to hide them

update_resultproperty_from_plot_item(item: LabelItem) None#

Update result properties from merged label plot item.

When the merged results label is moved, update the stored position in the merged result adapter.

Parameters:

item – Merged results label item