[new] tooltip for phases on mouseover (untested)

This commit is contained in:
Marcel Paffrath 2018-01-15 11:21:43 +01:00
parent 534222e241
commit 0013d099f3
2 changed files with 32 additions and 7 deletions

View File

@ -1 +1 @@
796e-dirty 5342-dirty

View File

@ -375,8 +375,8 @@ class ComparisonWidget(QWidget):
ax = axes_dict[phase]['exp'] ax = axes_dict[phase]['exp']
xlims = ax.get_xlim() xlims = ax.get_xlim()
ylims = ax.get_ylim() ylims = ax.get_ylim()
ax.fill_between([xlims[0], 0], ylims[0], ylims[1], color=(0.9, 1.0, 0.9, 0.5), label='earlier than manual') #ax.fill_between([xlims[0], 0], ylims[0], ylims[1], color=(0.9, 1.0, 0.9, 0.5), label='earlier than manual')
ax.fill_between([0, xlims[1]], ylims[0], ylims[1], color=(1.0, 0.9, 0.9, 0.5), label='later than manual') #ax.fill_between([0, xlims[1]], ylims[0], ylims[1], color=(1.0, 0.9, 0.9, 0.5), label='later than manual')
legend = ax.legend() legend = ax.legend()
legend.draggable() legend.draggable()
@ -1140,6 +1140,7 @@ class PickDlg(QDialog):
self.components = 'ZNE' self.components = 'ZNE'
self.currentPhase = None self.currentPhase = None
self.phaseText = [] self.phaseText = []
self.phaseLines = []
self.arrivals = [] self.arrivals = []
self.arrivalsText = [] self.arrivalsText = []
self.cidpick = [] self.cidpick = []
@ -2085,8 +2086,9 @@ class PickDlg(QDialog):
color = pick_color_plt(picktype, phaseID, quality) color = pick_color_plt(picktype, phaseID, quality)
if not textOnly: if not textOnly:
linestyle_mpp, width_mpp = pick_linestyle_plt(picktype, 'mpp') linestyle_mpp, width_mpp = pick_linestyle_plt(picktype, 'mpp')
ax.plot([mpp, mpp], ylims, color=color, linestyle=linestyle_mpp, linewidth=width_mpp, vl = ax.axvline(mpp, ylims[0], ylims[1], color=color, linestyle=linestyle_mpp, linewidth=width_mpp,
label='{}-Pick (quality: {})'.format(phase, quality), picker=5) label='{}-Pick (quality: {})'.format(phase, quality), picker=5)
self.phaseLines.append(vl)
if spe: if spe:
ax.fill_between([mpp-spe, mpp+spe], ylims[0], ylims[1], ax.fill_between([mpp-spe, mpp+spe], ylims[0], ylims[1],
alpha=.25, color=color, label='{}-SPE'.format(phase)) alpha=.25, color=color, label='{}-SPE'.format(phase))
@ -2109,8 +2111,9 @@ class PickDlg(QDialog):
if not textOnly: if not textOnly:
ax.plot(mpp, ylims[1], color=color, marker='v') ax.plot(mpp, ylims[1], color=color, marker='v')
ax.plot(mpp, ylims[0], color=color, marker='^') ax.plot(mpp, ylims[0], color=color, marker='^')
ax.vlines(mpp, ylims[0], ylims[1], color=color, linestyle=linestyle_mpp, linewidth=width_mpp, vl = ax.vlines(mpp, ylims[0], ylims[1], color=color, linestyle=linestyle_mpp, linewidth=width_mpp,
picker=5, label='{}-Autopick (quality: {})'.format(phase, quality)) picker=5, label='{}-Autopick (quality: {})'.format(phase, quality))
self.phaseLines.append(vl)
# append phase text (if textOnly: draw with current ylims) # append phase text (if textOnly: draw with current ylims)
self.phaseText.append(ax.text(mpp, ylims[1], phase, color=color)) self.phaseText.append(ax.text(mpp, ylims[1], phase, color=color))
else: else:
@ -2124,6 +2127,7 @@ class PickDlg(QDialog):
def connect_pick_delete(self): def connect_pick_delete(self):
self.cidpick = self.multicompfig.mpl_connect('pick_event', self.onpick) self.cidpick = self.multicompfig.mpl_connect('pick_event', self.onpick)
self.cidpick = self.multicompfig.mpl_connect('motion_notify_event', self.on_hover_info)
def disconnect_pick_delete(self): def disconnect_pick_delete(self):
if hasattr(self, 'cidpick'): if hasattr(self, 'cidpick'):
@ -2140,6 +2144,27 @@ class PickDlg(QDialog):
elif event.mouseevent.button == 3: elif event.mouseevent.button == 3:
self.onpick_delete(event) self.onpick_delete(event)
def on_hover_info(self, event):
if not any([phase.contains(event)[0] for phase in self.phaseLines]):
return
x = event.xdata
if not x:
return
allpicks, pick_rel, phase, picktype = self.identify_selected_picks(x)
pick = allpicks[picktype][phase]
message = '{} {}-pick'.format(picktype, phase)
if 'mpp' in pick:
message += ', MPP: {}'.format(pick['mpp'])
if 'spe' in pick:
message += ', SPE: {} [s]'.format(pick['spe'])
if 'filteroptions' in pick:
message += ', FILTER: {}'.format(pick['filteroptions'])
x = event.x
y = event.y
y = self.size().height() - y
pt = self.mapToGlobal(QtCore.QPoint(x, y))
QtGui.QToolTip.showText(pt, message)
def onpick_info(self, event): def onpick_info(self, event):
if not event.mouseevent.button == 1: if not event.mouseevent.button == 1:
return return