X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7276cbe3f07b66d8923cbadd71b684d08197acd0..c079af66c8fb4a2f68f33c6d3940b8ad8ec98f27:/wxPython/wx/lib/ogl/_lines.py diff --git a/wxPython/wx/lib/ogl/_lines.py b/wxPython/wx/lib/ogl/_lines.py index ea4b9ea959..77ce392cac 100644 --- a/wxPython/wx/lib/ogl/_lines.py +++ b/wxPython/wx/lib/ogl/_lines.py @@ -14,7 +14,7 @@ import sys import math -from _basic import Shape, ShapeRegion, ControlPoint, RectangleShape +from _basic import Shape, ShapeRegion, ShapeTextLine, ControlPoint, RectangleShape from _oglmisc import * # Line alignment flags @@ -131,7 +131,7 @@ class LabelShape(RectangleShape): RectangleShape.__init__(self, w, h) self._lineShape = parent self._shapeRegion = region - self.SetPen(wx.ThePenList.FindOrCreatePen(wx.Colour(0, 0, 0), 1, wx.DOT)) + self.SetPen(wx.Pen(wx.Colour(0, 0, 0), 1, wx.DOT)) def OnDraw(self, dc): if self._lineShape and not self._lineShape.GetDrawHandles(): @@ -218,16 +218,6 @@ class LineShape(Shape): self._lineControlPoints = [] self._arcArrows = [] - def __del__(self): - if self._lineControlPoints: - self._lineControlPoints = [] - for i in range(3): - if self._labelObjects[i]: - self._labelObjects[i].Select(False) - self._labelObjects[i].RemoveFromCanvas(self._canvas) - self._labelObjects = [] - self.ClearArrowsAtPosition(-1) - def GetFrom(self): """Return the 'from' object.""" return self._from @@ -298,19 +288,22 @@ class LineShape(Shape): # the middle points to something other than (-999, -999) self._initialised = False - def InsertLineControlPoint(self, dc = None): - """Insert a control point at an arbitrary position.""" + def InsertLineControlPoint(self, dc = None, point = None): + """Insert a control point at an optional given position.""" if dc: self.Erase(dc) - last_point = self._lineControlPoints[-1] - second_last_point = self._lineControlPoints[-2] + if point: + line_x, line_y = point + else: + last_point = self._lineControlPoints[-1] + second_last_point = self._lineControlPoints[-2] - line_x = (last_point[0] + second_last_point[0]) / 2.0 - line_y = (last_point[1] + second_last_point[1]) / 2.0 + line_x = (last_point[0] + second_last_point[0]) / 2.0 + line_y = (last_point[1] + second_last_point[1]) / 2.0 point = wx.RealPoint(line_x, line_y) - self._lineControlPoints.insert(len(self._lineControlPoints), point) + self._lineControlPoints.insert(len(self._lineControlPoints)-1, point) def DeleteLineControlPoint(self): """Delete an arbitary point on the line.""" @@ -347,7 +340,7 @@ class LineShape(Shape): y2 = first_point[1] y1 = last_point[1] self._lineControlPoints[i] = wx.RealPoint((x2 - x1) / 2.0 + x1, (y2 - y1) / 2.0 + y1) - self._initialised = True + self._initialised = True def FormatText(self, dc, s, i): """Format a text string according to the region size, adding @@ -489,6 +482,11 @@ class LineShape(Shape): self._from.GetLines().remove(self) self._to = None self._from = None + for i in range(3): + if self._labelObjects[i]: + self._labelObjects[i].Select(False) + self._labelObjects[i].RemoveFromCanvas(self._canvas) + self.ClearArrowsAtPosition(-1) def SetEnds(self, x1, y1, x2, y2): """Set the end positions of the line.""" @@ -1024,7 +1022,7 @@ class LineShape(Shape): # Problem with pen - if not a solid pen, does strange things # to the arrowhead. So make (get) a new pen that's solid. if self._pen and self._pen.GetStyle() != wx.SOLID: - solid_pen = wx.ThePenList.FindOrCreatePen(self._pen.GetColour(), 1, wx.SOLID) + solid_pen = wx.Pen(self._pen.GetColour(), 1, wx.SOLID) if solid_pen: dc.SetPen(solid_pen) @@ -1511,12 +1509,7 @@ class LineShape(Shape): labelShape._shapeRegion.SetSize(labelShape.GetWidth(), labelShape.GetHeight()) # Find position in line's region list - i = 0 - for region in self.GetRegions(): - if labelShape._shapeRegion == region: - self.GetRegions().remove(region) - else: - i += 1 + i = self._regions.index(labelShape._shapeRegion) xx, yy = self.GetLabelPosition(i) # Set the region's offset, relative to the default position for