# initialize them by placing them half way between the first
# and the last.
- for point in self._lineControlPoints[1:]:
+ for i in range(1,len(self._lineControlPoints)):
+ point = self._lineControlPoints[i]
if point[0] == -999:
if first_point[0] < last_point[0]:
x1 = first_point[0]
else:
y2 = first_point[1]
y1 = last_point[1]
- point[0] = (x2 - x1) / 2.0 + x1
- point[1] = (y2 - y1) / 2.0 + y1
+ self._lineControlPoints[i] = wx.RealPoint((x2 - x1) / 2.0 + x1, (y2 - y1) / 2.0 + y1)
def FormatText(self, dc, s, i):
"""Format a text string according to the region size, adding
def SetEnds(self, x1, y1, x2, y2):
"""Set the end positions of the line."""
- # Find centre point
- first_point = self._lineControlPoints[0]
- last_point = self._lineControlPoints[-1]
-
- first_point[0] = x1
- first_point[1] = y1
- last_point[0] = x2
- last_point[1] = y2
+ self._lineControlPoints[0] = wx.RealPoint(x1, y1)
+ self._lineControlPoints[-1] = wx.RealPoint(x2, y2)
+ # Find centre point
self._xpos = (x1 + x2) / 2.0
self._ypos = (y1 + y2) / 2.0
# manually if necessary
end_x, end_y, other_end_x, other_end_y = self.FindLineEndPoints()
- first = self._lineControlPoints[0]
- last = self._lineControlPoints[-1]
-
oldX, oldY = self._xpos, self._ypos
self.SetEnds(end_x, end_y, other_end_x, other_end_y)
# if attachment mode is ON
if self._from == self._to and self._from.GetAttachmentMode() != ATTACHMENT_MODE_NONE and moveControlPoints and self._lineControlPoints and not (x_offset == 0 and y_offset == 0):
for point in self._lineControlPoints[1:-1]:
- point.x += x_offset
- point.y += y_offset
+ point[0] += x_offset
+ point[1] += y_offset
self.Move(dc, self._xpos, self._ypos)
if self._to.GetAttachmentMode() == ATTACHMENT_MODE_NONE:
other_end_x, other_end_y = self._to.GetPerimeterPoint(self._to.GetX(), self._to.GetY(), fromX, fromY)
- #print type(self._from), type(self._to), end_x, end_y, other_end_x, other_end_y
- return end_x, end_y, other_end_x, other_end_y
+ return end_x, end_y, other_end_x, other_end_y
+
def OnDraw(self, dc):
if not self._lineControlPoints:
points = []
for point in self._lineControlPoints:
- points.append(wx.Point(point.x, point.y))
+ points.append(wx.Point(point[0], point[1]))
#print points
if self._isSpline:
if sys.platform[:3] == "win":
# For some reason, last point isn't drawn under Windows
pt = points[-1]
- dc.DrawPoint(pt.x, pt.y)
+ dc.DrawPoint(pt[0], pt[1])
# Problem with pen - if not a solid pen, does strange things
# to the arrowhead. So make (get) a new pen that's solid.
control = LineControlPoint(self._canvas, self, CONTROL_POINT_SIZE, first[0], first[1], CONTROL_POINT_ENDPOINT_FROM)
control._point = first
self._canvas.AddShape(control)
- self._controlPoints.Append(control)
+ self._controlPoints.append(control)
for point in self._lineControlPoints[1:-1]:
control = LineControlPoint(self._canvas, self, CONTROL_POINT_SIZE, point[0], point[1], CONTROL_POINT_LINE)
control._point = point
self._canvas.AddShape(control)
- self._controlPoints.Append(control)
+ self._controlPoints.append(control)
control = LineControlPoint(self._canvas, self, CONTROL_POINT_SIZE, last[0], last[1], CONTROL_POINT_ENDPOINT_TO)
control._point = last
self._canvas.AddShape(control)
- self._controlPoints.Append(control)
+ self._controlPoints.append(control)
def ResetControlPoints(self):
if self._canvas and self._lineControlPoints:
dc.SetBrush(wx.TRANSPARENT_BRUSH)
if pt._type == CONTROL_POINT_LINE:
- x, y = self._canvas.Snap()
+ x, y = self._canvas.Snap(x, y)
pt.SetX(x)
pt.SetY(y)
- pt._point[0] = x
- pt._point[1] = y
+ pt._point = x, y
old_pen = self.GetPen()
old_brush = self.GetBrush()
if pt._type == CONTROL_POINT_LINE:
pt._originalPos = pt._point
- x, y = self._canvas.Snap()
+ x, y = self._canvas.Snap(x, y)
self.Erase(dc)
pt._xpos = x
pt._ypos = y
- pt._point[0] = x
- pt._point[1] = y
+ pt._point = x, y
old_pen = self.GetPen()
old_brush = self.GetBrush()
self.SetBrush(old_brush)
if pt._type == CONTROL_POINT_ENDPOINT_FROM or pt._type == CONTROL_POINT_ENDPOINT_TO:
- self._canvas.SetCursor(wx.Cursor(wx.CURSOR_BULLSEYE))
+ self._canvas.SetCursor(wx.StockCursor(wx.CURSOR_BULLSEYE))
pt._oldCursor = wx.STANDARD_CURSOR
def OnSizingEndDragLeft(self, pt, x, y, keys = 0, attachment = 0):
self.SetDisableLabel(False)
if pt._type == CONTROL_POINT_LINE:
- x, y = self._canvas.Snap()
+ x, y = self._canvas.Snap(x, y)
rpt = wx.RealPoint(x, y)
# as it changed shape.
pt._xpos = pt._originalPos[0]
pt._ypos = pt._originalPos[1]
- pt._point[0] = pt._originalPos[0]
- pt._point[1] = pt._originalPos[1]
+ pt._point = pt._originalPos[0], pt._originalPos[1]
self.OnMoveMiddleControlPoint(dc, pt, rpt)
lpt._xpos = pt[0]
lpt._ypos = pt[1]
- lpt._point[0] = pt[0]
- lpt._point[1] = pt[1]
+ lpt._point = pt[0], pt[1]
self.GetEventHandler().OnMoveLink(dc)