--- 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 @@
# Returns the position of this group
+ def GetPosition(self, exclude_wires=False): + 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 + posx = min(posx, bbox.x) + posy = min(posy, bbox.y) + if posx is None and posy is None: return self.BoundingBox.x, self.BoundingBox.y
# Forbids to change the group size
@@ -1378,12 +1391,13 @@
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 - 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 @@ -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