1
0
forked from IPKM/nmreval

number of function parameter is counted correctly when setting new values

This commit is contained in:
Dominik Demuth 2023-01-15 19:09:28 +01:00
parent 5b0c5bb4bb
commit e997712f0a
5 changed files with 50 additions and 15 deletions

View File

@ -1,10 +1,11 @@
# -*- coding: utf-8 -*- # -*- 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 from PyQt5 import QtCore, QtGui, QtWidgets
@ -13,7 +14,12 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_FormFit(object): class Ui_FormFit(object):
def setupUi(self, FormFit): def setupUi(self, FormFit):
FormFit.setObjectName("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 = QtWidgets.QVBoxLayout(FormFit)
self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setSpacing(3) self.verticalLayout.setSpacing(3)
@ -33,7 +39,7 @@ class Ui_FormFit(object):
self.scrollArea.setWidgetResizable(True) self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea") self.scrollArea.setObjectName("scrollArea")
self.scrollwidget = QtWidgets.QWidget() 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.scrollwidget.setObjectName("scrollwidget")
self.scrollArea.setWidget(self.scrollwidget) self.scrollArea.setWidget(self.scrollwidget)
self.verticalLayout_2.addWidget(self.scrollArea) 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 = QtWidgets.QVBoxLayout(self.data_tab)
self.verticalLayout_3.setObjectName("verticalLayout_3") self.verticalLayout_3.setObjectName("verticalLayout_3")
self.comboBox = QtWidgets.QComboBox(self.data_tab) 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.comboBox.setObjectName("comboBox")
self.verticalLayout_3.addWidget(self.comboBox) self.verticalLayout_3.addWidget(self.comboBox)
self.scrollArea2 = QtWidgets.QScrollArea(self.data_tab) self.scrollArea2 = QtWidgets.QScrollArea(self.data_tab)
@ -52,7 +64,7 @@ class Ui_FormFit(object):
self.scrollArea2.setWidgetResizable(True) self.scrollArea2.setWidgetResizable(True)
self.scrollArea2.setObjectName("scrollArea2") self.scrollArea2.setObjectName("scrollArea2")
self.scrollwidget2 = QtWidgets.QWidget() 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.scrollwidget2.setObjectName("scrollwidget2")
self.scrollArea2.setWidget(self.scrollwidget2) self.scrollArea2.setWidget(self.scrollwidget2)
self.verticalLayout_3.addWidget(self.scrollArea2) self.verticalLayout_3.addWidget(self.scrollArea2)

View File

@ -263,6 +263,8 @@ class QFitParameterWidget(QtWidgets.QWidget, Ui_FormFit):
return data_parameter, lb, ub, is_fixed, global_p, is_linked return data_parameter, lb, ub, is_fixed, global_p, is_linked
def set_parameter(self, set_id: str | None, parameter: list[float]) -> int: 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: if set_id is None:
for val, g in zip(parameter, self.global_parameter): for val, g in zip(parameter, self.global_parameter):
if isinstance(g, SelectionWidget): if isinstance(g, SelectionWidget):
@ -271,13 +273,13 @@ class QFitParameterWidget(QtWidgets.QWidget, Ui_FormFit):
else: else:
new_param = self.data_values[set_id] 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): for i in range(min_len):
new_param[i] = parameter[i] new_param[i] = parameter[i]
self.change_data(self.comboBox.currentIndex()) self.change_data(self.comboBox.currentIndex())
return len(self.global_parameter) return param_len
class ParameterSingleWidget(QtWidgets.QWidget): class ParameterSingleWidget(QtWidgets.QWidget):

View File

@ -58,7 +58,7 @@ class QFileReader(QtCore.QObject):
try: try:
# If QAsciiReader.skip = True it accepts automatically and returns None # If QAsciiReader.skip = True it accepts automatically and returns None
r(f).exec() r(f).exec()
except ImportError: except AttributeError:
pass pass
self.data_read.emit(self.data) self.data_read.emit(self.data)

View File

@ -380,6 +380,8 @@ class RegionItem(LinearRegionItem):
self.logmode = False self.logmode = False
self.first = True self.first = True
if not hasattr(self, '_bounds') and hasattr(self, '_boundingRectCache'):
self._bounds = self._boundingRectCache
def setLogMode(self, xmode, _): def setLogMode(self, xmode, _):
if self.logmode == xmode: if self.logmode == xmode:

View File

@ -6,10 +6,16 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>292</width> <width>308</width>
<height>477</height> <height>477</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
@ -73,8 +79,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>284</width> <width>304</width>
<height>442</height> <height>444</height>
</rect> </rect>
</property> </property>
</widget> </widget>
@ -88,7 +94,20 @@
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<widget class="QComboBox" name="comboBox"/> <widget class="QComboBox" name="comboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>288</width>
<height>16777215</height>
</size>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QScrollArea" name="scrollArea2"> <widget class="QScrollArea" name="scrollArea2">
@ -109,8 +128,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>272</width> <width>286</width>
<height>357</height> <height>393</height>
</rect> </rect>
</property> </property>
</widget> </widget>