From 8d6de02afe1c0391c9ea6a2597cb3a1a0dc02a1a Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 10 Jan 2018 16:00:34 +0100 Subject: [PATCH 1/4] [bugfix] filter settings will be retained when leaving picking mode etc --- pylot/RELEASE-VERSION | 2 +- pylot/core/util/widgets.py | 33 +++++++++++++++------------------ 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/pylot/RELEASE-VERSION b/pylot/RELEASE-VERSION index 5f884094..8d6b1403 100644 --- a/pylot/RELEASE-VERSION +++ b/pylot/RELEASE-VERSION @@ -1 +1 @@ -7c61-dirty +a76d-dirty diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index 679ec36f..e31dc46b 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -1647,7 +1647,7 @@ class PickDlg(QDialog): self.currentPhase = None self.reset_p_button() self.reset_s_button() - self.resetPlot() + self.refreshPlot() self.deactivatePicking() def activatePicking(self): @@ -1773,7 +1773,7 @@ class PickDlg(QDialog): def delPicks(self): self.resetPicks() - self.resetPlot() + self.refreshPlot() def setIniPick(self, gui_event): self.multicompfig.set_frame_color('green') @@ -1884,7 +1884,7 @@ class PickDlg(QDialog): if filteroptions: try: data.filter(**filteroptions) - wfdata.filter(**filteroptions) + #wfdata.filter(**filteroptions) MP MP as above except ValueError as e: self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Information, 'Denied', 'setIniPickS: Could not filter waveform: {}'.format(e)) @@ -2110,7 +2110,7 @@ class PickDlg(QDialog): return x = event.mouseevent.xdata self.remove_pick_by_x(x) - self.resetPlot() + self.refreshPlot() def remove_pick_by_x(self, x): if not self.picks and not self.autopicks: @@ -2193,12 +2193,11 @@ class PickDlg(QDialog): data.detrend('linear') data.taper(0.02, type='cosine') data.filter(**filtoptions) - title += '({} filtered - '.format(filtoptions['type']) + title += ' | {} filtered |'.format(filtoptions['type']) for key, value in filtoptions.items(): if key == 'type': continue - title += ' {}: {},'.format(key, value) - title += ')' + title += ' {}: {} |'.format(key, value) self.multicompfig.plotWFData(wfdata=data, title=title, zoomx=self.getXLims(), zoomy=self.getYLims()) @@ -2211,33 +2210,31 @@ class PickDlg(QDialog): if self.filterActionP.isChecked(): self.filterWFData('P') else: - self.resetPlot() + self.refreshPlot() def filterS(self): self.filterActionP.setChecked(False) if self.filterActionS.isChecked(): self.filterWFData('S') else: - self.resetPlot() + self.refreshPlot() def toggleAutoFilter(self): settings = QSettings() settings.setValue('autoFilter', self.autoFilterAction.isChecked()) def resetPlot(self): + self.resetZoom() + self.refreshPlot() + + def refreshPlot(self): if self.autoFilterAction.isChecked(): self.filterActionP.setChecked(False) self.filterActionS.setChecked(False) - self.resetZoom() data = self.getWFData().copy() - #title = self.multicompfig.axes[0].get_title() title = self.getStation() - self.multicompfig.plotWFData(wfdata=data, title=title, - zoomx=self.getXLims(), - zoomy=self.getYLims()) - self.setPlotLabels() - self.drawAllPicks() - self.draw() + filter = self.filterActionP.isChecked or self.filterActionS.isChecked() + self.plotWFData(filter=filter) def resetZoom(self): ax = self.multicompfig.axes[0] @@ -2290,7 +2287,7 @@ class PickDlg(QDialog): if not self._embedded: QDialog.reject(self) else: - self.resetPlot() + self.refreshPlot() self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Information, 'Denied', 'New picks rejected!') self.qmb.show() From 78d5ee58b560952b28e39fb1777dd196c2bb4bb9 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 10 Jan 2018 16:08:28 +0100 Subject: [PATCH 2/4] [update] apply new filter settings after selection --- PyLoT.py | 1 + pylot/RELEASE-VERSION | 2 +- pylot/core/util/widgets.py | 9 ++++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/PyLoT.py b/PyLoT.py index fbdc303b..a53dadc5 100755 --- a/PyLoT.py +++ b/PyLoT.py @@ -1816,6 +1816,7 @@ class MainWindow(QMainWindow): kwargs = self.getFilterOptions()[self.getSeismicPhase()].parseFilterOptions() self.pushFilterWF(kwargs) self.plotWaveformDataThread() + return True def checkFilterOptions(self): fstring = "Filter Options" diff --git a/pylot/RELEASE-VERSION b/pylot/RELEASE-VERSION index 8d6b1403..b7c866b9 100644 --- a/pylot/RELEASE-VERSION +++ b/pylot/RELEASE-VERSION @@ -1 +1 @@ -a76d-dirty +8d6de0-dirty diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index e31dc46b..56b6c2a6 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -1547,7 +1547,14 @@ class PickDlg(QDialog): filterMenu.addAction(filterOptionsAction) def filterOptions(self): - self.orig_parent.adjustFilterOptions() + if self.orig_parent.adjustFilterOptions(): + phase = None + if self.filterActionP.isChecked(): + phase = 'P' + elif self.filterActionS.isChecked(): + phase = 'S' + if phase: + self.plotWFData(phase=phase, filter=True) def disable_ar_buttons(self): self.enable_ar_buttons(False) From 0ebc6e11f8d3c0090071af1d719201efbae19fa4 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 10 Jan 2018 16:54:26 +0100 Subject: [PATCH 3/4] [add] prev/next event button (~~had to remove min button width) --- PyLoT.py | 34 +++++++++++++++++++++++++++++++++- pylot/RELEASE-VERSION | 2 +- pylot/core/util/widgets.py | 2 ++ pylot/styles/bright.qss | 1 - pylot/styles/dark.qss | 1 - 5 files changed, 36 insertions(+), 4 deletions(-) diff --git a/PyLoT.py b/PyLoT.py index a53dadc5..063a89ca 100755 --- a/PyLoT.py +++ b/PyLoT.py @@ -563,20 +563,29 @@ class MainWindow(QMainWindow): style = settings.value('style') self.set_style(style) - # add event combo box and ref/test buttons + # add event combo box, forward, backward and ref/test buttons self.eventBox = self.createEventBox() self.eventBox.setMaxVisibleItems(30) self.eventBox.setEnabled(False) + self.previous_button = QPushButton('<') + self.next_button = QPushButton('>') self.init_ref_test_buttons() self._event_layout = QHBoxLayout() self._event_layout.addWidget(QLabel('Event: ')) self._event_layout.addWidget(self.eventBox) + self._event_layout.addWidget(self.previous_button) + self._event_layout.addWidget(self.next_button) self._event_layout.addWidget(self.ref_event_button) self._event_layout.addWidget(self.test_event_button) self._event_layout.setStretch(1, 1) # set stretch of item 1 to 1 self._main_layout.addLayout(self._event_layout) self.eventBox.activated.connect(self.refreshEvents) + self.previous_button.clicked.connect(self.previous_event) + self.next_button.clicked.connect(self.next_event) + self.previous_button.setEnabled(False) + self.next_button.setEnabled(False) + # add main tab widget self.tabs = QTabWidget(self) self._main_layout.addWidget(self.tabs) @@ -652,6 +661,8 @@ class MainWindow(QMainWindow): ''' self.ref_event_button = QtGui.QPushButton('Tune') self.test_event_button = QtGui.QPushButton('Test') + self.ref_event_button.setMinimumWidth(100) + self.test_event_button.setMinimumWidth(100) self.ref_event_button.setToolTip('Set manual picks of current ' + 'event as reference picks for autopicker tuning.') self.test_event_button.setToolTip('Set manual picks of current ' + @@ -1473,6 +1484,26 @@ class MainWindow(QMainWindow): if self.tap: self.tap.fill_eventbox() + def checkEventButtons(self): + if self.eventBox.currentIndex() == 0: + prev_state = False + else: + prev_state = True + if self.eventBox.currentIndex() == len(self.project.eventlist) - 1: + next_state = False + else: + next_state = True + self.previous_button.setEnabled(prev_state) + self.next_button.setEnabled(next_state) + + def previous_event(self): + self.eventBox.setCurrentIndex(self.eventBox.currentIndex() - 1) + self.eventBox.activated.emit(-1) + + def next_event(self): + self.eventBox.setCurrentIndex(self.eventBox.currentIndex() + 1) + self.eventBox.activated.emit(+1) + def refreshEvents(self): ''' Refresh GUI when events get changed. @@ -1483,6 +1514,7 @@ class MainWindow(QMainWindow): # array_map refresh is not necessary when changing event in waveform plot tab, # but gets necessary when switching from one to another after changing an event. self._eventChanged = [True, True] + self.checkEventButtons() self.refreshTabs() def refreshTabs(self): diff --git a/pylot/RELEASE-VERSION b/pylot/RELEASE-VERSION index b7c866b9..d95f4865 100644 --- a/pylot/RELEASE-VERSION +++ b/pylot/RELEASE-VERSION @@ -1 +1 @@ -8d6de0-dirty +78d5e-dirty diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index 56b6c2a6..05c2d1e1 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -1300,6 +1300,8 @@ class PickDlg(QDialog): # create buttons for P and S filter and picking self.p_button = QPushButton('P', self) self.s_button = QPushButton('S', self) + self.p_button.setMinimumWidth(100) + self.s_button.setMinimumWidth(100) self.p_button.setCheckable(True) self.s_button.setCheckable(True) # set button tooltips diff --git a/pylot/styles/bright.qss b/pylot/styles/bright.qss index 2247f5ac..71e5c5a3 100644 --- a/pylot/styles/bright.qss +++ b/pylot/styles/bright.qss @@ -124,7 +124,6 @@ color:rgba(0, 0, 0, 255); border-style: outset; border-width: 1px; border-color: rgba(100, 100, 120, 255); -min-width: 6em; padding: 4px; padding-left:5px; padding-right:5px; diff --git a/pylot/styles/dark.qss b/pylot/styles/dark.qss index 930203a9..fc866e20 100644 --- a/pylot/styles/dark.qss +++ b/pylot/styles/dark.qss @@ -123,7 +123,6 @@ color:rgba(255, 255, 255, 255); border-style: outset; border-width: 2px; border-color: rgba(50, 50, 60, 255); -min-width: 6em; padding: 4px; padding-left:5px; padding-right:5px; From c7dc1481a14e9e62f15d0f2a7204209b144ddc71 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 10 Jan 2018 16:59:34 +0100 Subject: [PATCH 4/4] [bugfix] wrong parent set for TuneAutoPicker --- pylot/RELEASE-VERSION | 2 +- pylot/core/util/widgets.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pylot/RELEASE-VERSION b/pylot/RELEASE-VERSION index d95f4865..b775f1a3 100644 --- a/pylot/RELEASE-VERSION +++ b/pylot/RELEASE-VERSION @@ -1 +1 @@ -78d5e-dirty +0ebc-dirty diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index 05c2d1e1..16ead10a 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -2759,7 +2759,7 @@ class TuneAutopicker(QWidget): metadata = self.parent().metadata event = self.get_current_event() filteroptions = self.parent().filteroptions - self.pickDlg = PickDlg(self, data=data.select(station=station), + self.pickDlg = PickDlg(self.parent(), data=data.select(station=station), station=station, parameter=self.parameter, picks=self.get_current_event_picks(station), autopicks=self.get_current_event_autopicks(station),