forked from IPKM/nmreval
		
	more ui work
This commit is contained in:
		@@ -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:
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user