[update] working version of autopickwidget

This commit is contained in:
Marcel Paffrath 2017-08-23 10:25:46 +02:00
parent 9a5196c33f
commit 0e650dfb75
2 changed files with 52 additions and 7 deletions

View File

@ -1910,8 +1910,8 @@ class MainWindow(QMainWindow):
return return
self.pickoptions =[('current event', self.get_current_event), self.pickoptions =[('current event', self.get_current_event),
('reference set events', self.get_ref_events), ('tune events', self.get_ref_events),
('test set events', self.get_test_events), ('test events', self.get_test_events),
('all (picked) events', self.get_manu_picked_events), ('all (picked) events', self.get_manu_picked_events),
('all events', self.get_all_events)] ('all events', self.get_all_events)]
@ -2001,7 +2001,8 @@ class MainWindow(QMainWindow):
continue continue
event.addAutopicks(result[eventID]) event.addAutopicks(result[eventID])
jkw = JackknifeWidget(self, self.canvas_dict_wadatijack[eventID]['jackknife']) jkw = JackknifeWidget(self, self.canvas_dict_wadatijack[eventID]['jackknife'])
self.apw.insert_plot_widget(jkw, 'Jackknife', eventID) self.apw.add_plot_widget(jkw, 'Jackknife', eventID)
self.apw.update_plots()
self.drawPicks(picktype='auto') self.drawPicks(picktype='auto')
self.draw() self.draw()

View File

@ -12,6 +12,7 @@ import multiprocessing
import os import os
import subprocess import subprocess
import sys import sys
import time
import numpy as np import numpy as np
@ -2032,6 +2033,8 @@ class AutoPickWidget(QWidget):
self.pickoptions = pickoptions self.pickoptions = pickoptions
self.setupUi() self.setupUi()
self.connect_buttons() self.connect_buttons()
self.reinitEvents2plot()
self.setWindowTitle('Autopick events interactively')
# set initial size # set initial size
self.resize(1280, 720) self.resize(1280, 720)
@ -2047,6 +2050,9 @@ class AutoPickWidget(QWidget):
self.init_log_layout() self.init_log_layout()
self.init_plot_layout() self.init_plot_layout()
self.eventbox = QtGui.QComboBox()
self.button_clear = QtGui.QPushButton('Clear')
self.main_layout.insertWidget(1, self.main_splitter) self.main_layout.insertWidget(1, self.main_splitter)
self.main_layout.setStretch(0, 0) self.main_layout.setStretch(0, 0)
@ -2056,6 +2062,7 @@ class AutoPickWidget(QWidget):
def connect_buttons(self): def connect_buttons(self):
self.start_button.clicked.connect(self.start_picker) self.start_button.clicked.connect(self.start_picker)
self.button_clear.clicked.connect(self.reinitEvents2plot)
def init_checkboxes(self): def init_checkboxes(self):
self.rb_layout = QtGui.QHBoxLayout() self.rb_layout = QtGui.QHBoxLayout()
@ -2080,12 +2087,13 @@ class AutoPickWidget(QWidget):
self.main_layout.insertLayout(0, self.rb_layout) self.main_layout.insertLayout(0, self.rb_layout)
def init_plot_layout(self): def init_plot_layout(self):
# init tab widget
self.tab_plots = QtGui.QTabWidget() self.tab_plots = QtGui.QTabWidget()
self.gb_plots = QtGui.QGroupBox('Plots') self.gb_plots = QtGui.QGroupBox('Plots')
self.gb_plots.setMinimumSize(100, 100) self.gb_plots.setMinimumSize(100, 100)
self.main_splitter.insertWidget(1, self.gb_plots) self.main_splitter.insertWidget(1, self.gb_plots)
self.plot_layout = QtGui.QVBoxLayout() self.plot_layout = QtGui.QVBoxLayout()
self.plot_layout.addWidget(self.tab_plots) self.plot_layout.insertWidget(1, self.tab_plots)
self.gb_plots.setLayout(self.plot_layout) self.gb_plots.setLayout(self.plot_layout)
def init_log_layout(self): def init_log_layout(self):
@ -2098,8 +2106,44 @@ class AutoPickWidget(QWidget):
vl.addWidget(widget) vl.addWidget(widget)
self.gb_log.setLayout(vl) self.gb_log.setLayout(vl)
def insert_plot_widget(self, widget, key, eventID): def add_plot_widget(self, widget, key, eventID):
self.tab_plots.addTab(widget, str(key+eventID)) eventID += ' [picked: {}]'.format(time.strftime('%X %x %z'))
if not eventID in self.events2plot.keys():
self.events2plot[eventID] = {}
self.events2plot[eventID][key] = widget
def generate_combobox(self):
self.eventbox.clear()
for eventID, widgets in self.events2plot.items():
self.eventbox.addItem(str(eventID), widgets)
self.eventbox.currentIndexChanged.connect(self.draw_plots)
self.draw_plots()
def draw_plots(self, index=0):
self.refresh_plot_tabs()
widgets = self.eventbox.itemData(index)
if not widgets:
return
for key, widget in widgets.items():
self.tab_plots.addTab(widget, str(key))
def update_plots(self):
self.refresh_plot_tabs()
if len(self.events2plot) > 0:
self.eventbox_layout = QtGui.QHBoxLayout()
self.generate_combobox()
self.eventbox_layout.addWidget(self.eventbox)
self.eventbox_layout.addWidget(self.button_clear)
self.eventbox_layout.setStretch(0, 1)
self.plot_layout.insertLayout(0, self.eventbox_layout)
def reinitEvents2plot(self):
self.events2plot = {}
self.eventbox.clear()
self.refresh_plot_tabs()
def refresh_plot_tabs(self):
self.tab_plots.clear()
def refresh_tooltips(self): def refresh_tooltips(self):
for key, func in self.pickoptions: for key, func in self.pickoptions:
@ -2116,7 +2160,7 @@ class AutoPickWidget(QWidget):
self.rb_dict[key].setToolTip(tooltip) self.rb_dict[key].setToolTip(tooltip)
def start_picker(self): def start_picker(self):
self.tab_plots.clear() self.refresh_plot_tabs()
self.start.emit() self.start.emit()
def enable(self, bool): def enable(self, bool):