nmreval/src/gui_qt/dsc/glass_dialog.py

44 lines
1.2 KiB
Python
Raw Normal View History

2023-05-26 16:22:13 +00:00
from ..Qt import QtWidgets, QtCore
from .._py.tnmh_dialog import Ui_Dialog
from ..lib.pg_objects import PlotItem, RegionItem
from nmreval.data import DSC
2023-05-23 17:23:13 +00:00
2023-05-24 17:34:06 +00:00
class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
def __init__(self, management, parent=None):
2023-05-23 17:23:13 +00:00
super().__init__(parent=parent)
2023-05-24 17:34:06 +00:00
self.setupUi(self)
self._management = management
2023-05-26 15:28:06 +00:00
self._plots = {}
2023-05-26 16:22:13 +00:00
self.limits = RegionItem(), RegionItem()
for lim in self.limits:
self.graphicsView.addItem(lim)
self.add_sets()
2023-05-26 15:28:06 +00:00
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]
2023-05-26 16:22:13 +00:00
if not isinstance(data.data, DSC):
continue
2023-05-26 15:28:06 +00:00
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