[update] no more replotting of whole data when pick is changed

This commit is contained in:
Marcel Paffrath 2018-07-17 09:42:13 +02:00
parent 5b48b744fd
commit 64885db214

View File

@ -134,6 +134,9 @@ class MainWindow(QMainWindow):
self._ctrl = False # control key pressed self._ctrl = False # control key pressed
self._shift = False # shift key pressed self._shift = False # shift key pressed
self.drawnPicks = {'auto': {},
'manual': {}}
# default factor for dataplot e.g. enabling/disabling scrollarea # default factor for dataplot e.g. enabling/disabling scrollarea
self.height_factor = 12 self.height_factor = 12
self.plot_method = 'normal' self.plot_method = 'normal'
@ -2324,16 +2327,14 @@ class MainWindow(QMainWindow):
if pickDlg._dirty: if pickDlg._dirty:
self.setDirty(True) self.setDirty(True)
self.update_status('picks accepted ({0})'.format(station)) self.update_status('picks accepted ({0})'.format(station))
replot1 = self.addPicks(station, pickDlg.getPicks(picktype='manual'), type='manual') self.addPicks(station, pickDlg.getPicks(picktype='manual'), type='manual')
replot2 = self.addPicks(station, pickDlg.getPicks(picktype='auto'), type='auto') self.addPicks(station, pickDlg.getPicks(picktype='auto'), type='auto')
self.enableSaveEventAction() self.enableSaveEventAction()
if replot1 or replot2: self.comparable = self.checkEvents4comparison()
self.plotWaveformDataThread() if True in self.comparable.values():
self.compare_action.setEnabled(True)
self.draw() self.drawPicks(station)
else: self.draw()
self.drawPicks(station)
self.draw()
if self.nextStation: if self.nextStation:
self.pickDialog(wfID - 1) self.pickDialog(wfID - 1)
else: else:
@ -2652,6 +2653,9 @@ class MainWindow(QMainWindow):
self.drawPicks(station, 'auto', stime) self.drawPicks(station, 'auto', stime)
return return
if not picktype in ['manual', 'auto']:
raise TypeError('Unknown picktype {0}'.format(picktype))
# if picks to draw not specified, draw all picks available # if picks to draw not specified, draw all picks available
if not station: if not station:
for station in self.getPicks(type=picktype): for station in self.getPicks(type=picktype):
@ -2674,6 +2678,11 @@ class MainWindow(QMainWindow):
stat_picks = self.getPicks(type=picktype)[station] stat_picks = self.getPicks(type=picktype)[station]
if station in self.drawnPicks[picktype].keys():
for item in self.drawnPicks[picktype][station]:
pw.removeItem(item)
self.drawnPicks[picktype][station] = []
for phase in stat_picks: for phase in stat_picks:
if phase == 'SPt': continue # wadati SP time if phase == 'SPt': continue # wadati SP time
picks = stat_picks[phase] picks = stat_picks[phase]
@ -2698,32 +2707,31 @@ class MainWindow(QMainWindow):
spe = picks['spe'] spe = picks['spe']
if self.pg: if self.pg:
if picktype == 'manual' or picktype == 'auto': if spe:
if spe: if picks['epp'] and picks['lpp']:
if picks['epp'] and picks['lpp']: pen = make_pen(picktype, phaseID, 'epp', quality)
pen = make_pen(picktype, phaseID, 'epp', quality) self.drawnPicks[picktype][station].append(pw.plot([epp, epp], ylims,
pw.plot([epp, epp], ylims, alpha=.25, pen=pen, name='EPP'))
alpha=.25, pen=pen, name='EPP') pen = make_pen(picktype, phaseID, 'lpp', quality)
pen = make_pen(picktype, phaseID, 'lpp', quality) self.drawnPicks[picktype][station].append(pw.plot([lpp, lpp], ylims,
pw.plot([lpp, lpp], ylims, alpha=.25, pen=pen, name='LPP'))
alpha=.25, pen=pen, name='LPP') pen = make_pen(picktype, phaseID, 'spe', quality)
pen = make_pen(picktype, phaseID, 'spe', quality) spe_l = pg.PlotDataItem([mpp - spe, mpp - spe], ylims, pen=pen,
spe_l = pg.PlotDataItem([mpp - spe, mpp - spe], ylims, pen=pen, name='{}-SPE'.format(phase))
name='{}-SPE'.format(phase)) spe_r = pg.PlotDataItem([mpp + spe, mpp + spe], ylims, pen=pen)
spe_r = pg.PlotDataItem([mpp + spe, mpp + spe], ylims, pen=pen) try:
try: color = pen.color()
color = pen.color() color.setAlpha(100.)
color.setAlpha(100.) brush = pen.brush()
brush = pen.brush() brush.setColor(color)
brush.setColor(color) fill = pg.FillBetweenItem(spe_l, spe_r, brush=brush)
fill = pg.FillBetweenItem(spe_l, spe_r, brush=brush) fb = pw.addItem(fill)
fb = pw.addItem(fill) self.drawnPicks[picktype][station].append(fill)
except: except:
print('Warning: drawPicks: Could not create fill for symmetric pick error.') print('Warning: drawPicks: Could not create fill for symmetric pick error.')
pen = make_pen(picktype, phaseID, 'mpp', quality) pen = make_pen(picktype, phaseID, 'mpp', quality)
pw.plot([mpp, mpp], ylims, pen=pen, name='{}-Pick'.format(phase)) self.drawnPicks[picktype][station].append(
else: pw.plot([mpp, mpp], ylims, pen=pen, name='{}-Pick'.format(phase)))
raise TypeError('Unknown picktype {0}'.format(picktype))
else: else:
if picktype == 'manual': if picktype == 'manual':
linestyle_mpp, width_mpp = pick_linestyle_plt(picktype, 'mpp') linestyle_mpp, width_mpp = pick_linestyle_plt(picktype, 'mpp')