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

Time series limits are now a Bounds property, instead of four separate

float properties. Improved zoom mode
parent c129e70b
No related branches found
No related tags found
No related merge requests found
...@@ -34,10 +34,11 @@ class TimeSeriesControlPanel(fslpanel.FSLViewPanel): ...@@ -34,10 +34,11 @@ class TimeSeriesControlPanel(fslpanel.FSLViewPanel):
self.__xlabel = props.makeWidget(self, tsPanel, 'xlabel') self.__xlabel = props.makeWidget(self, tsPanel, 'xlabel')
self.__ylabel = props.makeWidget(self, tsPanel, 'ylabel') self.__ylabel = props.makeWidget(self, tsPanel, 'ylabel')
self.__xmin = props.makeWidget(self, tsPanel, 'xmin') limits = props.makeListWidgets(self, tsPanel, 'limits')
self.__xmax = props.makeWidget(self, tsPanel, 'xmax') self.__xmin = limits[0]
self.__ymin = props.makeWidget(self, tsPanel, 'ymin') self.__xmax = limits[1]
self.__ymax = props.makeWidget(self, tsPanel, 'ymax') self.__ymin = limits[2]
self.__ymax = limits[3]
self.__lblLabel = wx.StaticText(self) self.__lblLabel = wx.StaticText(self)
self.__xlblLabel = wx.StaticText(self) self.__xlblLabel = wx.StaticText(self)
......
...@@ -70,10 +70,7 @@ class TimeSeriesPanel(plotpanel.PlotPanel): ...@@ -70,10 +70,7 @@ class TimeSeriesPanel(plotpanel.PlotPanel):
smooth = props.Boolean(default=False) smooth = props.Boolean(default=False)
xlabel = props.String() xlabel = props.String()
ylabel = props.String() ylabel = props.String()
xmin = props.Real() limits = props.Bounds(ndims=2)
xmax = props.Real()
ymin = props.Real()
ymax = props.Real()
def export(self, *a): def export(self, *a):
...@@ -194,30 +191,24 @@ class TimeSeriesPanel(plotpanel.PlotPanel): ...@@ -194,30 +191,24 @@ class TimeSeriesPanel(plotpanel.PlotPanel):
def __calcLimits(self, xlims, ylims): def __calcLimits(self, xlims, ylims):
if (self.autoScale and self.__mouseDown is None) or \ xmin = min([lim[0] for lim in xlims])
(self.xmin == self.xmax) or \ xmax = max([lim[1] for lim in xlims])
(self.ymin == self.ymax): ymin = min([lim[0] for lim in ylims])
xmin = min([lim[0] for lim in xlims]) ymax = max([lim[1] for lim in ylims])
xmax = max([lim[1] for lim in xlims])
ymin = min([lim[0] for lim in ylims])
ymax = max([lim[1] for lim in ylims])
else:
xmin = self.xmin
xmax = self.xmax
ymin = self.ymin
ymax = self.ymax
for prop in ['xmin', 'xmax', 'ymin', 'ymax']:
self.disableListener(prop, self._name)
self.xmin = xmin
self.xmax = xmax
self.ymin = ymin
self.ymax = ymax
for prop in ['xmin', 'xmax', 'ymin', 'ymax']:
self.enableListener(prop, self._name)
return (xmin, xmax), (ymin, ymax) if (self.autoScale and self.__mouseDown is None):
self.disableListener('limits', self._name)
self.limits[:] = [xmin, xmax, ymin, ymax]
self.enableListener('limits', self._name)
else:
xmin = self.limits.xlo
xmax = self.limits.xhi
ymin = self.limits.ylo
ymax = self.limits.yhi
return (xmin, xmax), (ymin, ymax)
def _draw(self, *a): def _draw(self, *a):
...@@ -380,8 +371,7 @@ class TimeSeriesPanel(plotpanel.PlotPanel): ...@@ -380,8 +371,7 @@ class TimeSeriesPanel(plotpanel.PlotPanel):
else: self.__zoomMode = False else: self.__zoomMode = False
self.__mouseDown = ev.xdata, ev.ydata self.__mouseDown = ev.xdata, ev.ydata
self.__mouseDownLimits = ((self.xmin, self.xmax), self.__mouseDownLimits = (self.limits.x, self.limits.y)
(self.ymin, self.ymax))
def __onMouseUp(self, ev): def __onMouseUp(self, ev):
...@@ -398,16 +388,9 @@ class TimeSeriesPanel(plotpanel.PlotPanel): ...@@ -398,16 +388,9 @@ class TimeSeriesPanel(plotpanel.PlotPanel):
if self.__zoomMode: newxlim, newylim = self.__zoomLimits(ev) if self.__zoomMode: newxlim, newylim = self.__zoomLimits(ev)
else: newxlim, newylim = self.__panLimits( ev) else: newxlim, newylim = self.__panLimits( ev)
for prop in ['xmin', 'xmax', 'ymin', 'ymax']: self.disableListener('limits', self._name)
self.disableListener(prop, self._name) self.limits[:] = newxlim + newylim
self.enableListener('limits', self._name)
self.xmin = newxlim[0]
self.xmax = newxlim[1]
self.ymin = newylim[0]
self.ymax = newylim[1]
for prop in ['xmin', 'xmax', 'ymin', 'ymax']:
self.enableListener(prop, self._name)
self._draw() self._draw()
...@@ -422,14 +405,23 @@ class TimeSeriesPanel(plotpanel.PlotPanel): ...@@ -422,14 +405,23 @@ class TimeSeriesPanel(plotpanel.PlotPanel):
xmid = xlim[0] + 0.5 * xlen xmid = xlim[0] + 0.5 * xlen
ymid = ylim[0] + 0.5 * ylen ymid = ylim[0] + 0.5 * ylen
xdist = 2 * (ev.xdata - self.__mouseDown[0]) mdx, mdy = self.__mouseDown
ydist = 2 * (ev.ydata - self.__mouseDown[1]) evx, evy = ev.xdata, ev.ydata
mdx = (mdx - xlim[0]) / xlen
mdy = (mdy - ylim[0]) / ylen
evx = (evx - self.limits.xlo) / self.limits.xlen
evy = (evy - self.limits.ylo) / self.limits.ylen
xdist = 2 * xlen * (evx - mdx)
ydist = 2 * ylen * (evy - mdy)
newxlen = xlen * xlen / (xlen + xdist) newxlen = abs(xlen - xdist)
newylen = ylen * ylen / (ylen + ydist) newylen = abs(ylen - ydist)
newxlim = (xmid - newxlen * 0.5, xmid + newxlen * 0.5) newxlim = [xmid - newxlen * 0.5, xmid + newxlen * 0.5]
newylim = (ymid - newylen * 0.5, ymid + newylen * 0.5) newylim = [ymid - newylen * 0.5, ymid + newylen * 0.5]
return newxlim, newylim return newxlim, newylim
...@@ -439,5 +431,5 @@ class TimeSeriesPanel(plotpanel.PlotPanel): ...@@ -439,5 +431,5 @@ class TimeSeriesPanel(plotpanel.PlotPanel):
xdist = self.__mouseDown[0] - mouseEv.xdata xdist = self.__mouseDown[0] - mouseEv.xdata
ydist = self.__mouseDown[1] - mouseEv.ydata ydist = self.__mouseDown[1] - mouseEv.ydata
return ((self.xmin + xdist, self.xmax + xdist), return ((self.limits.xlo + xdist, self.limits.xhi + xdist),
(self.ymin + ydist, self.ymax + ydist)) (self.limits.ylo + ydist, self.limits.yhi + ydist))
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