dev #297
@ -1,8 +1,8 @@
|
|||||||
# -*- coding: utf-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
|
# 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.
|
# 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.gridLayout.addWidget(self.interp_comboBox, 4, 1, 1, 1)
|
||||||
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
|
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
|
||||||
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
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.buttonBox.setObjectName("buttonBox")
|
||||||
self.gridLayout.addWidget(self.buttonBox, 12, 0, 1, 2)
|
self.gridLayout.addWidget(self.buttonBox, 12, 0, 1, 2)
|
||||||
self.line = QtWidgets.QFrame(Dialog)
|
self.line = QtWidgets.QFrame(Dialog)
|
||||||
@ -132,8 +132,6 @@ class Ui_Dialog(object):
|
|||||||
self.label_8.setBuddy(self.dest_combobox)
|
self.label_8.setBuddy(self.dest_combobox)
|
||||||
|
|
||||||
self.retranslateUi(Dialog)
|
self.retranslateUi(Dialog)
|
||||||
self.buttonBox.accepted.connect(Dialog.accept) # type: ignore
|
|
||||||
self.buttonBox.rejected.connect(Dialog.reject) # type: ignore
|
|
||||||
QtCore.QMetaObject.connectSlotsByName(Dialog)
|
QtCore.QMetaObject.connectSlotsByName(Dialog)
|
||||||
Dialog.setTabOrder(self.listWidget, self.ylog_checkBox)
|
Dialog.setTabOrder(self.listWidget, self.ylog_checkBox)
|
||||||
Dialog.setTabOrder(self.ylog_checkBox, self.interp_comboBox)
|
Dialog.setTabOrder(self.ylog_checkBox, self.interp_comboBox)
|
||||||
|
@ -62,6 +62,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
|||||||
self.fitresult_dialog = None
|
self.fitresult_dialog = None
|
||||||
self.eval = None
|
self.eval = None
|
||||||
self.editor = None
|
self.editor = None
|
||||||
|
self._interpol_dialog = None
|
||||||
|
|
||||||
self.logtext = QTextHandler(self)
|
self.logtext = QTextHandler(self)
|
||||||
logger.addHandler(self.logtext)
|
logger.addHandler(self.logtext)
|
||||||
@ -701,10 +702,13 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
|||||||
return
|
return
|
||||||
|
|
||||||
gnames = self.management.graphs.tree()
|
gnames = self.management.graphs.tree()
|
||||||
dialog = InterpolDialog(parent=self)
|
if self._interpol_dialog is None:
|
||||||
dialog.set_data(gnames, self.current_graph_widget.id)
|
self._interpol_dialog = InterpolDialog(parent=self)
|
||||||
dialog.new_data.connect(self.management.interpolate_data)
|
self._interpol_dialog.new_data.connect(self.management.interpolate_data)
|
||||||
dialog.show()
|
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')
|
@QtCore.pyqtSlot(name='on_action_calc_triggered')
|
||||||
def open_eval_dialog(self):
|
def open_eval_dialog(self):
|
||||||
|
@ -16,6 +16,12 @@ class InterpolDialog(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
self.step_lineEdit.setValidator(QtGui.QIntValidator())
|
self.step_lineEdit.setValidator(QtGui.QIntValidator())
|
||||||
|
|
||||||
self._data = {}
|
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')
|
@QtCore.pyqtSlot(int, name='on_xaxis_comboBox_currentIndexChanged')
|
||||||
def change_x_source(self, idx: int):
|
def change_x_source(self, idx: int):
|
||||||
@ -25,29 +31,41 @@ class InterpolDialog(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
def set_data(self, data, current_gid):
|
def set_data(self, data, current_gid):
|
||||||
self.graph_combobox.blockSignals(True)
|
self.graph_combobox.blockSignals(True)
|
||||||
self._data = {}
|
self._data = {}
|
||||||
|
dest_idx = 0
|
||||||
for (gid, graph_name), sets in data.items():
|
for (gid, graph_name), sets in data.items():
|
||||||
self.graph_combobox.addItem(graph_name, userData=gid)
|
self.graph_combobox.addItem(graph_name, userData=gid)
|
||||||
self.dest_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:
|
if gid == current_gid:
|
||||||
self.make_list(sets)
|
self.make_list(sets)
|
||||||
self._data[gid] = sets
|
self._data[gid] = sets
|
||||||
self.graph_combobox.blockSignals(False)
|
self.graph_combobox.blockSignals(False)
|
||||||
self.change_graph(0)
|
self.change_graph(dest_idx)
|
||||||
|
|
||||||
def make_list(self, current_sets):
|
def make_list(self, current_sets):
|
||||||
for sid, set_name in current_sets:
|
for sid, set_name in current_sets:
|
||||||
item = QtWidgets.QListWidgetItem(set_name)
|
item = QtWidgets.QListWidgetItem(set_name)
|
||||||
item.setData(QtCore.Qt.UserRole, sid)
|
item.setData(QtCore.Qt.ItemDataRole.UserRole, sid)
|
||||||
item.setCheckState(QtCore.Qt.Checked)
|
item.setCheckState(QtCore.Qt.CheckState.Checked)
|
||||||
self.listWidget.addItem(item)
|
self.listWidget.addItem(item)
|
||||||
|
|
||||||
@QtCore.pyqtSlot(int, name='on_graph_combobox_currentIndexChanged')
|
@QtCore.pyqtSlot(int, name='on_graph_combobox_currentIndexChanged')
|
||||||
def change_graph(self, idx: int):
|
def change_graph(self, idx: int):
|
||||||
self.set_combobox.clear()
|
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:
|
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)
|
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):
|
def collect_parameter(self):
|
||||||
xlog = self.xlog_checkBox.isChecked()
|
xlog = self.xlog_checkBox.isChecked()
|
||||||
@ -71,21 +89,35 @@ class InterpolDialog(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
|
|
||||||
x_src = (start, stop, step, loggy)
|
x_src = (start, stop, step, loggy)
|
||||||
else:
|
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 = []
|
use_data = []
|
||||||
for i in range(self.listWidget.count()):
|
for i in range(self.listWidget.count()):
|
||||||
item = self.listWidget.item(i)
|
item = self.listWidget.item(i)
|
||||||
if item.checkState() == QtCore.Qt.Checked:
|
if item.checkState() == QtCore.Qt.CheckState.Checked:
|
||||||
use_data.append(item.data(QtCore.Qt.UserRole))
|
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
|
return True
|
||||||
|
|
||||||
def accept(self):
|
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()
|
success = self.collect_parameter()
|
||||||
if success:
|
|
||||||
super().accept()
|
if success and role == self.buttonBox.ButtonRole.AcceptRole:
|
||||||
|
self.close()
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@
|
|||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -300,38 +300,5 @@
|
|||||||
<tabstop>dest_combobox</tabstop>
|
<tabstop>dest_combobox</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<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>
|
|
||||||
</ui>
|
</ui>
|
||||||
|
Loading…
Reference in New Issue
Block a user