# HG changeset patch # User laurent # Date 1347379820 -7200 # Node ID 0623820aa14ae5a5f4381315248a2aadd0d4d763 # Parent be669f4c51c474ee51c9d2caed5108fbd8ecfc18 Fix bug in Viewer when dragging element group with control down and group contains wires connected to blocks not in group diff -r be669f4c51c4 -r 0623820aa14a graphics/GraphicCommons.py --- a/graphics/GraphicCommons.py Tue Sep 11 17:22:11 2012 +0200 +++ b/graphics/GraphicCommons.py Tue Sep 11 18:10:20 2012 +0200 @@ -1345,7 +1345,20 @@ pass # Returns the position of this group - def GetPosition(self): + def GetPosition(self, exclude_wires=False): + if exclude_wires: + posx = posy = None + for element in self.Elements: + if not isinstance(element, Wire) or element in self.WireExcluded: + bbox = element.GetBoundingBox() + if posx is None and posy is None: + posx, posy = bbox.x, bbox.y + else: + posx = min(posx, bbox.x) + posy = min(posy, bbox.y) + if posx is None and posy is None: + return 0, 0 + return posx, posy return self.BoundingBox.x, self.BoundingBox.y # Forbids to change the group size @@ -1378,12 +1391,13 @@ if event.ControlDown(): self.CurrentDrag.x = self.CurrentDrag.x + movex self.CurrentDrag.y = self.CurrentDrag.y + movey + posx, posy = self.GetPosition(True) if abs(self.CurrentDrag.x) > abs(self.CurrentDrag.y): - movex = self.StartPos.x + self.CurrentDrag.x - self.Pos.x - movey = self.StartPos.y - self.Pos.y + movex = self.StartPos.x + self.CurrentDrag.x - posx + movey = self.StartPos.y - posy else: - movex = self.StartPos.x - self.Pos.x - movey = self.StartPos.y + self.CurrentDrag.y - self.Pos.y + movex = self.StartPos.x - posx + movey = self.StartPos.y + self.CurrentDrag.y - posy self.Move(movex, movey) return movex, movey return 0, 0 @@ -1401,6 +1415,7 @@ # Method called when a LeftDown event have been generated def OnLeftDown(self, event, dc, scaling): Graphic_Element.OnLeftDown(self, event, dc, scaling) + self.StartPos = wx.Point(*self.GetPosition(True)) for element in self.Elements: element.Handle = self.Handle