Merge branch 'develop' into map_projection

This commit is contained in:
Marcel Paffrath 2017-04-12 12:18:16 +02:00
commit 488068105b
2 changed files with 91 additions and 42 deletions

View File

@ -968,7 +968,7 @@ class MainWindow(QMainWindow):
elif picktype == 'auto': elif picktype == 'auto':
ax.plot(mpp, ylims[1], colors[3], ax.plot(mpp, ylims[1], colors[3],
mpp, ylims[0], colors[4]) mpp, ylims[0], colors[4])
ax.vlines(mpp, ylims[0], ylims[1], colors[5], linestyles='dashed') ax.vlines(mpp, ylims[0], ylims[1], colors[5], linestyles='dotted')
else: else:
raise TypeError('Unknown picktype {0}'.format(picktype)) raise TypeError('Unknown picktype {0}'.format(picktype))

View File

@ -25,7 +25,7 @@ from PySide.QtGui import QAction, QApplication, QCheckBox, QComboBox, \
QDateTimeEdit, QDialog, QDialogButtonBox, QDoubleSpinBox, QGroupBox, \ QDateTimeEdit, QDialog, QDialogButtonBox, QDoubleSpinBox, QGroupBox, \
QGridLayout, QIcon, QKeySequence, QLabel, QLineEdit, QMessageBox, \ QGridLayout, QIcon, QKeySequence, QLabel, QLineEdit, QMessageBox, \
QPixmap, QSpinBox, QTabWidget, QToolBar, QVBoxLayout, QWidget, \ QPixmap, QSpinBox, QTabWidget, QToolBar, QVBoxLayout, QWidget, \
QPushButton, QFileDialog, QInputDialog QPushButton, QFileDialog, QInputDialog, QKeySequence
from PySide.QtCore import QSettings, Qt, QUrl, Signal, Slot from PySide.QtCore import QSettings, Qt, QUrl, Signal, Slot
from PySide.QtWebKit import QWebView from PySide.QtWebKit import QWebView
from obspy import Stream, UTCDateTime from obspy import Stream, UTCDateTime
@ -518,6 +518,7 @@ class PickDlg(QDialog):
self.station = station self.station = station
self.rotate = rotate self.rotate = rotate
self.components = 'ZNE' self.components = 'ZNE'
self.currentPhase = None
settings = QSettings() settings = QSettings()
pylot_user = getpass.getuser() pylot_user = getpass.getuser()
self._user = settings.value('user/Login', pylot_user) self._user = settings.value('user/Login', pylot_user)
@ -617,9 +618,19 @@ class PickDlg(QDialog):
tip='Delete current picks.') tip='Delete current picks.')
# create other widget elements # create other widget elements
self.selectPhase = QComboBox()
phaseitems = [None] + FILTERDEFAULTS.keys() phaseitems = [None] + FILTERDEFAULTS.keys()
self.selectPhase.addItems(phaseitems)
# create buttons for P and S filter and picking
self.p_button = QPushButton('P', self)
self.s_button = QPushButton('S', self)
self.p_button.setCheckable(True)
self.s_button.setCheckable(True)
# button shortcuts (1 for P-button, 2 for S-button)
self.p_button.setShortcut(QKeySequence('1'))
self.s_button.setShortcut(QKeySequence('2'))
# set button tooltips
self.p_button.setToolTip('Hotkey: "1"')
self.s_button.setToolTip('Hotkey: "2"')
# layout the outermost appearance of the Pick Dialog # layout the outermost appearance of the Pick Dialog
_outerlayout = QVBoxLayout() _outerlayout = QVBoxLayout()
@ -627,7 +638,8 @@ class PickDlg(QDialog):
# fill toolbar with content # fill toolbar with content
_dialtoolbar.addAction(self.filterAction) _dialtoolbar.addAction(self.filterAction)
_dialtoolbar.addWidget(self.selectPhase) _dialtoolbar.addWidget(self.p_button)
_dialtoolbar.addWidget(self.s_button)
_dialtoolbar.addAction(self.zoomAction) _dialtoolbar.addAction(self.zoomAction)
_dialtoolbar.addSeparator() _dialtoolbar.addSeparator()
_dialtoolbar.addAction(self.resetZoomAction) _dialtoolbar.addAction(self.resetZoomAction)
@ -649,7 +661,8 @@ class PickDlg(QDialog):
# connect widget element signals with slots (methods to the dialog # connect widget element signals with slots (methods to the dialog
# object # object
self.selectPhase.currentIndexChanged.connect(self.verifyPhaseSelection) self.p_button.clicked.connect(self.p_clicked)
self.s_button.clicked.connect(self.s_clicked)
_buttonbox.accepted.connect(self.accept) _buttonbox.accepted.connect(self.accept)
_buttonbox.rejected.connect(self.reject) _buttonbox.rejected.connect(self.reject)
@ -692,14 +705,51 @@ class PickDlg(QDialog):
widget = self.getPlotWidget() widget = self.getPlotWidget()
return widget.mpl_connect('button_release_event', slot) return widget.mpl_connect('button_release_event', slot)
def verifyPhaseSelection(self): def p_clicked(self):
if self.pick_block: if self.p_button.isChecked():
self.pick_block = self.togglePickBlocker() self.s_button.setEnabled(False)
warnings.warn('Changed selection before phase was set!', self.init_p_pick()
UserWarning) else:
phase = self.selectPhase.currentText() self.leave_picking_mode()
def s_clicked(self):
if self.s_button.isChecked():
self.p_button.setEnabled(False)
self.init_s_pick()
else:
self.leave_picking_mode()
def init_p_pick(self):
self.set_button_color(self.p_button, 'green')
self.updateCurrentLimits() self.updateCurrentLimits()
if phase: self.activatePicking()
self.currentPhase = 'P'
def init_s_pick(self):
self.set_button_color(self.s_button, 'green')
self.updateCurrentLimits()
self.activatePicking()
self.currentPhase = 'S'
def set_button_color(self, button, color = None):
button.setStyleSheet("background-color: {}".format(color))
def leave_picking_mode(self):
self.currentPhase = None
self.set_button_color(self.p_button)
self.set_button_color(self.s_button)
self.p_button.setEnabled(True)
self.s_button.setEnabled(True)
self.p_button.setChecked(False)
self.s_button.setChecked(False)
self.getPlotWidget().plotWFData(wfdata=self.getWFData(),
title=self.getStation())
self.drawAllPicks()
self.setPlotLabels()
self.resetZoomAction.trigger()
self.deactivatePicking()
def activatePicking(self):
if self.zoomAction.isChecked(): if self.zoomAction.isChecked():
self.zoomAction.trigger() self.zoomAction.trigger()
self.disconnectReleaseEvent() self.disconnectReleaseEvent()
@ -709,7 +759,8 @@ class PickDlg(QDialog):
self.cidpress = self.connectPressEvent(self.setIniPick) self.cidpress = self.connectPressEvent(self.setIniPick)
self.filterWFData() self.filterWFData()
self.pick_block = self.togglePickBlocker() self.pick_block = self.togglePickBlocker()
else:
def deactivatePicking(self):
self.disconnectPressEvent() self.disconnectPressEvent()
self.cidpress = self.connectPressEvent(self.panPress) self.cidpress = self.connectPressEvent(self.panPress)
self.cidmotion = self.connectMotionEvent(self.panMotion) self.cidmotion = self.connectMotionEvent(self.panMotion)
@ -826,10 +877,12 @@ class PickDlg(QDialog):
self.disconnectMotionEvent() self.disconnectMotionEvent()
self.cidpress = self.connectPressEvent(self.setPick) self.cidpress = self.connectPressEvent(self.setPick)
print(self.selectPhase.currentText()) print(self.currentPhase)
if self.selectPhase.currentText().upper().startswith('P'): if self.currentPhase == 'P':
self.set_button_color(self.p_button, 'red')
self.setIniPickP(gui_event, wfdata, trace_number) self.setIniPickP(gui_event, wfdata, trace_number)
elif self.selectPhase.currentText().upper().startswith('S'): elif self.currentPhase == 'S':
self.set_button_color(self.s_button, 'red')
self.setIniPickS(gui_event, wfdata) self.setIniPickS(gui_event, wfdata)
self.zoomAction.setEnabled(False) self.zoomAction.setEnabled(False)
@ -857,7 +910,7 @@ class PickDlg(QDialog):
data = self.getWFData().copy() data = self.getWFData().copy()
# filter data and trace on which is picked prior to determination of SNR # filter data and trace on which is picked prior to determination of SNR
phase = self.selectPhase.currentText() phase = self.currentPhase
filteroptions = self.getFilterOptions(phase).parseFilterOptions() filteroptions = self.getFilterOptions(phase).parseFilterOptions()
if filteroptions: if filteroptions:
data.filter(**filteroptions) data.filter(**filteroptions)
@ -902,7 +955,7 @@ class PickDlg(QDialog):
data = self.getWFData().copy() data = self.getWFData().copy()
# filter data and trace on which is picked prior to determination of SNR # filter data and trace on which is picked prior to determination of SNR
phase = self.selectPhase.currentText() phase = self.currentPhase
filteroptions = self.getFilterOptions(phase).parseFilterOptions() filteroptions = self.getFilterOptions(phase).parseFilterOptions()
if filteroptions: if filteroptions:
data.filter(**filteroptions) data.filter(**filteroptions)
@ -953,7 +1006,7 @@ class PickDlg(QDialog):
channel = self.getChannelID(round(gui_event.ydata)) channel = self.getChannelID(round(gui_event.ydata))
# get name of phase actually picked # get name of phase actually picked
phase = self.selectPhase.currentText() phase = self.currentPhase
# get filter parameter for the phase to be picked # get filter parameter for the phase to be picked
filteroptions = self.getFilterOptions(phase).parseFilterOptions() filteroptions = self.getFilterOptions(phase).parseFilterOptions()
@ -1010,14 +1063,10 @@ class PickDlg(QDialog):
oepp=oepp, oepp=oepp,
ompp=ompp, ompp=ompp,
olpp=olpp) olpp=olpp)
self.getPlotWidget().plotWFData(wfdata=self.getWFData(),
title=self.getStation())
self.drawAllPicks()
self.disconnectPressEvent() self.disconnectPressEvent()
self.zoomAction.setEnabled(True) self.zoomAction.setEnabled(True)
self.pick_block = self.togglePickBlocker() self.pick_block = self.togglePickBlocker()
self.selectPhase.setCurrentIndex(-1) self.leave_picking_mode()
self.setPlotLabels()
def drawAllPicks(self): def drawAllPicks(self):
self.drawPicks(picktype='manual') self.drawPicks(picktype='manual')
@ -1058,7 +1107,7 @@ class PickDlg(QDialog):
elif picktype == 'auto': elif picktype == 'auto':
ax.plot(mpp, ylims[1], colors[3], ax.plot(mpp, ylims[1], colors[3],
mpp, ylims[0], colors[4]) mpp, ylims[0], colors[4])
ax.vlines(mpp, ylims[0], ylims[1], colors[5], linestyles='dashed') ax.vlines(mpp, ylims[0], ylims[1], colors[5], linestyles='dotted')
else: else:
raise TypeError('Unknown picktype {0}'.format(picktype)) raise TypeError('Unknown picktype {0}'.format(picktype))
@ -1099,7 +1148,7 @@ class PickDlg(QDialog):
data = self.getWFData().copy() data = self.getWFData().copy()
old_title = self.getPlotWidget().getAxes().get_title() old_title = self.getPlotWidget().getAxes().get_title()
title = None title = None
phase = self.selectPhase.currentText() phase = self.currentPhase
filtoptions = None filtoptions = None
if phase: if phase:
filtoptions = self.getFilterOptions(phase).parseFilterOptions() filtoptions = self.getFilterOptions(phase).parseFilterOptions()