Commit ee764fe4 authored by Yan's avatar Yan
Browse files

Improved mass_selector, fixed time_selector

* mass selector intensity routine is showing relevant rectangle
* putted accidentally-removed time_selector back
parent 1635b4ff
......@@ -251,6 +251,10 @@ def main():
gt.zoom_factory(spectrum, 1.15, ms)
gt.textedit_factory(spectrum, ms)
mass_selector = gt.AugSpanSelector(spectrum, ms)
time_selector = SpanSelector(chromatogram, lambda x_min, x_max:
gt.pick_times( x_min, x_max, spectrum, ds, chromatogram, ms, chrom,
paramstable), 'horizontal', useblit=True, rectprops=dict(
alpha=0.15, facecolor='purple'), button=3)
main_window = QtWidgets.QMainWindow(windowTitle="Prasopes")
if QtGui.QIcon.themeName() is "":
......
......@@ -14,8 +14,10 @@ colors = np.array([[0, 0, 0], [255, 0, 0], [0, 255, 0], [0, 0, 255],
[200, 50, 0], [255, 0, 200], [0, 100, 0],
[0, 100, 255], [100, 100, 100]])
ann_bbox = dict(boxstyle="round", fc="w", ec="0.5", alpha=0.5)
class AugSpanSelector(SpanSelector):
def __init__(self, ax, data):
SpanSelector.__init__(self, ax, onselect=lambda x,y: None,
......@@ -23,6 +25,7 @@ class AugSpanSelector(SpanSelector):
rectprops=dict(alpha=0.15, facecolor='purple'),
onmove_callback=None, span_stays=False, button=3)
self.data = data
def _press(self, event):
"""on button press event override"""
if QtWidgets.QApplication.keyboardModifiers() ==\
......@@ -35,6 +38,34 @@ class AugSpanSelector(SpanSelector):
self.new_axes(self.ax)
SpanSelector._press(self, event)
def _release(self, event):
"""on button release event"""
if self.pressv is None:
return
elif self.direction == 'horizontal':
SpanSelector._release(self, event)
else:
self.rect.set_visible(False)
self.canvas.draw_idle()
vmax = self._get_data(event)[1] or self.prev[1]
span = vmax - self.ax.get_ylim()[0]
if self.minspan is not None and span < self.minspan:
return
self.onselect(self.ax.get_ylim()[0], vmax)
self.pressv = None
return False
def _set_span_xy(self, event):
"""Setting the span coordinates override"""
if self.direction == 'horizontal':
SpanSelector._set_span_xy(self, event)
else:
x,y = self._get_data(event)
if y is None:
return
self.prev = x, y
self.rect.set_y(self.ax.get_ylim()[0])
self.rect.set_height(y)
def pick_masses(self, vmin, vmax):
"""zoom the spectrum in x axis by mass range"""
......@@ -42,7 +73,6 @@ class AugSpanSelector(SpanSelector):
autozoomy(self.ax)
ann_spec(self.ax, self.data)
def pick_intensities(self, vmin, vmax):
"""zoom the spectrum in y axis by top intensity from range"""
self.ax.set_ylim(-vmax*0.01, vmax)
......@@ -201,7 +231,9 @@ def plot_subtime(mpl_spectrum, mpl_chromatogram, ds, ms_data, chrom_data):
mpl_spectrum.set_ylim(slims[1])
if not ms_data['headers'] == []:
mpl_spectrum.legend(loc=2)
mpl_spectrum.get_legend().set_in_layout(False)
mpl_chromatogram.legend(loc=2)
mpl_chromatogram.get_legend().set_in_layout(False)
else:
autozoomy(mpl_spectrum)
ann_spec(mpl_spectrum, ms_data)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment