# HG changeset patch # User Laurent Bessard # Date 1341762518 -7200 # Node ID 8c098eb05498686ddd7f127a09eaf7e73d6db20d # Parent f3dffc1a5ffe4752c72770eb6a0810829df4d4e9 Fix bug with graphic viewer and zoom diff -r f3dffc1a5ffe -r 8c098eb05498 GraphicViewer.py --- a/GraphicViewer.py Sat Jul 07 20:50:24 2012 +0200 +++ b/GraphicViewer.py Sun Jul 08 17:48:38 2012 +0200 @@ -245,7 +245,7 @@ self.CanvasRange.SetStringSelection(TIME_RANGE_VALUES[0][0]) self.CurrentRange = TIME_RANGE_VALUES[0][1] / self.Ticktime - def RefreshView(self, force=True): + def RefreshView(self, force=False): self.Freeze() if force or not self.Fixed or (len(self.Datas) > 0 and self.StartTick + self.CurrentRange > self.Datas[-1][0]): if (self.MinValue is not None and @@ -255,7 +255,7 @@ else: Yrange = 2. / self.CurrentZoom - if not self.Fixed and len(self.Datas) > 0: + if not force and not self.Fixed and len(self.Datas) > 0: self.YCenter = max(self.Datas[-1][1] - Yrange / 2, min(self.YCenter, self.Datas[-1][1] + Yrange / 2)) @@ -268,7 +268,7 @@ self.GraphicsObject = plot.PlotGraphics([self.VariableGraphic], _("%s Graphics") % var_name, _("Tick"), _("Values")) self.Canvas.Draw(self.GraphicsObject, xAxis=(self.StartTick, self.StartTick + self.CurrentRange), - yAxis=(self.YCenter - Yrange * 1.1 / 2, self.YCenter + Yrange * 1.1 / 2)) + yAxis=(self.YCenter - Yrange * 1.1 / 2., self.YCenter + Yrange * 1.1 / 2.)) # Reset and draw cursor self.ResetLastCursor() @@ -321,7 +321,7 @@ self.StartTick = min(self.StartTick, self.Datas[-1][0] - self.CurrentRange) else: self.StartTick = max(self.Datas[0][0], self.Datas[-1][0] - self.CurrentRange) - self.NewDataAvailable(True) + self.RefreshView(True) def OnRangeChanged(self, event): try: @@ -336,7 +336,7 @@ def OnZoomChanged(self, event): self.CurrentZoom = ZOOM_VALUES[self.CanvasZoom.GetSelection()][1] - wx.CallAfter(self.NewDataAvailable, True) + wx.CallAfter(self.RefreshView, True) event.Skip() def OnPositionChanging(self, event): @@ -422,11 +422,11 @@ wx.CallAfter(self.RefreshRange) else: current = self.CanvasZoom.GetSelection() - new = max(0, min(current - rotation, len(ZOOM_VALUES) - 1)) + new = max(0, min(current + rotation, len(ZOOM_VALUES) - 1)) if new != current: self.CurrentZoom = ZOOM_VALUES[new][1] self.CanvasZoom.SetStringSelection(ZOOM_VALUES[new][0]) - wx.CallAfter(self.NewDataAvailable, True) + wx.CallAfter(self.RefreshView, True) event.Skip() def OnCanvasResize(self, event):