forked from HaeffnerLab/RealSimpleGrapher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTraceListWidget.py
More file actions
84 lines (69 loc) · 2.93 KB
/
TraceListWidget.py
File metadata and controls
84 lines (69 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from PyQt4 import QtGui
from PyQt4 import QtCore
from ParameterListWidget import ParameterList
from DataVaultListWidget import DataVaultList
from FitWindowWidget import FitWindow
from GUIConfig import traceListConfig
class TraceList(QtGui.QListWidget):
def __init__(self, parent):
super(TraceList, self).__init__()
self.parent = parent
self.windows = []
self.config = traceListConfig()
self.setStyleSheet("background-color:%s;" % self.config.background_color)
self.name = 'pmt'
self.initUI()
def initUI(self):
self.trace_dict = {}
item = QtGui.QListWidgetItem('Traces')
item.setCheckState(QtCore.Qt.Checked)
self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.customContextMenuRequested.connect(self.popupMenu)
def addTrace(self, ident):
item = QtGui.QListWidgetItem(ident)
item.setForeground(QtGui.QColor(255, 255, 255))
item.setBackground(QtGui.QColor(0, 0, 0))
item.setCheckState(QtCore.Qt.Checked)
self.addItem(item)
self.trace_dict[ident] = item
def removeTrace(self, ident):
item = self.trace_dict[ident]
row = self.row(item)
self.takeItem(row)
item = None
def popupMenu(self, pos):
menu = QtGui.QMenu()
item = self.itemAt(pos)
if (item == None):
dataaddAction = menu.addAction('Add Data Set')
action = menu.exec_(self.mapToGlobal(pos))
if action == dataaddAction:
dvlist = DataVaultList(self.parent.name)
self.windows.append(dvlist)
dvlist.show()
else:
ident = str(item.text())
parametersAction = menu.addAction('Parameters')
togglecolorsAction = menu.addAction('Toggle colors')
fitAction = menu.addAction('Fit')
action = menu.exec_(self.mapToGlobal(pos))
if action == parametersAction:
# option to show parameters in separate window
dataset = self.parent.artists[ident].dataset
pl = ParameterList(dataset)
self.windows.append(pl)
pl.show()
if action == togglecolorsAction:
# option to change color of line
new_color = self.parent.colorChooser.next()
#self.parent.artists[ident].artist.setData(color = new_color, symbolBrush = new_color)
if self.parent.show_points:
self.parent.artists[ident].artist.setData(pen = new_color, symbolBrush = new_color)
else:
self.parent.artists[ident].artist.setData(pen = new_color)
if action == fitAction:
dataset = self.parent.artists[ident].dataset
index = self.parent.artists[ident].index
fw = FitWindow(dataset, index, self)
self.windows.append(fw)
fw.show()