more ui work
This commit is contained in:
parent
f74dd982ba
commit
eb1e657dab
@ -1,5 +1,6 @@
|
|||||||
from itertools import cycle
|
from itertools import cycle
|
||||||
|
|
||||||
|
from numpy import array
|
||||||
from pyqtgraph import mkPen, mkBrush
|
from pyqtgraph import mkPen, mkBrush
|
||||||
|
|
||||||
from nmreval.lib.colors import Tab10
|
from nmreval.lib.colors import Tab10
|
||||||
@ -20,6 +21,7 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
|
|
||||||
self._dsc = {}
|
self._dsc = {}
|
||||||
self._tg_baselines = {}
|
self._tg_baselines = {}
|
||||||
|
self._tg_value_plot = []
|
||||||
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)
|
||||||
@ -41,6 +43,10 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
self.graphicsView.removeItem(v)
|
self.graphicsView.removeItem(v)
|
||||||
self._tg_baselines = {}
|
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
|
||||||
max_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')
|
@QtCore.pyqtSlot(name='on_pushButton_clicked')
|
||||||
def calc_tg(self):
|
def calc_tg(self):
|
||||||
for v in self._tg_baselines.values():
|
for v in self._tg_baselines.values():
|
||||||
self.graphicsView.removeItem(v)
|
for line in v:
|
||||||
|
self.graphicsView.removeItem(line)
|
||||||
self._tg_baselines = {}
|
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]
|
||||||
@ -79,7 +89,6 @@ 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()
|
||||||
print(color)
|
|
||||||
_, data = self._dsc[key]
|
_, data = self._dsc[key]
|
||||||
tg_results, glass, liquid, tangent = data.glass_transition(*baselines)
|
tg_results, glass, liquid, tangent = data.glass_transition(*baselines)
|
||||||
|
|
||||||
@ -90,8 +99,8 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
self.graphicsView.addItem(plt)
|
self.graphicsView.addItem(plt)
|
||||||
lines.append(plt)
|
lines.append(plt)
|
||||||
self._tg_baselines[key] = lines
|
self._tg_baselines[key] = lines
|
||||||
|
tg_plot = PlotItem(array(list(tg_results.values())), pen=None, symbolBrush=color, symbol='o')
|
||||||
tg_plot = PlotItem(*zip((i for i in tg_results.values())))
|
self._tg_value_plot.append(tg_plot)
|
||||||
self.graphicsView.addItem(tg_plot)
|
self.graphicsView.addItem(tg_plot)
|
||||||
|
|
||||||
def close(self) -> bool:
|
def close(self) -> bool:
|
||||||
|
@ -174,6 +174,7 @@ class PlotItem(PlotDataItem):
|
|||||||
pen = self.opts['pen']
|
pen = self.opts['pen']
|
||||||
if isinstance(pen, tuple):
|
if isinstance(pen, tuple):
|
||||||
self.opts['linecolor'] = pen
|
self.opts['linecolor'] = pen
|
||||||
|
self.opts['pen'] = mkPen(color=pen)
|
||||||
else:
|
else:
|
||||||
c = pen.color()
|
c = pen.color()
|
||||||
self.opts['linecolor'] = c.red(), c.green(), c.blue()
|
self.opts['linecolor'] = c.red(), c.green(), c.blue()
|
||||||
@ -320,7 +321,6 @@ class PlotItem(PlotDataItem):
|
|||||||
|
|
||||||
if width is not None:
|
if width is not None:
|
||||||
pen.setWidthF(width)
|
pen.setWidthF(width)
|
||||||
|
|
||||||
if style is not None:
|
if style is not None:
|
||||||
if isinstance(style, LineStyle):
|
if isinstance(style, LineStyle):
|
||||||
style = style.value
|
style = style.value
|
||||||
|
Loading…
Reference in New Issue
Block a user