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,13 +636,13 @@ class MainWindow(QMainWindow): | ||||
|     def createEventBox(self): | ||||
|         qcb = QComboBox() | ||||
|         palette = qcb.palette() | ||||
|         palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Highlight, | ||||
|                          QtGui.QBrush(QtGui.QColor(0,0,127,127))) | ||||
|         palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Highlight, | ||||
|                          QtGui.QBrush(QtGui.QColor(0,0,127,127))) | ||||
|         # change highlight color: | ||||
|         # palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Highlight, | ||||
|         #                  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) | ||||
|         return qcb | ||||
| 
 | ||||
|          | ||||
|     def init_events(self, new=False): | ||||
|         nitems = self.eventBox.count() | ||||
| @ -651,7 +651,7 @@ class MainWindow(QMainWindow): | ||||
|             self.clearWaveformDataPlot() | ||||
|             return | ||||
|         self.eventBox.setEnabled(True) | ||||
|         self.fill_eventbox() | ||||
|         self.fill_eventbox(self.eventBox) | ||||
|         if new: | ||||
|             self.eventBox.setCurrentIndex(0) | ||||
|         else: | ||||
| @ -659,8 +659,12 @@ class MainWindow(QMainWindow): | ||||
|         self.refreshEvents() | ||||
|         tabindex = self.tabs.currentIndex() | ||||
| 
 | ||||
|     def fill_eventbox(self): | ||||
|         index=self.eventBox.currentIndex() | ||||
|     def fill_eventbox(self, eventBox, select_events='all'): | ||||
|         ''' | ||||
|         :param: select_events, can be 'all', 'ref' | ||||
|         :type: str | ||||
|         ''' | ||||
|         index=eventBox.currentIndex() | ||||
|         tv=QtGui.QTableView() | ||||
|         header = tv.horizontalHeader() | ||||
|         header.setResizeMode(QtGui.QHeaderView.ResizeToContents) | ||||
| @ -669,10 +673,11 @@ class MainWindow(QMainWindow): | ||||
|         tv.verticalHeader().hide() | ||||
|         tv.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) | ||||
|          | ||||
|         self.eventBox.setView(tv) | ||||
|         self.eventBox.clear() | ||||
|         model = self.eventBox.model() | ||||
|         eventBox.setView(tv) | ||||
|         eventBox.clear() | ||||
|         model = eventBox.model() | ||||
|         plmax=0 | ||||
|         #set maximum length of path string | ||||
|         for event in self.project.eventlist: | ||||
|             pl = len(event.path) | ||||
|             if pl > plmax: | ||||
| @ -722,8 +727,11 @@ class MainWindow(QMainWindow): | ||||
|             # item2.setForeground(QtGui.QColor('black')) | ||||
|             # item2.setFont(font) | ||||
|             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) | ||||
|         self.eventBox.setCurrentIndex(index) | ||||
|         eventBox.setCurrentIndex(index) | ||||
| 
 | ||||
|     def filename_from_action(self, action): | ||||
|         if action.data() is None: | ||||
| @ -1169,11 +1177,12 @@ class MainWindow(QMainWindow): | ||||
|             fig = Figure() | ||||
|             self.fig_dict[key] = fig | ||||
| 
 | ||||
|         ap = self._inputs | ||||
|         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.show() | ||||
|         else: | ||||
|             self.tap.fill_eventbox() | ||||
|         self.tap.show() | ||||
|              | ||||
|     def update_autopicker(self): | ||||
|         for key in self.fig_dict.keys(): | ||||
| @ -1420,7 +1429,7 @@ class MainWindow(QMainWindow): | ||||
|         self.array_map.refresh_drawings(self.picks) | ||||
|         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): | ||||
|             if enabled and not checkable: | ||||
|                 item.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable) | ||||
| @ -1451,12 +1460,12 @@ class MainWindow(QMainWindow): | ||||
|                     event.setTestEvent(True) | ||||
|                 elif column == 4 and not item_test.checkState(): | ||||
|                     event.setTestEvent(False) | ||||
|                 self.fill_eventbox()                     | ||||
|                 self.fill_eventbox(self.eventBox)                     | ||||
|             elif column == 5: | ||||
|                 #update event notes | ||||
|                 notes = table[row][5].text() | ||||
|                 event.addNotes(notes) | ||||
|                 self.fill_eventbox() | ||||
|                 self.fill_eventbox(self.eventBox) | ||||
| 
 | ||||
|         if hasattr(self, 'qtl'): | ||||
|             self.qtl.setParent(None) | ||||
| @ -1521,7 +1530,7 @@ class MainWindow(QMainWindow): | ||||
|         self.qtl.cellChanged[int, int].connect(cell_changed) | ||||
|          | ||||
|         self.events_layout.addWidget(self.qtl) | ||||
|         self.tabs.setCurrentIndex(index) | ||||
|         self.tabs.setCurrentIndex(tabindex) | ||||
|          | ||||
|     def read_metadata_thread(self, fninv): | ||||
|         self.rm_thread = Thread(self, read_metadata, arg=fninv, progressText='Reading metadata...') | ||||
| @ -1710,7 +1719,7 @@ class MainWindow(QMainWindow): | ||||
|                 self.createNewProject(exists=True) | ||||
|                  | ||||
|     def draw(self): | ||||
|         self.fill_eventbox() | ||||
|         self.fill_eventbox(self.eventBox) | ||||
|         self.getPlotWidget().draw() | ||||
| 
 | ||||
|     def setDirty(self, value): | ||||
|  | ||||
| @ -1 +1 @@ | ||||
| 1849-dirty | ||||
| 12e6-dirty | ||||
|  | ||||
| @ -1273,41 +1273,60 @@ class PickDlg(QDialog): | ||||
| class TuneAutopicker(QWidget):      | ||||
|     update = QtCore.Signal(str) | ||||
|      | ||||
|     def __init__(self, ap, fig_dict, parent=None): | ||||
|     def __init__(self, parent): | ||||
|         QtGui.QWidget.__init__(self, parent, 1) | ||||
|         self.ap = ap | ||||
|         self.parent = parent | ||||
|         self.station = 'TMO53' ############# justs for testing | ||||
|         self.fig_dict = fig_dict | ||||
|         self.layout = QtGui.QHBoxLayout() | ||||
|         self.parameter_layout = QtGui.QVBoxLayout() | ||||
|         self.setLayout(self.layout) | ||||
|         self.ap = parent._inputs | ||||
|         self.fig_dict = parent.fig_dict | ||||
|         self.init_main_layouts() | ||||
|         self.init_eventlist() | ||||
|         self.init_figure_tabs() | ||||
|         self.add_parameter() | ||||
|         self.add_buttons() | ||||
|         self.set_stretch() | ||||
|         self.resize(1280, 720) | ||||
|         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): | ||||
|         self.main_tabs = QtGui.QTabWidget() | ||||
|         self.p_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.fill_tabs(None) | ||||
| 
 | ||||
|     def add_parameter(self): | ||||
|         self.parameters = AutoPickParaBox(self.ap) | ||||
|         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): | ||||
|         self.pick_button = QtGui.QPushButton('Pick Trace') | ||||
|         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): | ||||
|         self.ap = self.update_params() | ||||
|         args = {'parameter': self.ap, | ||||
| @ -1333,8 +1352,8 @@ class TuneAutopicker(QWidget): | ||||
|         return ap | ||||
| 
 | ||||
|     def set_stretch(self): | ||||
|         self.layout.setStretch(0, 3) | ||||
|         self.layout.setStretch(1, 1)         | ||||
|         self.tune_layout.setStretch(0, 3) | ||||
|         self.tune_layout.setStretch(1, 1)         | ||||
|          | ||||
|     def init_tab_names(self): | ||||
|         self.ptb_names = ['aicFig', 'slength', 'checkZ4s', 'refPpick', 'el_Ppick', 'fm_picker'] | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user