Move position of debug value to avoid wire to cross text
authorlaurent
Tue, 19 Apr 2011 14:53:08 +0200 (2011-04-19)
changeset 529 cbfbd0f7135b
parent 528 7ac133b11321
child 530 0fa72713501d
Move position of debug value to avoid wire to cross text
graphics/GraphicCommons.py
--- a/graphics/GraphicCommons.py	Sat Apr 16 10:42:43 2011 +0200
+++ b/graphics/GraphicCommons.py	Tue Apr 19 14:53:08 2011 +0200
@@ -1703,15 +1703,18 @@
             width, height = self.ValueSize
             if self.BoundingBox[2] > width * 4 or self.BoundingBox[3] > height * 4:
                 x = self.Points[0].x + width * self.StartPoint[1][0] / 2
-                y = self.Points[0].y + (height * self.StartPoint[1][1] - 1) / 2
+                y = self.Points[0].y + (height * self.StartPoint[1][1] - 1)
                 rect = rect.Union(wx.Rect(x, y, width, height))
                 x = self.Points[-1].x + width * self.EndPoint[1][0] / 2
-                y = self.Points[-1].y + (height * self.EndPoint[1][1] - 1) / 2
+                y = self.Points[-1].y + (height * self.EndPoint[1][1] - 1)
                 rect = rect.Union(wx.Rect(x, y, width, height))
             else:
                 middle = len(self.Segments) / 2 + len(self.Segments) % 2 - 1
-                x = self.Points[middle].x - width / 2
-                y = self.Points[middle].y - height / 2
+                x = (self.Points[middle].x + self.Points[middle + 1].x - width) / 2
+                if self.BoundingBox[3] > height and self.Segments[middle] in [NORTH, SOUTH]:
+                    y = (self.Points[middle].y + self.Points[middle + 1].y - height) / 2
+                else:
+                    y = self.Points[middle].y - height
                 rect = rect.Union(wx.Rect(x, y, width, height))
         return rect
     
@@ -2743,15 +2746,18 @@
                 width, height = self.ValueSize
                 if self.BoundingBox[2] > width * 4 or self.BoundingBox[3] > height * 4:
                     x = self.Points[0].x + width * (self.StartPoint[1][0] - 1) / 2
-                    y = self.Points[0].y + height * (self.StartPoint[1][1] - 1) / 2
+                    y = self.Points[0].y + height * (self.StartPoint[1][1] - 1)
                     dc.DrawText(self.ComputedValue, x, y)
                     x = self.Points[-1].x + width * (self.EndPoint[1][0] - 1) / 2
-                    y = self.Points[-1].y + height * (self.EndPoint[1][1] - 1) / 2
+                    y = self.Points[-1].y + height * (self.EndPoint[1][1] - 1)
                     dc.DrawText(self.ComputedValue, x, y)
                 else:
                     middle = len(self.Segments) / 2 + len(self.Segments) % 2 - 1
                     x = (self.Points[middle].x + self.Points[middle + 1].x - width) / 2
-                    y = (self.Points[middle].y + self.Points[middle + 1].y - height) / 2
+                    if self.BoundingBox[3] > height and self.Segments[middle] in [NORTH, SOUTH]:
+                        y = (self.Points[middle].y + self.Points[middle + 1].y - height) / 2
+                    else:
+                        y = self.Points[middle].y - height
                     dc.DrawText(self.ComputedValue, x, y)
             dc.SetFont(self.Parent.GetFont())
             dc.SetTextForeground(wx.BLACK)