dev #291

Merged
dominik merged 32 commits from dev into master 2024-09-29 17:21:40 +00:00
4 changed files with 59 additions and 58 deletions
Showing only changes of commit b355aab99d - Show all commits

View File

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'src/resources/_ui/interpol_dialog.ui'
# Form implementation generated from reading ui file './nmreval/src/resources/_ui/interpol_dialog.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.
@ -55,7 +55,7 @@ class Ui_Dialog(object):
self.gridLayout.addWidget(self.interp_comboBox, 4, 1, 1, 1)
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Apply|QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.gridLayout.addWidget(self.buttonBox, 12, 0, 1, 2)
self.line = QtWidgets.QFrame(Dialog)
@ -132,8 +132,6 @@ class Ui_Dialog(object):
self.label_8.setBuddy(self.dest_combobox)
self.retranslateUi(Dialog)
self.buttonBox.accepted.connect(Dialog.accept) # type: ignore
self.buttonBox.rejected.connect(Dialog.reject) # type: ignore
QtCore.QMetaObject.connectSlotsByName(Dialog)
Dialog.setTabOrder(self.listWidget, self.ylog_checkBox)
Dialog.setTabOrder(self.ylog_checkBox, self.interp_comboBox)

View File

@ -62,6 +62,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
self.fitresult_dialog = None
self.eval = None
self.editor = None
self._interpol_dialog = None
self.logtext = QTextHandler(self)
logger.addHandler(self.logtext)
@ -701,10 +702,13 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
return
gnames = self.management.graphs.tree()
dialog = InterpolDialog(parent=self)
dialog.set_data(gnames, self.current_graph_widget.id)
dialog.new_data.connect(self.management.interpolate_data)
dialog.show()
if self._interpol_dialog is None:
self._interpol_dialog = InterpolDialog(parent=self)
self._interpol_dialog.new_data.connect(self.management.interpolate_data)
else:
self._interpol_dialog()
self._interpol_dialog.set_data(gnames, self.current_graph_widget.id)
self._interpol_dialog.show()
@QtCore.pyqtSlot(name='on_action_calc_triggered')
def open_eval_dialog(self):

View File

@ -16,6 +16,12 @@ class InterpolDialog(QtWidgets.QDialog, Ui_Dialog):
self.step_lineEdit.setValidator(QtGui.QIntValidator())
self._data = {}
self._src_id = None
self._dest_graph = ''
def __call__(self):
self.listWidget.clear()
self._data = {}
@QtCore.pyqtSlot(int, name='on_xaxis_comboBox_currentIndexChanged')
def change_x_source(self, idx: int):
@ -25,29 +31,41 @@ class InterpolDialog(QtWidgets.QDialog, Ui_Dialog):
def set_data(self, data, current_gid):
self.graph_combobox.blockSignals(True)
self._data = {}
dest_idx = 0
for (gid, graph_name), sets in data.items():
self.graph_combobox.addItem(graph_name, userData=gid)
self.dest_combobox.addItem(graph_name, userData=gid)
if self._dest_graph == gid:
dest_idx = self.dest_combobox.currentIndex()
if gid == current_gid:
self.make_list(sets)
self._data[gid] = sets
self.graph_combobox.blockSignals(False)
self.change_graph(0)
self.change_graph(dest_idx)
def make_list(self, current_sets):
for sid, set_name in current_sets:
item = QtWidgets.QListWidgetItem(set_name)
item.setData(QtCore.Qt.UserRole, sid)
item.setCheckState(QtCore.Qt.Checked)
item.setData(QtCore.Qt.ItemDataRole.UserRole, sid)
item.setCheckState(QtCore.Qt.CheckState.Checked)
self.listWidget.addItem(item)
@QtCore.pyqtSlot(int, name='on_graph_combobox_currentIndexChanged')
def change_graph(self, idx: int):
self.set_combobox.clear()
gid = self.graph_combobox.itemData(idx, QtCore.Qt.UserRole)
gid = self.graph_combobox.itemData(idx, QtCore.Qt.ItemDataRole.UserRole)
set_idx = -1
if gid is not None:
for set_key, set_name in self._data[gid]:
for i, (set_key, set_name) in enumerate(self._data[gid]):
print(self._src_id, set_key, set_name, i)
self.set_combobox.addItem(set_name, userData=set_key)
print(self.set_combobox.currentIndex())
if self._src_id == set_key:
set_idx = i
print(set_idx)
if set_idx > -1:
self.set_combobox.setCurrentIndex(set_idx)
def collect_parameter(self):
xlog = self.xlog_checkBox.isChecked()
@ -71,21 +89,35 @@ class InterpolDialog(QtWidgets.QDialog, Ui_Dialog):
x_src = (start, stop, step, loggy)
else:
x_src = (self.set_combobox.currentData(QtCore.Qt.UserRole),)
self._src_id = self.set_combobox.currentData(QtCore.Qt.ItemDataRole.UserRole)
x_src = (self._src_id,)
dest_graph = self.dest_combobox.currentData(QtCore.Qt.UserRole)
self._dest_graph = self.dest_combobox.currentData(QtCore.Qt.ItemDataRole.UserRole)
use_data = []
for i in range(self.listWidget.count()):
item = self.listWidget.item(i)
if item.checkState() == QtCore.Qt.Checked:
use_data.append(item.data(QtCore.Qt.UserRole))
if item.checkState() == QtCore.Qt.CheckState.Checked:
use_data.append(item.data(QtCore.Qt.ItemDataRole.UserRole))
self.new_data.emit(use_data, mode, xlog, ylog, x_src, dest_graph)
self.new_data.emit(use_data, mode, xlog, ylog, x_src, self._dest_graph)
return True
def accept(self):
success = self.collect_parameter()
if success:
super().accept()
def _save_state(self):
self._src_id = self.set_combobox.currentData(QtCore.Qt.ItemDataRole.UserRole)
self._dest_graph = self.dest_combobox.currentData(QtCore.Qt.ItemDataRole.UserRole)
@QtCore.pyqtSlot(QtWidgets.QAbstractButton, name='on_buttonBox_clicked')
def check_next_actions(self, bttn: QtWidgets.QAbstractButton):
role = self.buttonBox.buttonRole(bttn)
self._save_state()
if role == self.buttonBox.ButtonRole.RejectRole:
self.close()
else:
success = self.collect_parameter()
if success and role == self.buttonBox.ButtonRole.AcceptRole:
self.close()

View File

@ -119,7 +119,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
@ -300,38 +300,5 @@
<tabstop>dest_combobox</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>251</x>
<y>490</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>319</x>
<y>490</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>