From e997712f0a9cec735e41897dc232a20f5e12c5cc Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Sun, 15 Jan 2023 19:09:28 +0100 Subject: [PATCH] number of function parameter is counted correctly when setting new values --- src/gui_qt/_py/fitfuncwidget.py | 24 +++++++++++++++++------ src/gui_qt/fit/fit_parameter.py | 6 ++++-- src/gui_qt/io/filereaders.py | 2 +- src/gui_qt/lib/pg_objects.py | 2 ++ src/resources/_ui/fitfuncwidget.ui | 31 ++++++++++++++++++++++++------ 5 files changed, 50 insertions(+), 15 deletions(-) diff --git a/src/gui_qt/_py/fitfuncwidget.py b/src/gui_qt/_py/fitfuncwidget.py index 38fa341..5a621e5 100644 --- a/src/gui_qt/_py/fitfuncwidget.py +++ b/src/gui_qt/_py/fitfuncwidget.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file 'resources/_ui/fitfuncwidget.ui' +# Form implementation generated from reading ui file 'src/resources/_ui/fitfuncwidget.ui' # -# Created by: PyQt5 UI code generator 5.12.3 +# Created by: PyQt5 UI code generator 5.15.7 # -# WARNING! All changes made in this file will be lost! +# 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. from PyQt5 import QtCore, QtGui, QtWidgets @@ -13,7 +14,12 @@ from PyQt5 import QtCore, QtGui, QtWidgets class Ui_FormFit(object): def setupUi(self, FormFit): FormFit.setObjectName("FormFit") - FormFit.resize(292, 477) + FormFit.resize(308, 477) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(FormFit.sizePolicy().hasHeightForWidth()) + FormFit.setSizePolicy(sizePolicy) self.verticalLayout = QtWidgets.QVBoxLayout(FormFit) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setSpacing(3) @@ -33,7 +39,7 @@ class Ui_FormFit(object): self.scrollArea.setWidgetResizable(True) self.scrollArea.setObjectName("scrollArea") self.scrollwidget = QtWidgets.QWidget() - self.scrollwidget.setGeometry(QtCore.QRect(0, 0, 284, 442)) + self.scrollwidget.setGeometry(QtCore.QRect(0, 0, 304, 444)) self.scrollwidget.setObjectName("scrollwidget") self.scrollArea.setWidget(self.scrollwidget) self.verticalLayout_2.addWidget(self.scrollArea) @@ -43,6 +49,12 @@ class Ui_FormFit(object): self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.data_tab) self.verticalLayout_3.setObjectName("verticalLayout_3") self.comboBox = QtWidgets.QComboBox(self.data_tab) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.comboBox.sizePolicy().hasHeightForWidth()) + self.comboBox.setSizePolicy(sizePolicy) + self.comboBox.setMaximumSize(QtCore.QSize(288, 16777215)) self.comboBox.setObjectName("comboBox") self.verticalLayout_3.addWidget(self.comboBox) self.scrollArea2 = QtWidgets.QScrollArea(self.data_tab) @@ -52,7 +64,7 @@ class Ui_FormFit(object): self.scrollArea2.setWidgetResizable(True) self.scrollArea2.setObjectName("scrollArea2") self.scrollwidget2 = QtWidgets.QWidget() - self.scrollwidget2.setGeometry(QtCore.QRect(0, 0, 272, 357)) + self.scrollwidget2.setGeometry(QtCore.QRect(0, 0, 286, 393)) self.scrollwidget2.setObjectName("scrollwidget2") self.scrollArea2.setWidget(self.scrollwidget2) self.verticalLayout_3.addWidget(self.scrollArea2) diff --git a/src/gui_qt/fit/fit_parameter.py b/src/gui_qt/fit/fit_parameter.py index 1027519..bcb3d1f 100644 --- a/src/gui_qt/fit/fit_parameter.py +++ b/src/gui_qt/fit/fit_parameter.py @@ -263,6 +263,8 @@ class QFitParameterWidget(QtWidgets.QWidget, Ui_FormFit): return data_parameter, lb, ub, is_fixed, global_p, is_linked def set_parameter(self, set_id: str | None, parameter: list[float]) -> int: + param_len = len(list(filter(lambda g: not isinstance(g, SelectionWidget), self.global_parameter))) + if set_id is None: for val, g in zip(parameter, self.global_parameter): if isinstance(g, SelectionWidget): @@ -271,13 +273,13 @@ class QFitParameterWidget(QtWidgets.QWidget, Ui_FormFit): else: new_param = self.data_values[set_id] - min_len = min(len(new_param), len(parameter)) + min_len = min(param_len, len(new_param), len(new_param)) for i in range(min_len): new_param[i] = parameter[i] self.change_data(self.comboBox.currentIndex()) - return len(self.global_parameter) + return param_len class ParameterSingleWidget(QtWidgets.QWidget): diff --git a/src/gui_qt/io/filereaders.py b/src/gui_qt/io/filereaders.py index 7ebed93..11d28c2 100755 --- a/src/gui_qt/io/filereaders.py +++ b/src/gui_qt/io/filereaders.py @@ -58,7 +58,7 @@ class QFileReader(QtCore.QObject): try: # If QAsciiReader.skip = True it accepts automatically and returns None r(f).exec() - except ImportError: + except AttributeError: pass self.data_read.emit(self.data) diff --git a/src/gui_qt/lib/pg_objects.py b/src/gui_qt/lib/pg_objects.py index c8626e0..4ab0f30 100644 --- a/src/gui_qt/lib/pg_objects.py +++ b/src/gui_qt/lib/pg_objects.py @@ -380,6 +380,8 @@ class RegionItem(LinearRegionItem): self.logmode = False self.first = True + if not hasattr(self, '_bounds') and hasattr(self, '_boundingRectCache'): + self._bounds = self._boundingRectCache def setLogMode(self, xmode, _): if self.logmode == xmode: diff --git a/src/resources/_ui/fitfuncwidget.ui b/src/resources/_ui/fitfuncwidget.ui index 5c8bdcc..2d4be34 100644 --- a/src/resources/_ui/fitfuncwidget.ui +++ b/src/resources/_ui/fitfuncwidget.ui @@ -6,10 +6,16 @@ 0 0 - 292 + 308 477 + + + 0 + 0 + + Form @@ -73,8 +79,8 @@ 0 0 - 284 - 442 + 304 + 444 @@ -88,7 +94,20 @@ - + + + + 0 + 0 + + + + + 288 + 16777215 + + + @@ -109,8 +128,8 @@ 0 0 - 272 - 357 + 286 + 393