From 3648cab1f828066f245c5993583b5196b28bcfc4 Mon Sep 17 00:00:00 2001 From: atse Date: Mon, 4 Nov 2024 13:06:32 +0800 Subject: [PATCH] pytec GUI: Implement PlotSettingsMenu Co-authored-by: linuswck --- pytec/pytec/gui/view/plot_options_menu.py | 25 +++++++++++++++++++++++ pytec/tec_qt.py | 4 ++++ 2 files changed, 29 insertions(+) create mode 100644 pytec/pytec/gui/view/plot_options_menu.py diff --git a/pytec/pytec/gui/view/plot_options_menu.py b/pytec/pytec/gui/view/plot_options_menu.py new file mode 100644 index 0000000..8ec6f76 --- /dev/null +++ b/pytec/pytec/gui/view/plot_options_menu.py @@ -0,0 +1,25 @@ +from PyQt6 import QtWidgets, QtGui + + +class PlotOptionsMenu(QtWidgets.QMenu): + def __init__(self, channel_graphs, max_samples=1000): + super().__init__() + self.channel_graphs = channel_graphs + + self.setTitle("Plot Settings") + + clear = QtGui.QAction("Clear graphs", self) + self.addAction(clear) + self.clear = clear + self.clear.triggered.connect(self.channel_graphs.clear_graphs) + + self.samples_spinbox = QtWidgets.QSpinBox() + self.samples_spinbox.setRange(2, 100000) + self.samples_spinbox.setSuffix(" samples") + self.samples_spinbox.setValue(max_samples) + self.samples_spinbox.valueChanged.connect(self.channel_graphs.set_max_samples) + + limit_samples = QtWidgets.QWidgetAction(self) + limit_samples.setDefaultWidget(self.samples_spinbox) + self.addAction(limit_samples) + self.limit_samples = limit_samples diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 30e3fe8..378e8c8 100755 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -14,6 +14,7 @@ from pytec.gui.model.pid_autotuner import PIDAutoTuner from pytec.gui.view.zero_limits_warning_view import ZeroLimitsWarningView from pytec.gui.view.thermostat_settings_menu import ThermostatSettingsMenu from pytec.gui.view.connection_details_menu import ConnectionDetailsMenu +from pytec.gui.view.plot_options_menu import PlotOptionsMenu from pytec.gui.view.live_plot_view import LiveDataPlotter from pytec.gui.view.info_box import InfoBox @@ -99,6 +100,9 @@ class MainWindow(QtWidgets.QMainWindow): ) self.thermostat_settings.setMenu(self._thermostat_settings_menu) + self._plot_options_menu = PlotOptionsMenu(self._channel_graphs) + self.plot_settings.setMenu(self._plot_options_menu) + # Status line self._zero_limits_warning_view = ZeroLimitsWarningView( self._thermostat, self.style(), self.limits_warning