Fixed lag when selecting all elements using CTRL+A or after paste a lot of blocks
authorLaurent Bessard
Wed, 05 Jun 2013 23:29:37 +0200
changeset 1226 93e7a8abce5e
parent 1225 ed8a89171a6c
child 1227 01e86190f8c7
Fixed lag when selecting all elements using CTRL+A or after paste a lot of blocks
editors/Viewer.py
graphics/GraphicCommons.py
--- a/editors/Viewer.py	Wed Jun 05 23:23:29 2013 +0200
+++ b/editors/Viewer.py	Wed Jun 05 23:29:37 2013 +0200
@@ -1090,6 +1090,12 @@
             instance = self.Controler.GetEditedElementInstanceInfos(self.TagName, exclude = ids, debug = self.Debug)
             if instance is not None:
                 self.loadInstance(instance, ids, selection)
+        
+        if (selection is not None and 
+            isinstance(self.SelectedElement, GraphicGroup)):
+            self.SelectedElement.RefreshWireExclusion()
+            self.SelectedElement.RefreshBoundingBox()
+        
         self.RefreshScrollBars()
         
         for wire in self.Wires:
@@ -1201,11 +1207,11 @@
         if self.SelectedElement is None:
             self.SelectedElement = element
         elif isinstance(self.SelectedElement, Graphic_Group):
-            self.SelectedElement.SelectElement(element)
+            self.SelectedElement.AddElement(element)
         else:
             group = Graphic_Group(self)
-            group.SelectElement(self.SelectedElement)
-            group.SelectElement(element)
+            group.AddElement(self.SelectedElement)
+            group.AddElement(element)
             self.SelectedElement = group
         
     # Load instance from given informations
@@ -1405,8 +1411,7 @@
         if self.SelectedElement is not None:
             self.SelectedElement.SetSelected(False)
         self.SelectedElement = Graphic_Group(self)
-        for element in self.GetElements():
-            self.SelectedElement.SelectElement(element)
+        self.SelectedElement.SetElements(self.GetElements())
         self.SelectedElement.SetSelected(True)
     
 #-------------------------------------------------------------------------------
--- a/graphics/GraphicCommons.py	Wed Jun 05 23:23:29 2013 +0200
+++ b/graphics/GraphicCommons.py	Wed Jun 05 23:29:37 2013 +0200
@@ -853,9 +853,12 @@
                 if movex != 0 or movey != 0:
                     element.Move(movex, movey)
                     element.RefreshModel()
-        self.RefreshWireExclusion()
         self.RefreshBoundingBox()
     
+    # Add the given element to the group of elements
+    def AddElement(self, element):
+        self.Elements.append(element)
+        
     # Remove or select the given element if it is or not in the group
     def SelectElement(self, element):
         if element in self.Elements: