forked from IPKM/nmreval
initialize plot at start
This commit is contained in:
parent
edc6af2762
commit
bec789318d
@ -20,8 +20,9 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
self._colors = cycle(Tab10)
|
self._colors = cycle(Tab10)
|
||||||
|
|
||||||
self._dsc = {}
|
self._dsc = {}
|
||||||
self._tg_baselines = {}
|
self._plots = {}
|
||||||
self._tg_value_plot = {}
|
self._tg_value = {}
|
||||||
|
|
||||||
self.limits = RegionItem(), RegionItem()
|
self.limits = RegionItem(), RegionItem()
|
||||||
for lim in self.limits:
|
for lim in self.limits:
|
||||||
self.graphicsView.addItem(lim)
|
self.graphicsView.addItem(lim)
|
||||||
@ -33,21 +34,13 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
def __call__(self):
|
def __call__(self):
|
||||||
self.clear()
|
self.clear()
|
||||||
self.add_sets()
|
self.add_sets()
|
||||||
# s.valuesChanged.connect(self.management.shift_scale)
|
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
self.listWidget.clear()
|
self.listWidget.clear()
|
||||||
for plot, data in self._dsc.values():
|
for plots in self._plots.values():
|
||||||
self.graphicsView.removeItem(plot)
|
for val in plots:
|
||||||
self._dsc = {}
|
self.graphicsView.removeItem(val)
|
||||||
|
self.graphicsView_2.removeItem(val)
|
||||||
for v in self._tg_baselines.values():
|
|
||||||
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):
|
def add_sets(self):
|
||||||
min_x = 10_000_000
|
min_x = 10_000_000
|
||||||
@ -61,13 +54,39 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
max_x = max(max_x, data.x.max())
|
max_x = max(max_x, data.x.max())
|
||||||
|
|
||||||
item = QtWidgets.QListWidgetItem(name)
|
item = QtWidgets.QListWidgetItem(name)
|
||||||
|
item.setCheckState(QtCore.Qt.Checked)
|
||||||
item.setData(QtCore.Qt.UserRole, key)
|
item.setData(QtCore.Qt.UserRole, key)
|
||||||
item.setForeground(mkBrush(c.rgb()))
|
item.setForeground(mkBrush(c.rgb()))
|
||||||
self.listWidget.addItem(item)
|
self.listWidget.addItem(item)
|
||||||
|
|
||||||
plot = PlotItem(x=data.x, y=data.y, pen=mkPen(c.rgb()))
|
self._dsc[key] = data
|
||||||
self.graphicsView.addItem(plot)
|
|
||||||
self._dsc[key] = (plot, data)
|
data_plot = PlotItem(x=data.x, y=data.y, pen=mkPen(c.rgb()))
|
||||||
|
self.graphicsView.addItem(data_plot)
|
||||||
|
|
||||||
|
glass = PlotItem()
|
||||||
|
glass.set_line(style=2, color=c)
|
||||||
|
self.graphicsView.addItem(glass)
|
||||||
|
|
||||||
|
liquid = PlotItem()
|
||||||
|
liquid.set_line(style=2, color=c)
|
||||||
|
self.graphicsView.addItem(liquid)
|
||||||
|
|
||||||
|
tangent = PlotItem()
|
||||||
|
tangent.set_line(style=2, color=c)
|
||||||
|
self.graphicsView.addItem(tangent)
|
||||||
|
|
||||||
|
tg_plot = PlotItem(pen=None, symbolBrush=c.rgb(), symbol='o')
|
||||||
|
self.graphicsView.addItem(tg_plot)
|
||||||
|
|
||||||
|
fictive_cp = PlotItem(pen=mkPen(c.rgb()))
|
||||||
|
self.graphicsView_2.addItem(fictive_cp)
|
||||||
|
|
||||||
|
tnmh_fit = PlotItem()
|
||||||
|
tnmh_fit.set_line(style=2, color=c)
|
||||||
|
self.graphicsView_2.addItem(tnmh_fit)
|
||||||
|
|
||||||
|
self._plots[key] = (data_plot, tg_plot, glass, liquid, tangent, fictive_cp, tnmh_fit)
|
||||||
|
|
||||||
dist = max_x - min_x
|
dist = max_x - min_x
|
||||||
self.limits[0].setRegion((min_x, min_x+0.1*dist))
|
self.limits[0].setRegion((min_x, min_x+0.1*dist))
|
||||||
@ -75,14 +94,6 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
|
|
||||||
@QtCore.pyqtSlot(name='on_pushButton_clicked')
|
@QtCore.pyqtSlot(name='on_pushButton_clicked')
|
||||||
def calc_tg(self):
|
def calc_tg(self):
|
||||||
for v in self._tg_baselines.values():
|
|
||||||
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)
|
baselines = tuple(lim.getRegion() for lim in self.limits)
|
||||||
if baselines[0][0] > baselines[1][0]:
|
if baselines[0][0] > baselines[1][0]:
|
||||||
baselines = baselines[1], baselines[0]
|
baselines = baselines[1], baselines[0]
|
||||||
@ -91,22 +102,20 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
item = self.listWidget.item(idx)
|
item = self.listWidget.item(idx)
|
||||||
key = item.data(QtCore.Qt.UserRole)
|
key = item.data(QtCore.Qt.UserRole)
|
||||||
color = item.foreground()
|
color = item.foreground()
|
||||||
_, data = self._dsc[key]
|
|
||||||
|
plot = self._plots[key]
|
||||||
|
data = self._dsc[key]
|
||||||
|
|
||||||
tg_results, glass, liquid, tangent = data.glass_transition(*baselines)
|
tg_results, glass, liquid, tangent = data.glass_transition(*baselines)
|
||||||
|
|
||||||
lines = []
|
for i, line in enumerate((glass, liquid, tangent)):
|
||||||
for line in (glass, liquid, tangent):
|
plot[i+2].setData(x=line[:, 0], y=line[:, 1])
|
||||||
plt = PlotItem(line[:, 0], line[:, 1])
|
|
||||||
plt.set_line(style=2, color=color.color())
|
plot[1].setData(array(list(tg_results.values())))
|
||||||
self.graphicsView.addItem(plt)
|
self._tg_value[key] = tg_results
|
||||||
lines.append(plt)
|
|
||||||
self._tg_baselines[key] = lines
|
|
||||||
tg_plot = PlotItem(array(list(tg_results.values())), pen=None, symbolBrush=color, symbol='o')
|
|
||||||
self._tg_value_plot[key] = (tg_results, tg_plot)
|
|
||||||
self.graphicsView.addItem(tg_plot)
|
|
||||||
|
|
||||||
def show_tg_values(self, item):
|
def show_tg_values(self, item):
|
||||||
values, _ = self._tg_value_plot.get(item.data(QtCore.Qt.UserRole), ({}, None))
|
values = self._tg_value.get(item.data(QtCore.Qt.UserRole))
|
||||||
|
|
||||||
if values is not None:
|
if values is not None:
|
||||||
self.listWidget_2.clear()
|
self.listWidget_2.clear()
|
||||||
@ -123,23 +132,20 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
for idx in range(self.listWidget.count()):
|
for idx in range(self.listWidget.count()):
|
||||||
item = self.listWidget.item(idx)
|
item = self.listWidget.item(idx)
|
||||||
key = item.data(QtCore.Qt.UserRole)
|
key = item.data(QtCore.Qt.UserRole)
|
||||||
color = item.foreground()
|
|
||||||
_, data = self._dsc[key]
|
plot = self._plots[key]
|
||||||
|
data = self._dsc[key]
|
||||||
cp, tg = data.get_fictive_cp(*baselines)
|
cp, tg = data.get_fictive_cp(*baselines)
|
||||||
|
|
||||||
plt = PlotItem(cp.x, cp.y)
|
plot[5].setData(cp.x, cp.y)
|
||||||
plt.set_line(color=color.color())
|
|
||||||
self.graphicsView_2.addItem(plt)
|
|
||||||
|
|
||||||
self._tg_value_plot[key][0]['fictive'] = (tg, 0)
|
self._tg_value[key]['fictive'] = (tg, 0)
|
||||||
tg_plot = PlotItem(array(list(self._tg_value_plot[key][0].values())), pen=None, symbolBrush=color, symbol='o')
|
|
||||||
self.graphicsView.addItem(tg_plot)
|
|
||||||
|
|
||||||
res = data.calculate_tnmh([100, 0.5, 1, 2e5], *baselines, return_fictive=False)
|
plot[1].setData(array(list(self._tg_value[key].values())))
|
||||||
plt = PlotItem(res.x, res.y)
|
|
||||||
|
res = data.calculate_tnmh([60, 0.5, 1, 2e5], *baselines, return_fictive=False)
|
||||||
print(res.pprint())
|
print(res.pprint())
|
||||||
plt.set_line(style=2, color=color.color())
|
plot[-1].setData(res.x, res.y)
|
||||||
self.graphicsView_2.addItem(plt)
|
|
||||||
|
|
||||||
def close(self) -> bool:
|
def close(self) -> bool:
|
||||||
self.clear()
|
self.clear()
|
||||||
|
Loading…
Reference in New Issue
Block a user