--- a/graphics/GraphicCommons.py Fri Mar 13 16:27:26 2009 +0100
+++ b/graphics/GraphicCommons.py Tue Mar 17 15:58:50 2009 +0100
@@ -2031,16 +2031,34 @@
handle_type, handle = self.Handle
if handle_type == HANDLE_SEGMENT:
segment, dir = handle
- pointx = self.Points[segment].x
- pointy = self.Points[segment].y
- if dir[0] != 0:
- pointx = (self.Points[segment].x + self.Points[segment + 1].x) / 2
- if dir[1] != 0:
- pointy = (self.Points[segment].y + self.Points[segment + 1].y) / 2
- self.Points.insert(segment + 1, wx.Point(pointx, pointy))
- self.Segments.insert(segment + 1, (dir[1], dir[0]))
- self.Points.insert(segment + 2, wx.Point(pointx, pointy))
- self.Segments.insert(segment + 2, dir)
+ if len(self.Segments) > 1:
+ pointx = self.Points[segment].x
+ pointy = self.Points[segment].y
+ if dir[0] != 0:
+ pointx = (self.Points[segment].x + self.Points[segment + 1].x) / 2
+ if dir[1] != 0:
+ pointy = (self.Points[segment].y + self.Points[segment + 1].y) / 2
+ self.Points.insert(segment + 1, wx.Point(pointx, pointy))
+ self.Segments.insert(segment + 1, (dir[1], dir[0]))
+ self.Points.insert(segment + 2, wx.Point(pointx, pointy))
+ self.Segments.insert(segment + 2, dir)
+ else:
+ p1x = p2x = self.Points[segment].x
+ p1y = p2y = self.Points[segment].y
+ if dir[0] != 0:
+ p1x = (2 * self.Points[segment].x + self.Points[segment + 1].x) / 3
+ p2x = (self.Points[segment].x + 2 * self.Points[segment + 1].x) / 3
+ if dir[1] != 0:
+ p1y = (2 * self.Points[segment].y + self.Points[segment + 1].y) / 3
+ p2y = (self.Points[segment].y + 2 * self.Points[segment + 1].y) / 3
+ self.Points.insert(segment + 1, wx.Point(p1x, p1y))
+ self.Segments.insert(segment + 1, (dir[1], dir[0]))
+ self.Points.insert(segment + 2, wx.Point(p1x, p1y))
+ self.Segments.insert(segment + 2, dir)
+ self.Points.insert(segment + 3, wx.Point(p2x, p2y))
+ self.Segments.insert(segment + 3, (dir[1], dir[0]))
+ self.Points.insert(segment + 4, wx.Point(p2x, p2y))
+ self.Segments.insert(segment + 4, dir)
self.GeneratePoints()
# Delete the handled segment by removing the two segment points
@@ -2083,8 +2101,9 @@
result = self.TestSegment(pos, True)
if result != None:
self.Handle = (HANDLE_SEGMENT, result)
+ print result, len(self.Segments)
# Popup the menu with special items for a wire
- self.Parent.PopupWireMenu(0 < result < len(self.Segments) - 1)
+ self.Parent.PopupWireMenu(0 < result[0] < len(self.Segments) - 1)
else:
# Execute the default method for a graphic element
Graphic_Element.OnRightUp(self, event, dc, scaling)