Skip to content
Snippets Groups Projects
Commit 12f57691 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

TimeSeriesPanel changes imagelist volume on mouse clicks/drags

parent c00cf46b
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@ import wx
import props
import numpy as np
import matplotlib as mpl
mpl.use('WXAgg')
......@@ -31,9 +32,19 @@ class TimeSeriesPanel(wx.Panel, props.HasProperties):
self._name = '{}_{}'.format(self.__class__.__name__, id(self))
self._figure = plt.Figure()
self._axis = self._figure.add_subplot(1, 1, 1)
self._axis = self._figure.add_subplot(111)
self._canvas = Canvas(self, -1, self._figure)
self._figure.subplots_adjust(
top=1.0, bottom=0.0, left=0.0, right=1.0)
self._figure.patch.set_visible(False)
self._mouseDown = False
self._canvas.mpl_connect('button_press_event', self._onPlotMouseDown)
self._canvas.mpl_connect('button_release_event', self._onPlotMouseUp)
self._canvas.mpl_connect('motion_notify_event', self._onPlotMouseMove)
self._sizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(self._sizer)
self._sizer.Add(self._canvas, flag=wx.EXPAND, proportion=1)
......@@ -105,10 +116,11 @@ class TimeSeriesPanel(wx.Panel, props.HasProperties):
if vox >= shape or vox < 0:
inBounds = False
if inBounds:
data = image.data[x, y, z, :]
self._axis.plot(data, 'r-', lw=2)
else:
if t < image.shape[3]:
self._axis.axvline(t, lw=2, c='#000080', alpha=0.6)
if not inBounds:
self._axis.text(
0.5,
0.5,
......@@ -117,7 +129,42 @@ class TimeSeriesPanel(wx.Panel, props.HasProperties):
ha='center',
transform=self._axis.transAxes)
if t < image.shape[3]:
self._axis.axvline(t, lw=2, c='#000080')
data = image.data[x, y, z, :]
self._axis.plot(data, 'r-', lw=2)
xmin = 0
xmax = image.shape[3]
ymin = data.min()
ymax = data.max()
xlen = xmax - xmin
ylen = ymax - ymin
self._axis.grid(True)
self._axis.set_xlim((xmin - xlen * 0.05, xmax + xlen * 0.05))
self._axis.set_ylim((ymin - ylen * 0.05, ymax + ylen * 0.05))
yticks = np.linspace(ymin, ymax, 5)
self._axis.set_yticks(yticks)
for tick in self._axis.yaxis.get_major_ticks():
tick.set_pad(-15)
tick.label1.set_horizontalalignment('left')
for tick in self._axis.xaxis.get_major_ticks():
tick.set_pad(-20)
self._canvas.draw()
self.Refresh()
def _onPlotMouseDown(self, ev):
self._mouseDown = True
def _onPlotMouseUp(self, ev):
self._mouseDown = False
def _onPlotMouseMove(self, ev):
if not self._mouseDown: return
if ev.inaxes != self._axis: return
self._imageList.volume = np.floor(ev.xdata)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment