8.6.6.4.4. pymodaq_gui.plotting.utils.plot_utils module

class pymodaq_gui.plotting.utils.plot_utils.Data0DWithHistory(Nsamples=200, sync_x_axis=True)[source]

Bases: object

Object to store scalar values and keep a history of a given length to them

Attributes:
data
length
size
sync_x_axis
timestamps
xaxis

Methods

add_data_dict(datas[, timestamp])

Add datas to the history on the form of a dict of key/data pairs (data is a numpy 0D array) :param datas: :type datas: dict

add_data_list(data[, timestamp])

Add datas to the history :param data: :type data: list

add_data

clear_data

add_data(data, timestamp=None)[source]
add_data_dict(datas, timestamp=None)[source]

Add datas to the history on the form of a dict of key/data pairs (data is a numpy 0D array) :param datas: :type datas: dict

add_data_list(data, timestamp=None)[source]

Add datas to the history :param data: :type data: list

clear_data()[source]
property data
property length
property size
property sync_x_axis: bool
property timestamps
property xaxis
class pymodaq_gui.plotting.utils.plot_utils.DetachablePanel(widget, dock, title, detached, orientation=<Orientation.Horizontal: 1>, layout_config_path=None, is_shown=<function DetachablePanel.<lambda>>)[source]

Bases: object

Show/hide a WidgetWithLabelTitle either docked or floating

Wraps the show/hide logic shared by every dockable, detachable side-panel (settings, controls, ROIs, …): when detached (or there is no dock at all) the widget is a floating top-level window; otherwise it lives inside dock.

Also owns the attach/detach state, which starts from detached (typically an app-wide config default) but can be overridden live for this instance via the widget’s sig_attach_detach signal (see WidgetWithLabelTitle) - if the panel is visible when the user toggles attach/detach, it is immediately re-shown in the new mode.

Parameters:
  • widget (QWidget) – Created with attachable=True; closable is up to the caller

  • dock (Optional[Dock]) – Dock to host the widget when attached; if None the widget can only float

  • title (str) – Window title used while floating

  • detached (bool) – Initial attach/detach state

  • orientation (Orientation) – Forwarded to display_in_dock() while attached; ignored if layout_config_path is given, in which case the dock’s own DockLayoutMenu decides instead

  • layout_config_path (Optional[Tuple[str, ...]]) – If given (and dock is not None), installs (or reuses) a DockLayoutMenu on the dock’s title bar, letting the user pick and persist how panels sharing this dock are arranged

  • is_shown (Callable[[], bool]) – Returns whether the panel is currently supposed to be visible; used to decide whether an attach/detach toggle should immediately re-render it

Attributes:
orientation

Methods

show

show(show=True)[source]
property orientation
class pymodaq_gui.plotting.utils.plot_utils.DockLayoutMenu(dock, config_path, on_change=None)[source]

Bases: object

Right-click menu on a shared Dock’s title bar to choose how the panels docked into it (settings, controls, ROIs, …) are arranged, and remember that choice

Several unrelated panels (e.g. every actuator’s settings widget) can land in the same Dock via display_in_dock(); the arrangement is therefore a property of the Dock itself, not of any one panel. One instance is installed per Dock (see get_dock_layout_menu()), and changing the layout reflows every widget currently docked into it by removing and re-adding them via display_in_dock.

Parameters:
class pymodaq_gui.plotting.utils.plot_utils.Point(*elt)[source]

Bases: object

Attributes:
coordinates

Methods

copy

copy()[source]
property coordinates
class pymodaq_gui.plotting.utils.plot_utils.QVector(*elt)[source]

Bases: QLineF

Methods

dot(qvect)

scalar product

prod(qvect)

vectoriel product length along z

copy

norm

normalVector

normalVector_not_vectorized

translate_to

unitVector

vectorize

copy()[source]
dot(qvect)[source]

scalar product

norm()[source]
normalVector()[source]
normalVector_not_vectorized()[source]
prod(qvect)[source]

vectoriel product length along z

translate_to(point=PySide6.QtCore.QPointF(0.000000, 0.000000))[source]
unitVector()[source]
vectorize()[source]
class pymodaq_gui.plotting.utils.plot_utils.Vector(coordinates, origin=None)[source]

Bases: object

Attributes:
coordinates
origin

Methods

copy

cross

dot

norm

unit_vector

copy()[source]
cross(other)[source]
dot(other)[source]
norm()[source]
unit_vector()[source]
property coordinates
property origin
class pymodaq_gui.plotting.utils.plot_utils.ViewBox(parent=None, border=None, lockAspect=False, enableMouse=True, invertY=False, enableMenu=True, name=None, invertX=False)[source]

Bases: ViewBox

Custom ViewBox used to enable other properties compared to parent class: pg.ViewBox

Methods

mouseClickEvent

sig_double_clicked

mouseClickEvent(ev)[source]
sig_double_clicked
staticMetaObject = PySide6.QtCore.QMetaObject("ViewBox" inherits "ViewBox": Methods:   #35 type=Signal, signature=sig_double_clicked(double,double), parameters=double, double )
pymodaq_gui.plotting.utils.plot_utils.display_in_dock(show, widget, dock, orientation=<Orientation.Horizontal: 1>)[source]
pymodaq_gui.plotting.utils.plot_utils.get_dock_layout_menu(dock, config_path, on_change=None)[source]

Get the DockLayoutMenu on this dock’s title bar, creating it on first use.

Return type:

DockLayoutMenu

pymodaq_gui.plotting.utils.plot_utils.get_sub_segmented_n_positions(spacing, points, limit=None)[source]

Number of Points returned by get_sub_segmented_positions, without building them

Parameters:
  • spacing (float) – Distance between two subpoints

  • points (List[Point]) – List of Points in arbitrary dimension forming segments one want to sample with a distance equal to spacing

  • limit (int) – If the raw number of positions (total length / spacing) exceeds this limit, it is returned directly instead of the exact one (the exact count is then not needed and may be huge to compute)

Return type:

int

pymodaq_gui.plotting.utils.plot_utils.get_sub_segmented_positions(spacing, points)[source]

Get Points coordinates spaced in between subsequent Points

Parameters:
  • spacing (float) – Distance between two subpoints

  • points (List[Point]) – List of Points in arbitrary dimension forming segments one want to sample with a distance equal to spacing

Returns:

List[np.ndarray]

Return type:

List[ndarray]

pymodaq_gui.plotting.utils.plot_utils.makeAlphaTriangles(data, lut=None, levels=None, scale=None, useRGBA=False)[source]

Convert an array of values into an ARGB array suitable for building QImages, OpenGL textures, etc.

Returns the ARGB array (unsigned byte) and a boolean indicating whether there is alpha channel data. This is a two stage process:

  1. compute the polygons (triangles) from triangulation of the points

  2. Rescale the data based on the values in the levels argument (min, max).

  3. Determine the final output by passing the rescaled values through a lookup table.

Both stages are optional.

Arguments:

data

numpy array of int/float types. If

levels

List [min, max]; optionally rescale data before converting through the lookup table. The data is rescaled such that min->0 and max->*scale*:

rescaled = (clip(data, min, max) - min) * (*scale* / (max - min))

It is also possible to use a 2D (N,2) array of values for levels. In this case, it is assumed that each pair of min,max values in the levels array should be applied to a different subset of the input data (for example, the input data may already have RGB values and the levels are used to independently scale each channel). The use of this feature requires that levels.shape[0] == data.shape[-1].

scale

The maximum value to which data will be rescaled before being passed through the lookup table (or returned if there is no lookup table). By default this will be set to the length of the lookup table, or 255 if no lookup table is provided.

lut

Optional lookup table (array with dtype=ubyte). Values in data will be converted to color by indexing directly from lut. The output data shape will be input.shape + lut.shape[1:]. Lookup tables can be built using ColorMap or GradientWidget.

useRGBA

If True, the data is returned in RGBA order (useful for building OpenGL textures). The default is False, which returns in ARGB order for use with QImage (Note that ‘ARGB’ is a term used by the Qt documentation; the actual order is BGRA).

pymodaq_gui.plotting.utils.plot_utils.makePolygons(tri)[source]
pymodaq_gui.plotting.utils.plot_utils.make_dashed_pens(color, nstyle=3)[source]