From 754883c5c97e329d656b10dfe9398547eedd9f7a Mon Sep 17 00:00:00 2001 From: Marcel Paffrath Date: Wed, 14 Jun 2017 16:22:26 +0200 Subject: [PATCH 1/5] [refs #204] adding application name/organisation/domain when building app before calling settings --- QtPyLoT.py | 3 +++ pylot/RELEASE-VERSION | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/QtPyLoT.py b/QtPyLoT.py index 9f271d8d..a18a6cb4 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -2461,6 +2461,9 @@ def create_window(): if app is None: app = QApplication(sys.argv) app_created = True + app.setOrganizationName("QtPyLoT"); + app.setOrganizationDomain("rub.de"); + app.setApplicationName("RUB"); app.references = set() #app.references.add(window) #window.show() diff --git a/pylot/RELEASE-VERSION b/pylot/RELEASE-VERSION index 038cd01d..f31df83e 100644 --- a/pylot/RELEASE-VERSION +++ b/pylot/RELEASE-VERSION @@ -1 +1 @@ -5412-dirty +d2d8-dirty From 7257d4315536080b0adfc937baa3e755e201f331 Mon Sep 17 00:00:00 2001 From: Marcel Paffrath Date: Mon, 19 Jun 2017 10:23:39 +0200 Subject: [PATCH 2/5] [fixes #205] call replot thread after manual picking --- QtPyLoT.py | 2 +- pylot/RELEASE-VERSION | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/QtPyLoT.py b/QtPyLoT.py index a18a6cb4..71ac5e8b 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -1523,7 +1523,7 @@ class MainWindow(QMainWindow): self.get_current_event().setPick(station, pickDlg.getPicks()) self.enableSaveManualPicksAction() if replot: - self.plotWaveformData() + self.plotWaveformDataThread() self.drawPicks() self.draw() else: diff --git a/pylot/RELEASE-VERSION b/pylot/RELEASE-VERSION index f31df83e..304c35ec 100644 --- a/pylot/RELEASE-VERSION +++ b/pylot/RELEASE-VERSION @@ -1 +1 @@ -d2d8-dirty +7548-dirty From aea77cd49c13812b8dac9638a2c21640a710d73a Mon Sep 17 00:00:00 2001 From: Marcel Paffrath Date: Mon, 19 Jun 2017 10:30:08 +0200 Subject: [PATCH 3/5] [change] removed redundant propmpt because new picks have to be accepted in the first place when closing PickDlg --- QtPyLoT.py | 51 +++++++++++++++++++++++-------------------- pylot/RELEASE-VERSION | 2 +- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/QtPyLoT.py b/QtPyLoT.py index 71ac5e8b..97c2f11e 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -1626,30 +1626,33 @@ class MainWindow(QMainWindow): self.thread.quit() def addPicks(self, station, picks, type='manual'): - stat_picks = self.getPicksOnStation(station, type) - rval = False - if not stat_picks: - stat_picks = picks - else: - msgBox = QMessageBox(self) - msgBox.setText("The picks for station {0} have been " - "changed.".format(station)) - msgBox.setDetailedText("Old picks:\n" - "{old_picks}\n\n" - "New picks:\n" - "{new_picks}".format(old_picks=stat_picks, - new_picks=picks)) - msgBox.setInformativeText("Do you want to save your changes?") - msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Cancel) - msgBox.setDefaultButton(QMessageBox.Save) - ret = msgBox.exec_() - if ret == QMessageBox.Save: - stat_picks = picks - rval = True - elif ret == QMessageBox.Cancel: - pass - else: - raise Exception('FATAL: Should never occur!') + # stat_picks = self.getPicksOnStation(station, type) + # rval = False + # if not stat_picks: + # stat_picks = picks + # else: + # msgBox = QMessageBox(self) + # msgBox.setText("The picks for station {0} have been " + # "changed.".format(station)) + # msgBox.setDetailedText("Old picks:\n" + # "{old_picks}\n\n" + # "New picks:\n" + # "{new_picks}".format(old_picks=stat_picks, + # new_picks=picks)) + # msgBox.setInformativeText("Do you want to save your changes?") + # msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Cancel) + # msgBox.setDefaultButton(QMessageBox.Save) + # ret = msgBox.exec_() + # if ret == QMessageBox.Save: + # stat_picks = picks + # rval = True + # elif ret == QMessageBox.Cancel: + # pass + # else: + # raise Exception('FATAL: Should never occur!') + # MP MP prompt redundant because new picks have to be accepted in the first place closing PickDlg + stat_picks = picks + rval = True self.getPicks(type=type)[station] = stat_picks return rval diff --git a/pylot/RELEASE-VERSION b/pylot/RELEASE-VERSION index 304c35ec..0238003d 100644 --- a/pylot/RELEASE-VERSION +++ b/pylot/RELEASE-VERSION @@ -1 +1 @@ -7548-dirty +7257-dirty From 053caa5cf6727b26bf92ece77351bcd77e29ff9b Mon Sep 17 00:00:00 2001 From: Marcel Paffrath Date: Mon, 19 Jun 2017 10:37:24 +0200 Subject: [PATCH 4/5] [change] replot after manual picking only if necessary (picks changed) --- QtPyLoT.py | 14 ++++++++------ pylot/RELEASE-VERSION | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/QtPyLoT.py b/QtPyLoT.py index 97c2f11e..2a82046e 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -1626,8 +1626,14 @@ class MainWindow(QMainWindow): self.thread.quit() def addPicks(self, station, picks, type='manual'): - # stat_picks = self.getPicksOnStation(station, type) - # rval = False + stat_picks = self.getPicksOnStation(station, type) + if not stat_picks: + rval = False + else: + #set picks (ugly syntax?) + self.getPicks(type=type)[station] = picks + rval = True + return rval # if not stat_picks: # stat_picks = picks # else: @@ -1651,10 +1657,6 @@ class MainWindow(QMainWindow): # else: # raise Exception('FATAL: Should never occur!') # MP MP prompt redundant because new picks have to be accepted in the first place closing PickDlg - stat_picks = picks - rval = True - self.getPicks(type=type)[station] = stat_picks - return rval def updatePicks(self, type='manual'): picks = picksdict_from_picks(evt=self.get_data(type).get_evt_data()) diff --git a/pylot/RELEASE-VERSION b/pylot/RELEASE-VERSION index 0238003d..321e9d20 100644 --- a/pylot/RELEASE-VERSION +++ b/pylot/RELEASE-VERSION @@ -1 +1 @@ -7257-dirty +aea7-dirty From 08b9cec6747ea2af28132100e105ce71a7a77262 Mon Sep 17 00:00:00 2001 From: Marcel Paffrath Date: Mon, 19 Jun 2017 11:28:11 +0200 Subject: [PATCH 5/5] [refs #206] savepicks XML now opens current event folder by default, also gives default filename [bugfix] could not save XML files with . in name [change] removed user prompt when changing picks on different event (redundant) --- QtPyLoT.py | 61 +++++++++++++++++++++++++------------------ pylot/RELEASE-VERSION | 2 +- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/QtPyLoT.py b/QtPyLoT.py index 2a82046e..ab7af35d 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -63,7 +63,7 @@ from pylot.core.pick.compare import Comparison from pylot.core.pick.utils import symmetrize_error from pylot.core.io.phases import picksdict_from_picks import pylot.core.loc.nll as nll -from pylot.core.util.defaults import FILTERDEFAULTS, SetChannelComponents +from pylot.core.util.defaults import FILTERDEFAULTS, OUTPUTFORMATS, SetChannelComponents from pylot.core.util.errors import FormatError, DatastructureError, \ OverwriteError, ProcessingError from pylot.core.util.connection import checkurl @@ -650,6 +650,8 @@ class MainWindow(QMainWindow): data[type] += Data(self, evtdata=fname) if not loc: self.updatePicks(type=type) + if self.get_current_event.picks: + self.plotWaveformDataThread() self.drawPicks(picktype=type) self.draw() self.setDirty(True) @@ -732,10 +734,14 @@ class MainWindow(QMainWindow): ''' Return event path of event (type QtPylot.Event) currently selected in eventbox. ''' - if not eventbox: - eventbox = self.eventBox - return str(eventbox.currentText().split('|')[0]).strip() - + return self.get_current_event(eventbox).path + + def get_current_event_name(self, eventbox=None): + ''' + Return event path of event (type QtPylot.Event) currently selected in eventbox. + ''' + return self.get_current_event_path(eventbox).split('/')[-1] + def getLastEvent(self): return self.recentfiles[0] @@ -908,41 +914,46 @@ class MainWindow(QMainWindow): def getSavePath(e): print('warning: {0}'.format(e)) - directory = os.path.realpath(self.getRoot()) + directory = self.get_current_event_path() + eventname = self.get_current_event_name() + filename = 'picks_'+eventname + outpath = os.path.join(directory, filename) file_filter = "QuakeML file (*.xml);;VELEST observation file " \ "format (*.cnv);;NonLinLoc observation file (*.obs)" title = 'Save pick data ...' fname, selected_filter = QFileDialog.getSaveFileName(self, title, - directory, + outpath, file_filter) fbasename, exform = os.path.splitext(fname) - if not exform and selected_filter: + if not exform and selected_filter or not exform in OUTPUTFORMATS: exform = selected_filter.split('*')[1][:-1] - + if not exform in OUTPUTFORMATS: + return fname, exform return fbasename, exform settings = QSettings() fbasename = self.getEventFileName() exform = settings.value('data/exportFormat', 'QUAKEML') - try: - self.get_data().applyEVTData(self.getPicks()) - except OverwriteError: - msgBox = QMessageBox() - msgBox.setText("Picks have been modified!") - msgBox.setInformativeText( - "Do you want to save the changes and overwrite the picks?") - msgBox.setDetailedText(self.get_data().getPicksStr()) - msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Cancel) - msgBox.setDefaultButton(QMessageBox.Save) - ret = msgBox.exec_() - if ret == QMessageBox.Save: - self.get_data().resetPicks() - return self.saveData() - elif ret == QMessageBox.Cancel: - return False + # try: + # self.get_data().applyEVTData(self.getPicks()) + # except OverwriteError: + # msgBox = QMessageBox() + # msgBox.setText("Picks have been modified!") + # msgBox.setInformativeText( + # "Do you want to save the changes and overwrite the picks?") + # msgBox.setDetailedText(self.get_data().getPicksStr()) + # msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Cancel) + # msgBox.setDefaultButton(QMessageBox.Save) + # ret = msgBox.exec_() + # if ret == QMessageBox.Save: + # self.get_data().resetPicks() + # return self.saveData() + # elif ret == QMessageBox.Cancel: + # return False + # MP MP changed due to new event structure not uniquely refering to data object try: self.get_data().exportEvent(fbasename, exform) except FormatError as e: diff --git a/pylot/RELEASE-VERSION b/pylot/RELEASE-VERSION index 321e9d20..785fc992 100644 --- a/pylot/RELEASE-VERSION +++ b/pylot/RELEASE-VERSION @@ -1 +1 @@ -aea7-dirty +053c-dirty