[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:
parent
053caa5cf6
commit
08b9cec674
61
QtPyLoT.py
61
QtPyLoT.py
@ -63,7 +63,7 @@ from pylot.core.pick.compare import Comparison
|
|||||||
from pylot.core.pick.utils import symmetrize_error
|
from pylot.core.pick.utils import symmetrize_error
|
||||||
from pylot.core.io.phases import picksdict_from_picks
|
from pylot.core.io.phases import picksdict_from_picks
|
||||||
import pylot.core.loc.nll as nll
|
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, \
|
from pylot.core.util.errors import FormatError, DatastructureError, \
|
||||||
OverwriteError, ProcessingError
|
OverwriteError, ProcessingError
|
||||||
from pylot.core.util.connection import checkurl
|
from pylot.core.util.connection import checkurl
|
||||||
@ -650,6 +650,8 @@ class MainWindow(QMainWindow):
|
|||||||
data[type] += Data(self, evtdata=fname)
|
data[type] += Data(self, evtdata=fname)
|
||||||
if not loc:
|
if not loc:
|
||||||
self.updatePicks(type=type)
|
self.updatePicks(type=type)
|
||||||
|
if self.get_current_event.picks:
|
||||||
|
self.plotWaveformDataThread()
|
||||||
self.drawPicks(picktype=type)
|
self.drawPicks(picktype=type)
|
||||||
self.draw()
|
self.draw()
|
||||||
self.setDirty(True)
|
self.setDirty(True)
|
||||||
@ -732,10 +734,14 @@ class MainWindow(QMainWindow):
|
|||||||
'''
|
'''
|
||||||
Return event path of event (type QtPylot.Event) currently selected in eventbox.
|
Return event path of event (type QtPylot.Event) currently selected in eventbox.
|
||||||
'''
|
'''
|
||||||
if not eventbox:
|
return self.get_current_event(eventbox).path
|
||||||
eventbox = self.eventBox
|
|
||||||
return str(eventbox.currentText().split('|')[0]).strip()
|
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):
|
def getLastEvent(self):
|
||||||
return self.recentfiles[0]
|
return self.recentfiles[0]
|
||||||
|
|
||||||
@ -908,41 +914,46 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
def getSavePath(e):
|
def getSavePath(e):
|
||||||
print('warning: {0}'.format(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 " \
|
file_filter = "QuakeML file (*.xml);;VELEST observation file " \
|
||||||
"format (*.cnv);;NonLinLoc observation file (*.obs)"
|
"format (*.cnv);;NonLinLoc observation file (*.obs)"
|
||||||
title = 'Save pick data ...'
|
title = 'Save pick data ...'
|
||||||
fname, selected_filter = QFileDialog.getSaveFileName(self,
|
fname, selected_filter = QFileDialog.getSaveFileName(self,
|
||||||
title,
|
title,
|
||||||
directory,
|
outpath,
|
||||||
file_filter)
|
file_filter)
|
||||||
|
|
||||||
fbasename, exform = os.path.splitext(fname)
|
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]
|
exform = selected_filter.split('*')[1][:-1]
|
||||||
|
if not exform in OUTPUTFORMATS:
|
||||||
|
return fname, exform
|
||||||
return fbasename, exform
|
return fbasename, exform
|
||||||
|
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
fbasename = self.getEventFileName()
|
fbasename = self.getEventFileName()
|
||||||
exform = settings.value('data/exportFormat', 'QUAKEML')
|
exform = settings.value('data/exportFormat', 'QUAKEML')
|
||||||
try:
|
# try:
|
||||||
self.get_data().applyEVTData(self.getPicks())
|
# self.get_data().applyEVTData(self.getPicks())
|
||||||
except OverwriteError:
|
# except OverwriteError:
|
||||||
msgBox = QMessageBox()
|
# msgBox = QMessageBox()
|
||||||
msgBox.setText("Picks have been modified!")
|
# msgBox.setText("Picks have been modified!")
|
||||||
msgBox.setInformativeText(
|
# msgBox.setInformativeText(
|
||||||
"Do you want to save the changes and overwrite the picks?")
|
# "Do you want to save the changes and overwrite the picks?")
|
||||||
msgBox.setDetailedText(self.get_data().getPicksStr())
|
# msgBox.setDetailedText(self.get_data().getPicksStr())
|
||||||
msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Cancel)
|
# msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Cancel)
|
||||||
msgBox.setDefaultButton(QMessageBox.Save)
|
# msgBox.setDefaultButton(QMessageBox.Save)
|
||||||
ret = msgBox.exec_()
|
# ret = msgBox.exec_()
|
||||||
if ret == QMessageBox.Save:
|
# if ret == QMessageBox.Save:
|
||||||
self.get_data().resetPicks()
|
# self.get_data().resetPicks()
|
||||||
return self.saveData()
|
# return self.saveData()
|
||||||
elif ret == QMessageBox.Cancel:
|
# elif ret == QMessageBox.Cancel:
|
||||||
return False
|
# return False
|
||||||
|
# MP MP changed due to new event structure not uniquely refering to data object
|
||||||
try:
|
try:
|
||||||
self.get_data().exportEvent(fbasename, exform)
|
self.get_data().exportEvent(fbasename, exform)
|
||||||
except FormatError as e:
|
except FormatError as e:
|
||||||
|
@ -1 +1 @@
|
|||||||
aea7-dirty
|
053c-dirty
|
||||||
|
Loading…
Reference in New Issue
Block a user