forked from IPKM/nmreval
work on export
This commit is contained in:
@ -10,10 +10,12 @@ from ..Qt import QtWidgets, QtCore
|
||||
from .._py.tnmh_dialog import Ui_Dialog
|
||||
from ..lib.pg_objects import PlotItem, RegionItem
|
||||
|
||||
from nmreval.data import DSC
|
||||
from nmreval.data import DSC, Points
|
||||
|
||||
|
||||
class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
||||
newTg = QtCore.pyqtSignal(dict, dict, str)
|
||||
|
||||
def __init__(self, management, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
|
||||
@ -25,6 +27,7 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
||||
self._plots = {}
|
||||
self._tg_value = {}
|
||||
self._fit = {}
|
||||
self._lines = {}
|
||||
self._hodge = {
|
||||
'onset': (PlotItem(x=[], y=[], pen=None, symbol='o', symbolBrush=Tab10.TabBlue.rgb(), name='Onset'), None),
|
||||
'mid': (PlotItem(x=[], y=[], pen=None, symbol='s', symbolBrush=Tab10.TabOrange.rgb(), name='Midpoint'), None),
|
||||
@ -48,7 +51,7 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.listWidget.itemClicked.connect(self.show_tg_values)
|
||||
|
||||
self.new_graph_tau_combo.setEnabled(False)
|
||||
self.new_graph_tau_check.stateChanged.connect(lambda state: self.new_graph_tau_combo.setEnabled(bool(state)))
|
||||
self.new_graph_tau_check.stateChanged.connect(lambda state: self.new_graph_tau_combo.setEnabled(not bool(state)))
|
||||
|
||||
def __call__(self):
|
||||
self.clear()
|
||||
@ -65,11 +68,13 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.graphicsView_2.removeItem(val)
|
||||
|
||||
for plt in self._hodge.values():
|
||||
plt.setData(x=[], y=[])
|
||||
plt[0].setData(x=[], y=[])
|
||||
plt[1] = None
|
||||
|
||||
self._dsc = {}
|
||||
self._plots = {}
|
||||
self._tg_value = {}
|
||||
self._lines = {}
|
||||
self._fit = {}
|
||||
|
||||
def add_sets(self):
|
||||
@ -145,9 +150,10 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
||||
data, _ = self._dsc[key]
|
||||
|
||||
tg_results, glass, liquid, tangent = data.glass_transition(*baselines)
|
||||
self._lines[key] = (glass, liquid, tangent)
|
||||
|
||||
for i, line in enumerate((glass, liquid, tangent)):
|
||||
plot[i+2].setData(x=line[:, 0], y=line[:, 1])
|
||||
plot[i+2].setData(x=line.x, y=line.y)
|
||||
|
||||
self._tg_value[key].update(tg_results)
|
||||
|
||||
@ -249,6 +255,8 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
||||
data = tau_hodge(*array(m).T)
|
||||
plot.setData(data.x, data.y)
|
||||
|
||||
self._hodge[tg_type] = (plot, data)
|
||||
|
||||
def close(self) -> bool:
|
||||
self.clear()
|
||||
return super().close()
|
||||
@ -259,13 +267,19 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
||||
else:
|
||||
graph_id = self.new_graph_tau_combo.currentData()
|
||||
|
||||
print(graph_id)
|
||||
|
||||
ret_dic = {}
|
||||
|
||||
for key, tg in self._tg_value.items():
|
||||
plts = self._plots[key]
|
||||
ret_dic[key] = (tg, plts[1].getData(), plts[2].getData(), plts[3].getData(), plts[4].getData())
|
||||
tgx = [x for x, y in tg.values()]
|
||||
tgy = [y for x, y in tg.values()]
|
||||
tg_pts = Points(x=tgx, y=tgy, name=self._management[key].name, value=self._management[key].value)
|
||||
ret_dic[key] = (
|
||||
tg_pts,
|
||||
self._lines[key],
|
||||
)
|
||||
|
||||
pprint.pprint(ret_dic)
|
||||
pprint.pprint(self._hodge)
|
||||
ret_dic2 = {}
|
||||
for k, (_, v) in self._hodge.items():
|
||||
ret_dic2[k] = v
|
||||
|
||||
self.newTg.emit(ret_dic, ret_dic2, graph_id)
|
||||
self.close()
|
||||
|
@ -1095,6 +1095,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
def show_tg_dialog(self):
|
||||
if self._tg_dialog is None:
|
||||
self._tg_dialog = TgCalculator(self.management, parent=self)
|
||||
self._tg_dialog.newTg.connect(self.management.addTg)
|
||||
else:
|
||||
self._tg_dialog()
|
||||
self._tg_dialog.show()
|
||||
|
@ -775,6 +775,22 @@ class UpperManagement(QtCore.QObject):
|
||||
|
||||
self.newData.emit(new_data, self.current_graph)
|
||||
|
||||
@QtCore.pyqtSlot(dict, dict, str)
|
||||
def addTg(self, dic1: dict, dic2: dict, graph_id: str):
|
||||
for k, v in dic1.items():
|
||||
p: ExperimentContainer = self[k]
|
||||
col = p.plot_real.linecolor
|
||||
set_id = self.add(v[0], color=col)
|
||||
self.newData.emit([set_id], self.current_graph)
|
||||
for line in v[1]:
|
||||
set_id = self.add(line, color=col)
|
||||
self.newData.emit([set_id], self.current_graph)
|
||||
|
||||
set_id_list = []
|
||||
for v in dic2.values():
|
||||
set_id_list.append(self.add(v))
|
||||
self.newData.emit(set_id_list, '')
|
||||
|
||||
@QtCore.pyqtSlot(int, dict)
|
||||
def smooth_data(self, npoints, param_kwargs):
|
||||
_active = self.graphs[self.current_graph].active
|
||||
|
Reference in New Issue
Block a user