several updates to internal refreshing of widgets when manual picks are set

This commit is contained in:
Marcel Paffrath 2017-05-31 15:41:25 +02:00
parent 02a59f46a9
commit 62fa3ad8b1
3 changed files with 47 additions and 31 deletions

View File

@ -343,7 +343,7 @@ class MainWindow(QMainWindow):
self.saveManualPicksAction = self.createAction(self, "Save &picks ...", self.saveManualPicksAction = self.createAction(self, "Save &picks ...",
self.saveData, "Ctrl+P", self.saveData, "Ctrl+P",
saveIcon, "Save event pick data.") saveIcon, "Save event pick data.")
self.saveManualPicksAction.setEnabled(False) self.disableSaveManualPicksAction()
self.addEventDataAction = self.createAction(self, "Add &events ...", self.addEventDataAction = self.createAction(self, "Add &events ...",
self.add_events, self.add_events,
@ -758,7 +758,7 @@ class MainWindow(QMainWindow):
self.clearWaveformDataPlot() self.clearWaveformDataPlot()
return return
self.eventBox.setEnabled(True) self.eventBox.setEnabled(True)
self.fill_eventbox(self.eventBox) self.fill_eventbox()
if new: if new:
self.eventBox.setCurrentIndex(0) self.eventBox.setCurrentIndex(0)
else: else:
@ -766,7 +766,7 @@ class MainWindow(QMainWindow):
self.refreshEvents() self.refreshEvents()
tabindex = self.tabs.currentIndex() tabindex = self.tabs.currentIndex()
def fill_eventbox(self, eventBox=None, select_events='all'): def fill_eventbox(self, event=None, eventBox=None, select_events='all'):
''' '''
(Re)fill the selected eventBox (type = QtGui.QComboBox). (Re)fill the selected eventBox (type = QtGui.QComboBox).
@ -884,7 +884,7 @@ class MainWindow(QMainWindow):
directory = os.path.realpath(self.getRoot()) directory = os.path.realpath(self.getRoot())
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 event data ...' title = 'Save pick data ...'
fname, selected_filter = QFileDialog.getSaveFileName(self, fname, selected_filter = QFileDialog.getSaveFileName(self,
title, title,
directory, directory,
@ -927,24 +927,31 @@ class MainWindow(QMainWindow):
if not fbasename: if not fbasename:
return False return False
# warn overwriting # warn overwriting
elif os.path.exists(fbasename + exform): # elif os.path.exists(fbasename + exform):
ans = QMessageBox.question(self, self.tr("Overwrite file..."), # ans = QMessageBox.question(self, self.tr("Overwrite file..."),
self.tr("File already exists: {0}\n".format(fbasename + exform) + \ # self.tr("File already exists: {0}\n".format(fbasename + exform) + \
"Overwrite file anyway?"), # "Overwrite file anyway?"),
QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel) # QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
# only negative answers have to be caught # # only negative answers have to be caught
if ans == QMessageBox.No: # if ans == QMessageBox.No:
self.saveData() # self.saveData()
elif ans == QMessageBox.Cancel: # elif ans == QMessageBox.Cancel:
return False # return False
# export to given path # export to given path
self.get_data().exportEvent(fbasename, exform) self.get_data().exportEvent(fbasename, exform)
# all files save (ui clean) # all files save (ui clean)
self.setDirty(False) self.setDirty(False)
self.update_status('Event saved as %s' % (fbasename + exform)) self.update_status('Picks saved as %s' % (fbasename + exform))
self.disableSaveManualPicksAction()
return True return True
def enableSaveManualPicksAction(self):
self.saveManualPicksAction.setEnabled(True)
def disableSaveManualPicksAction(self):
self.saveManualPicksAction.setEnabled(False)
def getinfile(self): def getinfile(self):
return self.infile return self.infile
@ -960,8 +967,12 @@ class MainWindow(QMainWindow):
return self.data return self.data
def getPicks(self, type='manual'): def getPicks(self, type='manual'):
rdict = dict(auto=self.autopicks, manual=self.picks) if type == 'manual':
return rdict[type] return self.get_current_event().getPicks()
if type == 'auto':
return self.get_current_event().getAutopicks()
# rdict = dict(auto=self.autopicks, manual=self.picks)
# return rdict[type]
def getPicksOnStation(self, station, type='manual'): def getPicksOnStation(self, station, type='manual'):
try: try:
@ -1203,11 +1214,11 @@ class MainWindow(QMainWindow):
self.openmanualpicksaction.setEnabled(True) self.openmanualpicksaction.setEnabled(True)
self.openautopicksaction.setEnabled(True) self.openautopicksaction.setEnabled(True)
self.loadpilotevent.setEnabled(True) self.loadpilotevent.setEnabled(True)
self.saveManualPicksAction.setEnabled(True)
event = self.get_current_event() event = self.get_current_event()
if event.picks: if event.picks:
self.picks = event.picks self.picks = event.picks
self.drawPicks(picktype='manual') self.drawPicks(picktype='manual')
self.enableSaveManualPicksAction()
if event.autopicks: if event.autopicks:
self.autopicks = event.autopicks self.autopicks = event.autopicks
self.drawPicks(picktype='auto') self.drawPicks(picktype='auto')
@ -1226,7 +1237,7 @@ class MainWindow(QMainWindow):
self.openmanualpicksaction.setEnabled(False) self.openmanualpicksaction.setEnabled(False)
self.openautopicksaction.setEnabled(False) self.openautopicksaction.setEnabled(False)
self.loadpilotevent.setEnabled(False) self.loadpilotevent.setEnabled(False)
self.saveManualPicksAction.setEnabled(False) self.disableSaveManualPicksAction()
self.draw() self.draw()
def plotWaveformDataThread(self): def plotWaveformDataThread(self):
@ -1424,10 +1435,13 @@ class MainWindow(QMainWindow):
picks=self.getPicksOnStation(station, 'manual'), picks=self.getPicksOnStation(station, 'manual'),
autopicks=self.getPicksOnStation(station, 'auto')) autopicks=self.getPicksOnStation(station, 'auto'))
if pickDlg.exec_(): if pickDlg.exec_():
if not pickDlg.getPicks():
return
self.setDirty(True) self.setDirty(True)
self.update_status('picks accepted ({0})'.format(station)) self.update_status('picks accepted ({0})'.format(station))
replot = self.addPicks(station, pickDlg.getPicks()) replot = self.addPicks(station, pickDlg.getPicks())
self.get_current_event().setPick(station, pickDlg.getPicks()) self.get_current_event().setPick(station, pickDlg.getPicks())
self.enableSaveManualPicksAction()
if replot: if replot:
self.plotWaveformData() self.plotWaveformData()
self.drawPicks() self.drawPicks()
@ -1800,12 +1814,12 @@ class MainWindow(QMainWindow):
event.setTestEvent(True) event.setTestEvent(True)
elif column == 4 and not item_test.checkState(): elif column == 4 and not item_test.checkState():
event.setTestEvent(False) event.setTestEvent(False)
self.fill_eventbox(self.eventBox) self.fill_eventbox()
elif column == 5: elif column == 5:
#update event notes #update event notes
notes = table[row][5].text() notes = table[row][5].text()
event.addNotes(notes) event.addNotes(notes)
self.fill_eventbox(self.eventBox) self.fill_eventbox()
# remove old table # remove old table
if hasattr(self, 'event_table'): if hasattr(self, 'event_table'):
@ -2082,8 +2096,7 @@ class MainWindow(QMainWindow):
else: else:
self.project.save() self.project.save()
if not self.project.dirty: if not self.project.dirty:
qmb = QMessageBox(icon=QMessageBox.Information, text='Saved back project to file:\n{}'.format(self.project.location)) print('Saved back project to file:\n{}'.format(self.project.location))
qmb.exec_()
self.setDirty(False) self.setDirty(False)
return True return True
else: else:
@ -2094,7 +2107,7 @@ class MainWindow(QMainWindow):
return self.createNewProject(exists=True) return self.createNewProject(exists=True)
def draw(self): def draw(self):
self.fill_eventbox(self.eventBox) self.fill_eventbox()
self.getPlotWidget().draw() self.getPlotWidget().draw()
def setDirty(self, value): def setDirty(self, value):

View File

@ -1 +1 @@
5897-dirty 02a5-dirty

View File

@ -1328,15 +1328,15 @@ class PickDlg(QDialog):
def apply(self): def apply(self):
picks = self.getPicks() picks = self.getPicks()
self.update_picks.emit(picks) self.update_picks.emit(picks)
for pick in picks: # for pick in picks:
print(pick, picks[pick]) # print(pick, picks[pick])
def discard(self): def discard(self):
picks = self._init_picks picks = self._init_picks
self.picks = picks self.picks = picks
self.update_picks.emit(picks) self.update_picks.emit(picks)
for pick in picks: # for pick in picks:
print(pick, picks[pick]) # print(pick, picks[pick])
def reject(self): def reject(self):
self.discard() self.discard()
@ -1512,6 +1512,9 @@ class TuneAutopicker(QWidget):
pickDlg.update_picks.connect(self.picks_from_pickdlg) pickDlg.update_picks.connect(self.picks_from_pickdlg)
pickDlg.update_picks.connect(self.fill_eventbox) pickDlg.update_picks.connect(self.fill_eventbox)
pickDlg.update_picks.connect(self.fill_stationbox) pickDlg.update_picks.connect(self.fill_stationbox)
pickDlg.update_picks.connect(self.parent.drawPicks)
pickDlg.update_picks.connect(lambda: self.parent.setDirty(True))
pickDlg.update_picks.connect(self.parent.enableSaveManualPicksAction)
self.pickDlg = QtGui.QWidget() self.pickDlg = QtGui.QWidget()
hl = QtGui.QHBoxLayout() hl = QtGui.QHBoxLayout()
self.pickDlg.setLayout(hl) self.pickDlg.setLayout(hl)
@ -1626,8 +1629,8 @@ class TuneAutopicker(QWidget):
self.init_tab_names() self.init_tab_names()
def fill_eventbox(self): def fill_eventbox(self):
self.parent.fill_eventbox(self.eventBox, 'ref') self.parent.fill_eventbox(eventBox=self.eventBox, select_events='ref')
self.parent.fill_eventbox(self.parent.eventBox) self.parent.fill_eventbox()
def update_eventID(self): def update_eventID(self):
self.parameters.boxes['eventID'].setText( self.parameters.boxes['eventID'].setText(