diff --git a/PyLoT.py b/PyLoT.py index fbdc303b..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): @@ -1816,6 +1848,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 5f884094..b775f1a3 100644 --- a/pylot/RELEASE-VERSION +++ b/pylot/RELEASE-VERSION @@ -1 +1 @@ -7c61-dirty +0ebc-dirty diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index b265980f..aeaa2eec 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -1314,6 +1314,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 @@ -1562,7 +1564,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) @@ -1662,7 +1671,7 @@ class PickDlg(QDialog): self.currentPhase = None self.reset_p_button() self.reset_s_button() - self.resetPlot() + self.refreshPlot() self.deactivatePicking() def activatePicking(self): @@ -1788,7 +1797,7 @@ class PickDlg(QDialog): def delPicks(self): self.resetPicks() - self.resetPlot() + self.refreshPlot() def setIniPick(self, gui_event): self.multicompfig.set_frame_color('green') @@ -1900,7 +1909,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)) @@ -2127,7 +2136,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: @@ -2210,12 +2219,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(), @@ -2229,34 +2237,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(), - plot_additional=self.additionalChannel.isChecked()) - 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] @@ -2309,7 +2314,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() @@ -2772,7 +2777,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), 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;