forked from IPKM/nmreval
dev (#275)
closes issues #267 #274, #255, #256 Co-authored-by: Dominik Demuth <dominik.demuth@physik.tu-darmstadt.de> Reviewed-on: IPKM/nmreval#275
This commit is contained in:
parent
6ecc789cd5
commit
8f92d8d822
@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Form implementation generated from reading ui file 'src/resources/_ui/basewindow.ui'
|
# Form implementation generated from reading ui file './nmreval/src/resources/_ui/basewindow.ui'
|
||||||
#
|
#
|
||||||
# Created by: PyQt5 UI code generator 5.15.10
|
# Created by: PyQt5 UI code generator 5.15.10
|
||||||
#
|
#
|
||||||
@ -87,6 +87,8 @@ class Ui_BaseWindow(object):
|
|||||||
self.menuSave.setObjectName("menuSave")
|
self.menuSave.setObjectName("menuSave")
|
||||||
self.menuData = QtWidgets.QMenu(self.menubar)
|
self.menuData = QtWidgets.QMenu(self.menubar)
|
||||||
self.menuData.setObjectName("menuData")
|
self.menuData.setObjectName("menuData")
|
||||||
|
self.menuCut_to_visible_range = QtWidgets.QMenu(self.menuData)
|
||||||
|
self.menuCut_to_visible_range.setObjectName("menuCut_to_visible_range")
|
||||||
self.menuHelp = QtWidgets.QMenu(self.menubar)
|
self.menuHelp = QtWidgets.QMenu(self.menubar)
|
||||||
self.menuHelp.setObjectName("menuHelp")
|
self.menuHelp.setObjectName("menuHelp")
|
||||||
self.menuExtra = QtWidgets.QMenu(self.menubar)
|
self.menuExtra = QtWidgets.QMenu(self.menubar)
|
||||||
@ -304,8 +306,6 @@ class Ui_BaseWindow(object):
|
|||||||
self.actionDerivation.setObjectName("actionDerivation")
|
self.actionDerivation.setObjectName("actionDerivation")
|
||||||
self.actionIntegration = QtWidgets.QAction(BaseWindow)
|
self.actionIntegration = QtWidgets.QAction(BaseWindow)
|
||||||
self.actionIntegration.setObjectName("actionIntegration")
|
self.actionIntegration.setObjectName("actionIntegration")
|
||||||
self.action_cut = QtWidgets.QAction(BaseWindow)
|
|
||||||
self.action_cut.setObjectName("action_cut")
|
|
||||||
self.actionMove_between_plots = QtWidgets.QAction(BaseWindow)
|
self.actionMove_between_plots = QtWidgets.QAction(BaseWindow)
|
||||||
self.actionMove_between_plots.setObjectName("actionMove_between_plots")
|
self.actionMove_between_plots.setObjectName("actionMove_between_plots")
|
||||||
self.actionBaseline = QtWidgets.QAction(BaseWindow)
|
self.actionBaseline = QtWidgets.QAction(BaseWindow)
|
||||||
@ -368,6 +368,10 @@ class Ui_BaseWindow(object):
|
|||||||
self.actionExclude_region = QtWidgets.QAction(BaseWindow)
|
self.actionExclude_region = QtWidgets.QAction(BaseWindow)
|
||||||
self.actionExclude_region.setCheckable(True)
|
self.actionExclude_region.setCheckable(True)
|
||||||
self.actionExclude_region.setObjectName("actionExclude_region")
|
self.actionExclude_region.setObjectName("actionExclude_region")
|
||||||
|
self.action_cut_xaxis = QtWidgets.QAction(BaseWindow)
|
||||||
|
self.action_cut_xaxis.setObjectName("action_cut_xaxis")
|
||||||
|
self.action_cut_yaxis = QtWidgets.QAction(BaseWindow)
|
||||||
|
self.action_cut_yaxis.setObjectName("action_cut_yaxis")
|
||||||
self.menuSave.addAction(self.actionSave)
|
self.menuSave.addAction(self.actionSave)
|
||||||
self.menuSave.addAction(self.actionExportGraphic)
|
self.menuSave.addAction(self.actionExportGraphic)
|
||||||
self.menuSave.addAction(self.action_save_fit_parameter)
|
self.menuSave.addAction(self.action_save_fit_parameter)
|
||||||
@ -380,6 +384,9 @@ class Ui_BaseWindow(object):
|
|||||||
self.menuFile.addSeparator()
|
self.menuFile.addSeparator()
|
||||||
self.menuFile.addAction(self.action_close)
|
self.menuFile.addAction(self.action_close)
|
||||||
self.menuFile.addSeparator()
|
self.menuFile.addSeparator()
|
||||||
|
self.menuCut_to_visible_range.addSeparator()
|
||||||
|
self.menuCut_to_visible_range.addAction(self.action_cut_xaxis)
|
||||||
|
self.menuCut_to_visible_range.addAction(self.action_cut_yaxis)
|
||||||
self.menuData.addAction(self.action_new_set)
|
self.menuData.addAction(self.action_new_set)
|
||||||
self.menuData.addAction(self.action_delete_sets)
|
self.menuData.addAction(self.action_delete_sets)
|
||||||
self.menuData.addAction(self.actionMove_between_plots)
|
self.menuData.addAction(self.actionMove_between_plots)
|
||||||
@ -389,7 +396,7 @@ class Ui_BaseWindow(object):
|
|||||||
self.menuData.addAction(self.action_sort_pts)
|
self.menuData.addAction(self.action_sort_pts)
|
||||||
self.menuData.addAction(self.actionSkip_points)
|
self.menuData.addAction(self.actionSkip_points)
|
||||||
self.menuData.addSeparator()
|
self.menuData.addSeparator()
|
||||||
self.menuData.addAction(self.action_cut)
|
self.menuData.addAction(self.menuCut_to_visible_range.menuAction())
|
||||||
self.menuData.addSeparator()
|
self.menuData.addSeparator()
|
||||||
self.menuData.addAction(self.actionChange_datatypes)
|
self.menuData.addAction(self.actionChange_datatypes)
|
||||||
self.menuHelp.addAction(self.actionShow_error_log)
|
self.menuHelp.addAction(self.actionShow_error_log)
|
||||||
@ -515,6 +522,7 @@ class Ui_BaseWindow(object):
|
|||||||
self.menuFile.setTitle(_translate("BaseWindow", "&File"))
|
self.menuFile.setTitle(_translate("BaseWindow", "&File"))
|
||||||
self.menuSave.setTitle(_translate("BaseWindow", "&Save..."))
|
self.menuSave.setTitle(_translate("BaseWindow", "&Save..."))
|
||||||
self.menuData.setTitle(_translate("BaseWindow", "&Data"))
|
self.menuData.setTitle(_translate("BaseWindow", "&Data"))
|
||||||
|
self.menuCut_to_visible_range.setTitle(_translate("BaseWindow", "Cut to visible range"))
|
||||||
self.menuHelp.setTitle(_translate("BaseWindow", "&Help"))
|
self.menuHelp.setTitle(_translate("BaseWindow", "&Help"))
|
||||||
self.menuExtra.setTitle(_translate("BaseWindow", "Math"))
|
self.menuExtra.setTitle(_translate("BaseWindow", "Math"))
|
||||||
self.menuNormalize.setTitle(_translate("BaseWindow", "&Normalize"))
|
self.menuNormalize.setTitle(_translate("BaseWindow", "&Normalize"))
|
||||||
@ -608,7 +616,6 @@ class Ui_BaseWindow(object):
|
|||||||
self.actionIntegrate.setText(_translate("BaseWindow", "Integrate"))
|
self.actionIntegrate.setText(_translate("BaseWindow", "Integrate"))
|
||||||
self.actionDerivation.setText(_translate("BaseWindow", "Differentiation..."))
|
self.actionDerivation.setText(_translate("BaseWindow", "Differentiation..."))
|
||||||
self.actionIntegration.setText(_translate("BaseWindow", "Integration..."))
|
self.actionIntegration.setText(_translate("BaseWindow", "Integration..."))
|
||||||
self.action_cut.setText(_translate("BaseWindow", "Cut to visible range"))
|
|
||||||
self.actionMove_between_plots.setText(_translate("BaseWindow", "Move sets..."))
|
self.actionMove_between_plots.setText(_translate("BaseWindow", "Move sets..."))
|
||||||
self.actionBaseline.setText(_translate("BaseWindow", "Baseline..."))
|
self.actionBaseline.setText(_translate("BaseWindow", "Baseline..."))
|
||||||
self.actionCalculateT1.setText(_translate("BaseWindow", "Calculate relaxation..."))
|
self.actionCalculateT1.setText(_translate("BaseWindow", "Calculate relaxation..."))
|
||||||
@ -636,6 +643,10 @@ class Ui_BaseWindow(object):
|
|||||||
self.actionBinning.setText(_translate("BaseWindow", "Binning..."))
|
self.actionBinning.setText(_translate("BaseWindow", "Binning..."))
|
||||||
self.actionTNMH.setText(_translate("BaseWindow", "TNMH..."))
|
self.actionTNMH.setText(_translate("BaseWindow", "TNMH..."))
|
||||||
self.actionExclude_region.setText(_translate("BaseWindow", "Exclude region"))
|
self.actionExclude_region.setText(_translate("BaseWindow", "Exclude region"))
|
||||||
|
self.action_cut_xaxis.setText(_translate("BaseWindow", "x axis"))
|
||||||
|
self.action_cut_xaxis.setToolTip(_translate("BaseWindow", "Remove data points outside visible x range."))
|
||||||
|
self.action_cut_yaxis.setText(_translate("BaseWindow", "y axis"))
|
||||||
|
self.action_cut_yaxis.setToolTip(_translate("BaseWindow", "Remove data points outside visible y range. Uses real part of points."))
|
||||||
from ..data.datawidget.datawidget import DataWidget
|
from ..data.datawidget.datawidget import DataWidget
|
||||||
from ..data.integral_widget import IntegralWidget
|
from ..data.integral_widget import IntegralWidget
|
||||||
from ..data.point_select import PointSelectWidget
|
from ..data.point_select import PointSelectWidget
|
||||||
|
@ -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)
|
||||||
|
@ -300,10 +300,12 @@ class ExperimentContainer(QtCore.QObject):
|
|||||||
self._relations.pop(relation_type)
|
self._relations.pop(relation_type)
|
||||||
|
|
||||||
def _update_actions(self):
|
def _update_actions(self):
|
||||||
self.actions.update({'sort': self._data.sort,
|
self.actions.update({
|
||||||
'cut': self._data.cut,
|
'sort': self._data.sort,
|
||||||
'norm': self._data.normalize,
|
'cut': self._data.cut,
|
||||||
'center': self.center})
|
'norm': self._data.normalize,
|
||||||
|
'center': self.center,
|
||||||
|
})
|
||||||
|
|
||||||
@plot_update
|
@plot_update
|
||||||
def update(self, opts: dict):
|
def update(self, opts: dict):
|
||||||
@ -311,9 +313,11 @@ class ExperimentContainer(QtCore.QObject):
|
|||||||
|
|
||||||
def get_properties(self) -> dict:
|
def get_properties(self) -> dict:
|
||||||
props = OrderedDict()
|
props = OrderedDict()
|
||||||
props['General'] = OrderedDict([('Name', self.name),
|
props['General'] = OrderedDict([
|
||||||
('Value', str(self.value)),
|
('Name', self.name),
|
||||||
('Group', str(self.group))])
|
('Value', str(self.value)),
|
||||||
|
('Group', str(self.group)),
|
||||||
|
])
|
||||||
props['Symbol'] = OrderedDict()
|
props['Symbol'] = OrderedDict()
|
||||||
props['Line'] = OrderedDict()
|
props['Line'] = OrderedDict()
|
||||||
|
|
||||||
@ -480,10 +484,12 @@ class ExperimentContainer(QtCore.QObject):
|
|||||||
else:
|
else:
|
||||||
prefix = f'g[{i}].s[{j}].'
|
prefix = f'g[{i}].s[{j}].'
|
||||||
|
|
||||||
namespace = {prefix + 'x': (self.x, 'x values'),
|
namespace = {
|
||||||
prefix + 'y': [self.y, 'y values'],
|
prefix + 'x': (self.x, 'x values'),
|
||||||
prefix + 'y_err': (self.y_err, 'y error values'),
|
prefix + 'y': [self.y, 'y values'],
|
||||||
prefix + 'value': (self.value, str(self.value))}
|
prefix + 'y_err': (self.y_err, 'y error values'),
|
||||||
|
prefix + 'value': (self.value, str(self.value)),
|
||||||
|
}
|
||||||
|
|
||||||
if len(self._fits) == 1:
|
if len(self._fits) == 1:
|
||||||
namespace.update({
|
namespace.update({
|
||||||
|
@ -385,6 +385,6 @@ class ValueModel(QtCore.QAbstractTableModel):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def as_string(value) -> str:
|
def as_string(value) -> str:
|
||||||
if isinstance(value, complex):
|
if isinstance(value, complex):
|
||||||
return f'{value.real:.8g}{value.imag:+.8g}j'
|
return f'{value.real:.13g}{value.imag:+.13g}j'
|
||||||
else:
|
else:
|
||||||
return f'{value:.8g}'
|
return f'{value:.13g}'
|
||||||
|
@ -28,6 +28,12 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog):
|
|||||||
|
|
||||||
self.listWidget.installEventFilter(self)
|
self.listWidget.installEventFilter(self)
|
||||||
|
|
||||||
|
def __call__(self, path=None):
|
||||||
|
if path is None:
|
||||||
|
path = pathlib.Path().home()
|
||||||
|
self.path = path
|
||||||
|
self.listWidget.clear()
|
||||||
|
|
||||||
def eventFilter(self, src: QtCore.QObject, evt: QtCore.QEvent) -> bool:
|
def eventFilter(self, src: QtCore.QObject, evt: QtCore.QEvent) -> bool:
|
||||||
# intercept key press in listwidget to allow deletion with Del
|
# intercept key press in listwidget to allow deletion with Del
|
||||||
if evt.type() == QtCore.QEvent.Type.KeyPress:
|
if evt.type() == QtCore.QEvent.Type.KeyPress:
|
||||||
@ -82,6 +88,7 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog):
|
|||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
items = [self.listWidget.item(i).text() for i in range(self.listWidget.count())]
|
items = [self.listWidget.item(i).text() for i in range(self.listWidget.count())]
|
||||||
|
print(items)
|
||||||
if items:
|
if items:
|
||||||
with busy_cursor():
|
with busy_cursor():
|
||||||
self.read(items)
|
self.read(items)
|
||||||
@ -116,6 +123,7 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog):
|
|||||||
|
|
||||||
ret_vals = []
|
ret_vals = []
|
||||||
ret_vals.extend(fc_eval.get_parameter(path=self.label.text(), kind='temp', parameter=save_variables))
|
ret_vals.extend(fc_eval.get_parameter(path=self.label.text(), kind='temp', parameter=save_variables))
|
||||||
|
print(ret_vals)
|
||||||
|
|
||||||
grp = ''
|
grp = ''
|
||||||
if not self.graph_checkbox.isChecked():
|
if not self.graph_checkbox.isChecked():
|
||||||
|
@ -62,6 +62,8 @@ 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.fc_reader = None
|
||||||
|
|
||||||
self.logtext = QTextHandler(self)
|
self.logtext = QTextHandler(self)
|
||||||
logger.addHandler(self.logtext)
|
logger.addHandler(self.logtext)
|
||||||
@ -233,7 +235,8 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
|||||||
self.action_norm_first.triggered.connect(lambda: self.management.apply('norm', ('first',)))
|
self.action_norm_first.triggered.connect(lambda: self.management.apply('norm', ('first',)))
|
||||||
self.action_norm_last.triggered.connect(lambda: self.management.apply('norm', ('last',)))
|
self.action_norm_last.triggered.connect(lambda: self.management.apply('norm', ('last',)))
|
||||||
self.action_norm_area.triggered.connect(lambda: self.management.apply('norm', ('area',)))
|
self.action_norm_area.triggered.connect(lambda: self.management.apply('norm', ('area',)))
|
||||||
self.action_cut.triggered.connect(lambda: self.management.cut())
|
self.action_cut_xaxis.triggered.connect(lambda: self.management.cut(True, False))
|
||||||
|
self.action_cut_yaxis.triggered.connect(lambda: self.management.cut(False, True))
|
||||||
|
|
||||||
self.actionConcatenate_sets.triggered.connect(lambda: self.management.cat())
|
self.actionConcatenate_sets.triggered.connect(lambda: self.management.cat())
|
||||||
|
|
||||||
@ -264,14 +267,15 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
|||||||
|
|
||||||
@QtCore.pyqtSlot(name='on_actionOpen_FC_triggered')
|
@QtCore.pyqtSlot(name='on_actionOpen_FC_triggered')
|
||||||
def read_fc(self):
|
def read_fc(self):
|
||||||
reader = QFCReader(path=self.path, parent=self)
|
if self.fc_reader is None:
|
||||||
reader.add_graphs(self.management.graphs.list())
|
self.fc_reader = QFCReader(path=self.path, parent=self)
|
||||||
reader.data_read.connect(self.management.add_new_data)
|
self.fc_reader.data_read.connect(self.management.add_new_data)
|
||||||
reader.exec()
|
else:
|
||||||
|
self.fc_reader(path=self.path)
|
||||||
|
self.fc_reader.add_graphs(self.management.graphs.list())
|
||||||
|
self.fc_reader.exec()
|
||||||
|
|
||||||
self.path = reader.path
|
self.path = self.fc_reader.path
|
||||||
|
|
||||||
del reader
|
|
||||||
|
|
||||||
@QtCore.pyqtSlot(name='on_actionPrint_triggered')
|
@QtCore.pyqtSlot(name='on_actionPrint_triggered')
|
||||||
def print(self):
|
def print(self):
|
||||||
@ -701,10 +705,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):
|
||||||
|
@ -450,10 +450,17 @@ class UpperManagement(QtCore.QObject):
|
|||||||
self.undostack.push(single_undo)
|
self.undostack.push(single_undo)
|
||||||
self.undostack.endMacro()
|
self.undostack.endMacro()
|
||||||
|
|
||||||
def cut(self):
|
def cut(self, x: bool = False, y: bool = False) -> None:
|
||||||
if self.current_graph:
|
if self.current_graph:
|
||||||
xlim, _ = self.graphs[self.current_graph].ranges
|
xlim, ylim = self.graphs[self.current_graph].ranges
|
||||||
self.apply('cut', xlim)
|
|
||||||
|
if x is False:
|
||||||
|
xlim = (None, None)
|
||||||
|
|
||||||
|
if y is False:
|
||||||
|
ylim = (None, None)
|
||||||
|
|
||||||
|
self.apply('cut', (*xlim, *ylim))
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def unmask(self):
|
def unmask(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):
|
||||||
success = self.collect_parameter()
|
self._src_id = self.set_combobox.currentData(QtCore.Qt.ItemDataRole.UserRole)
|
||||||
if success:
|
self._dest_graph = self.dest_combobox.currentData(QtCore.Qt.ItemDataRole.UserRole)
|
||||||
super().accept()
|
|
||||||
|
@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()
|
||||||
|
|
||||||
|
@ -540,26 +540,37 @@ class Points:
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def cut(self, low_lim: float = None, high_lim: float = None):
|
def cut(self, x_low: float = None, x_high: float = None, y_low: float = None, y_high: float = None):
|
||||||
"""
|
"""
|
||||||
Cut
|
Cut
|
||||||
Args:
|
Args:
|
||||||
low_lim:
|
x_low: Lower limit
|
||||||
high_lim:
|
x_high: Upper limit for x values
|
||||||
|
y_low: Lower limit
|
||||||
|
y_high: Upper limit for x valuew
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if low_lim is None and high_lim is None:
|
|
||||||
|
if x_low is None and x_high is None and y_low is None and y_high is None:
|
||||||
return self
|
return self
|
||||||
|
|
||||||
if low_lim is None:
|
if x_low is None:
|
||||||
low_lim = np.min(self._x)
|
x_low = np.min(self._x)-1
|
||||||
|
|
||||||
if high_lim is None:
|
if x_high is None:
|
||||||
high_lim = np.max(self._x)
|
x_high = np.max(self._x)+1
|
||||||
|
|
||||||
_mask = np.ma.masked_inside(self._x, low_lim, high_lim).mask
|
if y_low is None:
|
||||||
|
y_low = np.min(self._y.real)-1
|
||||||
|
|
||||||
|
if y_high is None:
|
||||||
|
y_high = np.max(self._y.real)+1
|
||||||
|
|
||||||
|
x_mask = (self._x >= x_low) & (self._x <= x_high)
|
||||||
|
y_mask = (self._y.real >= y_low) & (self._y.real <= y_high)
|
||||||
|
_mask = x_mask & y_mask
|
||||||
|
|
||||||
self._x = self._x[_mask]
|
self._x = self._x[_mask]
|
||||||
self._y = self._y[_mask]
|
self._y = self._y[_mask]
|
||||||
|
@ -191,6 +191,18 @@ class PowerLawCross:
|
|||||||
return ret_val
|
return ret_val
|
||||||
|
|
||||||
|
|
||||||
|
class Sinc:
|
||||||
|
type = 'Basic'
|
||||||
|
name = 'Sinc'
|
||||||
|
equation = 'C * sinc((x-x_{0})/w)'
|
||||||
|
params = ['C', 'x_{0}', 'w']
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def func(x, c: float, x0: float, w: float):
|
||||||
|
# numpy sinc is defined as sin(pi*x)/(pi*x)
|
||||||
|
return c * np.sinc(((x-x0)/w)/np.pi)
|
||||||
|
|
||||||
|
|
||||||
class Sine:
|
class Sine:
|
||||||
"""
|
"""
|
||||||
Wavy sine function
|
Wavy sine function
|
||||||
|
@ -172,6 +172,14 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>&Data</string>
|
<string>&Data</string>
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="QMenu" name="menuCut_to_visible_range">
|
||||||
|
<property name="title">
|
||||||
|
<string>Cut to visible range</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="action_cut_xaxis"/>
|
||||||
|
<addaction name="action_cut_yaxis"/>
|
||||||
|
</widget>
|
||||||
<addaction name="action_new_set"/>
|
<addaction name="action_new_set"/>
|
||||||
<addaction name="action_delete_sets"/>
|
<addaction name="action_delete_sets"/>
|
||||||
<addaction name="actionMove_between_plots"/>
|
<addaction name="actionMove_between_plots"/>
|
||||||
@ -181,7 +189,7 @@
|
|||||||
<addaction name="action_sort_pts"/>
|
<addaction name="action_sort_pts"/>
|
||||||
<addaction name="actionSkip_points"/>
|
<addaction name="actionSkip_points"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="action_cut"/>
|
<addaction name="menuCut_to_visible_range"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionChange_datatypes"/>
|
<addaction name="actionChange_datatypes"/>
|
||||||
</widget>
|
</widget>
|
||||||
@ -862,11 +870,6 @@
|
|||||||
<string>Integration...</string>
|
<string>Integration...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_cut">
|
|
||||||
<property name="text">
|
|
||||||
<string>Cut to visible range</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionMove_between_plots">
|
<action name="actionMove_between_plots">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Move sets...</string>
|
<string>Move sets...</string>
|
||||||
@ -1030,6 +1033,22 @@
|
|||||||
<string>Exclude region</string>
|
<string>Exclude region</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="action_cut_xaxis">
|
||||||
|
<property name="text">
|
||||||
|
<string>x axis</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Remove data points outside visible x range.</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_cut_yaxis">
|
||||||
|
<property name="text">
|
||||||
|
<string>y axis</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Remove data points outside visible y range. Uses real part of points.</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
@ -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