Fix bug in GraphicViewer when changing range while no data received
authorlaurent
Fri, 17 Feb 2012 00:13:19 +0100
changeset 648 95d165193770
parent 647 2d53c653d8d2
child 649 ea237e1431ec
Fix bug in GraphicViewer when changing range while no data received
GraphicViewer.py
PLCOpenEditor.py
--- a/GraphicViewer.py	Thu Feb 16 22:55:50 2012 +0100
+++ b/GraphicViewer.py	Fri Feb 17 00:13:19 2012 +0100
@@ -263,14 +263,15 @@
                 self.CurrentRange = self.RangeValues_dict[self.CanvasRange.GetValue()] / self.Ticktime
         except ValueError, e:
             self.CanvasRange.SetValue(str(self.CurrentRange))
-        if self.Fixed and self.Datas[-1][0] - self.Datas[0][0] < self.CurrentRange:
-            self.Fixed = False
-        if self.Fixed:
-            self.StartValue = min(self.StartValue, self.GetNearestData(self.Datas[-1][0] - self.CurrentRange, -1))
-            self.EndValue = self.GetNearestData(self.StartValue + self.CurrentRange, 1)
-        else:
-            self.StartValue = self.GetNearestData(self.Datas[-1][0] - self.CurrentRange - 1, -1)
-            self.EndValue = len(self.Datas) - 1
+        if len(self.Datas) > 0:
+            if self.Fixed and self.Datas[-1][0] - self.Datas[0][0] < self.CurrentRange:
+                self.Fixed = False
+            if self.Fixed:
+                self.StartValue = min(self.StartValue, self.GetNearestData(self.Datas[-1][0] - self.CurrentRange, -1))
+                self.EndValue = self.GetNearestData(self.StartValue + self.CurrentRange, 1)
+            else:
+                self.StartValue = self.GetNearestData(self.Datas[-1][0] - self.CurrentRange - 1, -1)
+                self.EndValue = len(self.Datas) - 1
         self.NewDataAvailable(True)
         event.Skip()
     
--- a/PLCOpenEditor.py	Thu Feb 16 22:55:50 2012 +0100
+++ b/PLCOpenEditor.py	Fri Feb 17 00:13:19 2012 +0100
@@ -1866,6 +1866,7 @@
     def OpenGraphicViewer(self, var_path):
         new_window = GraphicViewer(self.TabsOpened, self, self.Controler, var_path)
         self.AddPage(new_window, "")
+        new_window.RefreshView()
         new_window.SetFocus()
         self.RefreshPageTitles()