Fixed various latency issues removing unnecessary calls
authorLaurent Bessard
Thu, 03 Oct 2013 18:59:18 +0200
changeset 1342 c17507a10807
parent 1341 0923e602c603
child 1343 a76a020b8822
Fixed various latency issues removing unnecessary calls
controls/CustomTable.py
controls/VariablePanel.py
editors/Viewer.py
--- a/controls/CustomTable.py	Wed Oct 02 19:58:32 2013 +0200
+++ b/controls/CustomTable.py	Thu Oct 03 18:59:18 2013 +0200
@@ -18,6 +18,11 @@
 import wx
 import wx.grid
 
+if wx.Platform == '__WXMSW__':
+    ROW_HEIGHT = 20
+else:
+    ROW_HEIGHT = 28
+
 class CustomTable(wx.grid.PyGridTableBase):
     
     """
@@ -124,11 +129,9 @@
             self.ResizeRow(grid, row)
     
     def ResizeRow(self, grid, row):
-        if wx.Platform == '__WXMSW__':
-            grid.SetRowMinimalHeight(row, 20)
-        else:
-            grid.SetRowMinimalHeight(row, 28)
-        grid.AutoSizeRow(row, False)
+        if grid.GetRowSize(row) < ROW_HEIGHT:
+            grid.SetRowMinimalHeight(row, ROW_HEIGHT)
+            grid.AutoSizeRow(row, False)
     
     def SetData(self, data):
         self.data = data
--- a/controls/VariablePanel.py	Wed Oct 02 19:58:32 2013 +0200
+++ b/controls/VariablePanel.py	Thu Oct 03 18:59:18 2013 +0200
@@ -457,7 +457,7 @@
              "Documentation" : "", 
              "Edit" : True
         }
-
+        
         if element_type in ["config", "resource"]:
             self.DefaultTypes = {"All" : "Global"}
         else:
@@ -503,7 +503,10 @@
             #                      Num  Name    Class   Type    Init    Option   Doc
             self.ColSizes       = [40,  80,     70,     80,     80,     100,     160]
             self.ColAlignements = [c,   l,      l,      l,      l,      l,       l]
-
+            
+        self.ElementType = element_type
+        self.BodyType = None
+        
         for choice in self.FilterChoices:
             self.ClassFilter.Append(_(choice))
 
@@ -608,14 +611,13 @@
     
     def SetTagName(self, tagname):
         self.TagName = tagname
+        self.BodyType = self.Controler.GetEditedElementBodyType(self.TagName)
     
     def GetTagName(self):
         return self.TagName
     
     def IsFunctionBlockType(self, name):
-        bodytype = self.Controler.GetEditedElementBodyType(self.TagName)
-        pouname, poutype = self.Controler.GetEditedElementType(self.TagName)
-        if poutype != "function" and bodytype in ["ST", "IL"]:
+        if self.ElementType != "function" and self.BodyType in ["ST", "IL"]:
             return False
         else:
             return self.Controler.GetBlockType(name, debug=self.Debug) is not None
--- a/editors/Viewer.py	Wed Oct 02 19:58:32 2013 +0200
+++ b/editors/Viewer.py	Thu Oct 03 18:59:18 2013 +0200
@@ -570,6 +570,7 @@
         self.Editor.SetBackgroundColour(wx.Colour(255,255,255))
         self.Editor.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
         self.ResetView()
+        self.LastClientSize = None
         self.Scaling = None
         self.DrawGrid = True
         self.GridBrush = wx.TRANSPARENT_BRUSH
@@ -1343,10 +1344,10 @@
                          start_connector.GetDirection()],
                         [wx.Point(*end_connector.GetPosition()),
                          end_connector.GetDirection()])
-                start_connector.Connect((wire, 0), False)
-                end_connector.Connect((wire, -1), False)
-                wire.ConnectStartPoint(None, start_connector)
-                wire.ConnectEndPoint(None, end_connector)
+                start_connector.Wires.append((wire, 0))
+                end_connector.Wires.append((wire, -1))
+                wire.StartConnected = start_connector
+                wire.EndConnected = end_connector
                 connected.RefreshConnectors()
                 self.AddWire(wire)
                 if selection is not None and (\
@@ -2223,7 +2224,6 @@
                     movex, movey = self.SelectedElement.OnMotion(event, dc, self.Scaling)
                     if movex != 0 or movey != 0:
                         self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(movex, movey)), False)
-                    self.RefreshVisibleElements()
             elif self.Debug and self.StartMousePos is not None and event.Dragging():
                 pos = event.GetPosition()
                 if abs(self.StartMousePos.x - pos.x) > 5 or abs(self.StartMousePos.y - pos.y) > 5:
@@ -3468,8 +3468,11 @@
                 self.Scroll(x, yp)
             
     def OnMoveWindow(self, event):
-        self.RefreshScrollBars()
-        self.RefreshVisibleElements()
+        client_size = self.GetClientSize()
+        if self.LastClientSize != client_size:
+            self.LastClientSize = client_size
+            self.RefreshScrollBars()
+            self.RefreshVisibleElements()
         event.Skip()
 
     def DoDrawing(self, dc, printing = False):