threading for tuneAutopicker working now, to do: change figures (vfill), tight layout?
This commit is contained in:
parent
12e6106227
commit
77b076d560
49
QtPyLoT.py
49
QtPyLoT.py
@ -636,14 +636,14 @@ class MainWindow(QMainWindow):
|
|||||||
def createEventBox(self):
|
def createEventBox(self):
|
||||||
qcb = QComboBox()
|
qcb = QComboBox()
|
||||||
palette = qcb.palette()
|
palette = qcb.palette()
|
||||||
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Highlight,
|
# change highlight color:
|
||||||
QtGui.QBrush(QtGui.QColor(0,0,127,127)))
|
# palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Highlight,
|
||||||
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Highlight,
|
# QtGui.QBrush(QtGui.QColor(0,0,127,127)))
|
||||||
QtGui.QBrush(QtGui.QColor(0,0,127,127)))
|
# palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Highlight,
|
||||||
|
# QtGui.QBrush(QtGui.QColor(0,0,127,127)))
|
||||||
qcb.setPalette(palette)
|
qcb.setPalette(palette)
|
||||||
return qcb
|
return qcb
|
||||||
|
|
||||||
|
|
||||||
def init_events(self, new=False):
|
def init_events(self, new=False):
|
||||||
nitems = self.eventBox.count()
|
nitems = self.eventBox.count()
|
||||||
if len(self.project.eventlist) == 0:
|
if len(self.project.eventlist) == 0:
|
||||||
@ -651,7 +651,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.clearWaveformDataPlot()
|
self.clearWaveformDataPlot()
|
||||||
return
|
return
|
||||||
self.eventBox.setEnabled(True)
|
self.eventBox.setEnabled(True)
|
||||||
self.fill_eventbox()
|
self.fill_eventbox(self.eventBox)
|
||||||
if new:
|
if new:
|
||||||
self.eventBox.setCurrentIndex(0)
|
self.eventBox.setCurrentIndex(0)
|
||||||
else:
|
else:
|
||||||
@ -659,8 +659,12 @@ class MainWindow(QMainWindow):
|
|||||||
self.refreshEvents()
|
self.refreshEvents()
|
||||||
tabindex = self.tabs.currentIndex()
|
tabindex = self.tabs.currentIndex()
|
||||||
|
|
||||||
def fill_eventbox(self):
|
def fill_eventbox(self, eventBox, select_events='all'):
|
||||||
index=self.eventBox.currentIndex()
|
'''
|
||||||
|
:param: select_events, can be 'all', 'ref'
|
||||||
|
:type: str
|
||||||
|
'''
|
||||||
|
index=eventBox.currentIndex()
|
||||||
tv=QtGui.QTableView()
|
tv=QtGui.QTableView()
|
||||||
header = tv.horizontalHeader()
|
header = tv.horizontalHeader()
|
||||||
header.setResizeMode(QtGui.QHeaderView.ResizeToContents)
|
header.setResizeMode(QtGui.QHeaderView.ResizeToContents)
|
||||||
@ -669,10 +673,11 @@ class MainWindow(QMainWindow):
|
|||||||
tv.verticalHeader().hide()
|
tv.verticalHeader().hide()
|
||||||
tv.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
|
tv.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
|
||||||
|
|
||||||
self.eventBox.setView(tv)
|
eventBox.setView(tv)
|
||||||
self.eventBox.clear()
|
eventBox.clear()
|
||||||
model = self.eventBox.model()
|
model = eventBox.model()
|
||||||
plmax=0
|
plmax=0
|
||||||
|
#set maximum length of path string
|
||||||
for event in self.project.eventlist:
|
for event in self.project.eventlist:
|
||||||
pl = len(event.path)
|
pl = len(event.path)
|
||||||
if pl > plmax:
|
if pl > plmax:
|
||||||
@ -722,8 +727,11 @@ class MainWindow(QMainWindow):
|
|||||||
# item2.setForeground(QtGui.QColor('black'))
|
# item2.setForeground(QtGui.QColor('black'))
|
||||||
# item2.setFont(font)
|
# item2.setFont(font)
|
||||||
itemlist = [item_path, item_nmp, item_nap, item_ref, item_test, item_notes]
|
itemlist = [item_path, item_nmp, item_nap, item_ref, item_test, item_notes]
|
||||||
|
if event_test and select_events == 'ref':
|
||||||
|
for item in itemlist:
|
||||||
|
item.setEnabled(False)
|
||||||
model.appendRow(itemlist)
|
model.appendRow(itemlist)
|
||||||
self.eventBox.setCurrentIndex(index)
|
eventBox.setCurrentIndex(index)
|
||||||
|
|
||||||
def filename_from_action(self, action):
|
def filename_from_action(self, action):
|
||||||
if action.data() is None:
|
if action.data() is None:
|
||||||
@ -1169,11 +1177,12 @@ class MainWindow(QMainWindow):
|
|||||||
fig = Figure()
|
fig = Figure()
|
||||||
self.fig_dict[key] = fig
|
self.fig_dict[key] = fig
|
||||||
|
|
||||||
ap = self._inputs
|
|
||||||
if not self.tap:
|
if not self.tap:
|
||||||
self.tap = TuneAutopicker(ap, self.fig_dict, self)
|
self.tap = TuneAutopicker(self)
|
||||||
self.tap.update.connect(self.update_autopicker)
|
self.tap.update.connect(self.update_autopicker)
|
||||||
self.tap.show()
|
else:
|
||||||
|
self.tap.fill_eventbox()
|
||||||
|
self.tap.show()
|
||||||
|
|
||||||
def update_autopicker(self):
|
def update_autopicker(self):
|
||||||
for key in self.fig_dict.keys():
|
for key in self.fig_dict.keys():
|
||||||
@ -1420,7 +1429,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.array_map.refresh_drawings(self.picks)
|
self.array_map.refresh_drawings(self.picks)
|
||||||
self._eventChanged[1] = False
|
self._eventChanged[1] = False
|
||||||
|
|
||||||
def init_event_table(self, index=2):
|
def init_event_table(self, tabindex=2):
|
||||||
def set_enabled(item, enabled=True, checkable=False):
|
def set_enabled(item, enabled=True, checkable=False):
|
||||||
if enabled and not checkable:
|
if enabled and not checkable:
|
||||||
item.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable)
|
item.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable)
|
||||||
@ -1451,12 +1460,12 @@ class MainWindow(QMainWindow):
|
|||||||
event.setTestEvent(True)
|
event.setTestEvent(True)
|
||||||
elif column == 4 and not item_test.checkState():
|
elif column == 4 and not item_test.checkState():
|
||||||
event.setTestEvent(False)
|
event.setTestEvent(False)
|
||||||
self.fill_eventbox()
|
self.fill_eventbox(self.eventBox)
|
||||||
elif column == 5:
|
elif column == 5:
|
||||||
#update event notes
|
#update event notes
|
||||||
notes = table[row][5].text()
|
notes = table[row][5].text()
|
||||||
event.addNotes(notes)
|
event.addNotes(notes)
|
||||||
self.fill_eventbox()
|
self.fill_eventbox(self.eventBox)
|
||||||
|
|
||||||
if hasattr(self, 'qtl'):
|
if hasattr(self, 'qtl'):
|
||||||
self.qtl.setParent(None)
|
self.qtl.setParent(None)
|
||||||
@ -1521,7 +1530,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.qtl.cellChanged[int, int].connect(cell_changed)
|
self.qtl.cellChanged[int, int].connect(cell_changed)
|
||||||
|
|
||||||
self.events_layout.addWidget(self.qtl)
|
self.events_layout.addWidget(self.qtl)
|
||||||
self.tabs.setCurrentIndex(index)
|
self.tabs.setCurrentIndex(tabindex)
|
||||||
|
|
||||||
def read_metadata_thread(self, fninv):
|
def read_metadata_thread(self, fninv):
|
||||||
self.rm_thread = Thread(self, read_metadata, arg=fninv, progressText='Reading metadata...')
|
self.rm_thread = Thread(self, read_metadata, arg=fninv, progressText='Reading metadata...')
|
||||||
@ -1710,7 +1719,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.createNewProject(exists=True)
|
self.createNewProject(exists=True)
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
self.fill_eventbox()
|
self.fill_eventbox(self.eventBox)
|
||||||
self.getPlotWidget().draw()
|
self.getPlotWidget().draw()
|
||||||
|
|
||||||
def setDirty(self, value):
|
def setDirty(self, value):
|
||||||
|
@ -1 +1 @@
|
|||||||
1849-dirty
|
12e6-dirty
|
||||||
|
@ -1273,40 +1273,59 @@ class PickDlg(QDialog):
|
|||||||
class TuneAutopicker(QWidget):
|
class TuneAutopicker(QWidget):
|
||||||
update = QtCore.Signal(str)
|
update = QtCore.Signal(str)
|
||||||
|
|
||||||
def __init__(self, ap, fig_dict, parent=None):
|
def __init__(self, parent):
|
||||||
QtGui.QWidget.__init__(self, parent, 1)
|
QtGui.QWidget.__init__(self, parent, 1)
|
||||||
self.ap = ap
|
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.station = 'TMO53' ############# justs for testing
|
self.ap = parent._inputs
|
||||||
self.fig_dict = fig_dict
|
self.fig_dict = parent.fig_dict
|
||||||
self.layout = QtGui.QHBoxLayout()
|
self.init_main_layouts()
|
||||||
self.parameter_layout = QtGui.QVBoxLayout()
|
self.init_eventlist()
|
||||||
self.setLayout(self.layout)
|
|
||||||
self.init_figure_tabs()
|
self.init_figure_tabs()
|
||||||
self.add_parameter()
|
self.add_parameter()
|
||||||
self.add_buttons()
|
self.add_buttons()
|
||||||
self.set_stretch()
|
self.set_stretch()
|
||||||
self.resize(1280, 720)
|
self.resize(1280, 720)
|
||||||
self.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal)
|
self.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal)
|
||||||
self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint)
|
#self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint)
|
||||||
|
|
||||||
|
def init_main_layouts(self):
|
||||||
|
self.main_layout = QtGui.QVBoxLayout()
|
||||||
|
self.tune_layout = QtGui.QHBoxLayout()
|
||||||
|
self.trace_layout = QtGui.QHBoxLayout()
|
||||||
|
self.parameter_layout = QtGui.QVBoxLayout()
|
||||||
|
|
||||||
|
self.main_layout.addLayout(self.tune_layout)
|
||||||
|
self.main_layout.addLayout(self.trace_layout)
|
||||||
|
self.setLayout(self.main_layout)
|
||||||
|
|
||||||
|
def init_eventlist(self):
|
||||||
|
self.eventBox = self.parent.createEventBox()
|
||||||
|
self.fill_eventbox()
|
||||||
|
self.trace_layout.addWidget(self.eventBox)
|
||||||
|
|
||||||
|
def init_stationlist(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def init_figure_tabs(self):
|
def init_figure_tabs(self):
|
||||||
self.main_tabs = QtGui.QTabWidget()
|
self.main_tabs = QtGui.QTabWidget()
|
||||||
self.p_tabs = QtGui.QTabWidget()
|
self.p_tabs = QtGui.QTabWidget()
|
||||||
self.s_tabs = QtGui.QTabWidget()
|
self.s_tabs = QtGui.QTabWidget()
|
||||||
self.layout.insertWidget(0, self.main_tabs)
|
self.tune_layout.insertWidget(0, self.main_tabs)
|
||||||
self.init_tab_names()
|
self.init_tab_names()
|
||||||
#self.fill_tabs(None)
|
|
||||||
|
|
||||||
def add_parameter(self):
|
def add_parameter(self):
|
||||||
self.parameters = AutoPickParaBox(self.ap)
|
self.parameters = AutoPickParaBox(self.ap)
|
||||||
self.parameter_layout.addWidget(self.parameters)
|
self.parameter_layout.addWidget(self.parameters)
|
||||||
self.layout.insertLayout(1, self.parameter_layout)
|
self.tune_layout.insertLayout(1, self.parameter_layout)
|
||||||
|
|
||||||
def add_buttons(self):
|
def add_buttons(self):
|
||||||
self.pick_button = QtGui.QPushButton('Pick Trace')
|
self.pick_button = QtGui.QPushButton('Pick Trace')
|
||||||
self.pick_button.clicked.connect(self.call_picker)
|
self.pick_button.clicked.connect(self.call_picker)
|
||||||
self.parameter_layout.addWidget(self.pick_button)
|
self.trace_layout.addWidget(self.pick_button)
|
||||||
|
self.trace_layout.setStretch(0, 1)
|
||||||
|
|
||||||
|
def fill_eventbox(self):
|
||||||
|
self.parent.fill_eventbox(self.eventBox, 'ref')
|
||||||
|
|
||||||
def call_picker(self):
|
def call_picker(self):
|
||||||
self.ap = self.update_params()
|
self.ap = self.update_params()
|
||||||
@ -1333,8 +1352,8 @@ class TuneAutopicker(QWidget):
|
|||||||
return ap
|
return ap
|
||||||
|
|
||||||
def set_stretch(self):
|
def set_stretch(self):
|
||||||
self.layout.setStretch(0, 3)
|
self.tune_layout.setStretch(0, 3)
|
||||||
self.layout.setStretch(1, 1)
|
self.tune_layout.setStretch(1, 1)
|
||||||
|
|
||||||
def init_tab_names(self):
|
def init_tab_names(self):
|
||||||
self.ptb_names = ['aicFig', 'slength', 'checkZ4s', 'refPpick', 'el_Ppick', 'fm_picker']
|
self.ptb_names = ['aicFig', 'slength', 'checkZ4s', 'refPpick', 'el_Ppick', 'fm_picker']
|
||||||
|
Loading…
Reference in New Issue
Block a user