added scroll functionality when mouse inside dataPlot canvas
This commit is contained in:
parent
a3fbeafeac
commit
ba56bfbd25
22
QtPyLoT.py
22
QtPyLoT.py
@ -104,6 +104,7 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
self.poS_id = None
|
self.poS_id = None
|
||||||
self.ae_id = None
|
self.ae_id = None
|
||||||
|
self.scroll_id = None
|
||||||
|
|
||||||
# default colors for ref/test event
|
# default colors for ref/test event
|
||||||
self._colors = {
|
self._colors = {
|
||||||
@ -1047,13 +1048,20 @@ class MainWindow(QMainWindow):
|
|||||||
self.ae_id = self.dataPlot.mpl_connect('axes_enter_event',
|
self.ae_id = self.dataPlot.mpl_connect('axes_enter_event',
|
||||||
lambda event: self.tutor_user())
|
lambda event: self.tutor_user())
|
||||||
|
|
||||||
|
if not self.scroll_id:
|
||||||
|
self.scroll_id = self.dataPlot.mpl_connect('scroll_event',
|
||||||
|
self.scrollPlot)
|
||||||
|
|
||||||
def disconnectWFplotEvents(self):
|
def disconnectWFplotEvents(self):
|
||||||
if self.poS_id:
|
if self.poS_id:
|
||||||
self.dataPlot.mpl_disconnect(self.poS_id)
|
self.dataPlot.mpl_disconnect(self.poS_id)
|
||||||
if self.ae_id:
|
if self.ae_id:
|
||||||
self.dataPlot.mpl_disconnect(self.ae_id)
|
self.dataPlot.mpl_disconnect(self.ae_id)
|
||||||
|
if self.scroll_id:
|
||||||
|
self.dataPlot.mpl_connect(self.scroll_id)
|
||||||
self.poS_id = None
|
self.poS_id = None
|
||||||
self.ae_id = None
|
self.ae_id = None
|
||||||
|
self.scroll_id = None
|
||||||
|
|
||||||
def finishWaveformDataPlot(self):
|
def finishWaveformDataPlot(self):
|
||||||
self.connectWFplotEvents()
|
self.connectWFplotEvents()
|
||||||
@ -1116,7 +1124,7 @@ class MainWindow(QMainWindow):
|
|||||||
plotWidget.plotWFData(wfdata=wfst, title=title, mapping=False)
|
plotWidget.plotWFData(wfdata=wfst, title=title, mapping=False)
|
||||||
plotDict = plotWidget.getPlotDict()
|
plotDict = plotWidget.getPlotDict()
|
||||||
pos = plotDict.keys()
|
pos = plotDict.keys()
|
||||||
labels = [plotDict[n][0] for n in pos]
|
labels = [plotDict[n][2]+'.'+plotDict[n][0] for n in pos]
|
||||||
plotWidget.setYTickLabels(pos, labels)
|
plotWidget.setYTickLabels(pos, labels)
|
||||||
try:
|
try:
|
||||||
plotWidget.figure.tight_layout()
|
plotWidget.figure.tight_layout()
|
||||||
@ -1221,7 +1229,19 @@ class MainWindow(QMainWindow):
|
|||||||
self.update_status('Seismic phase changed to '
|
self.update_status('Seismic phase changed to '
|
||||||
'{0}'.format(self.getSeismicPhase()))
|
'{0}'.format(self.getSeismicPhase()))
|
||||||
|
|
||||||
|
def scrollPlot(self, gui_event):
|
||||||
|
button = gui_event.button
|
||||||
|
if not button == 'up' and not button == 'down':
|
||||||
|
return
|
||||||
|
vbar = self.wf_scroll_area.verticalScrollBar()
|
||||||
|
up_down = {'up': -60,
|
||||||
|
'down': 60}
|
||||||
|
if vbar.maximum():
|
||||||
|
vbar.setValue(vbar.value() + up_down[button])
|
||||||
|
|
||||||
def pickOnStation(self, gui_event):
|
def pickOnStation(self, gui_event):
|
||||||
|
if not gui_event.button == 1:
|
||||||
|
return
|
||||||
|
|
||||||
wfID = self.getWFID(gui_event)
|
wfID = self.getWFID(gui_event)
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
2a05-dirty
|
a3fbe-dirty
|
||||||
|
@ -439,6 +439,7 @@ class WaveformWidget(FigureCanvas):
|
|||||||
nmax = 0
|
nmax = 0
|
||||||
for n, trace in enumerate(wfdata):
|
for n, trace in enumerate(wfdata):
|
||||||
channel = trace.stats.channel
|
channel = trace.stats.channel
|
||||||
|
network = trace.stats.network
|
||||||
station = trace.stats.station
|
station = trace.stats.station
|
||||||
if mapping:
|
if mapping:
|
||||||
comp = channel[-1]
|
comp = channel[-1]
|
||||||
@ -458,7 +459,7 @@ class WaveformWidget(FigureCanvas):
|
|||||||
for level in noiselevel:
|
for level in noiselevel:
|
||||||
self.getAxes().plot([time_ax[0], time_ax[-1]],
|
self.getAxes().plot([time_ax[0], time_ax[-1]],
|
||||||
[level, level], '--k')
|
[level, level], '--k')
|
||||||
self.setPlotDict(n, (station, channel))
|
self.setPlotDict(n, (station, channel, network))
|
||||||
xlabel = 'seconds since {0}'.format(wfstart)
|
xlabel = 'seconds since {0}'.format(wfstart)
|
||||||
ylabel = ''
|
ylabel = ''
|
||||||
self.updateWidget(xlabel, ylabel, title)
|
self.updateWidget(xlabel, ylabel, title)
|
||||||
|
Loading…
Reference in New Issue
Block a user