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
- update_automatic_styles() None[source]#
Give the visible curves the automatic style of their position
Visible curves are numbered in the order of their signals in the panel. Each curve whose color and line style were not chosen by the user is given the automatic style of its position (see
CurveStyles.style_at()), so that the first curves shown are always given the first styles.
- 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
- 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_items(oids: Iterable[str]) None#
Remove the plot items associated to objects, at once
Removing the items one by one would refresh the plot observers (e.g. the item list panel) once per item: removing many items would take a long time.
- Parameters:
oids – Object uuids (objects without plot item are ignored, see
remove_item())
- 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_existing_items() None#
Update all existing plot items from their objects and current settings
Unlike
refresh_plot(), the visibility of the plot items and the shape items are left unchanged. This applies a change of display settings (e.g. signal auto downsampling or line width) to the plot items of all objects, and not only to those of the selected objects.
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
- 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
- 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_items(oids: Iterable[str]) None#
Remove the plot items associated to objects, at once
Removing the items one by one would refresh the plot observers (e.g. the item list panel) once per item: removing many items would take a long time.
- Parameters:
oids – Object uuids (objects without plot item are ignored, see
remove_item())
- 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_automatic_styles() None#
Update the automatic styles of the visible plot items
This base implementation does nothing.
- update_existing_items() None#
Update all existing plot items from their objects and current settings
Unlike
refresh_plot(), the visibility of the plot items and the shape items are left unchanged. This applies a change of display settings (e.g. signal auto downsampling or line width) to the plot items of all objects, and not only to those of the selected objects.