[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)
This commit is contained in:
Marcel Paffrath 2017-06-19 11:28:11 +02:00
parent 053caa5cf6
commit 08b9cec674
2 changed files with 37 additions and 26 deletions

View File

@ -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:

View File

@ -1 +1 @@
aea7-dirty
053c-dirty