From c9ea32629d224f9d83350702db32fe98c323fbe5 Mon Sep 17 00:00:00 2001
From: Dominik Demuth
Tg values:
")) - self.tg_value_label.setText(_translate("Dialog", "TextLabel")) self.label_4.setText(_translate("Dialog", "TNMH parameter:
")) self.hodge_selection.setItemText(0, _translate("Dialog", "Onset")) self.hodge_selection.setItemText(1, _translate("Dialog", "Midpoint")) diff --git a/src/gui_qt/data/container.py b/src/gui_qt/data/container.py index fca491b..93d2f12 100644 --- a/src/gui_qt/data/container.py +++ b/src/gui_qt/data/container.py @@ -317,7 +317,7 @@ class ExperimentContainer(QtCore.QObject): if mode in ['imag', 'all'] and self.plot_imag is not None: self.plot_imag.set_color(color, symbol=symbol, line=line) - def setSymbol(self, symbol=None, color=None, size=None, mode='real'): + def setSymbol(self, *, symbol=None, color=None, size=None, mode='real'): if mode in ['real', 'all']: self.plot_real.set_symbol(symbol=symbol, size=size, color=color) if color is not None and self.plot_error is not None and self.plot_real.symbol != SymbolStyle.No: @@ -329,7 +329,7 @@ class ExperimentContainer(QtCore.QObject): else: print('Updating symbol failed for ' + str(self.id)) - def setLine(self, width=None, style=None, color=None, mode='real'): + def setLine(self, *, width=None, style=None, color=None, mode='real'): if mode in ['real', 'all']: self.plot_real.set_line(width=width, style=style, color=color) if color is not None and self.plot_error is not None and self.plot_real.symbol == SymbolStyle.No: diff --git a/src/gui_qt/dsc/glass_dialog.py b/src/gui_qt/dsc/glass_dialog.py index 7dd342b..d30ea57 100644 --- a/src/gui_qt/dsc/glass_dialog.py +++ b/src/gui_qt/dsc/glass_dialog.py @@ -14,7 +14,7 @@ from nmreval.data import DSC, Points class TgCalculator(QtWidgets.QDialog, Ui_Dialog): - newTg = QtCore.pyqtSignal(dict, dict, str) + newTg = QtCore.pyqtSignal(dict, list, str) def __init__(self, management, parent=None): super().__init__(parent=parent) @@ -30,7 +30,7 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): 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), + 'midpoint': (PlotItem(x=[], y=[], pen=None, symbol='s', symbolBrush=Tab10.TabOrange.rgb(), name='Midpoint'), None), 'end': (PlotItem(x=[], y=[], pen=None, symbol='t', symbolBrush=Tab10.TabGreen.rgb(), name='End'), None), 'inflection': (PlotItem(x=[], y=[], pen=None, symbol='d', symbolBrush=Tab10.TabRed.rgb(), name='Inflection'), None), # 'fictive': PlotItem(x=[], y=[], pen=None, symbol='t1', symbolBrush=Tab10.TabPurple.rgb(), name='Fictive'), @@ -40,6 +40,9 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): for plt, _ in self._hodge.values(): self.tau_plot.addItem(plt) self.tau_plot.setLogMode(y=True) + self.pushButton_2.hide() + self.label_4.hide() + self.label_5.hide() self.limits = RegionItem(), RegionItem() for lim in self.limits: @@ -253,6 +256,7 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): if len(m) > 1: data = tau_hodge(*array(m).T) + data.name = f'{data.name} ({tg_type.capitalize()})' plot.setData(data.x, data.y) self._hodge[tg_type] = (plot, data) @@ -271,15 +275,25 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): for key, tg in self._tg_value.items(): 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], - ) + if self.tg_export_check.isChecked(): + tg_pts = Points(x=tgx, y=tgy, name=self._management[key].name + ' (Tg)', value=self._management[key].value) + else: + tg_pts = None - ret_dic2 = {} - for k, (_, v) in self._hodge.items(): - ret_dic2[k] = v + if self.tglines_export_check.isChecked(): + line = self._lines[key] + else: + line = [] + + ret_dic[key] = (tg_pts, line) + + ret_dic2 = [] + + for i in range(self.hodge_selection.count()): + if self.hodge_selection.isChecked(i): + item = self.hodge_selection.itemText(i).lower() + v = self._hodge.get(item) + ret_dic2.append(v[1]) self.newTg.emit(ret_dic, ret_dic2, graph_id) self.close() diff --git a/src/gui_qt/lib/pg_objects.py b/src/gui_qt/lib/pg_objects.py index cfa316d..fba116b 100644 --- a/src/gui_qt/lib/pg_objects.py +++ b/src/gui_qt/lib/pg_objects.py @@ -280,7 +280,7 @@ class PlotItem(PlotDataItem): else: self.scatter.hide() - def set_symbol(self, symbol=None, size=None, color=None): + def set_symbol(self, *, symbol=None, size=None, color=None): if symbol is not None: if isinstance(symbol, int): self.setSymbol(SymbolStyle(symbol).to_str()) @@ -314,7 +314,7 @@ class PlotItem(PlotDataItem): self.opts['pen'] = pen self.updateItems() - def set_line(self, style=None, width=None, color=None): + def set_line(self, *, style=None, width=None, color=None): pen = self.opts['pen'] if pen is None: pen = mkPen(style=QtCore.Qt.NoPen) diff --git a/src/gui_qt/main/management.py b/src/gui_qt/main/management.py index 5a6f878..d62aca8 100644 --- a/src/gui_qt/main/management.py +++ b/src/gui_qt/main/management.py @@ -773,21 +773,29 @@ 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(): + @QtCore.pyqtSlot(dict, list, str) + def addTg(self, dic1: dict, dic2: list, graph_id: str): + for k, (tg, lines) 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]: + + tg_data_id = [] + + if tg is not None: + tg_data_id.append(self.add(tg, color=col)) + + for line in lines: set_id = self.add(line, color=col) - self.newData.emit([set_id], self.current_graph) + self[set_id].setLine(style=LineStyle.Dashed) + self[set_id].setSymbol(symbol=SymbolStyle.No) + tg_data_id.append(set_id) + + self.newData.emit(tg_data_id, self.current_graph) set_id_list = [] - for v in dic2.values(): + for v in dic2: set_id_list.append(self.add(v)) - self.newData.emit(set_id_list, '') + self.newData.emit(set_id_list, graph_id) @QtCore.pyqtSlot(int, dict) def smooth_data(self, npoints, param_kwargs): diff --git a/src/nmreval/data/dsc.py b/src/nmreval/data/dsc.py index 9bd3afd..f9c82fa 100644 --- a/src/nmreval/data/dsc.py +++ b/src/nmreval/data/dsc.py @@ -121,13 +121,13 @@ class DSC(Points): midpoint = np.argmin(np.abs(y - 0.5 * (liquid_baseline[end] - glass_baseline[onset]))) cut_tangent = np.where((tangent_line > y.min() - 1) & (tangent_line < y.max() + 1)) - glass = Points(x, glass_baseline, name='Glass baseline', value=self.value) - tangent = Points(x[cut_tangent], tangent_line[cut_tangent], name='Tangent', value=self.value) - liquid = Points(x, liquid_baseline, name='Liquid baseline', value=self.value) + glass = Points(x, glass_baseline, name=f'Glass baseline ({self.name})', value=self.value) + tangent = Points(x[cut_tangent], tangent_line[cut_tangent], name=f'Tangent ({self.name})', value=self.value) + liquid = Points(x, liquid_baseline, name=f'Liquid baseline ({self.name})', value=self.value) ret_dic = { 'onset': (x[onset], glass_baseline[onset]), - 'mid': (x[midpoint], y[midpoint]), + 'midpoint': (x[midpoint], y[midpoint]), 'end': (x[end], liquid_baseline[end]), 'inflection': (x[inflection], y[inflection]), } diff --git a/src/resources/_ui/tnmh_dialog.ui b/src/resources/_ui/tnmh_dialog.ui index fd29a3c..dec99ec 100644 --- a/src/resources/_ui/tnmh_dialog.ui +++ b/src/resources/_ui/tnmh_dialog.ui @@ -55,7 +55,7 @@