improved flexibility of the GUI actions (Matplotlib) implementation
This commit is contained in:
		
							parent
							
								
									bb84e27e54
								
							
						
					
					
						commit
						463535f01a
					
				| @ -285,9 +285,9 @@ class PickDlg(QDialog): | |||||||
| 
 | 
 | ||||||
|         # connect button press event to an action |         # connect button press event to an action | ||||||
|         self.cidpress = self.connectPressEvent(self.panPress) |         self.cidpress = self.connectPressEvent(self.panPress) | ||||||
|         self.cidmotion = self.connectMotionEvent() |         self.cidmotion = self.connectMotionEvent(self.panMotion) | ||||||
|         self.cidrelease = self.connectReleaseEvent() |         self.cidrelease = self.connectReleaseEvent(self.panRelease) | ||||||
|         self.cidscroll = self.connectScrollEvent() |         self.cidscroll = self.connectScrollEvent(self.scrollZoom) | ||||||
| 
 | 
 | ||||||
|     def setupUi(self): |     def setupUi(self): | ||||||
| 
 | 
 | ||||||
| @ -328,6 +328,7 @@ class PickDlg(QDialog): | |||||||
| 
 | 
 | ||||||
|         _dialtoolbar.addAction(self.filterAction) |         _dialtoolbar.addAction(self.filterAction) | ||||||
|         _dialtoolbar.addWidget(self.selectPhase) |         _dialtoolbar.addWidget(self.selectPhase) | ||||||
|  |         _dialtoolbar.addAction(self.zoomAction) | ||||||
| 
 | 
 | ||||||
|         _innerlayout = QVBoxLayout() |         _innerlayout = QVBoxLayout() | ||||||
| 
 | 
 | ||||||
| @ -346,39 +347,40 @@ class PickDlg(QDialog): | |||||||
|         self.setLayout(_outerlayout) |         self.setLayout(_outerlayout) | ||||||
| 
 | 
 | ||||||
|     def disconnectPressEvent(self): |     def disconnectPressEvent(self): | ||||||
|         self.getPlotWidget().mpl_disconnect(self.cidpress) |         widget = self.getPlotWidget() | ||||||
|  |         widget.mpl_disconnect(self.cidpress) | ||||||
|  |         self.cidpress = None | ||||||
| 
 | 
 | ||||||
|     def connectPressEvent(self, slot): |     def connectPressEvent(self, slot): | ||||||
|         widget = self.getPlotWidget() |         widget = self.getPlotWidget() | ||||||
|         return widget.mpl_connect('button_press_event', slot) |         return widget.mpl_connect('button_press_event', slot) | ||||||
| 
 | 
 | ||||||
|     def reconnectPressEvent(self, slot): |  | ||||||
|         self.disconnectPressEvent() |  | ||||||
|         return self.connectPressEvent(slot) |  | ||||||
| 
 |  | ||||||
|     def disconnectScrollEvent(self): |     def disconnectScrollEvent(self): | ||||||
|         widget = self.getPlotWidget() |         widget = self.getPlotWidget() | ||||||
|         widget.mpl_disconnect(self.cidscroll) |         widget.mpl_disconnect(self.cidscroll) | ||||||
|  |         self.cidscroll = None | ||||||
| 
 | 
 | ||||||
|     def connectScrollEvent(self): |     def connectScrollEvent(self, slot): | ||||||
|         widget = self.getPlotWidget() |         widget = self.getPlotWidget() | ||||||
|         return widget.mpl_connect('scroll_event', self.scrollZoom) |         return widget.mpl_connect('scroll_event', slot) | ||||||
| 
 | 
 | ||||||
|     def disconnectMotionEvent(self): |     def disconnectMotionEvent(self): | ||||||
|         widget = self.getPlotWidget() |         widget = self.getPlotWidget() | ||||||
|         widget.mpl_disconnect(self.cidmotion) |         widget.mpl_disconnect(self.cidmotion) | ||||||
|  |         self.cidmotion = None | ||||||
| 
 | 
 | ||||||
|     def connectMotionEvent(self): |     def connectMotionEvent(self, slot): | ||||||
|         widget = self.getPlotWidget() |         widget = self.getPlotWidget() | ||||||
|         return widget.mpl_connect('motion_notify_event', self.panMotion) |         return widget.mpl_connect('motion_notify_event', slot) | ||||||
| 
 | 
 | ||||||
|     def disconnectReleaseEvent(self): |     def disconnectReleaseEvent(self): | ||||||
|         widget = self.getPlotWidget() |         widget = self.getPlotWidget() | ||||||
|         widget.mpl_disconnect(self.cidrelease) |         widget.mpl_disconnect(self.cidrelease) | ||||||
|  |         self.cidrelease = None | ||||||
| 
 | 
 | ||||||
|     def connectReleaseEvent(self): |     def connectReleaseEvent(self, slot): | ||||||
|         widget = self.getPlotWidget() |         widget = self.getPlotWidget() | ||||||
|         return widget.mpl_connect('button_release_event', self.panRelease) |         return widget.mpl_connect('button_release_event', slot) | ||||||
| 
 | 
 | ||||||
|     def verifyPhaseSelection(self): |     def verifyPhaseSelection(self): | ||||||
|         phase = self.selectPhase.currentText() |         phase = self.selectPhase.currentText() | ||||||
| @ -386,12 +388,13 @@ class PickDlg(QDialog): | |||||||
|             self.disconnectReleaseEvent() |             self.disconnectReleaseEvent() | ||||||
|             self.disconnectScrollEvent() |             self.disconnectScrollEvent() | ||||||
|             self.disconnectMotionEvent() |             self.disconnectMotionEvent() | ||||||
|             self.reconnectPressEvent(self.setIniPick) |             self.disconnectPressEvent() | ||||||
|  |             self.cidpress = self.connectPressEvent(self.setIniPick) | ||||||
|         else: |         else: | ||||||
|             self.cidpress = self.connectPressEvent(self.panPress) |             self.cidpress = self.connectPressEvent(self.panPress) | ||||||
|             self.cidmotion = self.connectMotionEvent() |             self.cidmotion = self.connectMotionEvent(self.panMotion) | ||||||
|             self.cidrelease = self.connectReleaseEvent() |             self.cidrelease = self.connectReleaseEvent(self.panRelease) | ||||||
|             self.cidscroll = self.connectScrollEvent() |             self.cidscroll = self.connectScrollEvent(self.scrollZoom) | ||||||
| 
 | 
 | ||||||
|     def getComponents(self): |     def getComponents(self): | ||||||
|         return self.components |         return self.components | ||||||
| @ -438,8 +441,10 @@ class PickDlg(QDialog): | |||||||
|         wfdata = self.selectWFData(channel) |         wfdata = self.selectWFData(channel) | ||||||
| 
 | 
 | ||||||
|         self.disconnectScrollEvent() |         self.disconnectScrollEvent() | ||||||
| 
 |         self.disconnectPressEvent() | ||||||
|         self.cidpress = self.reconnectPressEvent(self.setPick) |         self.disconnectReleaseEvent() | ||||||
|  |         self.disconnectMotionEvent() | ||||||
|  |         self.cidpress = self.connectPressEvent(self.setPick) | ||||||
| 
 | 
 | ||||||
|         ini_pick = gui_event.xdata |         ini_pick = gui_event.xdata | ||||||
| 
 | 
 | ||||||
| @ -457,7 +462,7 @@ class PickDlg(QDialog): | |||||||
|             'VLRW' : 15. |             'VLRW' : 15. | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         result = getSNR(wfdata, (5., .5, 1.), ini_pick) |         result = getSNR(wfdata, (5., .5, 2.), ini_pick) | ||||||
| 
 | 
 | ||||||
|         snr = result[0] |         snr = result[0] | ||||||
|         noiselevel = result[2] * 1.5 |         noiselevel = result[2] * 1.5 | ||||||
| @ -493,7 +498,7 @@ class PickDlg(QDialog): | |||||||
| 
 | 
 | ||||||
|         wfdata = self.getAPD().copy().select(channel=channel) |         wfdata = self.getAPD().copy().select(channel=channel) | ||||||
|         # get earliest and latest possible pick |         # get earliest and latest possible pick | ||||||
|         [epp, lpp, pickerror] = earllatepicker(wfdata, 1.5, (5., .5, 1.), pick) |         [epp, lpp, pickerror] = earllatepicker(wfdata, 1.5, (5., .5, 2.), pick) | ||||||
| 
 | 
 | ||||||
|         # plotting picks |         # plotting picks | ||||||
|         ax = self.getPlotWidget().axes |         ax = self.getPlotWidget().axes | ||||||
| @ -559,9 +564,11 @@ class PickDlg(QDialog): | |||||||
|     def zoom(self): |     def zoom(self): | ||||||
|         if self.zoomAction.isChecked(): |         if self.zoomAction.isChecked(): | ||||||
|             self.disconnectPressEvent() |             self.disconnectPressEvent() | ||||||
|  |             self.disconnectMotionEvent() | ||||||
|  |             self.disconnectReleaseEvent() | ||||||
|             self.figToolBar.zoom() |             self.figToolBar.zoom() | ||||||
|         else: |         else: | ||||||
|             self.connectPressEvent(self.setIniPick) |             self.cidpress = self.connectPressEvent(self.setIniPick) | ||||||
| 
 | 
 | ||||||
|     def scrollZoom(self, gui_event, factor=2.): |     def scrollZoom(self, gui_event, factor=2.): | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user