Point x,y fixes from Pierre
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29206 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -836,9 +836,9 @@ class Shape(ShapeEvtHandler):
|
|||||||
"""
|
"""
|
||||||
physicalAttachment = self.LogicalToPhysicalAttachment(attachmentPoint)
|
physicalAttachment = self.LogicalToPhysicalAttachment(attachmentPoint)
|
||||||
if physicalAttachment in [0, 2]:
|
if physicalAttachment in [0, 2]:
|
||||||
return pt1.x <= pt2.x
|
return pt1[0] <= pt2[0]
|
||||||
elif physicalAttachment in [1, 3]:
|
elif physicalAttachment in [1, 3]:
|
||||||
return pt1.y <= pt2.y
|
return pt1[1] <= pt2[1]
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -1479,7 +1479,7 @@ class Shape(ShapeEvtHandler):
|
|||||||
return self._xpos, self._ypos
|
return self._xpos, self._ypos
|
||||||
elif self._attachmentMode == ATTACHMENT_MODE_BRANCHING:
|
elif self._attachmentMode == ATTACHMENT_MODE_BRANCHING:
|
||||||
pt, stemPt = self.GetBranchingAttachmentPoint(attachment, nth)
|
pt, stemPt = self.GetBranchingAttachmentPoint(attachment, nth)
|
||||||
return pt.x, pt.y
|
return pt[0], pt[1]
|
||||||
elif self._attachmentMode == ATTACHMENT_MODE_EDGE:
|
elif self._attachmentMode == ATTACHMENT_MODE_EDGE:
|
||||||
if len(self._attachmentPoints):
|
if len(self._attachmentPoints):
|
||||||
for point in self._attachmentPoints:
|
for point in self._attachmentPoints:
|
||||||
@@ -1670,41 +1670,41 @@ class Shape(ShapeEvtHandler):
|
|||||||
|
|
||||||
# Assume that we have attachment points 0 to 3: top, right, bottom, left
|
# Assume that we have attachment points 0 to 3: top, right, bottom, left
|
||||||
if physicalAttachment == 0:
|
if physicalAttachment == 0:
|
||||||
neck.x = self.GetX()
|
neck[0] = self.GetX()
|
||||||
neck.y = root.y - self._branchNeckLength
|
neck[1] = root[1] - self._branchNeckLength
|
||||||
|
|
||||||
shoulder1.x = root.x - totalBranchLength / 2.0
|
shoulder1[0] = root[0] - totalBranchLength / 2.0
|
||||||
shoulder2.x = root.x + totalBranchLength / 2.0
|
shoulder2[0] = root[0] + totalBranchLength / 2.0
|
||||||
|
|
||||||
shoulder1.y = neck.y
|
shoulder1[1] = neck[1]
|
||||||
shoulder2.y = neck.y
|
shoulder2[1] = neck[1]
|
||||||
elif physicalAttachment == 1:
|
elif physicalAttachment == 1:
|
||||||
neck.x = root.x + self._branchNeckLength
|
neck[0] = root[0] + self._branchNeckLength
|
||||||
neck.y = root.y
|
neck[1] = root[1]
|
||||||
|
|
||||||
shoulder1.x = neck.x
|
shoulder1[0] = neck[0]
|
||||||
shoulder2.x = neck.x
|
shoulder2[0] = neck[0]
|
||||||
|
|
||||||
shoulder1.y = neck.y - totalBranchLength / 2.0
|
shoulder1[1] = neck[1] - totalBranchLength / 2.0
|
||||||
shoulder1.y = neck.y + totalBranchLength / 2.0
|
shoulder1[1] = neck[1] + totalBranchLength / 2.0
|
||||||
elif physicalAttachment == 2:
|
elif physicalAttachment == 2:
|
||||||
neck.x = self.GetX()
|
neck[0] = self.GetX()
|
||||||
neck.y = root.y + self._branchNeckLength
|
neck[1] = root[1] + self._branchNeckLength
|
||||||
|
|
||||||
shoulder1.x = root.x - totalBranchLength / 2.0
|
shoulder1[0] = root[0] - totalBranchLength / 2.0
|
||||||
shoulder2.x = root.x + totalBranchLength / 2.0
|
shoulder2[0] = root[0] + totalBranchLength / 2.0
|
||||||
|
|
||||||
shoulder1.y = neck.y
|
shoulder1[1] = neck[1]
|
||||||
shoulder2.y = neck.y
|
shoulder2[1] = neck[1]
|
||||||
elif physicalAttachment == 3:
|
elif physicalAttachment == 3:
|
||||||
neck.x = root.x - self._branchNeckLength
|
neck[0] = root[0] - self._branchNeckLength
|
||||||
neck.y = root.y
|
neck[1] = root[1]
|
||||||
|
|
||||||
shoulder1.x = neck.x
|
shoulder1[0] = neck[0]
|
||||||
shoulder2.x = neck.x
|
shoulder2[0] = neck[0]
|
||||||
|
|
||||||
shoulder1.y = neck.y - totalBranchLength / 2.0
|
shoulder1[1] = neck[1] - totalBranchLength / 2.0
|
||||||
shoulder2.y = neck.y + totalBranchLength / 2.0
|
shoulder2[1] = neck[1] + totalBranchLength / 2.0
|
||||||
else:
|
else:
|
||||||
raise "Unrecognised attachment point in GetBranchingAttachmentInfo"
|
raise "Unrecognised attachment point in GetBranchingAttachmentInfo"
|
||||||
return root, neck, shoulder1, shoulder2
|
return root, neck, shoulder1, shoulder2
|
||||||
@@ -1717,29 +1717,29 @@ class Shape(ShapeEvtHandler):
|
|||||||
stemPt = wx.RealPoint()
|
stemPt = wx.RealPoint()
|
||||||
|
|
||||||
if physicalAttachment == 0:
|
if physicalAttachment == 0:
|
||||||
pt.y = neck.y - self._branchStemLength
|
pt[1] = neck[1] - self._branchStemLength
|
||||||
pt.x = shoulder1.x + n * self._branchSpacing
|
pt[0] = shoulder1[0] + n * self._branchSpacing
|
||||||
|
|
||||||
stemPt.x = pt.x
|
stemPt[0] = pt[0]
|
||||||
stemPt.y = neck.y
|
stemPt[1] = neck[1]
|
||||||
elif physicalAttachment == 2:
|
elif physicalAttachment == 2:
|
||||||
pt.y = neck.y + self._branchStemLength
|
pt[1] = neck[1] + self._branchStemLength
|
||||||
pt.x = shoulder1.x + n * self._branchStemLength
|
pt[0] = shoulder1[0] + n * self._branchStemLength
|
||||||
|
|
||||||
stemPt.x = pt.x
|
stemPt[0] = pt[0]
|
||||||
stemPt.y = neck.y
|
stemPt[1] = neck[1]
|
||||||
elif physicalAttachment == 1:
|
elif physicalAttachment == 1:
|
||||||
pt.x = neck.x + self._branchStemLength
|
pt[0] = neck[0] + self._branchStemLength
|
||||||
pt.y = shoulder1.y + n * self._branchSpacing
|
pt[1] = shoulder1[1] + n * self._branchSpacing
|
||||||
|
|
||||||
stemPt.x = neck.x
|
stemPt[0] = neck[0]
|
||||||
stemPt.y = pt.y
|
stemPt[1] = pt[1]
|
||||||
elif physicalAttachment == 3:
|
elif physicalAttachment == 3:
|
||||||
pt.x = neck.x - self._branchStemLength
|
pt[0] = neck[0] - self._branchStemLength
|
||||||
pt.y = shoulder1.y + n * self._branchSpacing
|
pt[1] = shoulder1[1] + n * self._branchSpacing
|
||||||
|
|
||||||
stemPt.x = neck.x
|
stemPt[0] = neck[0]
|
||||||
stemPt.y = pt.y
|
stemPt[1] = pt[1]
|
||||||
else:
|
else:
|
||||||
raise "Unrecognised attachment point in GetBranchingAttachmentPoint"
|
raise "Unrecognised attachment point in GetBranchingAttachmentPoint"
|
||||||
|
|
||||||
@@ -1765,17 +1765,17 @@ class Shape(ShapeEvtHandler):
|
|||||||
|
|
||||||
# Assume that we have attachment points 0 to 3: top, right, bottom, left
|
# Assume that we have attachment points 0 to 3: top, right, bottom, left
|
||||||
if physicalAttachment == 0:
|
if physicalAttachment == 0:
|
||||||
root.x = self.GetX()
|
root[0] = self.GetX()
|
||||||
root.y = self.GetY() - height / 2.0
|
root[1] = self.GetY() - height / 2.0
|
||||||
elif physicalAttachment == 1:
|
elif physicalAttachment == 1:
|
||||||
root.x = self.GetX() + width / 2.0
|
root[0] = self.GetX() + width / 2.0
|
||||||
root.y = self.GetY()
|
root[1] = self.GetY()
|
||||||
elif physicalAttachment == 2:
|
elif physicalAttachment == 2:
|
||||||
root.x = self.GetX()
|
root[0] = self.GetX()
|
||||||
root.y = self.GetY() + height / 2.0
|
root[1] = self.GetY() + height / 2.0
|
||||||
elif physicalAttachment == 3:
|
elif physicalAttachment == 3:
|
||||||
root.x = self.GetX() - width / 2.0
|
root[0] = self.GetX() - width / 2.0
|
||||||
root.y = self.GetY()
|
root[1] = self.GetY()
|
||||||
else:
|
else:
|
||||||
raise "Unrecognised attachment point in GetBranchingAttachmentRoot"
|
raise "Unrecognised attachment point in GetBranchingAttachmentRoot"
|
||||||
|
|
||||||
@@ -1809,7 +1809,7 @@ class Shape(ShapeEvtHandler):
|
|||||||
|
|
||||||
if self.GetBranchStyle() & BRANCHING_ATTACHMENT_BLOB and count > 1:
|
if self.GetBranchStyle() & BRANCHING_ATTACHMENT_BLOB and count > 1:
|
||||||
blobSize = 6.0
|
blobSize = 6.0
|
||||||
dc.DrawEllipse(stemPt.x - blobSize / 2.0, stemPt.y - blobSize / 2.0, blobSize, blobSize)
|
dc.DrawEllipse(stemPt[0] - blobSize / 2.0, stemPt[1] - blobSize / 2.0, blobSize, blobSize)
|
||||||
|
|
||||||
def OnDrawBranches(self, dc, erase = False):
|
def OnDrawBranches(self, dc, erase = False):
|
||||||
if self._attachmentMode != ATTACHMENT_MODE_BRANCHING:
|
if self._attachmentMode != ATTACHMENT_MODE_BRANCHING:
|
||||||
@@ -2442,15 +2442,15 @@ class PolygonShape(Shape):
|
|||||||
bottom = -10000
|
bottom = -10000
|
||||||
|
|
||||||
for point in self._points:
|
for point in self._points:
|
||||||
if point.x < left:
|
if point[0] < left:
|
||||||
left = point.x
|
left = point[0]
|
||||||
if point.x > right:
|
if point[0] > right:
|
||||||
right = point.x
|
right = point[0]
|
||||||
|
|
||||||
if point.y < top:
|
if point[1] < top:
|
||||||
top = point.y
|
top = point[1]
|
||||||
if point.y > bottom:
|
if point[1] > bottom:
|
||||||
bottom = point.y
|
bottom = point[1]
|
||||||
|
|
||||||
self._boundWidth = right - left
|
self._boundWidth = right - left
|
||||||
self._boundHeight = bottom - top
|
self._boundHeight = bottom - top
|
||||||
@@ -2468,15 +2468,15 @@ class PolygonShape(Shape):
|
|||||||
bottom = -10000
|
bottom = -10000
|
||||||
|
|
||||||
for point in self._points:
|
for point in self._points:
|
||||||
if point.x < left:
|
if point[0] < left:
|
||||||
left = point.x
|
left = point[0]
|
||||||
if point.x > right:
|
if point[0] > right:
|
||||||
right = point.x
|
right = point[0]
|
||||||
|
|
||||||
if point.y < top:
|
if point[1] < top:
|
||||||
top = point.y
|
top = point[1]
|
||||||
if point.y > bottom:
|
if point[1] > bottom:
|
||||||
bottom = point.y
|
bottom = point[1]
|
||||||
|
|
||||||
bwidth = right - left
|
bwidth = right - left
|
||||||
bheight = bottom - top
|
bheight = bottom - top
|
||||||
@@ -2484,9 +2484,8 @@ class PolygonShape(Shape):
|
|||||||
newCentreX = left + bwidth / 2.0
|
newCentreX = left + bwidth / 2.0
|
||||||
newCentreY = top + bheight / 2.0
|
newCentreY = top + bheight / 2.0
|
||||||
|
|
||||||
for point in self._points:
|
for i in range(len(self._points)):
|
||||||
point.x -= newCentreX
|
self._points[i] = self._points[i][0] - newCentreX, self._points[i][1] - newCentreY
|
||||||
point.y -= newCentreY
|
|
||||||
self._xpos += newCentreX
|
self._xpos += newCentreX
|
||||||
self._ypos += newCentreY
|
self._ypos += newCentreY
|
||||||
|
|
||||||
@@ -2502,8 +2501,8 @@ class PolygonShape(Shape):
|
|||||||
ypoints = []
|
ypoints = []
|
||||||
|
|
||||||
for point in self._points:
|
for point in self._points:
|
||||||
xpoints.append(point.x + self._xpos)
|
xpoints.append(point[0] + self._xpos)
|
||||||
ypoints.append(point.y + self._ypos)
|
ypoints.append(point[1] + self._ypos)
|
||||||
|
|
||||||
# We assume it's inside the polygon UNLESS one or more
|
# We assume it's inside the polygon UNLESS one or more
|
||||||
# lines don't hit the outline.
|
# lines don't hit the outline.
|
||||||
@@ -2542,8 +2541,7 @@ class PolygonShape(Shape):
|
|||||||
y_proportion = abs(float(new_height) / self._originalHeight)
|
y_proportion = abs(float(new_height) / self._originalHeight)
|
||||||
|
|
||||||
for i in range(max(len(self._points), len(self._originalPoints))):
|
for i in range(max(len(self._points), len(self._originalPoints))):
|
||||||
self._points[i].x = self._originalPoints[i][0] * x_proportion
|
self._points[i] = wx.Point(self._originalPoints[i][0] * x_proportion, self._originalPoints[i][1] * y_proportion)
|
||||||
self._points[i].y = self._originalPoints[i][1] * y_proportion
|
|
||||||
|
|
||||||
self._boundWidth = abs(new_width)
|
self._boundWidth = abs(new_width)
|
||||||
self._boundHeight = abs(new_height)
|
self._boundHeight = abs(new_height)
|
||||||
@@ -2557,7 +2555,7 @@ class PolygonShape(Shape):
|
|||||||
self._originalPoints = []
|
self._originalPoints = []
|
||||||
|
|
||||||
for point in self._points:
|
for point in self._points:
|
||||||
original_point = wx.RealPoint(point.x, point.y)
|
original_point = wx.RealPoint(point[0], point[1])
|
||||||
self._originalPoints.append(original_point)
|
self._originalPoints.append(original_point)
|
||||||
|
|
||||||
self.CalculateBoundingBox()
|
self.CalculateBoundingBox()
|
||||||
@@ -2576,8 +2574,8 @@ class PolygonShape(Shape):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
secondPoint = self._points[0]
|
secondPoint = self._points[0]
|
||||||
|
|
||||||
x = (secondPoint.x - firstPoint.x) / 2.0 + firstPoint.x
|
x = (secondPoint[0] - firstPoint[0]) / 2.0 + firstPoint[0]
|
||||||
y = (secondPoint.y - firstPoint.y) / 2.0 + firstPoint.y
|
y = (secondPoint[1] - firstPoint[1]) / 2.0 + firstPoint[1]
|
||||||
point = wx.RealPoint(x, y)
|
point = wx.RealPoint(x, y)
|
||||||
|
|
||||||
if pos >= len(self._points) - 1:
|
if pos >= len(self._points) - 1:
|
||||||
@@ -2610,17 +2608,17 @@ class PolygonShape(Shape):
|
|||||||
# Look for the point we'd be connecting to. This is
|
# Look for the point we'd be connecting to. This is
|
||||||
# a heuristic...
|
# a heuristic...
|
||||||
for point in self._points:
|
for point in self._points:
|
||||||
if point.x == 0:
|
if point[0] == 0:
|
||||||
if y2 > y1 and point.y > 0:
|
if y2 > y1 and point[1] > 0:
|
||||||
return point.x + self._xpos, point.y + self._ypos
|
return point[0] + self._xpos, point[1] + self._ypos
|
||||||
elif y2 < y1 and point.y < 0:
|
elif y2 < y1 and point[1] < 0:
|
||||||
return point.x + self._xpos, point.y + self._ypos
|
return point[0] + self._xpos, point[1] + self._ypos
|
||||||
|
|
||||||
xpoints = []
|
xpoints = []
|
||||||
ypoints = []
|
ypoints = []
|
||||||
for point in self._points:
|
for point in self._points:
|
||||||
xpoints.append(point.x + self._xpos)
|
xpoints.append(point[0] + self._xpos)
|
||||||
ypoints.append(point.y + self._ypos)
|
ypoints.append(point[1] + self._ypos)
|
||||||
|
|
||||||
return FindEndForPolyline(xpoints, ypoints, x1, y1, x2, y2)
|
return FindEndForPolyline(xpoints, ypoints, x1, y1, x2, y2)
|
||||||
|
|
||||||
@@ -2655,15 +2653,15 @@ class PolygonShape(Shape):
|
|||||||
# Make as many control points as there are vertices
|
# Make as many control points as there are vertices
|
||||||
def MakeControlPoints(self):
|
def MakeControlPoints(self):
|
||||||
for point in self._points:
|
for point in self._points:
|
||||||
control = PolygonControlPoint(self._canvas, self, CONTROL_POINT_SIZE, point, point.x, point.y)
|
control = PolygonControlPoint(self._canvas, self, CONTROL_POINT_SIZE, point, point[0], point[1])
|
||||||
self._canvas.AddShape(control)
|
self._canvas.AddShape(control)
|
||||||
self._controlPoints.append(control)
|
self._controlPoints.append(control)
|
||||||
|
|
||||||
def ResetControlPoints(self):
|
def ResetControlPoints(self):
|
||||||
for i in range(min(len(self._points), len(self._controlPoints))):
|
for i in range(min(len(self._points), len(self._controlPoints))):
|
||||||
point = self._points[i]
|
point = self._points[i]
|
||||||
self._controlPoints[i]._xoffset = point.x
|
self._controlPoints[i]._xoffset = point[0]
|
||||||
self._controlPoints[i]._yoffset = point.y
|
self._controlPoints[i]._yoffset = point[1]
|
||||||
self._controlPoints[i].polygonVertex = point
|
self._controlPoints[i].polygonVertex = point
|
||||||
|
|
||||||
def GetNumberOfAttachments(self):
|
def GetNumberOfAttachments(self):
|
||||||
@@ -2676,7 +2674,7 @@ class PolygonShape(Shape):
|
|||||||
def GetAttachmentPosition(self, attachment, nth = 0, no_arcs = 1, line = None):
|
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]
|
point = self._points[0]
|
||||||
return point.x + self._xpos, point.y + self._ypos
|
return point[0] + self._xpos, point[1] + self._ypos
|
||||||
return Shape.GetAttachmentPosition(self, attachment, nth, no_arcs, line)
|
return Shape.GetAttachmentPosition(self, attachment, nth, no_arcs, line)
|
||||||
|
|
||||||
def AttachmentIsValid(self, attachment):
|
def AttachmentIsValid(self, attachment):
|
||||||
@@ -2707,20 +2705,20 @@ class PolygonShape(Shape):
|
|||||||
point._x = x1 * cosTheta - y1 * sinTheta + x * (1 - cosTheta) + y * sinTheta
|
point._x = x1 * cosTheta - y1 * sinTheta + x * (1 - cosTheta) + y * sinTheta
|
||||||
point._y = x1 * sinTheta + y1 * cosTheta + y * (1 - cosTheta) + x * sinTheta
|
point._y = x1 * sinTheta + y1 * cosTheta + y * (1 - cosTheta) + x * sinTheta
|
||||||
|
|
||||||
for point in self._points:
|
for i in range(len(self._points)):
|
||||||
x1 = point.x
|
x1, y1 = self._points[i]
|
||||||
y1 = point.y
|
|
||||||
|
|
||||||
point.x = x1 * cosTheta - y1 * sinTheta + x * (1 - cosTheta) + y * sinTheta
|
self._points[i] = x1 * cosTheta - y1 * sinTheta + x * (1 - cosTheta) + y * sinTheta, x1 * sinTheta + y1 * cosTheta + y * (1 - cosTheta) + x * sinTheta
|
||||||
point.y = x1 * sinTheta + y1 * cosTheta + y * (1 - cosTheta) + x * sinTheta
|
|
||||||
|
|
||||||
for point in self._originalPoints:
|
for i in range(len(self._originalPoints)):
|
||||||
x1 = point.x
|
x1, y1 = self._originalPoints[i]
|
||||||
y1 = point.y
|
|
||||||
|
|
||||||
point.x = x1 * cosTheta - y1 * sinTheta + x * (1 - cosTheta) + y * sinTheta
|
self._originalPoints[i] = x1 * cosTheta - y1 * sinTheta + x * (1 - cosTheta) + y * sinTheta, x1 * sinTheta + y1 * cosTheta + y * (1 - cosTheta) + x * sinTheta
|
||||||
point.y = x1 * sinTheta + y1 * cosTheta + y * (1 - cosTheta) + x * sinTheta
|
|
||||||
|
|
||||||
|
# Added by Pierre Hj<48>lm. If we don't do this the outline will be
|
||||||
|
# the wrong size. Hopefully it won't have any ill effects.
|
||||||
|
self.UpdateOriginalPoints()
|
||||||
|
|
||||||
self._rotation = theta
|
self._rotation = theta
|
||||||
|
|
||||||
self.CalculatePolygonCentre()
|
self.CalculatePolygonCentre()
|
||||||
@@ -2743,7 +2741,7 @@ class PolygonShape(Shape):
|
|||||||
|
|
||||||
pt.CalculateNewSize(x, y)
|
pt.CalculateNewSize(x, y)
|
||||||
|
|
||||||
self.GetEventHandler().OnDrawOutline(dc, self.GetX(), self.GetY(), pt.GetNewSize().x, pt.GetNewSize().y)
|
self.GetEventHandler().OnDrawOutline(dc, self.GetX(), self.GetY(), pt.GetNewSize()[0], pt.GetNewSize()[1])
|
||||||
|
|
||||||
def OnSizingBeginDragLeft(self, pt, x, y, keys = 0, attachment = 0):
|
def OnSizingBeginDragLeft(self, pt, x, y, keys = 0, attachment = 0):
|
||||||
dc = wx.ClientDC(self.GetCanvas())
|
dc = wx.ClientDC(self.GetCanvas())
|
||||||
@@ -2758,8 +2756,8 @@ class PolygonShape(Shape):
|
|||||||
dist = math.sqrt((x - self.GetX()) * (x - self.GetX()) + (y - self.GetY()) * (y - self.GetY()))
|
dist = math.sqrt((x - self.GetX()) * (x - self.GetX()) + (y - self.GetY()) * (y - self.GetY()))
|
||||||
|
|
||||||
pt._originalDistance = dist
|
pt._originalDistance = dist
|
||||||
pt._originalSize.x = bound_x
|
pt._originalSize[0] = bound_x
|
||||||
pt._originalSize.y = bound_y
|
pt._originalSize[1] = bound_y
|
||||||
|
|
||||||
if pt._originalDistance == 0:
|
if pt._originalDistance == 0:
|
||||||
pt._originalDistance = 0.0001
|
pt._originalDistance = 0.0001
|
||||||
@@ -2772,7 +2770,7 @@ class PolygonShape(Shape):
|
|||||||
|
|
||||||
pt.CalculateNewSize(x, y)
|
pt.CalculateNewSize(x, y)
|
||||||
|
|
||||||
self.GetEventHandler().OnDrawOutline(dc, self.GetX(), self.GetY(), pt.GetNewSize().x, pt.GetNewSize().y)
|
self.GetEventHandler().OnDrawOutline(dc, self.GetX(), self.GetY(), pt.GetNewSize()[0], pt.GetNewSize()[1])
|
||||||
|
|
||||||
self._canvas.CaptureMouse()
|
self._canvas.CaptureMouse()
|
||||||
|
|
||||||
@@ -2789,7 +2787,7 @@ class PolygonShape(Shape):
|
|||||||
self.CalculateBoundingBox()
|
self.CalculateBoundingBox()
|
||||||
self.CalculatePolygonCentre()
|
self.CalculatePolygonCentre()
|
||||||
else:
|
else:
|
||||||
self.SetSize(pt.GetNewSize().x, pt.GetNewSize().y)
|
self.SetSize(pt.GetNewSize()[0], pt.GetNewSize()[1])
|
||||||
|
|
||||||
self.Recompute()
|
self.Recompute()
|
||||||
self.ResetControlPoints()
|
self.ResetControlPoints()
|
||||||
@@ -3152,8 +3150,8 @@ class PolygonControlPoint(ControlPoint):
|
|||||||
bound_x, bound_y = self.GetShape().GetBoundingBoxMax()
|
bound_x, bound_y = self.GetShape().GetBoundingBoxMax()
|
||||||
dist = math.sqrt((x - self._shape.GetX()) * (x - self._shape.GetX()) + (y - self._shape.GetY()) * (y - self._shape.GetY()))
|
dist = math.sqrt((x - self._shape.GetX()) * (x - self._shape.GetX()) + (y - self._shape.GetY()) * (y - self._shape.GetY()))
|
||||||
|
|
||||||
self._newSize.x = dist / self._originalDistance * self._originalSize.x
|
self._newSize[0] = dist / self._originalDistance * self._originalSize[0]
|
||||||
self._newSize.y = dist / self._originalDistance * self._originalSize.y
|
self._newSize[1] = dist / self._originalDistance * self._originalSize[1]
|
||||||
|
|
||||||
# Implement resizing polygon or moving the vertex
|
# Implement resizing polygon or moving the vertex
|
||||||
def OnDragLeft(self, draw, x, y, keys = 0, attachment = 0):
|
def OnDragLeft(self, draw, x, y, keys = 0, attachment = 0):
|
||||||
|
@@ -260,12 +260,12 @@ class DividedShape(RectangleShape):
|
|||||||
if line and line.GetAlignmentType(isEnd) == LINE_ALIGNMENT_TO_NEXT_HANDLE:
|
if line and line.GetAlignmentType(isEnd) == LINE_ALIGNMENT_TO_NEXT_HANDLE:
|
||||||
# Align line according to the next handle along
|
# Align line according to the next handle along
|
||||||
point = line.GetNextControlPoint(self)
|
point = line.GetNextControlPoint(self)
|
||||||
if point.x < left:
|
if point[0] < left:
|
||||||
x = left
|
x = left
|
||||||
elif point.x > right:
|
elif point[0] > right:
|
||||||
x = right
|
x = right
|
||||||
else:
|
else:
|
||||||
x = point.x
|
x = point[0]
|
||||||
else:
|
else:
|
||||||
x = left + (nth + 1) * self._width / (no_arcs + 1.0)
|
x = left + (nth + 1) * self._width / (no_arcs + 1.0)
|
||||||
else:
|
else:
|
||||||
@@ -276,12 +276,12 @@ class DividedShape(RectangleShape):
|
|||||||
if line and line.GetAlignmentType(isEnd) == LINE_ALIGNMENT_TO_NEXT_HANDLE:
|
if line and line.GetAlignmentType(isEnd) == LINE_ALIGNMENT_TO_NEXT_HANDLE:
|
||||||
# Align line according to the next handle along
|
# Align line according to the next handle along
|
||||||
point = line.GetNextControlPoint(self)
|
point = line.GetNextControlPoint(self)
|
||||||
if point.x < left:
|
if point[0] < left:
|
||||||
x = left
|
x = left
|
||||||
elif point.x > right:
|
elif point[0] > right:
|
||||||
x = right
|
x = right
|
||||||
else:
|
else:
|
||||||
x = point.x
|
x = point[0]
|
||||||
else:
|
else:
|
||||||
x = left + (nth + 1) * self._width / (no_arcs + 1.0)
|
x = left + (nth + 1) * self._width / (no_arcs + 1.0)
|
||||||
else:
|
else:
|
||||||
@@ -310,12 +310,12 @@ class DividedShape(RectangleShape):
|
|||||||
if line and line.GetAlignmentType(isEnd) == LINE_ALIGNMENT_TO_NEXT_HANDLE:
|
if line and line.GetAlignmentType(isEnd) == LINE_ALIGNMENT_TO_NEXT_HANDLE:
|
||||||
# Align line according to the next handle along
|
# Align line according to the next handle along
|
||||||
point = line.GetNextControlPoint(self)
|
point = line.GetNextControlPoint(self)
|
||||||
if point.y < bottom:
|
if point[1] < bottom:
|
||||||
y = bottom
|
y = bottom
|
||||||
elif point.y > top:
|
elif point[1] > top:
|
||||||
y = top
|
y = top
|
||||||
else:
|
else:
|
||||||
y = point.y
|
y = point[1]
|
||||||
else:
|
else:
|
||||||
y = top + (nth + 1) * region._height / (no_arcs + 1.0)
|
y = top + (nth + 1) * region._height / (no_arcs + 1.0)
|
||||||
else:
|
else:
|
||||||
|
@@ -61,6 +61,9 @@ class DrawOp(object):
|
|||||||
|
|
||||||
def Translate(self, x, y):
|
def Translate(self, x, y):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def Rotate(self, x, y, theta, sinTheta, cosTheta):
|
||||||
|
pass
|
||||||
|
|
||||||
class OpSetGDI(DrawOp):
|
class OpSetGDI(DrawOp):
|
||||||
"""Set font, brush, text colour."""
|
"""Set font, brush, text colour."""
|
||||||
@@ -163,7 +166,7 @@ class OpDraw(DrawOp):
|
|||||||
elif self._op == DRAWOP_DRAW_ARC:
|
elif self._op == DRAWOP_DRAW_ARC:
|
||||||
dc.DrawArc(self._x2 + xoffset, self._y2 + yoffset, self._x3 + xoffset, self._y3 + yoffset, self._x1 + xoffset, self._y1 + yoffset)
|
dc.DrawArc(self._x2 + xoffset, self._y2 + yoffset, self._x3 + xoffset, self._y3 + yoffset, self._x1 + xoffset, self._y1 + yoffset)
|
||||||
elif self._op == DRAWOP_DRAW_ELLIPTIC_ARC:
|
elif self._op == DRAWOP_DRAW_ELLIPTIC_ARC:
|
||||||
dc.DrawEllipticArc(self._x1 + xoffset, self._y1 + yoffset, self._x2, self._y2, self._x3 * 360 / (2 * math.pi), self.y3 * 360 / (2 * math.pi))
|
dc.DrawEllipticArc(self._x1 + xoffset, self._y1 + yoffset, self._x2, self._y2, self._x3 * 360 / (2 * math.pi), self._y3 * 360 / (2 * math.pi))
|
||||||
elif self._op == DRAWOP_DRAW_POINT:
|
elif self._op == DRAWOP_DRAW_POINT:
|
||||||
dc.DrawPoint(self._x1 + xoffset, self._y1 + yoffset)
|
dc.DrawPoint(self._x1 + xoffset, self._y1 + yoffset)
|
||||||
elif self._op == DRAWOP_DRAW_TEXT:
|
elif self._op == DRAWOP_DRAW_TEXT:
|
||||||
@@ -263,7 +266,7 @@ class OpPolyDraw(DrawOp):
|
|||||||
|
|
||||||
def Scale(self, scaleX, scaleY):
|
def Scale(self, scaleX, scaleY):
|
||||||
for i in range(self._noPoints):
|
for i in range(self._noPoints):
|
||||||
self._points[i] = self._points[i][0] * scaleX, self._points[i][1] * scaleY
|
self._points[i] = wx.Point(self._points[i][0] * scaleX, self._points[i][1] * scaleY)
|
||||||
|
|
||||||
def Translate(self, x, y):
|
def Translate(self, x, y):
|
||||||
for i in range(self._noPoints):
|
for i in range(self._noPoints):
|
||||||
@@ -275,8 +278,7 @@ class OpPolyDraw(DrawOp):
|
|||||||
x1 = self._points[i][0]
|
x1 = self._points[i][0]
|
||||||
y1 = self._points[i][1]
|
y1 = self._points[i][1]
|
||||||
|
|
||||||
self._points[i][0] = x1 * cosTheta - y1 * sinTheta + x * (1 - cosTheta) + y * sinTheta
|
self._points[i] = x1 * cosTheta - y1 * sinTheta + x * (1 - cosTheta) + y * sinTheta, x1 * sinTheta + y1 * cosTheta + y * (1 - cosTheta) + x * sinTheta
|
||||||
self._points[i][1] = x1 * sinTheta + y1 * cosTheta + y * (1 - cosTheta) + x * sinTheta
|
|
||||||
|
|
||||||
def OnDrawOutline(self, dc, x, y, w, h, oldW, oldH):
|
def OnDrawOutline(self, dc, x, y, w, h, oldW, oldH):
|
||||||
dc.SetBrush(wx.TRANSPARENT_BRUSH)
|
dc.SetBrush(wx.TRANSPARENT_BRUSH)
|
||||||
@@ -394,8 +396,8 @@ class PseudoMetaFile(object):
|
|||||||
if theta1 == 0:
|
if theta1 == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
cosTheta = cos(theta1)
|
cosTheta = math.cos(theta1)
|
||||||
sinTheta = sin(theta1)
|
sinTheta = math.sin(theta1)
|
||||||
|
|
||||||
for op in self._ops:
|
for op in self._ops:
|
||||||
op.Rotate(x, y, theta, sinTheta, cosTheta)
|
op.Rotate(x, y, theta, sinTheta, cosTheta)
|
||||||
@@ -710,7 +712,7 @@ class DrawnShape(RectangleShape):
|
|||||||
# of metafiles.
|
# of metafiles.
|
||||||
def DetermineMetaFile(self, rotation):
|
def DetermineMetaFile(self, rotation):
|
||||||
tolerance = 0.0001
|
tolerance = 0.0001
|
||||||
angles = [0.0, math.pi / 2, math.pi, 3 * pi / 2]
|
angles = [0.0, math.pi / 2, math.pi, 3 * math.pi / 2]
|
||||||
|
|
||||||
whichMetaFile = 0
|
whichMetaFile = 0
|
||||||
|
|
||||||
|
@@ -330,7 +330,8 @@ class LineShape(Shape):
|
|||||||
# initialize them by placing them half way between the first
|
# initialize them by placing them half way between the first
|
||||||
# and the last.
|
# and the last.
|
||||||
|
|
||||||
for point in self._lineControlPoints[1:]:
|
for i in range(1,len(self._lineControlPoints)):
|
||||||
|
point = self._lineControlPoints[i]
|
||||||
if point[0] == -999:
|
if point[0] == -999:
|
||||||
if first_point[0] < last_point[0]:
|
if first_point[0] < last_point[0]:
|
||||||
x1 = first_point[0]
|
x1 = first_point[0]
|
||||||
@@ -344,8 +345,7 @@ class LineShape(Shape):
|
|||||||
else:
|
else:
|
||||||
y2 = first_point[1]
|
y2 = first_point[1]
|
||||||
y1 = last_point[1]
|
y1 = last_point[1]
|
||||||
point[0] = (x2 - x1) / 2.0 + x1
|
self._lineControlPoints[i] = (x2 - x1) / 2.0 + x1, (y2 - y1) / 2.0 + y1
|
||||||
point[1] = (y2 - y1) / 2.0 + y1
|
|
||||||
|
|
||||||
def FormatText(self, dc, s, i):
|
def FormatText(self, dc, s, i):
|
||||||
"""Format a text string according to the region size, adding
|
"""Format a text string according to the region size, adding
|
||||||
@@ -490,15 +490,10 @@ class LineShape(Shape):
|
|||||||
|
|
||||||
def SetEnds(self, x1, y1, x2, y2):
|
def SetEnds(self, x1, y1, x2, y2):
|
||||||
"""Set the end positions of the line."""
|
"""Set the end positions of the line."""
|
||||||
|
self._lineControlPoints[0] = x1, y1
|
||||||
|
self._lineControlPoints[-1] = x2, y2
|
||||||
|
|
||||||
# Find centre point
|
# Find centre point
|
||||||
first_point = self._lineControlPoints[0]
|
|
||||||
last_point = self._lineControlPoints[-1]
|
|
||||||
|
|
||||||
first_point[0] = x1
|
|
||||||
first_point[1] = y1
|
|
||||||
last_point[0] = x2
|
|
||||||
last_point[1] = y2
|
|
||||||
|
|
||||||
self._xpos = (x1 + x2) / 2.0
|
self._xpos = (x1 + x2) / 2.0
|
||||||
self._ypos = (y1 + y2) / 2.0
|
self._ypos = (y1 + y2) / 2.0
|
||||||
|
|
||||||
@@ -935,8 +930,8 @@ class LineShape(Shape):
|
|||||||
# if attachment mode is ON
|
# if attachment mode is ON
|
||||||
if self._from == self._to and self._from.GetAttachmentMode() != ATTACHMENT_MODE_NONE and moveControlPoints and self._lineControlPoints and not (x_offset == 0 and y_offset == 0):
|
if self._from == self._to and self._from.GetAttachmentMode() != ATTACHMENT_MODE_NONE and moveControlPoints and self._lineControlPoints and not (x_offset == 0 and y_offset == 0):
|
||||||
for point in self._lineControlPoints[1:-1]:
|
for point in self._lineControlPoints[1:-1]:
|
||||||
point.x += x_offset
|
point[0] += x_offset
|
||||||
point.y += y_offset
|
point[1] += y_offset
|
||||||
|
|
||||||
self.Move(dc, self._xpos, self._ypos)
|
self.Move(dc, self._xpos, self._ypos)
|
||||||
|
|
||||||
@@ -1005,7 +1000,7 @@ class LineShape(Shape):
|
|||||||
|
|
||||||
points = []
|
points = []
|
||||||
for point in self._lineControlPoints:
|
for point in self._lineControlPoints:
|
||||||
points.append(wx.Point(point.x, point.y))
|
points.append(wx.Point(point[0], point[1]))
|
||||||
|
|
||||||
#print points
|
#print points
|
||||||
if self._isSpline:
|
if self._isSpline:
|
||||||
@@ -1016,7 +1011,7 @@ class LineShape(Shape):
|
|||||||
if sys.platform[:3] == "win":
|
if sys.platform[:3] == "win":
|
||||||
# For some reason, last point isn't drawn under Windows
|
# For some reason, last point isn't drawn under Windows
|
||||||
pt = points[-1]
|
pt = points[-1]
|
||||||
dc.DrawPoint(pt.x, pt.y)
|
dc.DrawPoint(pt[0], pt[1])
|
||||||
|
|
||||||
# Problem with pen - if not a solid pen, does strange things
|
# Problem with pen - if not a solid pen, does strange things
|
||||||
# to the arrowhead. So make (get) a new pen that's solid.
|
# to the arrowhead. So make (get) a new pen that's solid.
|
||||||
@@ -1150,8 +1145,7 @@ class LineShape(Shape):
|
|||||||
|
|
||||||
pt.SetX(x)
|
pt.SetX(x)
|
||||||
pt.SetY(y)
|
pt.SetY(y)
|
||||||
pt._point[0] = x
|
pt._point = x, y
|
||||||
pt._point[1] = y
|
|
||||||
|
|
||||||
old_pen = self.GetPen()
|
old_pen = self.GetPen()
|
||||||
old_brush = self.GetBrush()
|
old_brush = self.GetBrush()
|
||||||
@@ -1186,8 +1180,7 @@ class LineShape(Shape):
|
|||||||
|
|
||||||
pt._xpos = x
|
pt._xpos = x
|
||||||
pt._ypos = y
|
pt._ypos = y
|
||||||
pt._point[0] = x
|
pt._point = x, y
|
||||||
pt._point[1] = y
|
|
||||||
|
|
||||||
old_pen = self.GetPen()
|
old_pen = self.GetPen()
|
||||||
old_brush = self.GetBrush()
|
old_brush = self.GetBrush()
|
||||||
@@ -1223,8 +1216,7 @@ class LineShape(Shape):
|
|||||||
# as it changed shape.
|
# as it changed shape.
|
||||||
pt._xpos = pt._originalPos[0]
|
pt._xpos = pt._originalPos[0]
|
||||||
pt._ypos = pt._originalPos[1]
|
pt._ypos = pt._originalPos[1]
|
||||||
pt._point[0] = pt._originalPos[0]
|
pt._point = pt._originalPos[0], pt._originalPos[1]
|
||||||
pt._point[1] = pt._originalPos[1]
|
|
||||||
|
|
||||||
self.OnMoveMiddleControlPoint(dc, pt, rpt)
|
self.OnMoveMiddleControlPoint(dc, pt, rpt)
|
||||||
|
|
||||||
@@ -1247,8 +1239,7 @@ class LineShape(Shape):
|
|||||||
lpt._xpos = pt[0]
|
lpt._xpos = pt[0]
|
||||||
lpt._ypos = pt[1]
|
lpt._ypos = pt[1]
|
||||||
|
|
||||||
lpt._point[0] = pt[0]
|
lpt._point = pt[0], pt[1]
|
||||||
lpt._point[1] = pt[1]
|
|
||||||
|
|
||||||
self.GetEventHandler().OnMoveLink(dc)
|
self.GetEventHandler().OnMoveLink(dc)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user