[add] improved filteroptions and fixed some bugs

This commit is contained in:
Marcel Paffrath 2018-01-08 14:42:52 +01:00
parent 8c9fded873
commit fb4753ca83
7 changed files with 1972 additions and 220 deletions

View File

@ -367,7 +367,7 @@ class MainWindow(QMainWindow):
None, paraIcon, None, paraIcon,
"Modify Parameter") "Modify Parameter")
self.filterAction = self.createAction(self, "&Filter ...", self.filterAction = self.createAction(self, "&Filter ...",
self.plotWaveformDataThread, self.filterWaveformData,
"Ctrl+F", self.filter_icon, "Ctrl+F", self.filter_icon,
"""Toggle un-/filtered waveforms """Toggle un-/filtered waveforms
to be displayed, according to the to be displayed, according to the
@ -1631,7 +1631,6 @@ class MainWindow(QMainWindow):
def finishWaveformDataPlot(self): def finishWaveformDataPlot(self):
self.comparable = self.checkEvents4comparison() self.comparable = self.checkEvents4comparison()
self.filterWaveformData()
if self.pg: if self.pg:
self.finish_pg_plot() self.finish_pg_plot()
else: else:
@ -1797,6 +1796,7 @@ class MainWindow(QMainWindow):
self.adjustFilterOptions() self.adjustFilterOptions()
else: else:
self.get_data().resetWFData() self.get_data().resetWFData()
self.plotWaveformDataThread()
self.drawPicks() self.drawPicks()
self.draw() self.draw()

View File

@ -45,6 +45,8 @@
<file>icons/key_W.png</file> <file>icons/key_W.png</file>
<file>icons/key_Z.png</file> <file>icons/key_Z.png</file>
<file>icons/filter.png</file> <file>icons/filter.png</file>
<file>icons/filter_p.png</file>
<file>icons/filter_s.png</file>
<file>icons/sync.png</file> <file>icons/sync.png</file>
<file>icons/zoom_0.png</file> <file>icons/zoom_0.png</file>
<file>icons/zoom_in.png</file> <file>icons/zoom_in.png</file>

BIN
icons/filter_p.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

BIN
icons/filter_s.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1237,15 +1237,15 @@ class PickDlg(QDialog):
exitAction.triggered.connect(self.close) exitAction.triggered.connect(self.close)
exitMenu.addAction(exitAction) exitMenu.addAction(exitAction)
self.addPickPhases(menuBar)
# create matplotlib toolbar to inherit functionality # create matplotlib toolbar to inherit functionality
self.figToolBar = NavigationToolbar2QT(self.multicompfig, self) self.figToolBar = NavigationToolbar2QT(self.multicompfig, self)
self.figToolBar.hide() self.figToolBar.hide()
# create icons # create icons
filter_icon = QIcon() filter_icon_p = QIcon()
filter_icon.addPixmap(QPixmap(':/icons/filter.png')) filter_icon_p.addPixmap(QPixmap(':/icons/filter_p.png'))
filter_icon_s = QIcon()
filter_icon_s.addPixmap(QPixmap(':/icons/filter_s.png'))
zoom_icon = QIcon() zoom_icon = QIcon()
zoom_icon.addPixmap(QPixmap(':/icons/zoom_in.png')) zoom_icon.addPixmap(QPixmap(':/icons/zoom_in.png'))
home_icon = QIcon() home_icon = QIcon()
@ -1254,11 +1254,20 @@ class PickDlg(QDialog):
del_icon.addPixmap(QPixmap(':/icons/delete.png')) del_icon.addPixmap(QPixmap(':/icons/delete.png'))
# create actions # create actions
self.filterAction = createAction(parent=self, text='Filter', self.filterActionP = createAction(parent=self, text='Apply P Filter',
slot=self.filterWFData, slot=self.filterP,
icon=filter_icon, icon=filter_icon_p,
tip='Toggle filtered/original' tip='Toggle filtered/original'
' waveforms') ' waveforms',
checkable=True,
shortcut='Ctrl+F')
self.filterActionS = createAction(parent=self, text='Apply S Filter',
slot=self.filterS,
icon=filter_icon_s,
tip='Toggle filtered/original'
' waveforms',
checkable=True,
shortcut='Shift+S')
self.zoomAction = createAction(parent=self, text='Zoom', self.zoomAction = createAction(parent=self, text='Zoom',
slot=self.zoom, icon=zoom_icon, slot=self.zoom, icon=zoom_icon,
tip='Zoom into waveform', tip='Zoom into waveform',
@ -1270,6 +1279,8 @@ class PickDlg(QDialog):
slot=self.delPicks, icon=del_icon, slot=self.delPicks, icon=del_icon,
tip='Delete current picks.') tip='Delete current picks.')
self.addPickPhases(menuBar)
# create other widget elements # create other widget elements
phaseitems = [None] + list(FILTERDEFAULTS.keys()) phaseitems = [None] + list(FILTERDEFAULTS.keys())
@ -1302,7 +1313,8 @@ class PickDlg(QDialog):
_dialtoolbar = QToolBar() _dialtoolbar = QToolBar()
# fill toolbar with content # fill toolbar with content
_dialtoolbar.addAction(self.filterAction) _dialtoolbar.addAction(self.filterActionP)
_dialtoolbar.addAction(self.filterActionS)
_dialtoolbar.addWidget(self.p_button) _dialtoolbar.addWidget(self.p_button)
_dialtoolbar.addWidget(self.s_button) _dialtoolbar.addWidget(self.s_button)
_dialtoolbar.addAction(self.zoomAction) _dialtoolbar.addAction(self.zoomAction)
@ -1509,12 +1521,14 @@ class PickDlg(QDialog):
if phaseIndex == 0: if phaseIndex == 0:
picksMenu.addSeparator() picksMenu.addSeparator()
filterAction = createAction(parent=self, text="&Filter parameter ...", filterOptionsAction = createAction(parent=self, text="&Filter parameter ...",
slot=self.filterOptions, slot=self.filterOptions,
shortcut='Alt+F', shortcut='Alt+F',
icon=self.orig_parent.filter_icon) icon=self.orig_parent.filter_icon)
filterMenu = menuBar.addMenu('Filter') filterMenu = menuBar.addMenu('Filter')
filterMenu.addAction(filterAction) filterMenu.addAction(self.filterActionP)
filterMenu.addAction(self.filterActionS)
filterMenu.addAction(filterOptionsAction)
def filterOptions(self): def filterOptions(self):
self.orig_parent.adjustFilterOptions() self.orig_parent.adjustFilterOptions()
@ -2122,36 +2136,35 @@ class PickDlg(QDialog):
def togglePickBlocker(self): def togglePickBlocker(self):
return not self.pick_block return not self.pick_block
def filterWFData(self): def filterWFData(self, phase=None):
if self.pick_block: if self.pick_block:
return return
if not phase:
phase = self.currentPhase
self.cur_xlim = self.multicompfig.axes[0].get_xlim() self.cur_xlim = self.multicompfig.axes[0].get_xlim()
self.cur_ylim = self.multicompfig.axes[0].get_ylim() self.cur_ylim = self.multicompfig.axes[0].get_ylim()
#self.multicompfig.updateCurrentLimits() #self.multicompfig.updateCurrentLimits()
data = self.getWFData().copy() data = self.getWFData().copy()
old_title = self.multicompfig.axes[0].get_title() old_title = self.multicompfig.axes[0].get_title()
title = None title = None
phase = self.currentPhase
filtoptions = None filtoptions = None
if phase: if phase:
filtoptions = self.getFilterOptions(self.getPhaseID(phase)).parseFilterOptions() filtoptions = self.getFilterOptions(self.getPhaseID(phase)).parseFilterOptions()
if self.filterAction.isChecked():
if not phase: # if self.filterActionP.isChecked() or self.filterActionS.isChecked():
filtoptions = FilterOptionsDialog.getFilterObject() # if not phase:
filtoptions = filtoptions.parseFilterOptions() # filtoptions = FilterOptionsDialog.getFilterObject()
# filtoptions = filtoptions.parseFilterOptions()
title = self.getStation()
if filtoptions is not None: if filtoptions is not None:
data.filter(**filtoptions) data.filter(**filtoptions)
if not old_title.endswith(')'): title += '({} filtered'.format(filtoptions['type'])
title = old_title + ' (filtered)' for key, value in filtoptions.items():
elif not old_title.endswith(' (filtered)') and not old_title.endswith(', filtered)'): if key == 'type':
title = old_title[:-1] + ', filtered)' continue
else: title += ' {}: {},'.format(key, value)
if old_title.endswith(' (filtered)'): title += ')'
title = old_title.replace(' (filtered)', '')
elif old_title.endswith(', filtered)'):
title = old_title.replace(', filtered)', ')')
if title is None:
title = old_title
self.multicompfig.plotWFData(wfdata=data, title=title, self.multicompfig.plotWFData(wfdata=data, title=title,
zoomx=self.getXLims(), zoomx=self.getXLims(),
zoomy=self.getYLims()) zoomy=self.getYLims())
@ -2159,10 +2172,25 @@ class PickDlg(QDialog):
self.drawAllPicks() self.drawAllPicks()
self.draw() self.draw()
def filterP(self):
self.filterActionS.setChecked(False)
if self.filterActionP.isChecked():
self.filterWFData('P')
else:
self.resetPlot()
def filterS(self):
self.filterActionP.setChecked(False)
if self.filterActionS.isChecked():
self.filterWFData('S')
else:
self.resetPlot()
def resetPlot(self): def resetPlot(self):
self.resetZoom() self.resetZoom()
data = self.getWFData().copy() data = self.getWFData().copy()
title = self.multicompfig.axes[0].get_title() #title = self.multicompfig.axes[0].get_title()
title = self.getStation()
self.multicompfig.plotWFData(wfdata=data, title=title, self.multicompfig.plotWFData(wfdata=data, title=title,
zoomx=self.getXLims(), zoomx=self.getXLims(),
zoomy=self.getYLims()) zoomy=self.getYLims())