]> git.saurik.com Git - wxWidgets.git/commitdiff
Patch from Pierre Hjälm.
authorRobin Dunn <robin@alldunn.com>
Fri, 18 Jun 2004 16:32:03 +0000 (16:32 +0000)
committerRobin Dunn <robin@alldunn.com>
Fri, 18 Jun 2004 16:32:03 +0000 (16:32 +0000)
"""
It removes "from __future__ import division", fixes a couple of bugs and
adds a lot of whitespace.

Since I also removed an instance of [::-1] for list reversing, I think this
ought to work on older pythons (I have not tested though).
"""

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27884 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/wx/lib/ogl/__init__.py
wxPython/wx/lib/ogl/_basic.py
wxPython/wx/lib/ogl/_bmpshape.py
wxPython/wx/lib/ogl/_canvas.py
wxPython/wx/lib/ogl/_composit.py
wxPython/wx/lib/ogl/_diagram.py
wxPython/wx/lib/ogl/_divided.py
wxPython/wx/lib/ogl/_lines.py
wxPython/wx/lib/ogl/_oglmisc.py

index c295f493238b82da6eb34f028b4284c53c5f9d80..42da15c237f6eecea924ebd648ee034a4353656d 100644 (file)
@@ -14,7 +14,7 @@ from _composit import *
 
 
 # Set things up for documenting with epydoc.  The __docfilter__ will
 
 
 # Set things up for documenting with epydoc.  The __docfilter__ will
-# prevent some things from beign documented, and anything in __all__
+# prevent some things from being documented, and anything in __all__
 # will appear to actually exist in this module.
 import wx._core as _wx
 __docfilter__ = _wx.__DocFilter(globals())
 # will appear to actually exist in this module.
 import wx._core as _wx
 __docfilter__ = _wx.__DocFilter(globals())
index 250e8f942299cacd94a81749fd89f6d11049f133..e0d5c7307fa5915ea91a1904233b844f55d22120 100644 (file)
@@ -11,8 +11,6 @@
 # Licence:      wxWindows license
 #----------------------------------------------------------------------------
 
 # Licence:      wxWindows license
 #----------------------------------------------------------------------------
 
-from __future__ import division
-
 import wx
 import math
 
 import wx
 import math
 
@@ -254,7 +252,7 @@ class Shape(ShapeEvtHandler):
         self._shadowBrush = wx.BLACK_BRUSH
         self._textMarginX = 5
         self._textMarginY = 5
         self._shadowBrush = wx.BLACK_BRUSH
         self._textMarginX = 5
         self._textMarginY = 5
-        self._regionName="0"
+        self._regionName = "0"
         self._centreResize = True
         self._maintainAspectRatio = False
         self._highlighted = False
         self._centreResize = True
         self._maintainAspectRatio = False
         self._highlighted = False
@@ -431,8 +429,8 @@ class Shape(ShapeEvtHandler):
     def ClearText(self, regionId = 0):
         """Clear the text from the specified text region."""
         if regionId == 0:
     def ClearText(self, regionId = 0):
         """Clear the text from the specified text region."""
         if regionId == 0:
-            self._text=""
-        if regionId<len(self._regions):
+            self._text = ""
+        if regionId < len(self._regions):
             self._regions[regionId].ClearText()
             
     def ClearRegions(self):
             self._regions[regionId].ClearText()
             
     def ClearRegions(self):
@@ -456,18 +454,18 @@ class Shape(ShapeEvtHandler):
         the given point and target.
         """
         width, height = self.GetBoundingBoxMax()
         the given point and target.
         """
         width, height = self.GetBoundingBoxMax()
-        if abs(width)<4:
+        if abs(width) < 4:
             width = 4.0
             width = 4.0
-        if abs(height)<4:
+        if abs(height) < 4:
             height = 4.0
 
         width += 4 # Allowance for inaccurate mousing
         height += 4
         
             height = 4.0
 
         width += 4 # Allowance for inaccurate mousing
         height += 4
         
-        left = self._xpos - (width / 2)
-        top = self._ypos - (height / 2)
-        right = self._xpos + (width / 2)
-        bottom = self._ypos + (height / 2)
+        left = self._xpos - width / 2.0
+        top = self._ypos - height / 2.0
+        right = self._xpos + width / 2.0
+        bottom = self._ypos + height / 2.0
 
         nearest_attachment = 0
 
 
         nearest_attachment = 0
 
@@ -485,7 +483,7 @@ class Shape(ShapeEvtHandler):
                 if e:
                     xp, yp = e
                     l = math.sqrt(((xp - x) * (xp - x)) + (yp - y) * (yp - y))
                 if e:
                     xp, yp = e
                     l = math.sqrt(((xp - x) * (xp - x)) + (yp - y) * (yp - y))
-                    if l<nearest:
+                    if l < nearest:
                         nearest = l
                         nearest_attachment = i
 
                         nearest = l
                         nearest_attachment = i
 
@@ -504,7 +502,7 @@ class Shape(ShapeEvtHandler):
         if not self._regions:
             return
 
         if not self._regions:
             return
 
-        if i>len(self._regions):
+        if i > len(self._regions):
             return
 
         region = self._regions[i]
             return
 
         region = self._regions[i]
@@ -595,7 +593,7 @@ class Shape(ShapeEvtHandler):
     def SetFont(self, the_font, regionId = 0):
         """Set the font for the specified text region."""
         self._font = the_font
     def SetFont(self, the_font, regionId = 0):
         """Set the font for the specified text region."""
         self._font = the_font
-        if regionId<len(self._regions):
+        if regionId < len(self._regions):
             self._regions[regionId].SetFont(the_font)
 
     def GetFont(self, regionId = 0):
             self._regions[regionId].SetFont(the_font)
 
     def GetFont(self, regionId = 0):
@@ -615,7 +613,7 @@ class Shape(ShapeEvtHandler):
         FORMAT_CENTRE_VERT
           Vertical centring.
         """
         FORMAT_CENTRE_VERT
           Vertical centring.
         """
-        if regionId<len(self._regions):
+        if regionId < len(self._regions):
             self._regions[regionId].SetFormatMode(mode)
 
     def GetFormatMode(self, regionId = 0):
             self._regions[regionId].SetFormatMode(mode)
 
     def GetFormatMode(self, regionId = 0):
@@ -628,7 +626,7 @@ class Shape(ShapeEvtHandler):
         self._textColour = wx.TheColourDatabase.Find(the_colour)
         self._textColourName = the_colour
 
         self._textColour = wx.TheColourDatabase.Find(the_colour)
         self._textColourName = the_colour
 
-        if regionId<len(self._regions):
+        if regionId < len(self._regions):
             self._regions[regionId].SetColour(the_colour)
             
     def GetTextColour(self, regionId = 0):
             self._regions[regionId].SetColour(the_colour)
             
     def GetTextColour(self, regionId = 0):
@@ -642,7 +640,7 @@ class Shape(ShapeEvtHandler):
         The name for a region is unique within the scope of the whole
         composite, whereas a region id is unique only for a single image.
         """
         The name for a region is unique within the scope of the whole
         composite, whereas a region id is unique only for a single image.
         """
-        if regionId<len(self._regions):
+        if regionId < len(self._regions):
             self._regions[regionId].SetName(name)
 
     def GetRegionName(self, regionId = 0):
             self._regions[regionId].SetName(name)
 
     def GetRegionName(self, regionId = 0):
@@ -688,7 +686,7 @@ class Shape(ShapeEvtHandler):
         for the given region name.
         """
         id = self.GetRegionId(name)
         for the given region name.
         """
         id = self.GetRegionId(name)
-        if id>-1:
+        if id > -1:
             return self, id
 
         for child in self._children:
             return self, id
 
         for child in self._children:
@@ -696,7 +694,7 @@ class Shape(ShapeEvtHandler):
             if actualImage:
                 return actualImage, regionId
 
             if actualImage:
                 return actualImage, regionId
 
-        return None,-1
+        return None, -1
 
     # Finds all region names for this image (composite or simple).
     def FindRegionNames(self):
 
     # Finds all region names for this image (composite or simple).
     def FindRegionNames(self):
@@ -782,8 +780,8 @@ class Shape(ShapeEvtHandler):
         minX, minY = self.GetBoundingBoxMin()
         maxX, maxY = self.GetBoundingBoxMax()
 
         minX, minY = self.GetBoundingBoxMin()
         maxX, maxY = self.GetBoundingBoxMax()
 
-        topLeftX = xp - maxX / 2 - 2
-        topLeftY = yp - maxY / 2 - 2
+        topLeftX = xp - maxX / 2.0 - 2
+        topLeftY = yp - maxY / 2.0 - 2
 
         penWidth = 0
         if self._pen:
 
         penWidth = 0
         if self._pen:
@@ -794,7 +792,7 @@ class Shape(ShapeEvtHandler):
 
         dc.DrawRectangle(topLeftX - penWidth, topLeftY - penWidth, maxX + penWidth * 2 + 4, maxY + penWidth * 2 + 4)
 
 
         dc.DrawRectangle(topLeftX - penWidth, topLeftY - penWidth, maxX + penWidth * 2 + 4, maxY + penWidth * 2 + 4)
 
-    def EraseLinks(self, dc, attachment=-1, recurse = False):
+    def EraseLinks(self, dc, attachment = -1, recurse = False):
         """Erase links attached to this shape, but do not repair damage
         caused to other shapes.
         """
         """Erase links attached to this shape, but do not repair damage
         caused to other shapes.
         """
@@ -802,20 +800,20 @@ class Shape(ShapeEvtHandler):
             return
 
         for line in self._lines:
             return
 
         for line in self._lines:
-            if attachment==-1 or (line.GetTo() == self and line.GetAttachmentTo() == attachment or line.GetFrom() == self and line.GetAttachmentFrom() == attachment):
+            if attachment == -1 or (line.GetTo() == self and line.GetAttachmentTo() == attachment or line.GetFrom() == self and line.GetAttachmentFrom() == attachment):
                 line.GetEventHandler().OnErase(dc)
 
         if recurse:
             for child in self._children:
                 child.EraseLinks(dc, attachment, recurse)
 
                 line.GetEventHandler().OnErase(dc)
 
         if recurse:
             for child in self._children:
                 child.EraseLinks(dc, attachment, recurse)
 
-    def DrawLinks(self, dc, attachment=-1, recurse = False):
+    def DrawLinks(self, dc, attachment = -1, recurse = False):
         """Draws any lines linked to this shape."""
         if not self._visible:
             return
 
         for line in self._lines:
         """Draws any lines linked to this shape."""
         if not self._visible:
             return
 
         for line in self._lines:
-            if attachment==-1 or (line.GetTo() == self and line.GetAttachmentTo() == attachment or line.GetFrom() == self and line.GetAttachmentFrom() == attachment):
+            if attachment == -1 or (line.GetTo() == self and line.GetAttachmentTo() == attachment or line.GetFrom() == self and line.GetAttachmentFrom() == attachment):
                 line.GetEventHandler().Draw(dc)
                 
         if recurse:
                 line.GetEventHandler().Draw(dc)
                 
         if recurse:
@@ -878,8 +876,8 @@ class Shape(ShapeEvtHandler):
         # it to another position in the list
         del newOrdering[newOrdering.index(to_move)]
 
         # it to another position in the list
         del newOrdering[newOrdering.index(to_move)]
 
-        old_x=-99999.9
-        old_y=-99999.9
+        old_x = -99999.9
+        old_y = -99999.9
 
         found = False
 
 
         found = False
 
@@ -1048,7 +1046,7 @@ class Shape(ShapeEvtHandler):
                 hit = self._parent.HitTest(x, y)
                 if hit:
                     attachment, dist = hit
                 hit = self._parent.HitTest(x, y)
                 if hit:
                     attachment, dist = hit
-            self._parent.GetEventHandler().OnEndDragLeft(x, y, keys, attachment)
+                self._parent.GetEventHandler().OnEndDragLeft(x, y, keys, attachment)
             return
 
         dc = wx.ClientDC(self.GetCanvas())
             return
 
         dc = wx.ClientDC(self.GetCanvas())
@@ -1088,14 +1086,13 @@ class Shape(ShapeEvtHandler):
             return
 
     def OnDrawOutline(self, dc, x, y, w, h):
             return
 
     def OnDrawOutline(self, dc, x, y, w, h):
-        points = [[x - w / 2, y - h / 2],
-                [x + w / 2, y - h / 2],
-                [x + w / 2, y + h / 2],
-                [x - w / 2, y + h / 2],
-                [x - w / 2, y - h / 2],
+        points = [[x - w / 2.0, y - h / 2.0],
+                [x + w / 2.0, y - h / 2.0],
+                [x + w / 2.0, y + h / 2.0],
+                [x - w / 2.0, y + h / 2.0],
+                [x - w / 2.0, y - h / 2.0],
                 ]
 
                 ]
 
-        #dc.DrawLines([[round(x), round(y)] for x, y in points])
         dc.DrawLines(points)
         
     def Attach(self, can):
         dc.DrawLines(points)
         
     def Attach(self, can):
@@ -1197,18 +1194,18 @@ class Shape(ShapeEvtHandler):
         if width == 0:
             scaleX = 1.0
         else:
         if width == 0:
             scaleX = 1.0
         else:
-            scaleX = long(w) / width
+            scaleX = float(w) / width
         if height == 0:
             scaleY = 1.0
         else:
         if height == 0:
             scaleY = 1.0
         else:
-            scaleY = long(h) / height
+            scaleY = float(h) / height
 
         for point in self._attachmentPoints:
             point._x = point._x * scaleX
             point._y = point._y * scaleY
 
     # Add line FROM this object
 
         for point in self._attachmentPoints:
             point._x = point._x * scaleX
             point._y = point._y * scaleY
 
     # Add line FROM this object
-    def AddLine(self, line, other, attachFrom = 0, attachTo = 0, positionFrom=-1, positionTo=-1):
+    def AddLine(self, line, other, attachFrom = 0, attachTo = 0, positionFrom = -1, positionTo = -1):
         """Add a line between this shape and the given other shape, at the
         specified attachment points.
 
         """Add a line between this shape and the given other shape, at the
         specified attachment points.
 
@@ -1216,7 +1213,7 @@ class Shape(ShapeEvtHandler):
         so that the line will be drawn at a particular point on its attachment
         point.
         """
         so that the line will be drawn at a particular point on its attachment
         point.
         """
-        if positionFrom==-1:
+        if positionFrom == -1:
             if not line in self._lines:
                 self._lines.append(line)
         else:
             if not line in self._lines:
                 self._lines.append(line)
         else:
@@ -1225,12 +1222,12 @@ class Shape(ShapeEvtHandler):
                 self._lines.remove(line)
             except ValueError:
                 pass
                 self._lines.remove(line)
             except ValueError:
                 pass
-            if positionFrom<len(self._lines):
+            if positionFrom < len(self._lines):
                 self._lines.insert(positionFrom, line)
             else:
                 self._lines.append(line)
 
                 self._lines.insert(positionFrom, line)
             else:
                 self._lines.append(line)
 
-        if positionTo==-1:
+        if positionTo == -1:
             if not other in other._lines:
                 other._lines.append(line)
         else:
             if not other in other._lines:
                 other._lines.append(line)
         else:
@@ -1239,7 +1236,7 @@ class Shape(ShapeEvtHandler):
                 other._lines.remove(line)
             except ValueError:
                 pass
                 other._lines.remove(line)
             except ValueError:
                 pass
-            if positionTo<len(other._lines):
+            if positionTo < len(other._lines):
                 other._lines.insert(positionTo, line)
             else:
                 other._lines.append(line)
                 other._lines.insert(positionTo, line)
             else:
                 other._lines.append(line)
@@ -1273,10 +1270,10 @@ class Shape(ShapeEvtHandler):
         heightMin = minY + CONTROL_POINT_SIZE + 2
 
         # Offsets from main object
         heightMin = minY + CONTROL_POINT_SIZE + 2
 
         # Offsets from main object
-        top=-heightMin / 2
-        bottom = heightMin / 2 + (maxY - minY)
-        left=-widthMin / 2
-        right = widthMin / 2 + (maxX - minX)
+        top = -heightMin / 2.0
+        bottom = heightMin / 2.0 + (maxY - minY)
+        left = -widthMin / 2.0
+        right = widthMin / 2.0 + (maxX - minX)
 
         control = ControlPoint(self._canvas, self, CONTROL_POINT_SIZE, left, top, CONTROL_POINT_DIAGONAL)
         self._canvas.AddShape(control)
 
         control = ControlPoint(self._canvas, self, CONTROL_POINT_SIZE, left, top, CONTROL_POINT_DIAGONAL)
         self._canvas.AddShape(control)
@@ -1341,10 +1338,10 @@ class Shape(ShapeEvtHandler):
         heightMin = minY + CONTROL_POINT_SIZE + 2
         
         # Offsets from main object
         heightMin = minY + CONTROL_POINT_SIZE + 2
         
         # Offsets from main object
-        top=-heightMin / 2
-        bottom = heightMin / 2 + (maxY - minY)
-        left=-widthMin / 2
-        right = widthMin / 2 + (maxX - minX)
+        top = -heightMin / 2.0
+        bottom = heightMin / 2.0 + (maxY - minY)
+        left = -widthMin / 2.0
+        right = widthMin / 2.0 + (maxX - minX)
 
         self._controlPoints[0]._xoffset = left
         self._controlPoints[0]._yoffset = top
 
         self._controlPoints[0]._xoffset = left
         self._controlPoints[0]._yoffset = top
@@ -1458,7 +1455,7 @@ class Shape(ShapeEvtHandler):
         else:
             maxN = 3
             for point in self._attachmentPoints:
         else:
             maxN = 3
             for point in self._attachmentPoints:
-                if point._id>maxN:
+                if point._id > maxN:
                     maxN = point._id
             return maxN + 1
 
                     maxN = point._id
             return maxN + 1
 
@@ -1492,10 +1489,10 @@ class Shape(ShapeEvtHandler):
             else:
                 # Assume is rectangular
                 w, h = self.GetBoundingBoxMax()
             else:
                 # Assume is rectangular
                 w, h = self.GetBoundingBoxMax()
-                top = self._ypos + h / 2
-                bottom = self._ypos - h / 2
-                left = self._xpos - w / 2
-                right = self._xpos + w / 2
+                top = self._ypos + h / 2.0
+                bottom = self._ypos - h / 2.0
+                left = self._xpos - w / 2.0
+                right = self._xpos + w / 2.0
 
                 # wtf?
                 line and line.IsEnd(self)
 
                 # wtf?
                 line and line.IsEnd(self)
@@ -1583,7 +1580,7 @@ class Shape(ShapeEvtHandler):
         isHorizontal = RoughlyEqual(pt1[1], pt2[1])
 
         if isHorizontal:
         isHorizontal = RoughlyEqual(pt1[1], pt2[1])
 
         if isHorizontal:
-            if pt1[0]>pt2[0]:
+            if pt1[0] > pt2[0]:
                 firstPoint = pt2
                 secondPoint = pt1
             else:
                 firstPoint = pt2
                 secondPoint = pt1
             else:
@@ -1594,21 +1591,21 @@ class Shape(ShapeEvtHandler):
                 if line and line.GetAlignmentType(isEnd) == LINE_ALIGNMENT_TO_NEXT_HANDLE:
                     # Align line according to the next handle along
                     point = line.GetNextControlPoint(self)
                 if line and line.GetAlignmentType(isEnd) == LINE_ALIGNMENT_TO_NEXT_HANDLE:
                     # Align line according to the next handle along
                     point = line.GetNextControlPoint(self)
-                    if point[0]<firstPoint[0]:
+                    if point[0] < firstPoint[0]:
                         x = firstPoint[0]
                         x = firstPoint[0]
-                    elif point[0]>secondPoint[0]:
+                    elif point[0] > secondPoint[0]:
                         x = secondPoint[0]
                     else:
                         x = point[0]
                 else:
                         x = secondPoint[0]
                     else:
                         x = point[0]
                 else:
-                    x = firstPoint[0] + (nth + 1) * (secondPoint[0] - firstPoint[0]) / (noArcs + 1)
+                    x = firstPoint[0] + (nth + 1) * (secondPoint[0] - firstPoint[0]) / (noArcs + 1.0)
             else:
             else:
-                x = (secondPoint[0] - firstPoint[0]) / 2 # Midpoint
+                x = (secondPoint[0] - firstPoint[0]) / 2.0 # Midpoint
             y = pt1[1]
         else:
             assert RoughlyEqual(pt1[0], pt2[0])
 
             y = pt1[1]
         else:
             assert RoughlyEqual(pt1[0], pt2[0])
 
-            if pt1[1]>pt2[1]:
+            if pt1[1] > pt2[1]:
                 firstPoint = pt2
                 secondPoint = pt1
             else:
                 firstPoint = pt2
                 secondPoint = pt1
             else:
@@ -1619,16 +1616,16 @@ class Shape(ShapeEvtHandler):
                 if line and line.GetAlignmentType(isEnd) == LINE_ALIGNMENT_TO_NEXT_HANDLE:
                     # Align line according to the next handle along
                     point = line.GetNextControlPoint(self)
                 if line and line.GetAlignmentType(isEnd) == LINE_ALIGNMENT_TO_NEXT_HANDLE:
                     # Align line according to the next handle along
                     point = line.GetNextControlPoint(self)
-                    if point[1]<firstPoint[1]:
+                    if point[1] < firstPoint[1]:
                         y = firstPoint[1]
                         y = firstPoint[1]
-                    elif point[1]>secondPoint[1]:
+                    elif point[1] > secondPoint[1]:
                         y = secondPoint[1]
                     else:
                         y = point[1]
                 else:
                         y = secondPoint[1]
                     else:
                         y = point[1]
                 else:
-                    y = firstPoint[1] + (nth + 1) * (secondPoint[1] - firstPoint[1]) / (noArcs + 1)
+                    y = firstPoint[1] + (nth + 1) * (secondPoint[1] - firstPoint[1]) / (noArcs + 1.0)
             else:
             else:
-                y = (secondPoint[1] - firstPoint[1]) / 2 # Midpoint
+                y = (secondPoint[1] - firstPoint[1]) / 2.0 # Midpoint
             x = pt1[0]
 
         return x, y
             x = pt1[0]
 
         return x, y
@@ -1676,8 +1673,8 @@ class Shape(ShapeEvtHandler):
             neck.x = self.GetX()
             neck.y = root.y - self._branchNeckLength
 
             neck.x = self.GetX()
             neck.y = root.y - self._branchNeckLength
 
-            shoulder1.x = root.x - totalBranchLength / 2
-            shoulder2.x = root.x + totalBranchLength / 2
+            shoulder1.x = root.x - totalBranchLength / 2.0
+            shoulder2.x = root.x + totalBranchLength / 2.0
 
             shoulder1.y = neck.y
             shoulder2.y = neck.y
 
             shoulder1.y = neck.y
             shoulder2.y = neck.y
@@ -1688,14 +1685,14 @@ class Shape(ShapeEvtHandler):
             shoulder1.x = neck.x
             shoulder2.x = neck.x
 
             shoulder1.x = neck.x
             shoulder2.x = neck.x
 
-            shoulder1.y = neck.y - totalBranchLength / 2
-            shoulder1.y = neck.y + totalBranchLength / 2
+            shoulder1.y = neck.y - totalBranchLength / 2.0
+            shoulder1.y = neck.y + totalBranchLength / 2.0
         elif physicalAttachment == 2:
             neck.x = self.GetX()
             neck.y = root.y + self._branchNeckLength
 
         elif physicalAttachment == 2:
             neck.x = self.GetX()
             neck.y = root.y + self._branchNeckLength
 
-            shoulder1.x = root.x - totalBranchLength / 2
-            shoulder2.x = root.x + totalBranchLength / 2
+            shoulder1.x = root.x - totalBranchLength / 2.0
+            shoulder2.x = root.x + totalBranchLength / 2.0
 
             shoulder1.y = neck.y
             shoulder2.y = neck.y
 
             shoulder1.y = neck.y
             shoulder2.y = neck.y
@@ -1706,8 +1703,8 @@ class Shape(ShapeEvtHandler):
             shoulder1.x = neck.x
             shoulder2.x = neck.x
 
             shoulder1.x = neck.x
             shoulder2.x = neck.x
 
-            shoulder1.y = neck.y - totalBranchLength / 2
-            shoulder2.y = neck.y + totalBranchLength / 2
+            shoulder1.y = neck.y - totalBranchLength / 2.0
+            shoulder2.y = neck.y + totalBranchLength / 2.0
         else:
             raise "Unrecognised attachment point in GetBranchingAttachmentInfo"
         return root, neck, shoulder1, shoulder2
         else:
             raise "Unrecognised attachment point in GetBranchingAttachmentInfo"
         return root, neck, shoulder1, shoulder2
@@ -1769,15 +1766,15 @@ class Shape(ShapeEvtHandler):
         # Assume that we have attachment points 0 to 3: top, right, bottom, left
         if physicalAttachment == 0:
             root.x = self.GetX()
         # Assume that we have attachment points 0 to 3: top, right, bottom, left
         if physicalAttachment == 0:
             root.x = self.GetX()
-            root.y = self.GetY() - height / 2
+            root.y = self.GetY() - height / 2.0
         elif physicalAttachment == 1:
         elif physicalAttachment == 1:
-            root.x = self.GetX() + width / 2
+            root.x = self.GetX() + width / 2.0
             root.y = self.GetY()
         elif physicalAttachment == 2:
             root.x = self.GetX()
             root.y = self.GetY()
         elif physicalAttachment == 2:
             root.x = self.GetX()
-            root.y = self.GetY() + height / 2
+            root.y = self.GetY() + height / 2.0
         elif physicalAttachment == 3:
         elif physicalAttachment == 3:
-            root.x = self.GetX() - width / 2
+            root.x = self.GetX() - width / 2.0
             root.y = self.GetY()
         else:
             raise "Unrecognised attachment point in GetBranchingAttachmentRoot"
             root.y = self.GetY()
         else:
             raise "Unrecognised attachment point in GetBranchingAttachmentRoot"
@@ -1802,7 +1799,7 @@ class Shape(ShapeEvtHandler):
         # Draw neck
         dc.DrawLine(root, neck)
 
         # Draw neck
         dc.DrawLine(root, neck)
 
-        if count>1:
+        if count > 1:
             # Draw shoulder-to-shoulder line
             dc.DrawLine(shoulder1, shoulder2)
         # Draw all the little branches
             # Draw shoulder-to-shoulder line
             dc.DrawLine(shoulder1, shoulder2)
         # Draw all the little branches
@@ -1810,9 +1807,9 @@ class Shape(ShapeEvtHandler):
             pt, stemPt = self.GetBranchingAttachmentPoint(attachment, i)
             dc.DrawLine(stemPt, pt)
 
             pt, stemPt = self.GetBranchingAttachmentPoint(attachment, i)
             dc.DrawLine(stemPt, pt)
 
-            if self.GetBranchStyle() & BRANCHING_ATTACHMENT_BLOB and count>1:
-                blobSize = 6
-                dc.DrawEllipse(stemPt.x - blobSize / 2, stemPt.y - blobSize / 2, blobSize, blobSize)
+            if self.GetBranchStyle() & BRANCHING_ATTACHMENT_BLOB and count > 1:
+                blobSize = 6.0
+                dc.DrawEllipse(stemPt.x - blobSize / 2.0, stemPt.y - blobSize / 2.0, blobSize, blobSize)
 
     def OnDrawBranches(self, dc, erase = False):
         if self._attachmentMode != ATTACHMENT_MODE_BRANCHING:
 
     def OnDrawBranches(self, dc, erase = False):
         if self._attachmentMode != ATTACHMENT_MODE_BRANCHING:
@@ -1841,17 +1838,17 @@ class Shape(ShapeEvtHandler):
         """
         if RoughlyEqual(self.GetRotation(), 0):
             i = physicalAttachment
         """
         if RoughlyEqual(self.GetRotation(), 0):
             i = physicalAttachment
-        elif RoughlyEqual(self.GetRotation(), math.pi / 2):
+        elif RoughlyEqual(self.GetRotation(), math.pi / 2.0):
             i = physicalAttachment - 1
         elif RoughlyEqual(self.GetRotation(), math.pi):
             i = physicalAttachment - 2
             i = physicalAttachment - 1
         elif RoughlyEqual(self.GetRotation(), math.pi):
             i = physicalAttachment - 2
-        elif RoughlyEqual(self.GetRotation(), 3 * math.pi / 2):
+        elif RoughlyEqual(self.GetRotation(), 3 * math.pi / 2.0):
             i = physicalAttachment - 3
         else:
             # Can't handle -- assume the same
             return physicalAttachment
 
             i = physicalAttachment - 3
         else:
             # Can't handle -- assume the same
             return physicalAttachment
 
-        if i<0:
+        if i < 0:
             i += 4
 
         return i
             i += 4
 
         return i
@@ -1862,16 +1859,16 @@ class Shape(ShapeEvtHandler):
         """
         if RoughlyEqual(self.GetRotation(), 0):
             i = logicalAttachment
         """
         if RoughlyEqual(self.GetRotation(), 0):
             i = logicalAttachment
-        elif RoughlyEqual(self.GetRotation(), math.pi / 2):
+        elif RoughlyEqual(self.GetRotation(), math.pi / 2.0):
             i = logicalAttachment + 1
         elif RoughlyEqual(self.GetRotation(), math.pi):
             i = logicalAttachment + 2
             i = logicalAttachment + 1
         elif RoughlyEqual(self.GetRotation(), math.pi):
             i = logicalAttachment + 2
-        elif RoughlyEqual(self.GetRotation(), 3 * math.pi / 2):
+        elif RoughlyEqual(self.GetRotation(), 3 * math.pi / 2.0):
             i = logicalAttachment + 3
         else:
             return logicalAttachment
 
             i = logicalAttachment + 3
         else:
             return logicalAttachment
 
-        if i>3:
+        if i > 3:
             i -= 4
 
         return i
             i -= 4
 
         return i
@@ -1879,9 +1876,9 @@ class Shape(ShapeEvtHandler):
     def Rotate(self, x, y, theta):
         """Rotate about the given axis by the given amount in radians."""
         self._rotation = theta
     def Rotate(self, x, y, theta):
         """Rotate about the given axis by the given amount in radians."""
         self._rotation = theta
-        if self._rotation<0:
+        if self._rotation < 0:
             self._rotation += 2 * math.pi
             self._rotation += 2 * math.pi
-        elif self._rotation>2 * math.pi:
+        elif self._rotation > 2 * math.pi:
             self._rotation -= 2 * math.pi
 
     def GetBackgroundPen(self):
             self._rotation -= 2 * math.pi
 
     def GetBackgroundPen(self):
@@ -2128,14 +2125,14 @@ class Shape(ShapeEvtHandler):
                 newX1 = pt._controlPointDragStartX
                 newX2 = newX1 + pt._controlPointDragStartWidth
             elif pt._type == CONTROL_POINT_DIAGONAL and (keys & KEY_SHIFT or self.GetMaintainAspectRatio()):
                 newX1 = pt._controlPointDragStartX
                 newX2 = newX1 + pt._controlPointDragStartWidth
             elif pt._type == CONTROL_POINT_DIAGONAL and (keys & KEY_SHIFT or self.GetMaintainAspectRatio()):
-                newH = (newX2 - newX1) * (pt._controlPointDragStartHeight / pt._controlPointDragStartWidth)
-                if self.GetY()>pt._controlPointDragStartY:
+                newH = (newX2 - newX1) * (float(pt._controlPointDragStartHeight) / pt._controlPointDragStartWidth)
+                if self.GetY() > pt._controlPointDragStartY:
                     newY2 = newY1 + newH
                 else:
                     newY1 = newY2 - newH
 
                     newY2 = newY1 + newH
                 else:
                     newY1 = newY2 - newH
 
-            newWidth = newX2 - newX1
-            newHeight = newY2 - newY1
+            newWidth = float(newX2 - newX1)
+            newHeight = float(newY2 - newY1)
 
             if pt._type == CONTROL_POINT_VERTICAL and self.GetMaintainAspectRatio():
                 newWidth = bound_x * (newHeight / bound_y)
 
             if pt._type == CONTROL_POINT_VERTICAL and self.GetMaintainAspectRatio():
                 newWidth = bound_x * (newHeight / bound_y)
@@ -2143,8 +2140,8 @@ class Shape(ShapeEvtHandler):
             if pt._type == CONTROL_POINT_HORIZONTAL and self.GetMaintainAspectRatio():
                 newHeight = bound_y * (newWidth / bound_x)
 
             if pt._type == CONTROL_POINT_HORIZONTAL and self.GetMaintainAspectRatio():
                 newHeight = bound_y * (newWidth / bound_x)
 
-            pt._controlPointDragPosX = newX1 + newWidth / 2
-            pt._controlPointDragPosY = newY1 + newHeight / 2
+            pt._controlPointDragPosX = newX1 + newWidth / 2.0
+            pt._controlPointDragPosY = newY1 + newHeight / 2.0
             if self.GetFixedWidth():
                 newWidth = bound_x
 
             if self.GetFixedWidth():
                 newWidth = bound_x
 
@@ -2168,20 +2165,20 @@ class Shape(ShapeEvtHandler):
 
         # Choose the 'opposite corner' of the object as the stationary
         # point in case this is non-centring resizing.
 
         # Choose the 'opposite corner' of the object as the stationary
         # point in case this is non-centring resizing.
-        if pt.GetX()<self.GetX():
-            pt._controlPointDragStartX = self.GetX() + bound_x / 2
+        if pt.GetX() < self.GetX():
+            pt._controlPointDragStartX = self.GetX() + bound_x / 2.0
         else:
         else:
-            pt._controlPointDragStartX = self.GetX() - bound_x / 2
+            pt._controlPointDragStartX = self.GetX() - bound_x / 2.0
 
 
-        if pt.GetY()<self.GetY():
-            pt._controlPointDragStartY = self.GetY() + bound_y / 2
+        if pt.GetY() < self.GetY():
+            pt._controlPointDragStartY = self.GetY() + bound_y / 2.0
         else:
         else:
-            pt._controlPointDragStartY = self.GetY() - bound_y / 2
+            pt._controlPointDragStartY = self.GetY() - bound_y / 2.0
 
         if pt._type == CONTROL_POINT_HORIZONTAL:
 
         if pt._type == CONTROL_POINT_HORIZONTAL:
-            pt._controlPointDragStartY = self.GetY() - bound_y / 2
+            pt._controlPointDragStartY = self.GetY() - bound_y / 2.0
         elif pt._type == CONTROL_POINT_VERTICAL:
         elif pt._type == CONTROL_POINT_VERTICAL:
-            pt._controlPointDragStartX = self.GetX() - bound_x / 2
+            pt._controlPointDragStartX = self.GetX() - bound_x / 2.0
 
         # We may require the old width and height
         pt._controlPointDragStartWidth = bound_x
 
         # We may require the old width and height
         pt._controlPointDragStartWidth = bound_x
@@ -2231,14 +2228,14 @@ class Shape(ShapeEvtHandler):
                 newX1 = pt._controlPointDragStartX
                 newX2 = newX1 + pt._controlPointDragStartWidth
             elif pt._type == CONTROL_POINT_DIAGONAL and (keys & KEYS or self.GetMaintainAspectRatio()):
                 newX1 = pt._controlPointDragStartX
                 newX2 = newX1 + pt._controlPointDragStartWidth
             elif pt._type == CONTROL_POINT_DIAGONAL and (keys & KEYS or self.GetMaintainAspectRatio()):
-                newH = (newX2 - newX1) * (pt._controlPointDragStartHeight / pt._controlPointDragStartWidth)
-                if pt.GetY()>pt._controlPointDragStartY:
+                newH = (newX2 - newX1) * (float(pt._controlPointDragStartHeight) / pt._controlPointDragStartWidth)
+                if pt.GetY() > pt._controlPointDragStartY:
                     newY2 = newY1 + newH
                 else:
                     newY1 = newY2 - newH
 
                     newY2 = newY1 + newH
                 else:
                     newY1 = newY2 - newH
 
-            newWidth = newX2 - newX1
-            newHeight = newY2 - newY1
+            newWidth = float(newX2 - newX1)
+            newHeight = float(newY2 - newY1)
 
             if pt._type == CONTROL_POINT_VERTICAL and self.GetMaintainAspectRatio():
                 newWidth = bound_x * (newHeight / bound_y)
 
             if pt._type == CONTROL_POINT_VERTICAL and self.GetMaintainAspectRatio():
                 newWidth = bound_x * (newHeight / bound_y)
@@ -2246,8 +2243,8 @@ class Shape(ShapeEvtHandler):
             if pt._type == CONTROL_POINT_HORIZONTAL and self.GetMaintainAspectRatio():
                 newHeight = bound_y * (newWidth / bound_x)
 
             if pt._type == CONTROL_POINT_HORIZONTAL and self.GetMaintainAspectRatio():
                 newHeight = bound_y * (newWidth / bound_x)
 
-            pt._controlPointDragPosX = newX1 + newWidth / 2
-            pt._controlPointDragPosY = newY1 + newHeight / 2
+            pt._controlPointDragPosX = newX1 + newWidth / 2.0
+            pt._controlPointDragPosY = newY1 + newHeight / 2.0
             if self.GetFixedWidth():
                 newWidth = bound_x
 
             if self.GetFixedWidth():
                 newWidth = bound_x
 
@@ -2285,7 +2282,7 @@ class Shape(ShapeEvtHandler):
 
         # Recursively redraw links if we have a composite
         if len(self.GetChildren()):
 
         # Recursively redraw links if we have a composite
         if len(self.GetChildren()):
-            self.DrawLinks(dc,-1, True)
+            self.DrawLinks(dc, -1, True)
 
         width, height = self.GetBoundingBoxMax()
         self.GetEventHandler().OnEndSize(width, height)
 
         width, height = self.GetBoundingBoxMax()
         self.GetEventHandler().OnEndSize(width, height)
@@ -2310,8 +2307,8 @@ class RectangleShape(Shape):
         self.SetDefaultRegionSize()
 
     def OnDraw(self, dc):
         self.SetDefaultRegionSize()
 
     def OnDraw(self, dc):
-        x1 = self._xpos - self._width / 2
-        y1 = self._ypos - self._height / 2
+        x1 = self._xpos - self._width / 2.0
+        y1 = self._ypos - self._height / 2.0
 
         if self._shadowMode != SHADOW_NONE:
             if self._shadowBrush:
 
         if self._shadowMode != SHADOW_NONE:
             if self._shadowBrush:
@@ -2440,19 +2437,19 @@ class PolygonShape(Shape):
     def CalculateBoundingBox(self):
         # Calculate bounding box at construction (and presumably resize) time
         left = 10000
     def CalculateBoundingBox(self):
         # Calculate bounding box at construction (and presumably resize) time
         left = 10000
-        right=-10000
+        right = -10000
         top = 10000
         top = 10000
-        bottom=-10000
+        bottom = -10000
 
         for point in self._points:
 
         for point in self._points:
-            if point.x<left:
+            if point.x < left:
                 left = point.x
                 left = point.x
-            if point.x>right:
+            if point.x > right:
                 right = point.x
 
                 right = point.x
 
-            if point.y<top:
+            if point.y < top:
                 top = point.y
                 top = point.y
-            if point.y>bottom:
+            if point.y > bottom:
                 bottom = point.y
 
         self._boundWidth = right - left
                 bottom = point.y
 
         self._boundWidth = right - left
@@ -2466,26 +2463,26 @@ class PolygonShape(Shape):
         box.
         """
         left = 10000
         box.
         """
         left = 10000
-        right=-10000
+        right = -10000
         top = 10000
         top = 10000
-        bottom=-10000
+        bottom = -10000
 
         for point in self._points:
 
         for point in self._points:
-            if point.x<left:
+            if point.x < left:
                 left = point.x
                 left = point.x
-            if point.x>right:
+            if point.x > right:
                 right = point.x
 
                 right = point.x
 
-            if point.y<top:
+            if point.y < top:
                 top = point.y
                 top = point.y
-            if point.y>bottom:
+            if point.y > bottom:
                 bottom = point.y
 
         bwidth = right - left
         bheight = bottom - top
 
                 bottom = point.y
 
         bwidth = right - left
         bheight = bottom - top
 
-        newCentreX = left + bwidth / 2
-        newCentreY = top + bheight / 2
+        newCentreX = left + bwidth / 2.0
+        newCentreY = top + bheight / 2.0
 
         for point in self._points:
             point.x -= newCentreX
 
         for point in self._points:
             point.x -= newCentreX
@@ -2529,7 +2526,7 @@ class PolygonShape(Shape):
             if e:
                 xp, yp = e
                 l = math.sqrt((xp - x) * (xp - x) + (yp - y) * (yp - y))
             if e:
                 xp, yp = e
                 l = math.sqrt((xp - x) * (xp - x) + (yp - y) * (yp - y))
-                if l<nearest:
+                if l < nearest:
                     nearest = l
                     nearest_attachment = i
 
                     nearest = l
                     nearest_attachment = i
 
@@ -2541,8 +2538,8 @@ class PolygonShape(Shape):
         self.SetAttachmentSize(new_width, new_height)
 
         # Multiply all points by proportion of new size to old size
         self.SetAttachmentSize(new_width, new_height)
 
         # Multiply all points by proportion of new size to old size
-        x_proportion = abs(new_width / self._originalWidth)
-        y_proportion = abs(new_height / self._originalHeight)
+        x_proportion = abs(float(new_width) / self._originalWidth)
+        y_proportion = abs(float(new_height) / self._originalHeight)
 
         for i in range(max(len(self._points), len(self._originalPoints))):
             self._points[i].x = self._originalPoints[i][0] * x_proportion
 
         for i in range(max(len(self._points), len(self._originalPoints))):
             self._points[i].x = self._originalPoints[i][0] * x_proportion
@@ -2579,8 +2576,8 @@ class PolygonShape(Shape):
         except ValueError:
             secondPoint = self._points[0]
 
         except ValueError:
             secondPoint = self._points[0]
 
-        x = (secondPoint.x - firstPoint.x) / 2 + firstPoint.x
-        y = (secondPoint.y - firstPoint.y) / 2 + firstPoint.y
+        x = (secondPoint.x - firstPoint.x) / 2.0 + firstPoint.x
+        y = (secondPoint.y - firstPoint.y) / 2.0 + firstPoint.y
         point = wx.RealPoint(x, y)
 
         if pos >= len(self._points) - 1:
         point = wx.RealPoint(x, y)
 
         if pos >= len(self._points) - 1:
@@ -2596,7 +2593,7 @@ class PolygonShape(Shape):
 
     def DeletePolygonPoint(self, pos):
         """Delete the given control point."""
 
     def DeletePolygonPoint(self, pos):
         """Delete the given control point."""
-        if pos<len(self._points):
+        if pos < len(self._points):
             del self._points[pos]
             self.UpdateOriginalPoints()
             if self._selected:
             del self._points[pos]
             self.UpdateOriginalPoints()
             if self._selected:
@@ -2614,9 +2611,9 @@ class PolygonShape(Shape):
             # a heuristic...
             for point in self._points:
                 if point.x == 0:
             # a heuristic...
             for point in self._points:
                 if point.x == 0:
-                    if y2>y1 and point.y>0:
+                    if y2 > y1 and point.y > 0:
                         return point.x + self._xpos, point.y + self._ypos
                         return point.x + self._xpos, point.y + self._ypos
-                    elif y2<y1 and point.y<0:
+                    elif y2 < y1 and point.y < 0:
                         return point.x + self._xpos, point.y + self._ypos
 
         xpoints = []
                         return point.x + self._xpos, point.y + self._ypos
 
         xpoints = []
@@ -2647,8 +2644,8 @@ class PolygonShape(Shape):
     def OnDrawOutline(self, dc, x, y, w, h):
         dc.SetBrush(wx.TRANSPARENT_BRUSH)
         # Multiply all points by proportion of new size to old size
     def OnDrawOutline(self, dc, x, y, w, h):
         dc.SetBrush(wx.TRANSPARENT_BRUSH)
         # Multiply all points by proportion of new size to old size
-        x_proportion = abs(w / self._originalWidth)
-        y_proportion = abs(h / self._originalHeight)
+        x_proportion = abs(float(w) / self._originalWidth)
+        y_proportion = abs(float(h) / self._originalHeight)
 
         intPoints = []
         for point in self._originalPoints:
 
         intPoints = []
         for point in self._originalPoints:
@@ -2672,12 +2669,12 @@ class PolygonShape(Shape):
     def GetNumberOfAttachments(self):
         maxN = max(len(self._points) - 1, 0)
         for point in self._attachmentPoints:
     def GetNumberOfAttachments(self):
         maxN = max(len(self._points) - 1, 0)
         for point in self._attachmentPoints:
-            if point._id>maxN:
+            if point._id > maxN:
                 maxN = point._id
         return maxN + 1
 
     def GetAttachmentPosition(self, attachment, nth = 0, no_arcs = 1, line = None):
                 maxN = point._id
         return maxN + 1
 
     def GetAttachmentPosition(self, attachment, nth = 0, no_arcs = 1, line = None):
-        if self._attachmentMode == ATTACHMENT_MODE_EDGE and self._points and attachment<len(self._points):
+        if self._attachmentMode == ATTACHMENT_MODE_EDGE and self._points and attachment < len(self._points):
             point = self._points[0]
             return point.x + self._xpos, point.y + self._ypos
         return Shape.GetAttachmentPosition(self, attachment, nth, no_arcs, line)
             point = self._points[0]
             return point.x + self._xpos, point.y + self._ypos
         return Shape.GetAttachmentPosition(self, attachment, nth, no_arcs, line)
@@ -2686,7 +2683,7 @@ class PolygonShape(Shape):
         if not self._points:
             return False
 
         if not self._points:
             return False
 
-        if attachment >= 0 and attachment<len(self._points):
+        if attachment >= 0 and attachment < len(self._points):
             return True
 
         for point in self._attachmentPoints:
             return True
 
         for point in self._attachmentPoints:
@@ -2840,8 +2837,8 @@ class EllipseShape(Shape):
             if self._shadowBrush:
                 dc.SetBrush(self._shadowBrush)
             dc.SetPen(TransparentPen)
             if self._shadowBrush:
                 dc.SetBrush(self._shadowBrush)
             dc.SetPen(TransparentPen)
-            dc.DrawEllipse(self._xpos - self.GetWidth() / 2 + self._shadowOffsetX,
-                           self._ypos - self.GetHeight() / 2 + self._shadowOffsetY,
+            dc.DrawEllipse(self._xpos - self.GetWidth() / 2.0 + self._shadowOffsetX,
+                           self._ypos - self.GetHeight() / 2.0 + self._shadowOffsetY,
                            self.GetWidth(), self.GetHeight())
 
         if self._pen:
                            self.GetWidth(), self.GetHeight())
 
         if self._pen:
@@ -2851,7 +2848,7 @@ class EllipseShape(Shape):
                 dc.SetPen(self._pen)
         if self._brush:
             dc.SetBrush(self._brush)
                 dc.SetPen(self._pen)
         if self._brush:
             dc.SetBrush(self._brush)
-        dc.DrawEllipse(self._xpos - self.GetWidth() / 2, self._ypos - self.GetHeight() / 2, self.GetWidth(), self.GetHeight())
+        dc.DrawEllipse(self._xpos - self.GetWidth() / 2.0, self._ypos - self.GetHeight() / 2.0, self.GetWidth(), self.GetHeight())
 
     def SetSize(self, x, y, recursive = True):
         self.SetAttachmentSize(x, y)
 
     def SetSize(self, x, y, recursive = True):
         self.SetAttachmentSize(x, y)
@@ -2869,16 +2866,16 @@ class EllipseShape(Shape):
             return Shape.GetAttachmentPosition(self, attachment, nth, no_arcs, line)
 
         if self._attachmentMode != ATTACHMENT_MODE_NONE:
             return Shape.GetAttachmentPosition(self, attachment, nth, no_arcs, line)
 
         if self._attachmentMode != ATTACHMENT_MODE_NONE:
-            top = self._ypos + self._height / 2
-            bottom = self._ypos - self._height / 2
-            left = self._xpos - self._width / 2
-            right = self._xpos + self._width / 2
+            top = self._ypos + self._height / 2.0
+            bottom = self._ypos - self._height / 2.0
+            left = self._xpos - self._width / 2.0
+            right = self._xpos + self._width / 2.0
 
             physicalAttachment = self.LogicalToPhysicalAttachment(attachment)
 
             if physicalAttachment == 0:
                 if self._spaceAttachments:
 
             physicalAttachment = self.LogicalToPhysicalAttachment(attachment)
 
             if physicalAttachment == 0:
                 if self._spaceAttachments:
-                    x = left + (nth + 1) * self._width / (no_arcs + 1)
+                    x = left + (nth + 1) * self._width / (no_arcs + 1.0)
                 else:
                     x = self._xpos
                 y = top
                 else:
                     x = self._xpos
                 y = top
@@ -2891,13 +2888,13 @@ class EllipseShape(Shape):
             elif physicalAttachment == 1:
                 x = right
                 if self._spaceAttachments:
             elif physicalAttachment == 1:
                 x = right
                 if self._spaceAttachments:
-                    y = bottom + (nth + 1) * self._height / (no_arcs + 1)
+                    y = bottom + (nth + 1) * self._height / (no_arcs + 1.0)
                 else:
                     y = self._ypos
                 return DrawArcToEllipse(self._xpos, self._ypos, self._width, self._height, self._xpos + self._width + 500, y, self._xpos, y)
             elif physicalAttachment == 2:
                 if self._spaceAttachments:
                 else:
                     y = self._ypos
                 return DrawArcToEllipse(self._xpos, self._ypos, self._width, self._height, self._xpos + self._width + 500, y, self._xpos, y)
             elif physicalAttachment == 2:
                 if self._spaceAttachments:
-                    x = left + (nth + 1) * self._width / (no_arcs + 1)
+                    x = left + (nth + 1) * self._width / (no_arcs + 1.0)
                 else:
                     x = self._xpos
                 y = bottom
                 else:
                     x = self._xpos
                 y = bottom
@@ -2905,7 +2902,7 @@ class EllipseShape(Shape):
             elif physicalAttachment == 3:
                 x = left
                 if self._spaceAttachments:
             elif physicalAttachment == 3:
                 x = left
                 if self._spaceAttachments:
-                    y = bottom + (nth + 1) * self._height / (no_arcs + 1)
+                    y = bottom + (nth + 1) * self._height / (no_arcs + 1.0)
                 else:
                     y = self._ypos
                 return DrawArcToEllipse(self._xpos, self._ypos, self._width, self._height, self._xpos - self._width - 500, y, self._xpos, y)
                 else:
                     y = self._ypos
                 return DrawArcToEllipse(self._xpos, self._ypos, self._width, self._height, self._xpos - self._width - 500, y, self._xpos, y)
@@ -2923,7 +2920,7 @@ class CircleShape(EllipseShape):
         self.SetMaintainAspectRatio(True)
 
     def GetPerimeterPoint(self, x1, y1, x2, y2):
         self.SetMaintainAspectRatio(True)
 
     def GetPerimeterPoint(self, x1, y1, x2, y2):
-        return FindEndForCircle(self._width / 2, self._xpos, self._ypos, x2, y2)
+        return FindEndForCircle(self._width / 2.0, self._xpos, self._ypos, x2, y2)
 
 
 
 
 
 
@@ -2966,7 +2963,7 @@ class ShapeRegion(object):
                 new_line = ShapeTextLine(line.GetX(), line.GetY(), line.GetText())
                 self._formattedText.append(new_line)
         else:
                 new_line = ShapeTextLine(line.GetX(), line.GetY(), line.GetText())
                 self._formattedText.append(new_line)
         else:
-            self._regionText=""
+            self._regionText = ""
             self._font = NormalFont
             self._minHeight = 5.0
             self._minWidth = 5.0
             self._font = NormalFont
             self._minHeight = 5.0
             self._minWidth = 5.0
@@ -2975,12 +2972,12 @@ class ShapeRegion(object):
             self._x = 0.0
             self._y = 0.0
 
             self._x = 0.0
             self._y = 0.0
 
-            self._regionProportionX=-1.0
-            self._regionProportionY=-1.0
+            self._regionProportionX = -1.0
+            self._regionProportionY = -1.0
             self._formatMode = FORMAT_CENTRE_HORIZ | FORMAT_CENTRE_VERT
             self._formatMode = FORMAT_CENTRE_HORIZ | FORMAT_CENTRE_VERT
-            self._regionName=""
-            self._textColour="BLACK"
-            self._penColour="BLACK"
+            self._regionName = ""
+            self._textColour = "BLACK"
+            self._penColour = "BLACK"
             self._penStyle = wx.SOLID
             self._actualColourObject = wx.TheColourDatabase.Find("BLACK")
             self._actualPenObject = None
             self._penStyle = wx.SOLID
             self._actualColourObject = wx.TheColourDatabase.Find("BLACK")
             self._actualPenObject = None
index 8a12d85a044297eb083775e8431eb38fb5087dd6..c239aab6ddd67ff87748f7dca774191028ae647d 100644 (file)
@@ -11,8 +11,6 @@
 # Licence:      wxWindows license
 #----------------------------------------------------------------------------
 
 # Licence:      wxWindows license
 #----------------------------------------------------------------------------
 
-from __future__ import division
-
 from _basic import RectangleShape
 
 
 from _basic import RectangleShape
 
 
@@ -20,14 +18,14 @@ class BitmapShape(RectangleShape):
     """Draws a bitmap (non-resizable)."""
     def __init__(self):
         RectangleShape.__init__(self, 100, 50)
     """Draws a bitmap (non-resizable)."""
     def __init__(self):
         RectangleShape.__init__(self, 100, 50)
-        self._filename=""
+        self._filename = ""
 
     def OnDraw(self, dc):
         if not self._bitmap.Ok():
             return
 
 
     def OnDraw(self, dc):
         if not self._bitmap.Ok():
             return
 
-        x = self._xpos-self._bitmap.GetWidth() / 2
-        y = self._ypos-self._bitmap.GetHeight() / 2
+        x = self._xpos - self._bitmap.GetWidth() / 2.0
+        y = self._ypos - self._bitmap.GetHeight() / 2.0
         dc.DrawBitmap(self._bitmap, x, y, True)
 
     def SetSize(self, w, h, recursive = True):
         dc.DrawBitmap(self._bitmap, x, y, True)
 
     def SetSize(self, w, h, recursive = True):
index 105cfa22ab3bdbe1bcbf77a21bd89fbeeafcb72b..a3e2f11898b86879d6eaf0104ec45c2cdf3021d4 100644 (file)
@@ -11,8 +11,6 @@
 # Licence:      wxWindows license
 #----------------------------------------------------------------------------
 
 # Licence:      wxWindows license
 #----------------------------------------------------------------------------
 
-from __future__ import division
-
 import wx
 from _lines import LineShape
 from _composit import *
 import wx
 from _lines import LineShape
 from _composit import *
@@ -31,13 +29,13 @@ def WhollyContains(contains, contained):
     w1, h1 = contains.GetBoundingBoxMax()
     w2, h2 = contained.GetBoundingBoxMax()
     
     w1, h1 = contains.GetBoundingBoxMax()
     w2, h2 = contained.GetBoundingBoxMax()
     
-    left1 = xp1-w1 / 2.0
-    top1 = yp1-h1 / 2.0
+    left1 = xp1 - w1 / 2.0
+    top1 = yp1 - h1 / 2.0
     right1 = xp1 + w1 / 2.0
     bottom1 = yp1 + h1 / 2.0
     
     right1 = xp1 + w1 / 2.0
     bottom1 = yp1 + h1 / 2.0
     
-    left2 = xp2-w2 / 2.0
-    top2 = yp2-h2 / 2.0
+    left2 = xp2 - w2 / 2.0
+    top2 = yp2 - h2 / 2.0
     right2 = xp2 + w2 / 2.0
     bottom2 = yp2 + h2 / 2.0
     
     right2 = xp2 + w2 / 2.0
     bottom2 = yp2 + h2 / 2.0
     
@@ -46,7 +44,7 @@ def WhollyContains(contains, contained):
 
 
 class ShapeCanvas(wx.ScrolledWindow):
 
 
 class ShapeCanvas(wx.ScrolledWindow):
-    def __init__(self, parent = None, id=-1, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.BORDER, name="ShapeCanvas"):
+    def __init__(self, parent = None, id = -1, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.BORDER, name = "ShapeCanvas"):
         wx.ScrolledWindow.__init__(self, parent, id, pos, size, style, name)
 
         self._shapeDiagram = None
         wx.ScrolledWindow.__init__(self, parent, id, pos, size, style, name)
 
         self._shapeDiagram = None
@@ -95,8 +93,8 @@ class ShapeCanvas(wx.ScrolledWindow):
         # If we're very close to the position we started dragging
         # from, this may not be an intentional drag at all.
         if dragging:
         # If we're very close to the position we started dragging
         # from, this may not be an intentional drag at all.
         if dragging:
-            dx = abs(dc.LogicalToDeviceX(x-self._firstDragX))
-            dy = abs(dc.LogicalToDeviceY(y-self._firstDragY))
+            dx = abs(dc.LogicalToDeviceX(x - self._firstDragX))
+            dy = abs(dc.LogicalToDeviceY(y - self._firstDragY))
             if self._checkTolerance and (dx <= self.GetDiagram().GetMouseTolerance()) and (dy <= self.GetDiagram().GetMouseTolerance()):
                 return
             # If we've ignored the tolerance once, then ALWAYS ignore
             if self._checkTolerance and (dx <= self.GetDiagram().GetMouseTolerance()) and (dy <= self.GetDiagram().GetMouseTolerance()):
                 return
             # If we've ignored the tolerance once, then ALWAYS ignore
@@ -270,7 +268,9 @@ class ShapeCanvas(wx.ScrolledWindow):
         #     the other objects
         # (b) to find the control points FIRST if they exist
 
         #     the other objects
         # (b) to find the control points FIRST if they exist
 
-        for object in self.GetDiagram().GetShapeList()[::-1]:
+        rl = self.GetDiagram().GetShapeList()[:]
+        rl.reverse()
+        for object in rl:
             # First pass for lines, which might be inside a container, so we
             # want lines to take priority over containers. This first loop
             # could fail if we clickout side a line, so then we'll
             # First pass for lines, which might be inside a container, so we
             # want lines to take priority over containers. This first loop
             # could fail if we clickout side a line, so then we'll
@@ -288,12 +288,12 @@ class ShapeCanvas(wx.ScrolledWindow):
                 # to specify the nearest point to the centre of the line
                 # as our hit criterion, to give the user some room for
                 # manouevre.
                 # to specify the nearest point to the centre of the line
                 # as our hit criterion, to give the user some room for
                 # manouevre.
-                if dist<nearest:
+                if dist < nearest:
                     nearest = dist
                     nearest_object = object
                     nearest_attachment = temp_attachment
 
                     nearest = dist
                     nearest_object = object
                     nearest_attachment = temp_attachment
 
-        for object in self.GetDiagram().GetShapeList()[::-1]:
+        for object in rl:
             # On second pass, only ever consider non-composites or
             # divisions. If children want to pass up control to
             # the composite, that's up to them.
             # On second pass, only ever consider non-composites or
             # divisions. If children want to pass up control to
             # the composite, that's up to them.
index dbc20e6291bd609b8e7af49292ea677f0cdfcfa6..fba79f3b7367e1d82c035b43854f2e7385851d25 100644 (file)
@@ -11,8 +11,6 @@
 # Licence:      wxWindows license
 #----------------------------------------------------------------------------
 
 # Licence:      wxWindows license
 #----------------------------------------------------------------------------
 
-from __future__ import division
-
 import sys
 import wx
 
 import sys
 import wx
 
@@ -138,7 +136,7 @@ class Constraint(object):
         self._constraintingObject = constraining
 
         self._constraintId = 0
         self._constraintingObject = constraining
 
         self._constraintId = 0
-        self._constraintName="noname"
+        self._constraintName = "noname"
 
         self._constrainedObjects = constrained[:]
 
 
         self._constrainedObjects = constrained[:]
 
@@ -156,7 +154,7 @@ class Constraint(object):
         """
         marg = 0.5
 
         """
         marg = 0.5
 
-        return b <= a + marg and b >= a-marg
+        return b <= a + marg and b >= a - marg
 
     def Evaluate(self):
         """Evaluate this constraint and return TRUE if anything changed."""
 
     def Evaluate(self):
         """Evaluate this constraint and return TRUE if anything changed."""
@@ -177,21 +175,21 @@ class Constraint(object):
 
             # Check if within the constraining object...
             if totalObjectHeight + (n + 1) * self._ySpacing <= minHeight:
 
             # Check if within the constraining object...
             if totalObjectHeight + (n + 1) * self._ySpacing <= minHeight:
-                spacingY = (minHeight-totalObjectHeight) / (n + 1)
-                startY = y-minHeight / 2
+                spacingY = (minHeight - totalObjectHeight) / (n + 1.0)
+                startY = y - minHeight / 2.0
             else: # Otherwise, use default spacing
                 spacingY = self._ySpacing
             else: # Otherwise, use default spacing
                 spacingY = self._ySpacing
-                startY = y-(totalObjectHeight + (n + 1) * spacingY) / 2
+                startY = y - (totalObjectHeight + (n + 1) * spacingY) / 2.0
 
             # Now position the objects
             changed = False
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
 
             # Now position the objects
             changed = False
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
-                startY += spacingY + height2 / 2
+                startY += spacingY + height2 / 2.0
                 if not self.Equals(startY, constrainedObject.GetY()):
                     constrainedObject.Move(dc, constrainedObject.GetX(), startY, False)
                     changed = True
                 if not self.Equals(startY, constrainedObject.GetY()):
                     constrainedObject.Move(dc, constrainedObject.GetX(), startY, False)
                     changed = True
-                startY += height2 / 2
+                startY += height2 / 2.0
             return changed
         elif self._constraintType == CONSTRAINT_CENTRED_HORIZONTALLY:
             n = len(self._constrainedObjects)
             return changed
         elif self._constraintType == CONSTRAINT_CENTRED_HORIZONTALLY:
             n = len(self._constrainedObjects)
@@ -201,22 +199,22 @@ class Constraint(object):
                 totalObjectWidth += width2
 
             # Check if within the constraining object...
                 totalObjectWidth += width2
 
             # Check if within the constraining object...
-            if totalObjectWidth + (n + 1) * self._xSpacing<minWidth:
-                spacingX = (minWidth-totalObjectWidth) / (n + 1)
-                startX = x-minWidth / 2
+            if totalObjectWidth + (n + 1) * self._xSpacing <= minWidth:
+                spacingX = (minWidth - totalObjectWidth) / (n + 1.0)
+                startX = x - minWidth / 2.0
             else: # Otherwise, use default spacing
                 spacingX = self._xSpacing
             else: # Otherwise, use default spacing
                 spacingX = self._xSpacing
-                startX = x-(totalObjectWidth + (n + 1) * spacingX) / 2
+                startX = x - (totalObjectWidth + (n + 1) * spacingX) / 2.0
 
             # Now position the objects
             changed = False
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
 
             # Now position the objects
             changed = False
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
-                startX += spacingX + width2 / 2
+                startX += spacingX + width2 / 2.0
                 if not self.Equals(startX, constrainedObject.GetX()):
                     constrainedObject.Move(dc, startX, constrainedObject.GetY(), False)
                     changed = True
                 if not self.Equals(startX, constrainedObject.GetX()):
                     constrainedObject.Move(dc, startX, constrainedObject.GetY(), False)
                     changed = True
-                startX += width2 / 2
+                startX += width2 / 2.0
             return changed
         elif self._constraintType == CONSTRAINT_CENTRED_BOTH:
             n = len(self._constrainedObjects)
             return changed
         elif self._constraintType == CONSTRAINT_CENTRED_BOTH:
             n = len(self._constrainedObjects)
@@ -230,40 +228,40 @@ class Constraint(object):
 
             # Check if within the constraining object...
             if totalObjectHeight + (n + 1) * self._xSpacing <= minWidth:
 
             # Check if within the constraining object...
             if totalObjectHeight + (n + 1) * self._xSpacing <= minWidth:
-                spacingX = (minWidth-totalObjectWidth) / (n + 1)
-                startX = x-minWidth / 2
+                spacingX = (minWidth - totalObjectWidth) / (n + 1.0)
+                startX = x - minWidth / 2.0
             else: # Otherwise, use default spacing
                 spacingX = self._xSpacing
             else: # Otherwise, use default spacing
                 spacingX = self._xSpacing
-                startX = x-(totalObjectWidth + (n + 1) * spacingX) / 2
+                startX = x - (totalObjectWidth + (n + 1) * spacingX) / 2.0
 
             # Check if within the constraining object...
             if totalObjectHeight + (n + 1) * self._ySpacing <= minHeight:
 
             # Check if within the constraining object...
             if totalObjectHeight + (n + 1) * self._ySpacing <= minHeight:
-                spacingY = (minHeight-totalObjectHeight) / (n + 1)
-                startY = y-minHeight / 2
+                spacingY = (minHeight - totalObjectHeight) / (n + 1.0)
+                startY = y - minHeight / 2.0
             else: # Otherwise, use default spacing
                 spacingY = self._ySpacing
             else: # Otherwise, use default spacing
                 spacingY = self._ySpacing
-                startY = y-(totalObjectHeight + (n + 1) * spacingY) / 2
+                startY = y - (totalObjectHeight + (n + 1) * spacingY) / 2.0
 
             # Now position the objects
             changed = False
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
 
             # Now position the objects
             changed = False
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
-                startX += spacingX + width2 / 2
-                startY += spacingY + height2 / 2
+                startX += spacingX + width2 / 2.0
+                startY += spacingY + height2 / 2.0
 
                 if not self.Equals(startX, constrainedObject.GetX()) or not self.Equals(startY, constrainedObject.GetY()):
                     constrainedObject.Move(dc, startX, startY, False)
                     changed = True
 
 
                 if not self.Equals(startX, constrainedObject.GetX()) or not self.Equals(startY, constrainedObject.GetY()):
                     constrainedObject.Move(dc, startX, startY, False)
                     changed = True
 
-                startX += width2 / 2
-                startY += height2 / 2
+                startX += width2 / 2.0
+                startY += height2 / 2.0
             return changed
         elif self._constraintType == CONSTRAINT_LEFT_OF:
             changed = False
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
 
             return changed
         elif self._constraintType == CONSTRAINT_LEFT_OF:
             changed = False
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
 
-                x3 = x-minWidth / 2-width2 / 2-self._xSpacing
+                x3 = x - minWidth / 2.0 - width2 / 2.0 - self._xSpacing
                 if not self.Equals(x3, constrainedObject.GetX()):
                     changed = True
                     constrainedObject.Move(dc, x3, constrainedObject.GetY(), False)
                 if not self.Equals(x3, constrainedObject.GetX()):
                     changed = True
                     constrainedObject.Move(dc, x3, constrainedObject.GetY(), False)
@@ -273,7 +271,7 @@ class Constraint(object):
 
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
 
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
-                x3 = x + minWidth / 2 + width2 / 2 + self._xSpacing
+                x3 = x + minWidth / 2.0 + width2 / 2.0 + self._xSpacing
                 if not self.Equals(x3, constrainedObject.GetX()):
                     constrainedObject.Move(dc, x3, constrainedObject.GetY(), False)
                     changed = True
                 if not self.Equals(x3, constrainedObject.GetX()):
                     constrainedObject.Move(dc, x3, constrainedObject.GetY(), False)
                     changed = True
@@ -284,7 +282,7 @@ class Constraint(object):
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
 
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
 
-                y3 = y-minHeight / 2-height2 / 2-self._ySpacing
+                y3 = y - minHeight / 2.0 - height2 / 2.0 - self._ySpacing
                 if not self.Equals(y3, constrainedObject.GetY()):
                     changed = True
                     constrainedObject.Move(dc, constrainedObject.GetX(), y3, False)
                 if not self.Equals(y3, constrainedObject.GetY()):
                     changed = True
                     constrainedObject.Move(dc, constrainedObject.GetX(), y3, False)
@@ -295,7 +293,7 @@ class Constraint(object):
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
 
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
 
-                y3 = y + minHeight / 2 + height2 / 2 + self._ySpacing
+                y3 = y + minHeight / 2.0 + height2 / 2.0 + self._ySpacing
                 if not self.Equals(y3, constrainedObject.GetY()):
                     changed = True
                     constrainedObject.Move(dc, constrainedObject.GetX(), y3, False)
                 if not self.Equals(y3, constrainedObject.GetY()):
                     changed = True
                     constrainedObject.Move(dc, constrainedObject.GetX(), y3, False)
@@ -304,7 +302,7 @@ class Constraint(object):
             changed = False
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
             changed = False
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
-                x3 = x-minWidth / 2 + width2 / 2 + self._xSpacing
+                x3 = x - minWidth / 2.0 + width2 / 2.0 + self._xSpacing
                 if not self.Equals(x3, constrainedObject.GetX()):
                     changed = True
                     constrainedObject.Move(dc, x3, constrainedObject.GetY(), False)
                 if not self.Equals(x3, constrainedObject.GetX()):
                     changed = True
                     constrainedObject.Move(dc, x3, constrainedObject.GetY(), False)
@@ -313,7 +311,7 @@ class Constraint(object):
             changed = False
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
             changed = False
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
-                x3 = x + minWidth / 2-width2 / 2-self._xSpacing
+                x3 = x + minWidth / 2.0 - width2 / 2.0 - self._xSpacing
                 if not self.Equals(x3, constrainedObject.GetX()):
                     changed = True
                     constrainedObject.Move(dc, x3, constrainedObject.GetY(), False)
                 if not self.Equals(x3, constrainedObject.GetX()):
                     changed = True
                     constrainedObject.Move(dc, x3, constrainedObject.GetY(), False)
@@ -322,7 +320,7 @@ class Constraint(object):
             changed = False
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
             changed = False
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
-                y3 = y-minHeight / 2 + height2 / 2 + self._ySpacing
+                y3 = y -  minHeight / 2.0 + height2 / 2.0 + self._ySpacing
                 if not self.Equals(y3, constrainedObject.GetY()):
                     changed = True
                     constrainedObject.Move(dc, constrainedObject.GetX(), y3, False)
                 if not self.Equals(y3, constrainedObject.GetY()):
                     changed = True
                     constrainedObject.Move(dc, constrainedObject.GetX(), y3, False)
@@ -331,7 +329,7 @@ class Constraint(object):
             changed = False
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
             changed = False
             for constrainedObject in self._constrainedObjects:
                 width2, height2 = constrainedObject.GetBoundingBoxMax()
-                y3 = y + minHeight / 2-height2 / 2-self._ySpacing
+                y3 = y + minHeight / 2.0 - height2 / 2.0 - self._ySpacing
                 if not self.Equals(y3, constrainedObject.GetY()):
                     changed = True
                     constrainedObject.Move(dc, constrainedObject.GetX(), y3, False)
                 if not self.Equals(y3, constrainedObject.GetY()):
                     changed = True
                     constrainedObject.Move(dc, constrainedObject.GetX(), y3, False)
@@ -339,7 +337,7 @@ class Constraint(object):
         elif self._constraintType == CONSTRAINT_MIDALIGNED_LEFT:
             changed = False
             for constrainedObject in self._constrainedObjects:
         elif self._constraintType == CONSTRAINT_MIDALIGNED_LEFT:
             changed = False
             for constrainedObject in self._constrainedObjects:
-                x3 = x-minWidth / 2
+                x3 = x - minWidth / 2.0
                 if not self.Equals(x3, constrainedObject.GetX()):
                     changed = True
                     constrainedObject.Move(dc, x3, constrainedObject.GetY(), False)
                 if not self.Equals(x3, constrainedObject.GetX()):
                     changed = True
                     constrainedObject.Move(dc, x3, constrainedObject.GetY(), False)
@@ -347,7 +345,7 @@ class Constraint(object):
         elif self._constraintType == CONSTRAINT_MIDALIGNED_RIGHT:
             changed = False
             for constrainedObject in self._constrainedObjects:
         elif self._constraintType == CONSTRAINT_MIDALIGNED_RIGHT:
             changed = False
             for constrainedObject in self._constrainedObjects:
-                x3 = x + minWidth / 2
+                x3 = x + minWidth / 2.0
                 if not self.Equals(x3, constrainedObject.GetX()):
                     changed = True
                     constrainedObject.Move(dc, x3, constrainedObject.GetY(), False)
                 if not self.Equals(x3, constrainedObject.GetX()):
                     changed = True
                     constrainedObject.Move(dc, x3, constrainedObject.GetY(), False)
@@ -355,7 +353,7 @@ class Constraint(object):
         elif self._constraintType == CONSTRAINT_MIDALIGNED_TOP:
             changed = False
             for constrainedObject in self._constrainedObjects:
         elif self._constraintType == CONSTRAINT_MIDALIGNED_TOP:
             changed = False
             for constrainedObject in self._constrainedObjects:
-                y3 = y-minHeight / 2
+                y3 = y - minHeight / 2.0
                 if not self.Equals(y3, constrainedObject.GetY()):
                     changed = True
                     constrainedObject.Move(dc, constrainedObject.GetX(), y3, False)
                 if not self.Equals(y3, constrainedObject.GetY()):
                     changed = True
                     constrainedObject.Move(dc, constrainedObject.GetX(), y3, False)
@@ -363,7 +361,7 @@ class Constraint(object):
         elif self._constraintType == CONSTRAINT_MIDALIGNED_BOTTOM:
             changed = False
             for constrainedObject in self._constrainedObjects:
         elif self._constraintType == CONSTRAINT_MIDALIGNED_BOTTOM:
             changed = False
             for constrainedObject in self._constrainedObjects:
-                y3 = y + minHeight / 2
+                y3 = y + minHeight / 2.0
                 if not self.Equals(y3, constrainedObject.GetY()):
                     changed = True
                     constrainedObject.Move(dc, constrainedObject.GetX(), y3, False)
                 if not self.Equals(y3, constrainedObject.GetY()):
                     changed = True
                     constrainedObject.Move(dc, constrainedObject.GetX(), y3, False)
@@ -392,8 +390,8 @@ class CompositeShape(RectangleShape):
         self._divisions = [] # In case it's a container
         
     def OnDraw(self, dc):
         self._divisions = [] # In case it's a container
         
     def OnDraw(self, dc):
-        x1 = self._xpos-self._width / 2
-        y1 = self._ypos-self._height / 2
+        x1 = self._xpos - self._width / 2.0
+        y1 = self._ypos - self._height / 2.0
 
         if self._shadowMode != SHADOW_NONE:
             if self._shadowBrush:
 
         if self._shadowMode != SHADOW_NONE:
             if self._shadowBrush:
@@ -416,8 +414,8 @@ class CompositeShape(RectangleShape):
         Shape.OnDrawContents(self, dc)
 
     def OnMovePre(self, dc, x, y, old_x, old_y, display = True):
         Shape.OnDrawContents(self, dc)
 
     def OnMovePre(self, dc, x, y, old_x, old_y, display = True):
-        diffX = x-old_x
-        diffY = y-old_y
+        diffX = x - old_x
+        diffY = y - old_y
 
         for object in self._children:
             object.Erase(dc)
 
         for object in self._children:
             object.Erase(dc)
@@ -507,8 +505,8 @@ class CompositeShape(RectangleShape):
     def SetSize(self, w, h, recursive = True):
         self.SetAttachmentSize(w, h)
 
     def SetSize(self, w, h, recursive = True):
         self.SetAttachmentSize(w, h)
 
-        xScale = w / max(1, self.GetWidth())
-        yScale = h / max(1, self.GetHeight())
+        xScale = float(w) / max(1, self.GetWidth())
+        yScale = float(h) / max(1, self.GetHeight())
 
         self._width = w
         self._height = h
 
         self._width = w
         self._height = h
@@ -521,8 +519,8 @@ class CompositeShape(RectangleShape):
 
         for object in self._children:
             # Scale the position first
 
         for object in self._children:
             # Scale the position first
-            newX = (object.GetX()-self.GetX()) * xScale + self.GetX()
-            newY = (object.GetY()-self.GetY()) * yScale + self.GetY()
+            newX = (object.GetX() - self.GetX()) * xScale + self.GetX()
+            newY = (object.GetY() - self.GetY()) * yScale + self.GetY()
             object.Show(False)
             object.Move(dc, newX, newY)
             object.Show(True)
             object.Show(False)
             object.Move(dc, newX, newY)
             object.Show(True)
@@ -628,8 +626,8 @@ class CompositeShape(RectangleShape):
         """Calculates the size and position of the composite based on
         child sizes and positions.
         """
         """Calculates the size and position of the composite based on
         child sizes and positions.
         """
-        maxX=-999999.9
-        maxY=-999999.9
+        maxX = -999999.9
+        maxY = -999999.9
         minX = 999999.9
         minY = 999999.9
 
         minX = 999999.9
         minY = 999999.9
 
@@ -640,19 +638,19 @@ class CompositeShape(RectangleShape):
                 child.CalculateSize()
 
             w, h = child.GetBoundingBoxMax()
                 child.CalculateSize()
 
             w, h = child.GetBoundingBoxMax()
-            if child.GetX() + w / 2>maxX:
-                maxX = child.GetX() + w / 2
-            if child.GetX()-w / 2<minX:
-                minX = child.GetX()-w / 2
-            if child.GetY() + h / 2>maxY:
-                maxY = child.GetY() + h / 2
-            if child.GetY()-h / 2<minY:
-                minY = child.GetY()-h / 2
-
-        self._width = maxX-minX
-        self._height = maxY-minY
-        self._xpos = self._width / 2 + minX
-        self._ypos = self._height / 2 + minY
+            if child.GetX() + w / 2.0 > maxX:
+                maxX = child.GetX() + w / 2.0
+            if child.GetX() - w / 2.0 < minX:
+                minX = child.GetX() - w / 2.0
+            if child.GetY() + h / 2.0 > maxY:
+                maxY = child.GetY() + h / 2.0
+            if child.GetY() - h / 2.0 < minY:
+                minY = child.GetY() - h / 2.0
+
+        self._width = maxX - minX
+        self._height = maxY - minY
+        self._xpos = self._width / 2.0 + minX
+        self._ypos = self._height / 2.0 + minY
 
     def Recompute(self):
         """Recomputes any constraints associated with the object. If FALSE is
 
     def Recompute(self):
         """Recomputes any constraints associated with the object. If FALSE is
@@ -661,7 +659,7 @@ class CompositeShape(RectangleShape):
         """
         noIterations = 0
         changed = True
         """
         noIterations = 0
         changed = True
-        while changed and noIterations<500:
+        while changed and noIterations < 500:
             changed = self.Constrain()
             noIterations += 1
 
             changed = self.Constrain()
             noIterations += 1
 
@@ -783,17 +781,17 @@ class DivisionControlPoint(ControlPoint):
         divisionParent = division.GetParent()
 
         # Need to check it's within the bounds of the parent composite
         divisionParent = division.GetParent()
 
         # Need to check it's within the bounds of the parent composite
-        x1 = divisionParent.GetX()-divisionParent.GetWidth() / 2
-        y1 = divisionParent.GetY()-divisionParent.GetHeight() / 2
-        x2 = divisionParent.GetX() + divisionParent.GetWidth() / 2
-        y2 = divisionParent.GetY() + divisionParent.GetHeight() / 2
+        x1 = divisionParent.GetX() - divisionParent.GetWidth() / 2.0
+        y1 = divisionParent.GetY() - divisionParent.GetHeight() / 2.0
+        x2 = divisionParent.GetX() + divisionParent.GetWidth() / 2.0
+        y2 = divisionParent.GetY() + divisionParent.GetHeight() / 2.0
 
         # Need to check it has not made the division zero or negative
         # width / height
 
         # Need to check it has not made the division zero or negative
         # width / height
-        dx1 = division.GetX()-division.GetWidth() / 2
-        dy1 = division.GetY()-division.GetHeight() / 2
-        dx2 = division.GetX() + division.GetWidth() / 2
-        dy2 = division.GetY() + division.GetHeight() / 2
+        dx1 = division.GetX() - division.GetWidth() / 2.0
+        dy1 = division.GetY() - division.GetHeight() / 2.0
+        dx2 = division.GetX() + division.GetWidth() / 2.0
+        dy2 = division.GetY() + division.GetHeight() / 2.0
 
         success = True
         if division.GetHandleSide() == DIVISION_SIDE_LEFT:
 
         success = True
         if division.GetHandleSide() == DIVISION_SIDE_LEFT:
@@ -895,10 +893,10 @@ class DivisionShape(CompositeShape):
         self._handleSide = DIVISION_SIDE_NONE
         self._leftSidePen = wx.BLACK_PEN
         self._topSidePen = wx.BLACK_PEN
         self._handleSide = DIVISION_SIDE_NONE
         self._leftSidePen = wx.BLACK_PEN
         self._topSidePen = wx.BLACK_PEN
-        self._leftSideColour="BLACK"
-        self._topSideColour="BLACK"
-        self._leftSideStyle="Solid"
-        self._topSideStyle="Solid"
+        self._leftSideColour = "BLACK"
+        self._topSideColour = "BLACK"
+        self._leftSideStyle = "Solid"
+        self._topSideStyle = "Solid"
         self.ClearRegions()
 
     def SetLeftSide(self, shape):
         self.ClearRegions()
 
     def SetLeftSide(self, shape):
@@ -994,13 +992,13 @@ class DivisionShape(CompositeShape):
         dc.SetBrush(wx.TRANSPARENT_BRUSH)
         dc.SetBackgroundMode(wx.TRANSPARENT)
 
         dc.SetBrush(wx.TRANSPARENT_BRUSH)
         dc.SetBackgroundMode(wx.TRANSPARENT)
 
-        x1 = self.GetX()-self.GetWidth() / 2
-        y1 = self.GetY()-self.GetHeight() / 2
-        x2 = self.GetX() + self.GetWidth() / 2
-        y2 = self.GetY() + self.GetHeight() / 2
+        x1 = self.GetX() - self.GetWidth() / 2.0
+        y1 = self.GetY() - self.GetHeight() / 2.0
+        x2 = self.GetX() + self.GetWidth() / 2.0
+        y2 = self.GetY() + self.GetHeight() / 2.0
 
         # Should subtract 1 pixel if drawing under Windows
 
         # Should subtract 1 pixel if drawing under Windows
-        if sys.platform[:3]=="win":
+        if sys.platform[:3] == "win":
             y2 -= 1
 
         if self._leftSide:
             y2 -= 1
 
         if self._leftSide:
@@ -1020,8 +1018,8 @@ class DivisionShape(CompositeShape):
         CompositeShape.OnDrawContents(self, dc)
 
     def OnMovePre(self, dc, x, y, oldx, oldy, display = True):
         CompositeShape.OnDrawContents(self, dc)
 
     def OnMovePre(self, dc, x, y, oldx, oldy, display = True):
-        diffX = x-oldx
-        diffY = y-oldy
+        diffX = x - oldx
+        diffY = y - oldy
         for object in self._children:
             object.Erase(dc)
             object.Move(dc, object.GetX() + diffX, object.GetY() + diffY, display)
         for object in self._children:
             object.Erase(dc)
             object.Move(dc, object.GetX() + diffX, object.GetY() + diffY, display)
@@ -1100,8 +1098,8 @@ class DivisionShape(CompositeShape):
         vertically (direction is wxVERTICAL).
         """
         # Calculate existing top-left, bottom-right
         vertically (direction is wxVERTICAL).
         """
         # Calculate existing top-left, bottom-right
-        x1 = self.GetX()-self.GetWidth() / 2
-        y1 = self.GetY()-self.GetHeight() / 2
+        x1 = self.GetX() - self.GetWidth() / 2.0
+        y1 = self.GetY() - self.GetHeight() / 2.0
 
         compositeParent = self.GetParent()
         oldWidth = self.GetWidth()
 
         compositeParent = self.GetParent()
         oldWidth = self.GetWidth()
@@ -1117,9 +1115,9 @@ class DivisionShape(CompositeShape):
             # line through it.
             # Break existing piece into two.
             newXPos1 = self.GetX()
             # line through it.
             # Break existing piece into two.
             newXPos1 = self.GetX()
-            newYPos1 = y1 + self.GetHeight() / 4
+            newYPos1 = y1 + self.GetHeight() / 4.0
             newXPos2 = self.GetX()
             newXPos2 = self.GetX()
-            newYPos2 = y1 + 3 * self.GetHeight() / 4
+            newYPos2 = y1 + 3 * self.GetHeight() / 4.0
             newDivision = compositeParent.OnCreateDivision()
             newDivision.Show(True)
 
             newDivision = compositeParent.OnCreateDivision()
             newDivision.Show(True)
 
@@ -1153,18 +1151,18 @@ class DivisionShape(CompositeShape):
             self._handleSide = DIVISION_SIDE_BOTTOM
             newDivision.SetHandleSide(DIVISION_SIDE_TOP)
 
             self._handleSide = DIVISION_SIDE_BOTTOM
             newDivision.SetHandleSide(DIVISION_SIDE_TOP)
 
-            self.SetSize(oldWidth, oldHeight / 2)
+            self.SetSize(oldWidth, oldHeight / 2.0)
             self.Move(dc, newXPos1, newYPos1)
 
             self.Move(dc, newXPos1, newYPos1)
 
-            newDivision.SetSize(oldWidth, oldHeight / 2)
+            newDivision.SetSize(oldWidth, oldHeight / 2.0)
             newDivision.Move(dc, newXPos2, newYPos2)
         else:
             # Dividing horizontally means notionally putting a vertical line
             # through it.
             # Break existing piece into two.
             newDivision.Move(dc, newXPos2, newYPos2)
         else:
             # Dividing horizontally means notionally putting a vertical line
             # through it.
             # Break existing piece into two.
-            newXPos1 = x1 + self.GetWidth() / 4
+            newXPos1 = x1 + self.GetWidth() / 4.0
             newYPos1 = self.GetY()
             newYPos1 = self.GetY()
-            newXPos2 = x1 + 3 * self.GetWidth() / 4
+            newXPos2 = x1 + 3 * self.GetWidth() / 4.0
             newYPos2 = self.GetY()
             newDivision = compositeParent.OnCreateDivision()
             newDivision.Show(True)
             newYPos2 = self.GetY()
             newDivision = compositeParent.OnCreateDivision()
             newDivision.Show(True)
@@ -1189,10 +1187,10 @@ class DivisionShape(CompositeShape):
             self._handleSide = DIVISION_SIDE_RIGHT
             newDivision.SetHandleSide(DIVISION_SIDE_LEFT)
 
             self._handleSide = DIVISION_SIDE_RIGHT
             newDivision.SetHandleSide(DIVISION_SIDE_LEFT)
 
-            self.SetSize(oldWidth / 2, oldHeight)
+            self.SetSize(oldWidth / 2.0, oldHeight)
             self.Move(dc, newXPos1, newYPos1)
 
             self.Move(dc, newXPos1, newYPos1)
 
-            newDivision.SetSize(oldWidth / 2, oldHeight)
+            newDivision.SetSize(oldWidth / 2.0, oldHeight)
             newDivision.Move(dc, newXPos2, newYPos2)
 
         if compositeParent.Selected():
             newDivision.Move(dc, newXPos2, newYPos2)
 
         if compositeParent.Selected():
@@ -1212,16 +1210,16 @@ class DivisionShape(CompositeShape):
         direction = 0
 
         if self._handleSide == DIVISION_SIDE_LEFT:
         direction = 0
 
         if self._handleSide == DIVISION_SIDE_LEFT:
-            x=-maxX / 2
+            x = -maxX / 2.0
             direction = CONTROL_POINT_HORIZONTAL
         elif self._handleSide == DIVISION_SIDE_TOP:
             direction = CONTROL_POINT_HORIZONTAL
         elif self._handleSide == DIVISION_SIDE_TOP:
-            y=-maxY / 2
+            y = -maxY / 2.0
             direction = CONTROL_POINT_VERTICAL
         elif self._handleSide == DIVISION_SIDE_RIGHT:
             direction = CONTROL_POINT_VERTICAL
         elif self._handleSide == DIVISION_SIDE_RIGHT:
-            x = maxX / 2
+            x = maxX / 2.0
             direction = CONTROL_POINT_HORIZONTAL
         elif self._handleSide == DIVISION_SIDE_BOTTOM:
             direction = CONTROL_POINT_HORIZONTAL
         elif self._handleSide == DIVISION_SIDE_BOTTOM:
-            y = maxY / 2
+            y = maxY / 2.0
             direction = CONTROL_POINT_VERTICAL
 
         if self._handleSide != DIVISION_SIDE_NONE:
             direction = CONTROL_POINT_VERTICAL
 
         if self._handleSide != DIVISION_SIDE_NONE:
@@ -1241,20 +1239,20 @@ class DivisionShape(CompositeShape):
         node = self._controlPoints[0]
 
         if self._handleSide == DIVISION_SIDE_LEFT and node:
         node = self._controlPoints[0]
 
         if self._handleSide == DIVISION_SIDE_LEFT and node:
-            node._xoffset=-maxX / 2
+            node._xoffset = -maxX / 2.0
             node._yoffset = 0.0
 
         if self._handleSide == DIVISION_SIDE_TOP and node:
             node._xoffset = 0.0
             node._yoffset = 0.0
 
         if self._handleSide == DIVISION_SIDE_TOP and node:
             node._xoffset = 0.0
-            node._yoffset=-maxY / 2
+            node._yoffset = -maxY / 2.0
 
         if self._handleSide == DIVISION_SIDE_RIGHT and node:
 
         if self._handleSide == DIVISION_SIDE_RIGHT and node:
-            node._xoffset = maxX / 2
+            node._xoffset = maxX / 2.0
             node._yoffset = 0.0
 
         if self._handleSide == DIVISION_SIDE_BOTTOM and node:
             node._xoffset = 0.0
             node._yoffset = 0.0
 
         if self._handleSide == DIVISION_SIDE_BOTTOM and node:
             node._xoffset = 0.0
-            node._yoffset = maxY / 2
+            node._yoffset = maxY / 2.0
 
     def AdjustLeft(self, left, test):
         """Adjust a side.
 
     def AdjustLeft(self, left, test):
         """Adjust a side.
@@ -1262,7 +1260,7 @@ class DivisionShape(CompositeShape):
         Returns FALSE if it's not physically possible to adjust it to
         this point.
         """
         Returns FALSE if it's not physically possible to adjust it to
         this point.
         """
-        x2 = self.GetX() + self.GetWidth() / 2
+        x2 = self.GetX() + self.GetWidth() / 2.0
 
         if left >= x2:
             return False
 
         if left >= x2:
             return False
@@ -1270,8 +1268,8 @@ class DivisionShape(CompositeShape):
         if test:
             return True
 
         if test:
             return True
 
-        newW = x2-left
-        newX = left + newW / 2
+        newW = x2 - left
+        newX = left + newW / 2.0
         self.SetSize(newW, self.GetHeight())
 
         dc = wx.ClientDC(self.GetCanvas())
         self.SetSize(newW, self.GetHeight())
 
         dc = wx.ClientDC(self.GetCanvas())
@@ -1286,7 +1284,7 @@ class DivisionShape(CompositeShape):
         Returns FALSE if it's not physically possible to adjust it to
         this point.
         """
         Returns FALSE if it's not physically possible to adjust it to
         this point.
         """
-        y2 = self.GetY() + self.GetHeight() / 2
+        y2 = self.GetY() + self.GetHeight() / 2.0
 
         if top >= y2:
             return False
 
         if top >= y2:
             return False
@@ -1294,8 +1292,8 @@ class DivisionShape(CompositeShape):
         if test:
             return True
 
         if test:
             return True
 
-        newH = y2-top
-        newY = top + newH / 2
+        newH = y2 - top
+        newY = top + newH / 2.0
         self.SetSize(self.GetWidth(), newH)
 
         dc = wx.ClientDC(self.GetCanvas())
         self.SetSize(self.GetWidth(), newH)
 
         dc = wx.ClientDC(self.GetCanvas())
@@ -1310,7 +1308,7 @@ class DivisionShape(CompositeShape):
         Returns FALSE if it's not physically possible to adjust it to
         this point.
         """
         Returns FALSE if it's not physically possible to adjust it to
         this point.
         """
-        x1 = self.GetX()-self.GetWidth() / 2
+        x1 = self.GetX() - self.GetWidth() / 2.0
 
         if right <= x1:
             return False
 
         if right <= x1:
             return False
@@ -1318,8 +1316,8 @@ class DivisionShape(CompositeShape):
         if test:
             return True
 
         if test:
             return True
 
-        newW = right-x1
-        newX = x1 + newW / 2
+        newW = right - x1
+        newX = x1 + newW / 2.0
         self.SetSize(newW, self.GetHeight())
 
         dc = wx.ClientDC(self.GetCanvas())
         self.SetSize(newW, self.GetHeight())
 
         dc = wx.ClientDC(self.GetCanvas())
@@ -1334,7 +1332,7 @@ class DivisionShape(CompositeShape):
         Returns FALSE if it's not physically possible to adjust it to
         this point.
         """
         Returns FALSE if it's not physically possible to adjust it to
         this point.
         """
-        y1 = self.GetY()-self.GetHeight() / 2
+        y1 = self.GetY() - self.GetHeight() / 2.0
 
         if bottom <= y1:
             return False
 
         if bottom <= y1:
             return False
@@ -1342,8 +1340,8 @@ class DivisionShape(CompositeShape):
         if test:
             return True
 
         if test:
             return True
 
-        newH = bottom-y1
-        newY = y1 + newH / 2
+        newH = bottom - y1
+        newY = y1 + newH / 2.0
         self.SetSize(self.GetWidth(), newH)
 
         dc = wx.ClientDC(self.GetCanvas())
         self.SetSize(self.GetWidth(), newH)
 
         dc = wx.ClientDC(self.GetCanvas())
@@ -1422,8 +1420,8 @@ class DivisionShape(CompositeShape):
         dc = wx.ClientDC(self.GetCanvas())
         self.GetCanvas().PrepareDC(dc)
 
         dc = wx.ClientDC(self.GetCanvas())
         self.GetCanvas().PrepareDC(dc)
 
-        mouse_x = dc.LogicalToDeviceX(x-x1 * unit_x)
-        mouse_y = dc.LogicalToDeviceY(y-y1 * unit_y)
+        mouse_x = dc.LogicalToDeviceX(x - x1 * unit_x)
+        mouse_y = dc.LogicalToDeviceY(y - y1 * unit_y)
 
         self._canvas.PopupMenu(menu, (mouse_x, mouse_y))
 
 
         self._canvas.PopupMenu(menu, (mouse_x, mouse_y))
 
index 95ef272206fa00736e805a1999481bc351f9bc4a..a89bda3e95b2a620130147fdd2e859cd42cde028 100644 (file)
@@ -11,8 +11,6 @@
 # Licence:      wxWindows license
 #----------------------------------------------------------------------------
 
 # Licence:      wxWindows license
 #----------------------------------------------------------------------------
 
-from __future__ import division
-
 import wx
 
 DEFAULT_MOUSE_TOLERANCE = 3
 import wx
 
 DEFAULT_MOUSE_TOLERANCE = 3
index 9d5822229c618c6e24a3aff26e2648d03eeee484..7ea907d9abc84c801e324ee2f520e84abae6a6c6 100644 (file)
@@ -11,8 +11,6 @@
 # Licence:      wxWindows license
 #----------------------------------------------------------------------------
 
 # Licence:      wxWindows license
 #----------------------------------------------------------------------------
 
-from __future__ import division
-
 import sys
 import wx
 
 import sys
 import wx
 
@@ -37,9 +35,9 @@ class DividedShapeControlPoint(ControlPoint):
         dc.SetBrush(wx.TRANSPARENT_BRUSH)
 
         dividedObject = self._shape
         dc.SetBrush(wx.TRANSPARENT_BRUSH)
 
         dividedObject = self._shape
-        x1 = dividedObject.GetX()-dividedObject.GetWidth() / 2
+        x1 = dividedObject.GetX() - dividedObject.GetWidth() / 2.0
         y1 = y
         y1 = y
-        x2 = dividedObject.GetX() + dividedObject.GetWidth() / 2
+        x2 = dividedObject.GetX() + dividedObject.GetWidth() / 2.0
         y2 = y
 
         dc.DrawLine(x1, y1, x2, y2)
         y2 = y
 
         dc.DrawLine(x1, y1, x2, y2)
@@ -55,9 +53,9 @@ class DividedShapeControlPoint(ControlPoint):
 
         dividedObject = self._shape
         
 
         dividedObject = self._shape
         
-        x1 = dividedObject.GetX()-dividedObject.GetWidth() / 2
+        x1 = dividedObject.GetX() - dividedObject.GetWidth() / 2.0
         y1 = y
         y1 = y
-        x2 = dividedObject.GetX() + dividedObject.GetWidth() / 2
+        x2 = dividedObject.GetX() + dividedObject.GetWidth() / 2.0
         y2 = y
 
         dc.DrawLine(x1, y1, x2, y2)
         y2 = y
 
         dc.DrawLine(x1, y1, x2, y2)
@@ -82,8 +80,8 @@ class DividedShapeControlPoint(ControlPoint):
         # Find the old top and bottom of this region,
         # and calculate the new proportion for this region
         # if legal.
         # Find the old top and bottom of this region,
         # and calculate the new proportion for this region
         # if legal.
-        currentY = dividedObject.GetY()-dividedObject.GetHeight() / 2
-        maxY = dividedObject.GetY() + dividedObject.GetHeight() / 2
+        currentY = dividedObject.GetY() - dividedObject.GetHeight() / 2.0
+        maxY = dividedObject.GetY() + dividedObject.GetHeight() / 2.0
 
         # Save values
         theRegionTop = 0
 
         # Save values
         theRegionTop = 0
@@ -98,7 +96,7 @@ class DividedShapeControlPoint(ControlPoint):
             if region == thisRegion:
                 thisRegionTop = currentY
                 
             if region == thisRegion:
                 thisRegionTop = currentY
                 
-                if i + 1<len(dividedObject.GetRegions()):
+                if i + 1 < len(dividedObject.GetRegions()):
                     nextRegion = dividedObject.GetRegions()[i + 1]
             if region == nextRegion:
                 nextRegionBottom = actualY
                     nextRegion = dividedObject.GetRegions()[i + 1]
             if region == nextRegion:
                 nextRegionBottom = actualY
@@ -116,12 +114,12 @@ class DividedShapeControlPoint(ControlPoint):
         dividedObject.EraseLinks(dc)
 
         # Now calculate the new proportions of this region and the next region
         dividedObject.EraseLinks(dc)
 
         # Now calculate the new proportions of this region and the next region
-        thisProportion = (y-thisRegionTop) / dividedObject.GetHeight()
-        nextProportion = (nextRegionBottom-y) / dividedObject.GetHeight()
+        thisProportion = float(y - thisRegionTop) / dividedObject.GetHeight()
+        nextProportion = float(nextRegionBottom - y) / dividedObject.GetHeight()
 
         thisRegion.SetProportions(0, thisProportion)
         nextRegion.SetProportions(0, nextProportion)
 
         thisRegion.SetProportions(0, thisProportion)
         nextRegion.SetProportions(0, nextProportion)
-        self._yoffset = y-dividedObject.GetY()
+        self._yoffset = y - dividedObject.GetY()
 
         # Now reformat text
         for i, region in enumerate(dividedObject.GetRegions()):
 
         # Now reformat text
         for i, region in enumerate(dividedObject.GetRegions()):
@@ -152,14 +150,14 @@ class DividedShape(RectangleShape):
 
     def OnDrawContents(self, dc):
         if self.GetRegions():
 
     def OnDrawContents(self, dc):
         if self.GetRegions():
-            defaultProportion = 1 / len(self.GetRegions())
+            defaultProportion = 1.0 / len(self.GetRegions())
         else:
         else:
-            defaultProportion = 0
-        currentY = self._ypos-self._height / 2
-        maxY = self._ypos + self._height / 2
+            defaultProportion = 0.0
+        currentY = self._ypos - self._height / 2.0
+        maxY = self._ypos + self._height / 2.0
 
 
-        leftX = self._xpos-self._width / 2
-        rightX = self._xpos + self._width / 2
+        leftX = self._xpos - self._width / 2.0
+        rightX = self._xpos + self._width / 2.0
 
         if self._pen:
             dc.SetPen(self._pen)
 
         if self._pen:
             dc.SetPen(self._pen)
@@ -168,7 +166,7 @@ class DividedShape(RectangleShape):
 
         # For efficiency, don't do this under X - doesn't make
         # any visible difference for our purposes.
 
         # For efficiency, don't do this under X - doesn't make
         # any visible difference for our purposes.
-        if sys.platform[:3]=="win":
+        if sys.platform[:3] == "win":
             dc.SetTextBackground(self._brush.GetColour())
 
         if self.GetDisableLabel():
             dc.SetTextBackground(self._brush.GetColour())
 
         if self.GetDisableLabel():
@@ -183,7 +181,7 @@ class DividedShape(RectangleShape):
             dc.SetFont(region.GetFont())
             dc.SetTextForeground(region.GetActualColourObject())
 
             dc.SetFont(region.GetFont())
             dc.SetTextForeground(region.GetActualColourObject())
 
-            if region._regionProportionY<0:
+            if region._regionProportionY < 0:
                 proportion = defaultProportion
             else:
                 proportion = region._regionProportionY
                 proportion = defaultProportion
             else:
                 proportion = region._regionProportionY
@@ -192,9 +190,9 @@ class DividedShape(RectangleShape):
             actualY = min(maxY, y)
 
             centreX = self._xpos
             actualY = min(maxY, y)
 
             centreX = self._xpos
-            centreY = currentY + (actualY-currentY) / 2
+            centreY = currentY + (actualY - currentY) / 2.0
 
 
-            DrawFormattedText(dc, region._formattedText, centreX, centreY, self._width-2 * xMargin, actualY-currentY-2 * yMargin, region._formatMode)
+            DrawFormattedText(dc, region._formattedText, centreX, centreY, self._width - 2 * xMargin, actualY - currentY - 2 * yMargin, region._formatMode)
 
             if y <= maxY and region != self.GetRegions()[-1]:
                 regionPen = region.GetActualPen()
 
             if y <= maxY and region != self.GetRegions()[-1]:
                 regionPen = region.GetActualPen()
@@ -218,11 +216,11 @@ class DividedShape(RectangleShape):
             return
 
         if self.GetRegions():
             return
 
         if self.GetRegions():
-            defaultProportion = 1 / len(self.GetRegions())
+            defaultProportion = 1.0 / len(self.GetRegions())
         else:
         else:
-            defaultProportion = 0
-        currentY = self._ypos-self._height / 2
-        maxY = self._ypos + self._height / 2
+            defaultProportion = 0.0
+        currentY = self._ypos - self._height / 2.0
+        maxY = self._ypos + self._height / 2.0
         
         for region in self.GetRegions():
             if region._regionProportionY <= 0:
         
         for region in self.GetRegions():
             if region._regionProportionY <= 0:
@@ -234,10 +232,10 @@ class DividedShape(RectangleShape):
             y = currentY + sizeY
             actualY = min(maxY, y)
 
             y = currentY + sizeY
             actualY = min(maxY, y)
 
-            centreY = currentY + (actualY-currentY) / 2
+            centreY = currentY + (actualY - currentY) / 2.0
 
             region.SetSize(self._width, sizeY)
 
             region.SetSize(self._width, sizeY)
-            region.SetPosition(0, centreY-self._ypos)
+            region.SetPosition(0, centreY - self._ypos)
 
             currentY = actualY
 
 
             currentY = actualY
 
@@ -250,10 +248,10 @@ class DividedShape(RectangleShape):
         n = len(self.GetRegions())
         isEnd = line and line.IsEnd(self)
 
         n = len(self.GetRegions())
         isEnd = line and line.IsEnd(self)
 
-        left = self._xpos-self._width / 2
-        right = self._xpos + self._width / 2
-        top = self._ypos-self._height / 2
-        bottom = self._ypos + self._height / 2
+        left = self._xpos - self._width / 2.0
+        right = self._xpos + self._width / 2.0
+        top = self._ypos - self._height / 2.0
+        bottom = self._ypos + self._height / 2.0
 
         # Zero is top, n + 1 is bottom
         if attachment == 0:
 
         # Zero is top, n + 1 is bottom
         if attachment == 0:
@@ -262,14 +260,14 @@ class DividedShape(RectangleShape):
                 if line and line.GetAlignmentType(isEnd) == LINE_ALIGNMENT_TO_NEXT_HANDLE:
                     # Align line according to the next handle along
                     point = line.GetNextControlPoint(self)
                 if line and line.GetAlignmentType(isEnd) == LINE_ALIGNMENT_TO_NEXT_HANDLE:
                     # Align line according to the next handle along
                     point = line.GetNextControlPoint(self)
-                    if point.x<left:
+                    if point.x < left:
                         x = left
                         x = left
-                    elif point.x>right:
+                    elif point.x > right:
                         x = right
                     else:
                         x = point.x
                 else:
                         x = right
                     else:
                         x = point.x
                 else:
-                    x = left + (nth + 1) * self._width / (no_arcs + 1)
+                    x = left + (nth + 1) * self._width / (no_arcs + 1.0)
             else:
                 x = self._xpos
         elif attachment == n + 1:
             else:
                 x = self._xpos
         elif attachment == n + 1:
@@ -278,22 +276,22 @@ class DividedShape(RectangleShape):
                 if line and line.GetAlignmentType(isEnd) == LINE_ALIGNMENT_TO_NEXT_HANDLE:
                     # Align line according to the next handle along
                     point = line.GetNextControlPoint(self)
                 if line and line.GetAlignmentType(isEnd) == LINE_ALIGNMENT_TO_NEXT_HANDLE:
                     # Align line according to the next handle along
                     point = line.GetNextControlPoint(self)
-                    if point.x<left:
+                    if point.x < left:
                         x = left
                         x = left
-                    elif point.x>right:
+                    elif point.x > right:
                         x = right
                     else:
                         x = point.x
                 else:
                         x = right
                     else:
                         x = point.x
                 else:
-                    x = left + (nth + 1) * self._width / (no_arcs + 1)
+                    x = left + (nth + 1) * self._width / (no_arcs + 1.0)
             else:
                 x = self._xpos
         else: # Left or right
             else:
                 x = self._xpos
         else: # Left or right
-            isLeft = not attachment<(n + 1)
+            isLeft = not attachment < (n + 1)
             if isLeft:
             if isLeft:
-                i = totalNumberAttachments-attachment-1
+                i = totalNumberAttachments - attachment - 1
             else:
             else:
-                i = attachment-1
+                i = attachment - 1
 
             region = self.GetRegions()[i]
             if region:
 
             region = self.GetRegions()[i]
             if region:
@@ -303,8 +301,8 @@ class DividedShape(RectangleShape):
                     x = right
 
                 # Calculate top and bottom of region
                     x = right
 
                 # Calculate top and bottom of region
-                top = self._ypos + region._y-region._height / 2
-                bottom = self._ypos + region._y + region._height / 2
+                top = self._ypos + region._y - region._height / 2.0
+                bottom = self._ypos + region._y + region._height / 2.0
 
                 # Assuming we can trust the absolute size and
                 # position of these regions
 
                 # Assuming we can trust the absolute size and
                 # position of these regions
@@ -312,14 +310,14 @@ class DividedShape(RectangleShape):
                     if line and line.GetAlignmentType(isEnd) == LINE_ALIGNMENT_TO_NEXT_HANDLE:
                         # Align line according to the next handle along
                         point = line.GetNextControlPoint(self)
                     if line and line.GetAlignmentType(isEnd) == LINE_ALIGNMENT_TO_NEXT_HANDLE:
                         # Align line according to the next handle along
                         point = line.GetNextControlPoint(self)
-                        if point.y<bottom:
+                        if point.y < bottom:
                             y = bottom
                             y = bottom
-                        elif point.y>top:
+                        elif point.y > top:
                             y = top
                         else:
                             y = point.y
                     else:
                             y = top
                         else:
                             y = point.y
                     else:
-                        y = top + (nth + 1) * region._height / (no_arcs + 1)
+                        y = top + (nth + 1) * region._height / (no_arcs + 1.0)
                 else:
                     y = self._ypos + region._y
             else:
                 else:
                     y = self._ypos + region._y
             else:
@@ -331,9 +329,9 @@ class DividedShape(RectangleShape):
         # plus one on the top and one on the bottom.
         n = len(self.GetRegions()) * 2 + 2
 
         # plus one on the top and one on the bottom.
         n = len(self.GetRegions()) * 2 + 2
 
-        maxN = n-1
+        maxN = n - 1
         for point in self._attachmentPoints:
         for point in self._attachmentPoints:
-            if point._id>maxN:
+            if point._id > maxN:
                 maxN = point._id
 
         return maxN + 1
                 maxN = point._id
 
         return maxN + 1
@@ -350,8 +348,8 @@ class DividedShape(RectangleShape):
         self.MakeMandatoryControlPoints()
 
     def MakeMandatoryControlPoints(self):
         self.MakeMandatoryControlPoints()
 
     def MakeMandatoryControlPoints(self):
-        currentY = self.GetY()-self._height / 2
-        maxY = self.GetY() + self._height / 2
+        currentY = self.GetY() - self._height / 2.0
+        maxY = self.GetY() + self._height / 2.0
 
         for i, region in enumerate(self.GetRegions()):
             proportion = region._regionProportionY
 
         for i, region in enumerate(self.GetRegions()):
             proportion = region._regionProportionY
@@ -360,7 +358,7 @@ class DividedShape(RectangleShape):
             actualY = min(maxY, y)
 
             if region != self.GetRegions()[-1]:
             actualY = min(maxY, y)
 
             if region != self.GetRegions()[-1]:
-                controlPoint = DividedShapeControlPoint(self._canvas, self, i, CONTROL_POINT_SIZE, 0, actualY-self.GetY(), 0)
+                controlPoint = DividedShapeControlPoint(self._canvas, self, i, CONTROL_POINT_SIZE, 0, actualY - self.GetY(), 0)
                 self._canvas.AddShape(controlPoint)
                 self._controlPoints.append(controlPoint)
 
                 self._canvas.AddShape(controlPoint)
                 self._controlPoints.append(controlPoint)
 
@@ -368,14 +366,14 @@ class DividedShape(RectangleShape):
 
     def ResetControlPoints(self):
         # May only have the region handles, (n - 1) of them
 
     def ResetControlPoints(self):
         # May only have the region handles, (n - 1) of them
-        if len(self._controlPoints)>len(self.GetRegions())-1:
+        if len(self._controlPoints) > len(self.GetRegions()) - 1:
             RectangleShape.ResetControlPoints(self)
 
         self.ResetMandatoryControlPoints()
 
     def ResetMandatoryControlPoints(self):
             RectangleShape.ResetControlPoints(self)
 
         self.ResetMandatoryControlPoints()
 
     def ResetMandatoryControlPoints(self):
-        currentY = self.GetY()-self._height / 2
-        maxY = self.GetY() + self._height / 2
+        currentY = self.GetY() - self._height / 2.0
+        maxY = self.GetY() + self._height / 2.0
 
         i = 0
         for controlPoint in self._controlPoints:
 
         i = 0
         for controlPoint in self._controlPoints:
@@ -387,7 +385,7 @@ class DividedShape(RectangleShape):
                 actualY = min(maxY, y)
 
                 controlPoint._xoffset = 0
                 actualY = min(maxY, y)
 
                 controlPoint._xoffset = 0
-                controlPoint._yoffset = actualY-self.GetY()
+                controlPoint._yoffset = actualY - self.GetY()
 
                 currentY = actualY
 
 
                 currentY = actualY
 
index 65978c484f788229f4bce21baa01a1f1a30684ac..66e891cf7e386f2a8396ac2c8b4b0eb40dfe1f38 100644 (file)
@@ -11,8 +11,6 @@
 # Licence:      wxWindows license
 #----------------------------------------------------------------------------
 
 # Licence:      wxWindows license
 #----------------------------------------------------------------------------
 
-from __future__ import division
-
 import sys
 import math
 
 import sys
 import math
 
@@ -21,10 +19,10 @@ from _oglmisc import *
 
 # Line alignment flags
 # Vertical by default
 
 # Line alignment flags
 # Vertical by default
-LINE_ALIGNMENT_HORIZ=              1
-LINE_ALIGNMENT_VERT=               0
-LINE_ALIGNMENT_TO_NEXT_HANDLE=     2
-LINE_ALIGNMENT_NONE=               0
+LINE_ALIGNMENT_HORIZ =              1
+LINE_ALIGNMENT_VERT =               0
+LINE_ALIGNMENT_TO_NEXT_HANDLE =     2
+LINE_ALIGNMENT_NONE =               0
 
 
 
 
 
 
@@ -53,7 +51,7 @@ class LineControlPoint(ControlPoint):
 
 
 class ArrowHead(object):
 
 
 class ArrowHead(object):
-    def __init__(self, type = 0, end = 0, size = 0.0, dist = 0.0, name="",mf = None, arrowId=-1):
+    def __init__(self, type = 0, end = 0, size = 0.0, dist = 0.0, name = "", mf = None, arrowId = -1):
         if isinstance(type, ArrowHead):
             pass
         else:
         if isinstance(type, ArrowHead):
             pass
         else:
@@ -67,7 +65,7 @@ class ArrowHead(object):
             self._arrowName = name
             self._metaFile = mf
             self._id = arrowId
             self._arrowName = name
             self._metaFile = mf
             self._id = arrowId
-            if self._id==-1:
+            if self._id == -1:
                 self._id = wx.NewId()
             
     def _GetType(self):
                 self._id = wx.NewId()
             
     def _GetType(self):
@@ -98,7 +96,7 @@ class ArrowHead(object):
             if oldWidth == 0:
                 return
 
             if oldWidth == 0:
                 return
 
-            scale = size / oldWidth
+            scale = float(size) / oldWidth
             if scale != 1:
                 self._metaFile.Scale(scale, scale)
                 
             if scale != 1:
                 self._metaFile.Scale(scale, scale)
                 
@@ -139,8 +137,8 @@ class LabelShape(RectangleShape):
         if self._lineShape and not self._lineShape.GetDrawHandles():
             return
 
         if self._lineShape and not self._lineShape.GetDrawHandles():
             return
 
-        x1 = self._xpos-self._width / 2
-        y1 = self._ypos-self._height / 2
+        x1 = self._xpos - self._width / 2.0
+        y1 = self._ypos - self._height / 2.0
 
         if self._pen:
             if self._pen.GetWidth() == 0:
 
         if self._pen:
             if self._pen.GetWidth() == 0:
@@ -149,7 +147,7 @@ class LabelShape(RectangleShape):
                 dc.SetPen(self._pen)
         dc.SetBrush(wx.TRANSPARENT_BRUSH)
 
                 dc.SetPen(self._pen)
         dc.SetBrush(wx.TRANSPARENT_BRUSH)
 
-        if self._cornerRadius>0:
+        if self._cornerRadius > 0:
             dc.DrawRoundedRectangle(x1, y1, self._width, self._height, self._cornerRadius)
         else:
             dc.DrawRectangle(x1, y1, self._width, self._height)
             dc.DrawRoundedRectangle(x1, y1, self._width, self._height, self._cornerRadius)
         else:
             dc.DrawRectangle(x1, y1, self._width, self._height)
@@ -296,7 +294,7 @@ class LineShape(Shape):
         self._lineControlPoints = []
         
         for _ in range(n):
         self._lineControlPoints = []
         
         for _ in range(n):
-            point = wx.RealPoint(-999,-999)
+            point = wx.RealPoint(-999, -999)
             self._lineControlPoints.append(point)
 
     def InsertLineControlPoint(self, dc = None):
             self._lineControlPoints.append(point)
 
     def InsertLineControlPoint(self, dc = None):
@@ -307,15 +305,15 @@ class LineShape(Shape):
         last_point = self._lineControlPoints[-1]
         second_last_point = self._lineControlPoints[-2]
 
         last_point = self._lineControlPoints[-1]
         second_last_point = self._lineControlPoints[-2]
 
-        line_x = (last_point[0] + second_last_point[0]) / 2
-        line_y = (last_point[1] + second_last_point[1]) / 2
+        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)
 
     def DeleteLineControlPoint(self):
         """Delete an arbitary point on the line."""
 
         point = wx.RealPoint(line_x, line_y)
         self._lineControlPoints.insert(len(self._lineControlPoints), point)
 
     def DeleteLineControlPoint(self):
         """Delete an arbitary point on the line."""
-        if len(self._lineControlPoints)<3:
+        if len(self._lineControlPoints) < 3:
             return False
 
         del self._lineControlPoints[-2]
             return False
 
         del self._lineControlPoints[-2]
@@ -333,21 +331,21 @@ class LineShape(Shape):
             # and the last.
 
             for point in self._lineControlPoints[1:]:
             # and the last.
 
             for point in self._lineControlPoints[1:]:
-                if point[0]==-999:
-                    if first_point[0]<last_point[0]:
+                if point[0] == -999:
+                    if first_point[0] < last_point[0]:
                         x1 = first_point[0]
                         x2 = last_point[0]
                     else:
                         x2 = first_point[0]
                         x1 = last_point[0]
                         x1 = first_point[0]
                         x2 = last_point[0]
                     else:
                         x2 = first_point[0]
                         x1 = last_point[0]
-                    if first_point[1]<last_point[1]:
+                    if first_point[1] < last_point[1]:
                         y1 = first_point[1]
                         y2 = last_point[1]
                     else:
                         y2 = first_point[1]
                         y1 = last_point[1]
                         y1 = first_point[1]
                         y2 = last_point[1]
                     else:
                         y2 = first_point[1]
                         y1 = last_point[1]
-                    point[0] = (x2-x1) / 2 + x1
-                    point[1] = (y2-y1) / 2 + y1
+                    point[0] = (x2 - x1) / 2.0 + x1
+                    point[1] = (y2 - y1) / 2.0 + y1
                     
     def FormatText(self, dc, s, i):
         """Format a text string according to the region size, adding
                     
     def FormatText(self, dc, s, i):
         """Format a text string according to the region size, adding
@@ -368,7 +366,7 @@ class LineShape(Shape):
             w, h = 100, 50
             region.SetSize(w, h)
 
             w, h = 100, 50
             region.SetSize(w, h)
 
-        string_list = FormatText(dc, s, w-5, h-5, region.GetFormatMode())
+        string_list = FormatText(dc, s, w - 5, h - 5, region.GetFormatMode())
         for s in string_list:
             line = ShapeTextLine(0.0, 0.0, s)
             region.GetFormattedText().append(line)
         for s in string_list:
             line = ShapeTextLine(0.0, 0.0, s)
             region.GetFormattedText().append(line)
@@ -380,14 +378,14 @@ class LineShape(Shape):
             if actualW != w or actualH != h:
                 xx, yy = self.GetLabelPosition(i)
                 self.EraseRegion(dc, region, xx, yy)
             if actualW != w or actualH != h:
                 xx, yy = self.GetLabelPosition(i)
                 self.EraseRegion(dc, region, xx, yy)
-                if len(self._labelObjects)<i:
+                if len(self._labelObjects) < i:
                     self._labelObjects[i].Select(False, dc)
                     self._labelObjects[i].Erase(dc)
                     self._labelObjects[i].SetSize(actualW, actualH)
 
                 region.SetSize(actualW, actualH)
 
                     self._labelObjects[i].Select(False, dc)
                     self._labelObjects[i].Erase(dc)
                     self._labelObjects[i].SetSize(actualW, actualH)
 
                 region.SetSize(actualW, actualH)
 
-                if len(self._labelObjects)<i:
+                if len(self._labelObjects) < i:
                     self._labelObjects[i].Select(True, dc)
                     self._labelObjects[i].Draw(dc)
 
                     self._labelObjects[i].Select(True, dc)
                     self._labelObjects[i].Draw(dc)
 
@@ -415,7 +413,7 @@ class LineShape(Shape):
             # Now draw the text
             if region.GetFont():
                 dc.SetFont(region.GetFont())
             # Now draw the text
             if region.GetFont():
                 dc.SetFont(region.GetFont())
-                dc.DrawRectangle(xp-w / 2, yp-h / 2, w, h)
+                dc.DrawRectangle(xp - w / 2.0, yp - h / 2.0, w, h)
 
                 if self._pen:
                     dc.SetPen(self._pen)
 
                 if self._pen:
                     dc.SetPen(self._pen)
@@ -440,7 +438,7 @@ class LineShape(Shape):
             dc.SetPen(self.GetBackgroundPen())
             dc.SetBrush(self.GetBackgroundBrush())
 
             dc.SetPen(self.GetBackgroundPen())
             dc.SetBrush(self.GetBackgroundBrush())
 
-            dc.DrawRectangle(xp-w / 2, yp-h / 2, w, h)
+            dc.DrawRectangle(xp - w / 2.0, yp - h / 2.0, w, h)
 
     def GetLabelPosition(self, position):
         """Get the reference point for a label.
 
     def GetLabelPosition(self, position):
         """Get the reference point for a label.
@@ -450,16 +448,16 @@ class LineShape(Shape):
         """
         if position == 0:
             # Want to take the middle section for the label
         """
         if position == 0:
             # Want to take the middle section for the label
-            half_way = int(len(self._lineControlPoints) / 2)
+            half_way = int(len(self._lineControlPoints) / 2.0)
 
             # Find middle of this line
 
             # Find middle of this line
-            point = self._lineControlPoints[half_way-1]
+            point = self._lineControlPoints[half_way - 1]
             next_point = self._lineControlPoints[half_way]
 
             next_point = self._lineControlPoints[half_way]
 
-            dx = next_point[0]-point[0]
-            dy = next_point[1]-point[1]
+            dx = next_point[0] - point[0]
+            dy = next_point[1] - point[1]
 
 
-            return point[0] + dx / 2, point[1] + dy / 2
+            return point[0] + dx / 2.0, point[1] + dy / 2.0
         elif position == 1:
             return self._lineControlPoints[0][0], self._lineControlPoints[0][1]
         elif position == 2:
         elif position == 1:
             return self._lineControlPoints[0][0], self._lineControlPoints[0][1]
         elif position == 2:
@@ -467,7 +465,7 @@ class LineShape(Shape):
 
     def Straighten(self, dc = None):
         """Straighten verticals and horizontals."""
 
     def Straighten(self, dc = None):
         """Straighten verticals and horizontals."""
-        if len(self._lineControlPoints)<3:
+        if len(self._lineControlPoints) < 3:
             return
 
         if dc:
             return
 
         if dc:
@@ -475,7 +473,7 @@ class LineShape(Shape):
 
         GraphicsStraightenLine(self._lineControlPoints[-1], self._lineControlPoints[-2])
 
 
         GraphicsStraightenLine(self._lineControlPoints[-1], self._lineControlPoints[-2])
 
-        for i in range(len(self._lineControlPoints)-2):
+        for i in range(len(self._lineControlPoints) - 2):
             GraphicsStraightenLine(self._lineControlPoints[i], self._lineControlPoints[i + 1])
                 
         if dc:
             GraphicsStraightenLine(self._lineControlPoints[i], self._lineControlPoints[i + 1])
                 
         if dc:
@@ -501,8 +499,8 @@ class LineShape(Shape):
         last_point[0] = x2
         last_point[1] = y2
 
         last_point[0] = x2
         last_point[1] = y2
 
-        self._xpos = (x1 + x2) / 2
-        self._ypos = (y1 + y2) / 2
+        self._xpos = (x1 + x2) / 2.0
+        self._ypos = (y1 + y2) / 2.0
 
     # Get absolute positions of ends
     def GetEnds(self):
 
     # Get absolute positions of ends
     def GetEnds(self):
@@ -532,35 +530,35 @@ class LineShape(Shape):
                     xp, yp = self.GetLabelPosition(i)
                     # Offset region from default label position
                     cx, cy = region.GetPosition()
                     xp, yp = self.GetLabelPosition(i)
                     # Offset region from default label position
                     cx, cy = region.GetPosition()
-                    cw, ch = region.GetSize()
+                    cw, ch = region.GetSize() 
                     cx += xp
                     cy += yp
                     
                     cx += xp
                     cy += yp
                     
-                    rLeft = cx-cw / 2
-                    rTop = cy-ch / 2
-                    rRight = cx + cw / 2
-                    rBottom = cy + ch / 2
-                    if x>rLeft and x<rRight and y>rTop and y<rBottom:
+                    rLeft = cx - cw / 2.0
+                    rTop = cy - ch / 2.0
+                    rRight = cx + cw / 2.0
+                    rBottom = cy + ch / 2.0
+                    if x > rLeft and x < rRight and y > rTop and y < rBottom:
                         inLabelRegion = True
                         break
 
                         inLabelRegion = True
                         break
 
-        for i in range(len(self._lineControlPoints)-1):
+        for i in range(len(self._lineControlPoints) - 1):
             point1 = self._lineControlPoints[i]
             point2 = self._lineControlPoints[i + 1]
 
             # For inaccurate mousing allow 8 pixel corridor
             extra = 4
 
             point1 = self._lineControlPoints[i]
             point2 = self._lineControlPoints[i + 1]
 
             # For inaccurate mousing allow 8 pixel corridor
             extra = 4
 
-            dx = point2[0]-point1[0]
-            dy = point2[1]-point1[1]
+            dx = point2[0] - point1[0]
+            dy = point2[1] - point1[1]
 
             seg_len = math.sqrt(dx * dx + dy * dy)
             if dy == 0 or dx == 0:
                 return False
 
             seg_len = math.sqrt(dx * dx + dy * dy)
             if dy == 0 or dx == 0:
                 return False
-            distance_from_seg = seg_len * ((x-point1[0]) * dy-(y-point1[1]) * dx) / (dy * dy + dx * dx)
-            distance_from_prev = seg_len * ((y-point1[1]) * dy + (x-point1[0]) * dx) / (dy * dy + dx * dx)
+            distance_from_seg = seg_len * float((x - point1[0]) * dy - (y - point1[1]) * dx) / (dy * dy + dx * dx)
+            distance_from_prev = seg_len * float((y - point1[1]) * dy + (x - point1[0]) * dx) / (dy * dy + dx * dx)
 
 
-            if abs(distance_from_seg)<extra and distance_from_prev >= 0 and distance_from_prev <= seg_len or inLabelRegion:
+            if abs(distance_from_seg) < extra and distance_from_prev >= 0 and distance_from_prev <= seg_len or inLabelRegion:
                 return 0, distance_from_seg
 
         return False
                 return 0, distance_from_seg
 
         return False
@@ -612,7 +610,7 @@ class LineShape(Shape):
             # will be on the line.
             realOffset = XOffset
             if proportionalOffset:
             # will be on the line.
             realOffset = XOffset
             if proportionalOffset:
-                totalLength = math.sqrt((second_line_point[0]-first_line_point[0]) * (second_line_point[0]-first_line_point[0]) + (second_line_point[1]-first_line_point[1]) * (second_line_point[1]-first_line_point[1]))
+                totalLength = math.sqrt((second_line_point[0] - first_line_point[0]) * (second_line_point[0] - first_line_point[0]) + (second_line_point[1] - first_line_point[1]) * (second_line_point[1] - first_line_point[1]))
                 realOffset = XOffset * totalLength
 
             positionOnLineX, positionOnLineY = GetPointOnLine(second_line_point[0], second_line_point[1], first_line_point[0], first_line_point[1], realOffset)
                 realOffset = XOffset * totalLength
 
             positionOnLineX, positionOnLineY = GetPointOnLine(second_line_point[0], second_line_point[1], first_line_point[0], first_line_point[1], realOffset)
@@ -624,7 +622,7 @@ class LineShape(Shape):
             # will be on the line.
             realOffset = XOffset
             if proportionalOffset:
             # will be on the line.
             realOffset = XOffset
             if proportionalOffset:
-                totalLength = math.sqrt((second_last_line_point[0]-last_line_point[0]) * (second_last_line_point[0]-last_line_point[0]) + (second_last_line_point[1]-last_line_point[1]) * (second_last_line_point[1]-last_line_point[1]));
+                totalLength = math.sqrt((second_last_line_point[0] - last_line_point[0]) * (second_last_line_point[0] - last_line_point[0]) + (second_last_line_point[1] - last_line_point[1]) * (second_last_line_point[1] - last_line_point[1]));
                 realOffset = XOffset * totalLength
             
             positionOnLineX, positionOnLineY = GetPointOnLine(second_last_line_point[0], second_last_line_point[1], last_line_point[0], last_line_point[1], realOffset)
                 realOffset = XOffset * totalLength
             
             positionOnLineX, positionOnLineY = GetPointOnLine(second_last_line_point[0], second_last_line_point[1], last_line_point[0], last_line_point[1], realOffset)
@@ -633,14 +631,14 @@ class LineShape(Shape):
             startPositionY = second_last_line_point[1]
         elif ap == ARROW_POSITION_MIDDLE:
             # Choose a point half way between the last and penultimate points
             startPositionY = second_last_line_point[1]
         elif ap == ARROW_POSITION_MIDDLE:
             # Choose a point half way between the last and penultimate points
-            x = (last_line_point[0] + second_last_line_point[0]) / 2
-            y = (last_line_point[1] + second_last_line_point[1]) / 2
+            x = (last_line_point[0] + second_last_line_point[0]) / 2.0
+            y = (last_line_point[1] + second_last_line_point[1]) / 2.0
 
             # If we're using a proportional offset, calculate just where this
             # will be on the line.
             realOffset = XOffset
             if proportionalOffset:
 
             # If we're using a proportional offset, calculate just where this
             # will be on the line.
             realOffset = XOffset
             if proportionalOffset:
-                totalLength = math.sqrt((second_last_line_point[0]-x) * (second_last_line_point[0]-x) + (second_last_line_point[1]-y) * (second_last_line_point[1]-y));
+                totalLength = math.sqrt((second_last_line_point[0] - x) * (second_last_line_point[0] - x) + (second_last_line_point[1] - y) * (second_last_line_point[1] - y));
                 realOffset = XOffset * totalLength
 
             positionOnLineX, positionOnLineY = GetPointOnLine(second_last_line_point[0], second_last_line_point[1], x, y, realOffset)
                 realOffset = XOffset * totalLength
 
             positionOnLineX, positionOnLineY = GetPointOnLine(second_last_line_point[0], second_last_line_point[1], x, y, realOffset)
@@ -663,25 +661,25 @@ class LineShape(Shape):
             #   Where theta = math.tan(-1) of (y3-y1) / (x3-x1)
             x1 = startPositionX
             y1 = startPositionY
             #   Where theta = math.tan(-1) of (y3-y1) / (x3-x1)
             x1 = startPositionX
             y1 = startPositionY
-            x3 = positionOnLineX
-            y3 = positionOnLineY
-            d=-arrow.GetYOffset() # Negate so +offset is above line
+            x3 = float(positionOnLineX)
+            y3 = float(positionOnLineY)
+            d = -arrow.GetYOffset() # Negate so +offset is above line
 
             if x3 == x1:
 
             if x3 == x1:
-                theta = math.pi / 2
+                theta = math.pi / 2.0
             else:
             else:
-                theta = math.atan((y3-y1) / (x3-x1))
+                theta = math.atan((y3 - y1) / (x3 - x1))
 
 
-            x4 = x3-d * math.sin(theta)
+            x4 = x3 - d * math.sin(theta)
             y4 = y3 + d * math.cos(theta)
             
             y4 = y3 + d * math.cos(theta)
             
-            deltaX = x4-positionOnLineX
-            deltaY = y4-positionOnLineY
+            deltaX = x4 - positionOnLineX
+            deltaY = y4 - positionOnLineY
 
         at = arrow._GetType()
         if at == ARROW_ARROW:
             arrowLength = arrow.GetSize()
 
         at = arrow._GetType()
         if at == ARROW_ARROW:
             arrowLength = arrow.GetSize()
-            arrowWidth = arrowLength / 3
+            arrowWidth = arrowLength / 3.0
 
             tip_x, tip_y, side1_x, side1_y, side2_x, side2_y = GetArrowPoints(startPositionX + deltaX, startPositionY + deltaY, positionOnLineX + deltaX, positionOnLineY + deltaY, arrowLength, arrowWidth)
 
 
             tip_x, tip_y, side1_x, side1_y, side2_x, side2_y = GetArrowPoints(startPositionX + deltaX, startPositionY + deltaY, positionOnLineX + deltaX, positionOnLineY + deltaY, arrowLength, arrowWidth)
 
@@ -699,9 +697,9 @@ class LineShape(Shape):
             diameter = arrow.GetSize()
             x, y = GetPointOnLine(startPositionX + deltaX, startPositionY + deltaY,
                                positionOnLineX + deltaX, positionOnLineY + deltaY,
             diameter = arrow.GetSize()
             x, y = GetPointOnLine(startPositionX + deltaX, startPositionY + deltaY,
                                positionOnLineX + deltaX, positionOnLineY + deltaY,
-                               diameter / 2)
-            x1 = x-diameter / 2
-            y1 = y-diameter / 2
+                               diameter / 2.0)
+            x1 = x - diameter / 2.0
+            y1 = y - diameter / 2.0
             dc.SetPen(self._pen)
             if arrow._GetType() == ARROW_HOLLOW_CIRCLE:
                 dc.SetBrush(self.GetBackgroundBrush())
             dc.SetPen(self._pen)
             if arrow._GetType() == ARROW_HOLLOW_CIRCLE:
                 dc.SetBrush(self.GetBackgroundBrush())
@@ -724,7 +722,7 @@ class LineShape(Shape):
                 #
                 x, y = GetPointOnLine(startPositionX, startPositionY,
                                    positionOnLineX, positionOnLineY,
                 #
                 x, y = GetPointOnLine(startPositionX, startPositionY,
                                    positionOnLineX, positionOnLineY,
-                                   arrow.GetMetaFile()._width / 2)
+                                   arrow.GetMetaFile()._width / 2.0)
                 # Calculate theta for rotating the metafile.
                 #
                 # |
                 # Calculate theta for rotating the metafile.
                 #
                 # |
@@ -738,21 +736,21 @@ class LineShape(Shape):
                 theta = 0.0
                 x1 = startPositionX
                 y1 = startPositionY
                 theta = 0.0
                 x1 = startPositionX
                 y1 = startPositionY
-                x2 = positionOnLineX
-                y2 = positionOnLineY
+                x2 = float(positionOnLineX)
+                y2 = float(positionOnLineY)
 
                 if x1 == x2 and y1 == y2:
                     theta = 0.0
 
                 if x1 == x2 and y1 == y2:
                     theta = 0.0
-                elif x1 == x2 and y1>y2:
-                    theta = 3.0 * math.pi / 2
-                elif x1 == x2 and y2>y1:
-                    theta = math.pi / 2
-                elif x2>x1 and y2 >= y1:
-                    theta = math.atan((y2-y1) / (x2-x1))
-                elif x2<x1:
-                    theta = math.pi + math.atan((y2-y1) / (x2-x1))
-                elif x2>x1 and y2<y1:
-                    theta = 2 * math.pi + math.atan((y2-y1) / (x2-x1))
+                elif x1 == x2 and y1 > y2:
+                    theta = 3.0 * math.pi / 2.0
+                elif x1 == x2 and y2 > y1:
+                    theta = math.pi / 2.0
+                elif x2 > x1 and y2 >= y1:
+                    theta = math.atan((y2 - y1) / (x2 - x1))
+                elif x2 < x1:
+                    theta = math.pi + math.atan((y2 - y1) / (x2 - x1))
+                elif x2 > x1 and y2 < y1:
+                    theta = 2 * math.pi + math.atan((y2 - y1) / (x2 - x1))
                 else:
                     raise "Unknown arrowhead rotation case"
 
                 else:
                     raise "Unknown arrowhead rotation case"
 
@@ -766,7 +764,7 @@ class LineShape(Shape):
                     minX, minY, maxX, maxY = arrow.GetMetaFile().GetBounds()
                     # Make erasing rectangle slightly bigger or you get droppings
                     extraPixels = 4
                     minX, minY, maxX, maxY = arrow.GetMetaFile().GetBounds()
                     # Make erasing rectangle slightly bigger or you get droppings
                     extraPixels = 4
-                    dc.DrawRectangle(deltaX + x + minX-extraPixels / 2, deltaY + y + minY-extraPixels / 2, maxX-minX + extraPixels, maxY-minY + extraPixels)
+                    dc.DrawRectangle(deltaX + x + minX - extraPixels / 2.0, deltaY + y + minY - extraPixels / 2.0, maxX - minX + extraPixels, maxY - minY + extraPixels)
                 else:
                     arrow.GetMetaFile().Draw(dc, x + deltaX, y + deltaY)
 
                 else:
                     arrow.GetMetaFile().Draw(dc, x + deltaX, y + deltaY)
 
@@ -795,8 +793,8 @@ class LineShape(Shape):
 
         # Drawing over the line only seems to work if the line has a thickness
         # of 1.
 
         # Drawing over the line only seems to work if the line has a thickness
         # of 1.
-        if old_pen and old_pen.GetWidth()>1:
-            dc.DrawRectangle(self._xpos-bound_x / 2-2, self._ypos-bound_y / 2-2,
+        if old_pen and old_pen.GetWidth() > 1:
+            dc.DrawRectangle(self._xpos - bound_x / 2.0 - 2, self._ypos - bound_y / 2.0 - 2,
                              bound_x + 4, bound_y + 4)
         else:
             self._erasing = True
                              bound_x + 4, bound_y + 4)
         else:
             self._erasing = True
@@ -811,19 +809,19 @@ class LineShape(Shape):
 
     def GetBoundingBoxMin(self):
         x1, y1 = 10000, 10000
 
     def GetBoundingBoxMin(self):
         x1, y1 = 10000, 10000
-        x2, y2=-10000,-10000
+        x2, y2 = -10000, -10000
 
         for point in self._lineControlPoints:
 
         for point in self._lineControlPoints:
-            if point[0]<x1:
+            if point[0] < x1:
                 x1 = point[0]
                 x1 = point[0]
-            if point[1]<y1:
+            if point[1] < y1:
                 y1 = point[1]
                 y1 = point[1]
-            if point[0]>x2:
+            if point[0] > x2:
                 x2 = point[0]
                 x2 = point[0]
-            if point[1]>y2:
+            if point[1] > y2:
                 y2 = point[1]
 
                 y2 = point[1]
 
-        return x2-x1, y2-y1
+        return x2 - x1, y2 - y1
         
     # For a node image of interest, finds the position of this arc
     # amongst all the arcs which are attached to THIS SIDE of the node image,
         
     # For a node image of interest, finds the position of this arc
     # amongst all the arcs which are attached to THIS SIDE of the node image,
@@ -834,7 +832,7 @@ class LineShape(Shape):
         Specify whether incoming or outgoing lines are being considered
         with incoming.
         """
         Specify whether incoming or outgoing lines are being considered
         with incoming.
         """
-        n=-1
+        n = -1
         num = 0
         
         if image == self._to:
         num = 0
         
         if image == self._to:
@@ -884,8 +882,8 @@ class LineShape(Shape):
             self.SetBrush(None)
 
     def OnMovePre(self, dc, x, y, old_x, old_y, display = True):
             self.SetBrush(None)
 
     def OnMovePre(self, dc, x, y, old_x, old_y, display = True):
-        x_offset = x-old_x
-        y_offset = y-old_y
+        x_offset = x - old_x
+        y_offset = y - old_y
 
         if self._lineControlPoints and not (x_offset == 0 and y_offset == 0):
             for point in self._lineControlPoints:
 
         if self._lineControlPoints and not (x_offset == 0 and y_offset == 0):
             for point in self._lineControlPoints:
@@ -897,7 +895,7 @@ class LineShape(Shape):
             if self._labelObjects[i]:
                 self._labelObjects[i].Erase(dc)
                 xp, yp = self.GetLabelPosition(i)
             if self._labelObjects[i]:
                 self._labelObjects[i].Erase(dc)
                 xp, yp = self.GetLabelPosition(i)
-                if i<len(self._regions):
+                if i < len(self._regions):
                     xr, yr = self._regions[i].GetPosition()
                 else:
                     xr, yr = 0, 0
                     xr, yr = self._regions[i].GetPosition()
                 else:
                     xr, yr = 0, 0
@@ -911,7 +909,7 @@ class LineShape(Shape):
         if not self._from or not self._to:
             return
 
         if not self._from or not self._to:
             return
 
-        if len(self._lineControlPoints)>2:
+        if len(self._lineControlPoints) > 2:
             self.Initialise()
 
         # Do each end - nothing in the middle. User has to move other points
             self.Initialise()
 
         # Do each end - nothing in the middle. User has to move other points
@@ -930,8 +928,8 @@ class LineShape(Shape):
         self.SetEnds(end_x, end_y, other_end_x, other_end_y)
 
         # Try to move control points with the arc
         self.SetEnds(end_x, end_y, other_end_x, other_end_y)
 
         # Try to move control points with the arc
-        x_offset = self._xpos-oldX
-        y_offset = self._ypos-oldY
+        x_offset = self._xpos - oldX
+        y_offset = self._ypos - oldY
 
         # Only move control points if it's a self link. And only works
         # if attachment mode is ON
 
         # Only move control points if it's a self link. And only works
         # if attachment mode is ON
@@ -957,7 +955,7 @@ class LineShape(Shape):
         second_point = self._lineControlPoints[1]
         second_last_point = self._lineControlPoints[-2]
         
         second_point = self._lineControlPoints[1]
         second_last_point = self._lineControlPoints[-2]
         
-        if len(self._lineControlPoints)>2:
+        if len(self._lineControlPoints) > 2:
             if self._from.GetAttachmentMode() != ATTACHMENT_MODE_NONE:
                 nth, no_arcs = self.FindNth(self._from, False) # Not incoming
                 end_x, end_y = self._from.GetAttachmentPosition(self._attachmentFrom, nth, no_arcs, self)
             if self._from.GetAttachmentMode() != ATTACHMENT_MODE_NONE:
                 nth, no_arcs = self.FindNth(self._from, False) # Not incoming
                 end_x, end_y = self._from.GetAttachmentPosition(self._attachmentFrom, nth, no_arcs, self)
@@ -1015,7 +1013,7 @@ class LineShape(Shape):
         else:
             dc.DrawLines(points)
 
         else:
             dc.DrawLines(points)
 
-        if sys.platform[:3]=="win":
+        if sys.platform[:3] == "win":
             # For some reason, last point isn't drawn under Windows
             pt = points[-1]
             dc.DrawPoint(pt.x, pt.y)
             # For some reason, last point isn't drawn under Windows
             pt = points[-1]
             dc.DrawPoint(pt.x, pt.y)
@@ -1256,7 +1254,7 @@ class LineShape(Shape):
 
         return True
 
 
         return True
 
-    def AddArrow(self, type, end = ARROW_POSITION_END, size = 10.0, xOffset = 0.0, name="",mf = None, arrowId=-1):
+    def AddArrow(self, type, end = ARROW_POSITION_END, size = 10.0, xOffset = 0.0, name = "", mf = None, arrowId = -1):
         """Add an arrow (or annotation) to the line.
 
         type may currently be one of:
         """Add an arrow (or annotation) to the line.
 
         type may currently be one of:
@@ -1326,7 +1324,7 @@ class LineShape(Shape):
             return True
 
         i1 = i2 = 0
             return True
 
         i1 = i2 = 0
-        while i1<len(referenceList) and i2<len(self._arcArrows):
+        while i1 < len(referenceList) and i2 < len(self._arcArrows):
             refArrow = referenceList[i1]
             currArrow = self._arcArrows[i2]
 
             refArrow = referenceList[i1]
             currArrow = self._arcArrows[i2]
 
@@ -1337,7 +1335,7 @@ class LineShape(Shape):
             # Check if we're at the correct position in the
             # reference list
             if targetName == refArrow.GetName():
             # Check if we're at the correct position in the
             # reference list
             if targetName == refArrow.GetName():
-                if i2<len(self._arcArrows):
+                if i2 < len(self._arcArrows):
                     self._arcArrows.insert(i2, arrow)
                 else:
                     self._arcArrows.append(arrow)
                     self._arcArrows.insert(i2, arrow)
                 else:
                     self._arcArrows.append(arrow)
@@ -1351,7 +1349,7 @@ class LineShape(Shape):
         """Delete the arrows at the specified position, or at any position
         if position is -1.
         """
         """Delete the arrows at the specified position, or at any position
         if position is -1.
         """
-        if end==-1:
+        if end == -1:
             self._arcArrows = []
             return
 
             self._arcArrows = []
             return
 
@@ -1373,7 +1371,7 @@ class LineShape(Shape):
         if position is -1, matches any position.
         """
         for arrow in self._arcArrows:
         if position is -1, matches any position.
         """
         for arrow in self._arcArrows:
-            if (position==-1 or position == arrow.GetArrowEnd()) and arrow.GetName() == name:
+            if (position == -1 or position == arrow.GetArrowEnd()) and arrow.GetName() == name:
                 return arow
 
         return None
                 return arow
 
         return None
@@ -1392,7 +1390,7 @@ class LineShape(Shape):
         if position is -1, matches any position.
         """
         for arrow in self._arcArrows:
         if position is -1, matches any position.
         """
         for arrow in self._arcArrows:
-            if (position==-1 or position == arrow.GetArrowEnd()) and arrow.GetName() == name:
+            if (position == -1 or position == arrow.GetArrowEnd()) and arrow.GetName() == name:
                 self._arcArrows.remove(arrow)
                 return True
         return False
                 self._arcArrows.remove(arrow)
                 return True
         return False
@@ -1420,7 +1418,7 @@ class LineShape(Shape):
         # We have ABSOLUTE minimum now. So
         # scale it to give it reasonable aesthetics
         # when drawing with line.
         # We have ABSOLUTE minimum now. So
         # scale it to give it reasonable aesthetics
         # when drawing with line.
-        if minWidth>0:
+        if minWidth > 0:
             minWidth = minWidth * 1.4
         else:
             minWidth = 20.0
             minWidth = minWidth * 1.4
         else:
             minWidth = 20.0
@@ -1438,13 +1436,13 @@ class LineShape(Shape):
         startX, startY, endX, endY = self.GetEnds()
 
         # Find distances from centre, start and end. The smallest wins
         startX, startY, endX, endY = self.GetEnds()
 
         # Find distances from centre, start and end. The smallest wins
-        centreDistance = math.sqrt((x-self._xpos) * (x-self._xpos) + (y-self._ypos) * (y-self._ypos))
-        startDistance = math.sqrt((x-startX) * (x-startX) + (y-startY) * (y-startY))
-        endDistance = math.sqrt((x-endX) * (x-endX) + (y-endY) * (y-endY))
+        centreDistance = math.sqrt((x - self._xpos) * (x - self._xpos) + (y - self._ypos) * (y - self._ypos))
+        startDistance = math.sqrt((x - startX) * (x - startX) + (y - startY) * (y - startY))
+        endDistance = math.sqrt((x - endX) * (x - endX) + (y - endY) * (y - endY))
 
 
-        if centreDistance<startDistance and centreDistance<endDistance:
+        if centreDistance < startDistance and centreDistance < endDistance:
             return ARROW_POSITION_MIDDLE
             return ARROW_POSITION_MIDDLE
-        elif startDistance<endDistance:
+        elif startDistance < endDistance:
             return ARROW_POSITION_START
         else:
             return ARROW_POSITION_END
             return ARROW_POSITION_START
         else:
             return ARROW_POSITION_END
@@ -1495,10 +1493,10 @@ class LineShape(Shape):
         if self._to == shape:
             # Must be END of line, so we want (n - 1)th control point.
             # But indexing ends at n-1, so subtract 2.
         if self._to == shape:
             # Must be END of line, so we want (n - 1)th control point.
             # But indexing ends at n-1, so subtract 2.
-            nn = n-2
+            nn = n - 2
         else:
             nn = 1
         else:
             nn = 1
-        if nn<len(self._lineControlPoints):
+        if nn < len(self._lineControlPoints):
             return self._lineControlPoints[nn]
         return None
 
             return self._lineControlPoints[nn]
         return None
 
@@ -1520,7 +1518,7 @@ class LineShape(Shape):
         xx, yy = self.GetLabelPosition(i)
         # Set the region's offset, relative to the default position for
         # each region.
         xx, yy = self.GetLabelPosition(i)
         # Set the region's offset, relative to the default position for
         # each region.
-        labelShape._shapeRegion.SetPosition(x-xx, y-yy)
+        labelShape._shapeRegion.SetPosition(x - xx, y - yy)
         labelShape.SetX(x)
         labelShape.SetY(y)
 
         labelShape.SetX(x)
         labelShape.SetY(y)
 
index 42a79b2b152cb9e45329605795d3f418188cd890..f4f72bd9d6ace17ecc000fffe563d47a0ef234f1 100644 (file)
@@ -11,7 +11,6 @@
 # Licence:      wxWindows license
 #----------------------------------------------------------------------------
 
 # Licence:      wxWindows license
 #----------------------------------------------------------------------------
 
-from __future__ import division
 import math
 
 import wx
 import math
 
 import wx
@@ -79,28 +78,28 @@ LINE_ALIGNMENT_NONE               = 0
 # Interpret %n and 10 or 13 as a new line.
 def FormatText(dc, text, width, height, formatMode):
     i = 0
 # Interpret %n and 10 or 13 as a new line.
 def FormatText(dc, text, width, height, formatMode):
     i = 0
-    word=""
+    word = ""
     word_list = []
     end_word = False
     new_line = False
     word_list = []
     end_word = False
     new_line = False
-    while i<len(text):
-        if text[i]=="%":
+    while i < len(text):
+        if text[i] == "%":
             i += 1
             if i == len(text):
             i += 1
             if i == len(text):
-                word+="%"
+                word += "%"
             else:
             else:
-                if text[i]=="n":
+                if text[i] == "n":
                     new_line = True
                     end_word = True
                     i += 1
                 else:
                     new_line = True
                     end_word = True
                     i += 1
                 else:
-                    word+="%"+text[i]
+                    word += "%" + text[i]
                     i += 1
         elif text[i] in ["\012","\015"]:
             new_line = True
             end_word = True
             i += 1
                     i += 1
         elif text[i] in ["\012","\015"]:
             new_line = True
             end_word = True
             i += 1
-        elif text[i]==" ":
+        elif text[i] == " ":
             end_word = True
             i += 1
         else:
             end_word = True
             i += 1
         else:
@@ -112,7 +111,7 @@ def FormatText(dc, text, width, height, formatMode):
 
         if end_word:
             word_list.append(word)
 
         if end_word:
             word_list.append(word)
-            word=""
+            word = ""
             end_word = False
         if new_line:
             word_list.append(None)
             end_word = False
         if new_line:
             word_list.append(None)
@@ -120,23 +119,23 @@ def FormatText(dc, text, width, height, formatMode):
 
     # Now, make a list of strings which can fit in the box
     string_list = []
 
     # Now, make a list of strings which can fit in the box
     string_list = []
-    buffer=""
+    buffer = ""
     for s in word_list:
         oldBuffer = buffer
         if s is None:
             # FORCE NEW LINE
     for s in word_list:
         oldBuffer = buffer
         if s is None:
             # FORCE NEW LINE
-            if len(buffer)>0:
+            if len(buffer) > 0:
                 string_list.append(buffer)
                 string_list.append(buffer)
-            buffer=""
+            buffer = ""
         else:
             if len(buffer):
         else:
             if len(buffer):
-                buffer+=" "
+                buffer += " "
             buffer += s
             x, y = dc.GetTextExtent(buffer)
 
             # Don't fit within the bounding box if we're fitting
             # shape to contents
             buffer += s
             x, y = dc.GetTextExtent(buffer)
 
             # Don't fit within the bounding box if we're fitting
             # shape to contents
-            if (x>width) and not (formatMode & FORMAT_SIZE_TO_CONTENTS):
+            if (x > width) and not (formatMode & FORMAT_SIZE_TO_CONTENTS):
                 # Deal with first word being wider than box
                 if len(oldBuffer):
                     string_list.append(oldBuffer)
                 # Deal with first word being wider than box
                 if len(oldBuffer):
                     string_list.append(oldBuffer)
@@ -155,7 +154,7 @@ def GetCentredTextExtent(dc, text_list, xpos = 0, ypos = 0, width = 0, height =
     max_width = 0
     for line in text_list:
         current_width, char_height = dc.GetTextExtent(line)
     max_width = 0
     for line in text_list:
         current_width, char_height = dc.GetTextExtent(line)
-        if current_width>max_width:
+        if current_width > max_width:
             max_width = current_width
 
     return max_width, len(text_list) * char_height
             max_width = current_width
 
     return max_width, len(text_list) * char_height
@@ -176,31 +175,31 @@ def CentreText(dc, text_list, xpos, ypos, width, height, formatMode):
     for line in text_list:
         current_width, char_height = dc.GetTextExtent(line.GetText())
         widths.append(current_width)
     for line in text_list:
         current_width, char_height = dc.GetTextExtent(line.GetText())
         widths.append(current_width)
-        if current_width>max_width:
+        if current_width > max_width:
             max_width = current_width
 
     max_height = len(text_list) * char_height
 
     if formatMode & FORMAT_CENTRE_VERT:
             max_width = current_width
 
     max_height = len(text_list) * char_height
 
     if formatMode & FORMAT_CENTRE_VERT:
-        if max_height<height:
-            yoffset = ypos - height / 2 + (height - max_height) / 2
+        if max_height < height:
+            yoffset = ypos - height / 2.0 + (height - max_height) / 2.0
         else:
         else:
-            yoffset = ypos - height / 2
+            yoffset = ypos - height / 2.0
         yOffset = ypos
     else:
         yoffset = 0.0
         yOffset = 0.0
 
     if formatMode & FORMAT_CENTRE_HORIZ:
         yOffset = ypos
     else:
         yoffset = 0.0
         yOffset = 0.0
 
     if formatMode & FORMAT_CENTRE_HORIZ:
-        xoffset = xpos - width / 2
+        xoffset = xpos - width / 2.0
         xOffset = xpos
     else:
         xoffset = 0.0
         xOffset = 0.0
 
     for i, line in enumerate(text_list):
         xOffset = xpos
     else:
         xoffset = 0.0
         xOffset = 0.0
 
     for i, line in enumerate(text_list):
-        if formatMode & FORMAT_CENTRE_HORIZ and widths[i]<width:
-            x = (width - widths[i]) / 2 + xoffset
+        if formatMode & FORMAT_CENTRE_HORIZ and widths[i] < width:
+            x = (width - widths[i]) / 2.0 + xoffset
         else:
             x = xoffset
         y = i * char_height + yoffset
         else:
             x = xoffset
         y = i * char_height + yoffset
@@ -214,15 +213,15 @@ def DrawFormattedText(dc, text_list, xpos, ypos, width, height, formatMode):
     if formatMode & FORMAT_CENTRE_HORIZ:
         xoffset = xpos
     else:
     if formatMode & FORMAT_CENTRE_HORIZ:
         xoffset = xpos
     else:
-        xoffset = xpos - width / 2
+        xoffset = xpos - width / 2.0
 
     if formatMode & FORMAT_CENTRE_VERT:
         yoffset = ypos
     else:
 
     if formatMode & FORMAT_CENTRE_VERT:
         yoffset = ypos
     else:
-        yoffset = ypos - height / 2
+        yoffset = ypos - height / 2.0
 
     # +1 to allow for rounding errors
 
     # +1 to allow for rounding errors
-    dc.SetClippingRegion(xpos - width / 2, ypos - height / 2, width + 1, height + 1)
+    dc.SetClippingRegion(xpos - width / 2.0, ypos - height / 2.0, width + 1, height + 1)
 
     for line in text_list:
         dc.DrawText(line.GetText(), xoffset + line.GetX(), yoffset + line.GetY())
 
     for line in text_list:
         dc.DrawText(line.GetText(), xoffset + line.GetX(), yoffset + line.GetY())
@@ -232,14 +231,14 @@ def DrawFormattedText(dc, text_list, xpos, ypos, width, height, formatMode):
 
 
 def RoughlyEqual(val1, val2, tol = 0.00001):
 
 
 def RoughlyEqual(val1, val2, tol = 0.00001):
-    return val1<(val2 + tol) and val1>(val2 - tol) and \
-           val2<(val1 + tol) and val2>(val1 - tol)
+    return val1 < (val2 + tol) and val1 > (val2 - tol) and \
+           val2 < (val1 + tol) and val2 > (val1 - tol)
 
 
 
 def FindEndForBox(width, height, x1, y1, x2, y2):
 
 
 
 def FindEndForBox(width, height, x1, y1, x2, y2):
-    xvec = [x1 - width / 2, x1 - width / 2, x1 + width / 2, x1 + width / 2, x1 - width / 2]
-    yvec = [y1 - height / 2, y1 + height / 2, y1 + height / 2, y1 - height / 2, y1 - height / 2]
+    xvec = [x1 - width / 2.0, x1 - width / 2.0, x1 + width / 2.0, x1 + width / 2.0, x1 - width / 2.0]
+    yvec = [y1 - height / 2.0, y1 + height / 2.0, y1 + height / 2.0, y1 - height / 2.0, y1 - height / 2.0]
 
     return FindEndForPolyline(xvec, yvec, x2, y2, x1, y1)
 
 
     return FindEndForPolyline(xvec, yvec, x2, y2, x1, y1)
 
@@ -253,19 +252,19 @@ def CheckLineIntersection(x1, y1, x2, y2, x3, y3, x4, y4):
     k_line = 1.0
 
     # Check for parallel lines
     k_line = 1.0
 
     # Check for parallel lines
-    if denominator_term<0.005 and denominator_term>-0.005:
-        line_constant=-1.0
+    if denominator_term < 0.005 and denominator_term > -0.005:
+        line_constant = -1.0
     else:
         line_constant = float(numerator_term) / denominator_term
 
     # Check for intersection
     else:
         line_constant = float(numerator_term) / denominator_term
 
     # Check for intersection
-    if line_constant<1.0 and line_constant>0.0:
+    if line_constant < 1.0 and line_constant > 0.0:
         # Now must check that other line hits
         # Now must check that other line hits
-        if (y4 - y3)<0.005 and (y4 - y3)>-0.005:
+        if (y4 - y3) < 0.005 and (y4 - y3) > -0.005:
             k_line = (x1 - x3 + line_constant * (x2 - x1)) / (x4 - x3)
         else:
             k_line = (y1 - y3 + line_constant * (y2 - y1)) / (y4 - y3)
             k_line = (x1 - x3 + line_constant * (x2 - x1)) / (x4 - x3)
         else:
             k_line = (y1 - y3 + line_constant * (y2 - y1)) / (y4 - y3)
-        if k_line >= 0 and k_line<1:
+        if k_line >= 0 and k_line < 1:
             length_ratio = line_constant
         else:
             k_line = 1
             length_ratio = line_constant
         else:
             k_line = 1
@@ -285,13 +284,13 @@ def FindEndForPolyline(xvec, yvec, x1, y1, x2, y2):
         lastx = xvec[i]
         lasty = yvec[i]
 
         lastx = xvec[i]
         lasty = yvec[i]
 
-        if line_ratio<min_ratio:
+        if line_ratio < min_ratio:
             min_ratio = line_ratio
 
     # Do last (implicit) line if last and first doubles are not identical
     if not (xvec[0] == lastx and yvec[0] == lasty):
         line_ratio, other_ratio = CheckLineIntersection(x1, y1, x2, y2, lastx, lasty, xvec[0], yvec[0])
             min_ratio = line_ratio
 
     # Do last (implicit) line if last and first doubles are not identical
     if not (xvec[0] == lastx and yvec[0] == lasty):
         line_ratio, other_ratio = CheckLineIntersection(x1, y1, x2, y2, lastx, lasty, xvec[0], yvec[0])
-        if line_ratio<min_ratio:
+        if line_ratio < min_ratio:
             min_ratio = line_ratio
 
     return x1 + (x2 - x1) * min_ratio, y1 + (y2 - y1) * min_ratio
             min_ratio = line_ratio
 
     return x1 + (x2 - x1) * min_ratio, y1 + (y2 - y1) * min_ratio
@@ -312,7 +311,7 @@ def PolylineHitTest(xvec, yvec, x1, y1, x2, y2):
         lastx = xvec[i]
         lasty = yvec[i]
 
         lastx = xvec[i]
         lasty = yvec[i]
 
-        if line_ratio<min_ratio:
+        if line_ratio < min_ratio:
             min_ratio = line_ratio
 
     # Do last (implicit) line if last and first doubles are not identical
             min_ratio = line_ratio
 
     # Do last (implicit) line if last and first doubles are not identical
@@ -331,7 +330,7 @@ def GraphicsStraightenLine(point1, point2):
 
     if dx == 0:
         return
 
     if dx == 0:
         return
-    elif abs(dy / dx)>1:
+    elif abs(float(dy) / dx) > 1:
         point2[0] = point1[0]
     else:
         point2[1] = point1[0]
         point2[0] = point1[0]
     else:
         point2[1] = point1[0]
@@ -340,40 +339,40 @@ def GraphicsStraightenLine(point1, point2):
 
 def GetPointOnLine(x1, y1, x2, y2, length):
     l = math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
 
 def GetPointOnLine(x1, y1, x2, y2, length):
     l = math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
-    if l<0.01:
+    if l < 0.01:
         l = 0.01
 
     i_bar = (x2 - x1) / l
     j_bar = (y2 - y1) / l
 
         l = 0.01
 
     i_bar = (x2 - x1) / l
     j_bar = (y2 - y1) / l
 
-    return -length * i_bar + x2,-length * j_bar + y2
+    return -length * i_bar + x2, -length * j_bar + y2
 
 
 
 def GetArrowPoints(x1, y1, x2, y2, length, width):
     l = math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
 
 
 
 
 def GetArrowPoints(x1, y1, x2, y2, length, width):
     l = math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
 
-    if l<0.01:
+    if l < 0.01:
         l = 0.01
 
     i_bar = (x2 - x1) / l
     j_bar = (y2 - y1) / l
     
         l = 0.01
 
     i_bar = (x2 - x1) / l
     j_bar = (y2 - y1) / l
     
-    x3=-length * i_bar + x2
-    y3=-length * j_bar + y2
+    x3 = -length * i_bar + x2
+    y3 = -length * j_bar + y2
 
 
-    return x2, y2, width*-j_bar + x3, width * i_bar + y3,-width*-j_bar + x3,-width * i_bar + y3
+    return x2, y2, width * -j_bar + x3, width * i_bar + y3, -width * -j_bar + x3, -width * i_bar + y3
 
 
 
 def DrawArcToEllipse(x1, y1, width1, height1, x2, y2, x3, y3):
 
 
 
 def DrawArcToEllipse(x1, y1, width1, height1, x2, y2, x3, y3):
-    a1 = width1 / 2
-    b1 = height1 / 2
+    a1 = width1 / 2.0
+    b1 = height1 / 2.0
 
     # Check that x2 != x3
 
     # Check that x2 != x3
-    if abs(x2 - x3)<0.05:
+    if abs(x2 - x3) < 0.05:
         x4 = x2
         x4 = x2
-        if y3>y2:
+        if y3 > y2:
             y4 = y1 - math.sqrt((b1 * b1 - (((x2 - x1) * (x2 - x1)) * (b1 * b1) / (a1 * a1))))
         else:
             y4 = y1 + math.sqrt((b1 * b1 - (((x2 - x1) * (x2 - x1)) * (b1 * b1) / (a1 * a1))))
             y4 = y1 - math.sqrt((b1 * b1 - (((x2 - x1) * (x2 - x1)) * (b1 * b1) / (a1 * a1))))
         else:
             y4 = y1 + math.sqrt((b1 * b1 - (((x2 - x1) * (x2 - x1)) * (b1 * b1) / (a1 * a1))))
@@ -387,16 +386,16 @@ def DrawArcToEllipse(x1, y1, width1, height1, x2, y2, x3, y3):
     E = (A + B)
     F = (C - (2 * A * x1) - (2 * B * x2))
     G = ((A * x1 * x1) + (B * x2 * x2) - (C * x2) + D - 1)
     E = (A + B)
     F = (C - (2 * A * x1) - (2 * B * x2))
     G = ((A * x1 * x1) + (B * x2 * x2) - (C * x2) + D - 1)
-    H = ((y3 - y2) / (x2 - x2))
+    H = (float(y3 - y2) / (x2 - x2))
     K = ((F * F) - (4 * E * G))
 
     if K >= 0:
         # In this case the line intersects the ellipse, so calculate intersection
         if x2 >= x1:
     K = ((F * F) - (4 * E * G))
 
     if K >= 0:
         # In this case the line intersects the ellipse, so calculate intersection
         if x2 >= x1:
-            ellipse1_x = ((F*-1) + math.sqrt(K)) / (2 * E)
+            ellipse1_x = ((F * -1) + math.sqrt(K)) / (2 * E)
             ellipse1_y = ((H * (ellipse1_x - x2)) + y2)
         else:
             ellipse1_y = ((H * (ellipse1_x - x2)) + y2)
         else:
-            ellipse1_x = (((F*-1) - math.sqrt(K)) / (2 * E))
+            ellipse1_x = (((F * -1) - math.sqrt(K)) / (2 * E))
             ellipse1_y = ((H * (ellipse1_x - x2)) + y2)
     else:
         # in this case, arc does not intersect ellipse, so just draw arc
             ellipse1_y = ((H * (ellipse1_x - x2)) + y2)
     else:
         # in this case, arc does not intersect ellipse, so just draw arc