From 8a6c909c3e02c2e4bbc433b429805c9c53c34fe3 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Tue, 28 Nov 2023 19:31:05 +0100 Subject: [PATCH] button to reset view limits of fit results; closes #156 --- src/gui_qt/_py/fitresult.py | 23 ++++++++++++++-------- src/gui_qt/fit/result.py | 11 ++++++++++- src/resources/_ui/fitresult.ui | 35 ++++++++++++++++++++++++++++------ 3 files changed, 54 insertions(+), 15 deletions(-) diff --git a/src/gui_qt/_py/fitresult.py b/src/gui_qt/_py/fitresult.py index 568dafb..1e62a66 100644 --- a/src/gui_qt/_py/fitresult.py +++ b/src/gui_qt/_py/fitresult.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'src/resources/_ui/fitresult.ui' # -# Created by: PyQt5 UI code generator 5.15.9 +# Created by: PyQt5 UI code generator 5.15.10 # # WARNING: Any manual changes made to this file will be lost when pyuic5 is # run again. Do not edit this file unless you know what you are doing. @@ -30,17 +30,22 @@ class Ui_Dialog(object): self.gridLayout_3.setContentsMargins(3, 3, 3, 3) self.gridLayout_3.setSpacing(3) self.gridLayout_3.setObjectName("gridLayout_3") + self.autoscale_box = QtWidgets.QToolButton(self.stackPage1) + self.autoscale_box.setObjectName("autoscale_box") + self.gridLayout_3.addWidget(self.autoscale_box, 2, 0, 1, 1) self.logy_box = QtWidgets.QCheckBox(self.stackPage1) - self.logy_box.setLayoutDirection(QtCore.Qt.RightToLeft) + self.logy_box.setLayoutDirection(QtCore.Qt.LeftToRight) self.logy_box.setObjectName("logy_box") - self.gridLayout_3.addWidget(self.logy_box, 2, 1, 1, 1) - self.logx_box = QtWidgets.QCheckBox(self.stackPage1) - self.logx_box.setLayoutDirection(QtCore.Qt.RightToLeft) - self.logx_box.setObjectName("logx_box") - self.gridLayout_3.addWidget(self.logx_box, 2, 0, 1, 1) + self.gridLayout_3.addWidget(self.logy_box, 2, 3, 1, 1) self.graphicsView = GraphicsLayoutWidget(self.stackPage1) self.graphicsView.setObjectName("graphicsView") - self.gridLayout_3.addWidget(self.graphicsView, 0, 0, 1, 2) + self.gridLayout_3.addWidget(self.graphicsView, 0, 0, 1, 4) + self.logx_box = QtWidgets.QCheckBox(self.stackPage1) + self.logx_box.setLayoutDirection(QtCore.Qt.LeftToRight) + self.logx_box.setObjectName("logx_box") + self.gridLayout_3.addWidget(self.logx_box, 2, 2, 1, 1) + spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.gridLayout_3.addItem(spacerItem, 2, 1, 1, 1) self.stack.addTab(self.stackPage1, "") self.stackPage2 = QtWidgets.QWidget() self.stackPage2.setObjectName("stackPage2") @@ -203,6 +208,8 @@ class Ui_Dialog(object): def retranslateUi(self, Dialog): _translate = QtCore.QCoreApplication.translate Dialog.setWindowTitle(_translate("Dialog", "Fit results")) + self.autoscale_box.setToolTip(_translate("Dialog", "Auto-scale graph for all sets")) + self.autoscale_box.setText(_translate("Dialog", "Autoscale all sets")) self.logy_box.setText(_translate("Dialog", "logarithmic y axis")) self.logx_box.setText(_translate("Dialog", "logarithmic x axis")) self.stack.setTabText(self.stack.indexOf(self.stackPage1), _translate("Dialog", "Plot")) diff --git a/src/gui_qt/fit/result.py b/src/gui_qt/fit/result.py index 4e4b51c..45dfee3 100644 --- a/src/gui_qt/fit/result.py +++ b/src/gui_qt/fit/result.py @@ -153,6 +153,14 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog): self.del_prev_checkBox.setChecked(self._opts[idx][1]) self.del_prev_checkBox.blockSignals(False) + @QtCore.pyqtSlot(name='on_autoscale_box_clicked') + def reset_fit_ranges(self): + for i in range(self.sets_comboBox.count()): + graph_id = self.sets_comboBox.itemData(i) + self.graph_opts.pop(graph_id) + + self.fit_plot.enableAutoRange() + def set_plot(self, idx: str): if self.last_idx is not None: self.graph_opts[self.last_idx] = ( @@ -203,6 +211,8 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog): self.fit_plot.setLogMode(x=res.islog) self.resid_plot.setLogMode(x=res.islog) + print(self.graph_opts) + if idx in self.graph_opts: view_range, logx, logy = self.graph_opts[idx] self.fit_plot.setLogMode(x=logx, y=logy) @@ -215,7 +225,6 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog): self.logy_box.blockSignals(False) else: self.fit_plot.enableAutoRange() - self.fit_plot.disableAutoRange() def set_correlation(self, idx: str): while self.corr_tableWidget.rowCount(): diff --git a/src/resources/_ui/fitresult.ui b/src/resources/_ui/fitresult.ui index acc394d..d821e3c 100644 --- a/src/resources/_ui/fitresult.ui +++ b/src/resources/_ui/fitresult.ui @@ -45,28 +45,51 @@ 3 - + + + + Auto-scale graph for all sets + + + Autoscale all sets + + + + - Qt::RightToLeft + Qt::LeftToRight logarithmic y axis - + + + + - Qt::RightToLeft + Qt::LeftToRight logarithmic x axis - - + + + + Qt::Horizontal + + + + 40 + 20 + + +