plesty.lib.ui.qt.plot ===================== .. py:module:: plesty.lib.ui.qt.plot .. autoapi-nested-parse:: pyqtgraph renderer: draws a monitor's declared traces into a Qt widget. This is the only place in the platform that knows both a :class:`~plesty.lib.monitor.Monitor` and a plotting library. The monitor declares *what* it draws (:class:`~plesty.lib.monitor.TraceSpec`) and hands over *what to draw* (:class:`~plesty.lib.monitor.TraceData`); this module turns that into plot items and keeps them fed. pyqtgraph is used because a trace fed every few hundred milliseconds for hours must redraw without the operator noticing. Colours never appear here as literals: every pen comes from the :class:`~plesty.lib.ui.theme.Theme`, which reads the packaged palette. Classes ------- .. autoapisummary:: plesty.lib.ui.qt.plot.PlotRenderer Functions --------- .. autoapisummary:: plesty.lib.ui.qt.plot._lookup_table Module Contents --------------- .. py:function:: _lookup_table(theme: plesty.lib.ui.theme.Theme) -> numpy.ndarray Build the image lookup table from the theme's colour-map stops. .. py:class:: PlotRenderer(theme: Optional[plesty.lib.ui.theme.Theme] = None, parent: Optional[PySide6.QtWidgets.QWidget] = None) Bases: :py:obj:`plesty.lib.monitor.base_monitor.Renderer` Draw target that renders a monitor's traces into a pyqtgraph widget. The renderer owns its widget (:attr:`widget`), so a panel builds one and hands the widget to the shell: .. code-block:: python renderer = PlotRenderer(theme) monitor.attach(renderer) # builds the plot items, replays the last data shell_panel_widget = renderer.widget Create the plot widget. :param theme: Palette to resolve trace colours and chrome against; ``None`` loads the packaged PLESTY theme. :param parent: Parent widget. .. py:attribute:: theme .. py:attribute:: widget .. py:attribute:: plot .. py:attribute:: caption .. py:attribute:: _items :type: dict[str, Any] .. py:attribute:: _images :type: dict[str, pyqtgraph.ImageItem] .. py:attribute:: _texts :type: dict[str, str] .. py:attribute:: _lut .. py:method:: setup(monitor: plesty.lib.monitor.base_monitor.Monitor) -> None Build one plot item per declared trace. :param monitor: The monitor that was attached. .. py:method:: draw(monitor: plesty.lib.monitor.base_monitor.Monitor, data: dict[str, plesty.lib.monitor.base_monitor.TraceData]) -> None Feed new payloads into the plot items. :param monitor: The monitor that produced the update. :param data: Trace key → payload. .. py:method:: clear(monitor: plesty.lib.monitor.base_monitor.Monitor) -> None Empty every plot item without rebuilding them. :param monitor: The monitor whose view is being reset. .. py:method:: _style_plot() -> None Apply the theme to the plot background, axes, and grid. .. py:method:: _build_item(spec: plesty.lib.monitor.base_monitor.TraceSpec, index: int) -> None Create the plot item declared by one trace spec. .. py:method:: _draw_curve(key: str, payload: plesty.lib.monitor.base_monitor.TraceData) -> None Update one line or scatter trace. .. py:method:: _draw_image(key: str, payload: plesty.lib.monitor.base_monitor.TraceData) -> None Update one image trace, scaling it onto its physical axes. .. py:method:: _draw_text(key: str, spec: plesty.lib.monitor.base_monitor.TraceSpec, payload: plesty.lib.monitor.base_monitor.TraceData) -> None Record a scalar or text trace for the caption line under the plot.