Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions GraphWidgetPyQtGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,21 @@ def update_figure(self):
params.artist.setData(x,y)
except: pass

def _check_artist_exist(self, ident):
if ident in self.artists.keys():
counter = 1
while ident + str(counter) in self.artists.keys():
counter += 1
ident += str(counter)
return ident

def add_artist(self, ident, dataset, index, no_points = False):
'''
no_points is an override parameter to the global show_points setting.
It is to allow data fits to be plotted without points
'''
new_color = self.colorChooser.next()
ident = self._check_artist_exist(ident)
if self.show_points and not no_points:
line = self.pw.plot([], [], symbol='o', symbolBrush=self.getItemColor(new_color),
name=ident, pen = self.getItemColor(new_color), connect=self.scatter_plot)
Expand Down
10 changes: 9 additions & 1 deletion TraceListWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def popupMenu(self, pos):
if (item == None):
dataaddAction = menu.addAction('Add Data Set')
spectrumaddAction = menu.addAction('Add Predicted Spectrum')
removeallAction = menu.addAction('Remove All Traces')

action = menu.exec_(self.mapToGlobal(pos))
if action == dataaddAction:
Expand All @@ -71,7 +72,10 @@ def popupMenu(self, pos):
self.windows.append(ps)
ps.show()


if action == removeallAction:
for kk in reversed(range(self.count())):
ident = str(self.item(kk).text())
self.parent.remove_artist(ident)

else:
ident = str(item.text())
Expand All @@ -85,6 +89,7 @@ def popupMenu(self, pos):
cyanAction = selectColorMenu.addAction("Cyan")
magentaAction = selectColorMenu.addAction("Magenta")
whiteAction = selectColorMenu.addAction("White")
removeAction = menu.addAction('Remove')
colorActionDict = {redAction:"r", greenAction:"g", yellowAction:"y", cyanAction:"c", magentaAction:"m", whiteAction:"w"}

action = menu.exec_(self.mapToGlobal(pos))
Expand Down Expand Up @@ -124,3 +129,6 @@ def popupMenu(self, pos):
else:
self.parent.artists[ident].artist.setData(pen = new_color)
self.changeTraceListColor(ident, new_color)

if action == removeAction:
self.parent.remove_artist(ident)