From eb1e657dabff1317de8110bab5e3e3030e5512c4 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Wed, 31 May 2023 19:35:03 +0200 Subject: [PATCH] more ui work --- src/gui_qt/dsc/glass_dialog.py | 17 +++++++++++++---- src/gui_qt/lib/pg_objects.py | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/gui_qt/dsc/glass_dialog.py b/src/gui_qt/dsc/glass_dialog.py index dd7f6fd..bbf2a15 100644 --- a/src/gui_qt/dsc/glass_dialog.py +++ b/src/gui_qt/dsc/glass_dialog.py @@ -1,5 +1,6 @@ from itertools import cycle +from numpy import array from pyqtgraph import mkPen, mkBrush from nmreval.lib.colors import Tab10 @@ -20,6 +21,7 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): self._dsc = {} self._tg_baselines = {} + self._tg_value_plot = [] self.limits = RegionItem(), RegionItem() for lim in self.limits: self.graphicsView.addItem(lim) @@ -41,6 +43,10 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): self.graphicsView.removeItem(v) self._tg_baselines = {} + for v in self._tg_value_plot: + self.graphicsView.removeItem(v) + self._tg_value_plot = [] + def add_sets(self): min_x = 10_000_000 max_x = -10_000_000 @@ -68,9 +74,13 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): @QtCore.pyqtSlot(name='on_pushButton_clicked') def calc_tg(self): for v in self._tg_baselines.values(): - self.graphicsView.removeItem(v) + for line in v: + self.graphicsView.removeItem(line) self._tg_baselines = {} + for v in self._tg_value_plot: + self.graphicsView.removeItem(v) + baselines = tuple(lim.getRegion() for lim in self.limits) if baselines[0][0] > baselines[1][0]: baselines = baselines[1], baselines[0] @@ -79,7 +89,6 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): item = self.listWidget.item(idx) key = item.data(QtCore.Qt.UserRole) color = item.foreground() - print(color) _, data = self._dsc[key] tg_results, glass, liquid, tangent = data.glass_transition(*baselines) @@ -90,8 +99,8 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): self.graphicsView.addItem(plt) lines.append(plt) self._tg_baselines[key] = lines - - tg_plot = PlotItem(*zip((i for i in tg_results.values()))) + tg_plot = PlotItem(array(list(tg_results.values())), pen=None, symbolBrush=color, symbol='o') + self._tg_value_plot.append(tg_plot) self.graphicsView.addItem(tg_plot) def close(self) -> bool: diff --git a/src/gui_qt/lib/pg_objects.py b/src/gui_qt/lib/pg_objects.py index 4ab0f30..cfa316d 100644 --- a/src/gui_qt/lib/pg_objects.py +++ b/src/gui_qt/lib/pg_objects.py @@ -174,6 +174,7 @@ class PlotItem(PlotDataItem): pen = self.opts['pen'] if isinstance(pen, tuple): self.opts['linecolor'] = pen + self.opts['pen'] = mkPen(color=pen) else: c = pen.color() self.opts['linecolor'] = c.red(), c.green(), c.blue() @@ -320,7 +321,6 @@ class PlotItem(PlotDataItem): if width is not None: pen.setWidthF(width) - if style is not None: if isinstance(style, LineStyle): style = style.value