From c86adb4e6e7fec4c7d9843ae1c1d96bb65a219ec Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Thu, 28 May 2015 12:14:16 +0200 Subject: [PATCH] preparing storing the picks and making the GUI work more intuitively --- pylot/core/util/widgets.py | 65 +++++++++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 4 deletions(-) diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index 0dcea588..15c6a11c 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -344,6 +344,10 @@ class PickDlg(QDialog): self.selectPhase.currentIndexChanged.connect(self.verifyPhaseSelection) + _buttonbox.accepted.connect(self.accept) + _buttonbox.rejected.connect(self.reject) + _buttonbox.clicked(QDialogButtonBox.Apply).connect(self.apply) + self.setLayout(_outerlayout) def disconnectPressEvent(self): @@ -486,6 +490,8 @@ class PickDlg(QDialog): zoomy=zoomy, noiselevel=noiselevel) + self.zoomAction.enabled = False + self.updateAPD(wfdata) # reset labels @@ -500,12 +506,66 @@ class PickDlg(QDialog): # get earliest and latest possible pick [epp, lpp, pickerror] = earllatepicker(wfdata, 1.5, (5., .5, 2.), pick) + # get name of phase actually picked + phase = self.selectPhase.currentText() + + # save pick times for actual phase + phasepicks = {} + + phasepicks['epp'] = epp + phasepicks['lpp'] = lpp + phasepicks['mpp'] = pick + phasepicks['spe'] = pickerror + + try: + oldphasepick = self.picks[phase] + except KeyError: + self.picks[phase] = phasepicks + else: + self.picks[phase] = phasepicks + oepp = oldphasepick['epp'] + ompp = oldphasepick['mpp'] + olpp = oldphasepick['lpp'] + msg = """Warning old phase information for phase {phase} has been + altered.\n + New phase times:\n + earliest possible pick: {epp}\n + most probable pick: {mpp}\n + latest possible pick: {lpp}\n + \n + Old phase times (overwritten):\n + earliest possible pick: {oepp}\n + most probable pick: {ompp}\n + latest possible pick: {olpp}\n""".format(phase=phase, + epp=epp, + mpp=pick, + lpp=lpp, + oepp=oepp, + ompp=ompp, + olpp=olpp) + self.drawPicks(phase) + self.disconnectPressEvent() + self.selectPhase.setCurrentIndex(-1) + + self.cidpress = self.connectPressEvent(self.panPress) + self.cidmotion = self.connectMotionEvent(self.panMotion) + self.cidrelease = self.connectReleaseEvent(self.panRelease) + self.cidscroll = self.connectScrollEvent(self.scrollZoom) + + + def drawPicks(self, phase): # plotting picks ax = self.getPlotWidget().axes ylims = ax.get_ylim() - ax.plot([pick, pick], ylims, 'r--') + picks = self.getPicks() + + mpp = picks['mpp'] + epp = picks['lpp'] + lpp = picks['epp'] + + ax.plot([mpp, mpp], ylims, 'r--') ax.plot([epp, epp], ylims, 'c--') ax.plot([lpp, lpp], ylims, 'm--') @@ -606,9 +666,6 @@ class PickDlg(QDialog): for pick in picks: print pick - def reject(self): - QDialog.reject(self) - def accept(self): self.apply() QDialog.accept(self)