from ..Qt import QtWidgets, QtCore from .._py.tnmh_dialog import Ui_Dialog from ..lib.pg_objects import PlotItem, RegionItem from nmreval.data import DSC class TgCalculator(QtWidgets.QDialog, Ui_Dialog): def __init__(self, management, parent=None): super().__init__(parent=parent) self.setupUi(self) self._management = management self._plots = {} self.limits = RegionItem(), RegionItem() for lim in self.limits: self.graphicsView.addItem(lim) self.add_sets() def __call__(self): self.clear() self.add_sets() # s.valuesChanged.connect(self.management.shift_scale) def clear(self): self.listWidget.clear() for k, v in self._plots.items(): self.graphicsView.removeItem(v) def add_sets(self): for key, name in self._management.active_sets: data = self._management.data[key] if not isinstance(data.data, DSC): continue item = QtWidgets.QListWidgetItem(name) item.setData(QtCore.Qt.UserRole, key) plot = PlotItem(x=data.x, y=data.y) self.graphicsView.addItem(plot) self._plots[key] = plot