Since everything in the submodules is to appear in the pacakge
namespace rename the submodule to have a leading underscore to make it easier to document it that way. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27634 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -3,12 +3,20 @@ The Object Graphics Library provides for simple drawing and manipulation
|
||||
of 2D objects.
|
||||
"""
|
||||
|
||||
__all__ = ["basic", "diagram", "canvas", "lines", "bmpshape", "divided", "composit"]
|
||||
from _basic import *
|
||||
from _diagram import *
|
||||
from _canvas import *
|
||||
from _lines import *
|
||||
from _bmpshape import *
|
||||
from _divided import *
|
||||
from _composit import *
|
||||
|
||||
|
||||
|
||||
# Set things up for documenting with epydoc. The __docfilter__ will
|
||||
# prevent some things from beign documented, and anything in __all__
|
||||
# will appear to actually exist in this module.
|
||||
import wx._core as _wx
|
||||
__docfilter__ = _wx.__DocFilter(globals())
|
||||
__all__ = [name for name in dir() if not name.startswith('_')]
|
||||
|
||||
from basic import *
|
||||
from diagram import *
|
||||
from canvas import *
|
||||
from lines import *
|
||||
from bmpshape import *
|
||||
from divided import *
|
||||
from composit import *
|
||||
|
@@ -14,9 +14,9 @@
|
||||
from __future__ import division
|
||||
|
||||
import wx
|
||||
from math import pi, sqrt, atan, sin, cos
|
||||
import math
|
||||
|
||||
from oglmisc import *
|
||||
from _oglmisc import *
|
||||
|
||||
DragOffsetX = 0.0
|
||||
DragOffsetY = 0.0
|
||||
@@ -484,7 +484,7 @@ class Shape(ShapeEvtHandler):
|
||||
e = self.GetAttachmentPositionEdge(i)
|
||||
if e:
|
||||
xp, yp = e
|
||||
l = sqrt(((xp - x) * (xp - x)) + (yp - y) * (yp - y))
|
||||
l = math.sqrt(((xp - x) * (xp - x)) + (yp - y) * (yp - y))
|
||||
if l<nearest:
|
||||
nearest = l
|
||||
nearest_attachment = i
|
||||
@@ -1841,11 +1841,11 @@ class Shape(ShapeEvtHandler):
|
||||
"""
|
||||
if RoughlyEqual(self.GetRotation(), 0):
|
||||
i = physicalAttachment
|
||||
elif RoughlyEqual(self.GetRotation(), pi / 2):
|
||||
elif RoughlyEqual(self.GetRotation(), math.pi / 2):
|
||||
i = physicalAttachment - 1
|
||||
elif RoughlyEqual(self.GetRotation(), pi):
|
||||
elif RoughlyEqual(self.GetRotation(), math.pi):
|
||||
i = physicalAttachment - 2
|
||||
elif RoughlyEqual(self.GetRotation(), 3 * pi / 2):
|
||||
elif RoughlyEqual(self.GetRotation(), 3 * math.pi / 2):
|
||||
i = physicalAttachment - 3
|
||||
else:
|
||||
# Can't handle -- assume the same
|
||||
@@ -1862,11 +1862,11 @@ class Shape(ShapeEvtHandler):
|
||||
"""
|
||||
if RoughlyEqual(self.GetRotation(), 0):
|
||||
i = logicalAttachment
|
||||
elif RoughlyEqual(self.GetRotation(), pi / 2):
|
||||
elif RoughlyEqual(self.GetRotation(), math.pi / 2):
|
||||
i = logicalAttachment + 1
|
||||
elif RoughlyEqual(self.GetRotation(), pi):
|
||||
elif RoughlyEqual(self.GetRotation(), math.pi):
|
||||
i = logicalAttachment + 2
|
||||
elif RoughlyEqual(self.GetRotation(), 3 * pi / 2):
|
||||
elif RoughlyEqual(self.GetRotation(), 3 * math.pi / 2):
|
||||
i = logicalAttachment + 3
|
||||
else:
|
||||
return logicalAttachment
|
||||
@@ -1880,9 +1880,9 @@ class Shape(ShapeEvtHandler):
|
||||
"""Rotate about the given axis by the given amount in radians."""
|
||||
self._rotation = theta
|
||||
if self._rotation<0:
|
||||
self._rotation += 2 * pi
|
||||
elif self._rotation>2 * pi:
|
||||
self._rotation -= 2 * pi
|
||||
self._rotation += 2 * math.pi
|
||||
elif self._rotation>2 * math.pi:
|
||||
self._rotation -= 2 * math.pi
|
||||
|
||||
def GetBackgroundPen(self):
|
||||
"""Return pen of the right colour for the background."""
|
||||
@@ -2528,7 +2528,7 @@ class PolygonShape(Shape):
|
||||
e = self.GetAttachmentPositionEdge(i)
|
||||
if e:
|
||||
xp, yp = e
|
||||
l = sqrt((xp - x) * (xp - x) + (yp - y) * (yp - y))
|
||||
l = math.sqrt((xp - x) * (xp - x) + (yp - y) * (yp - y))
|
||||
if l<nearest:
|
||||
nearest = l
|
||||
nearest_attachment = i
|
||||
@@ -2700,8 +2700,8 @@ class PolygonShape(Shape):
|
||||
actualTheta = theta - self._rotation
|
||||
|
||||
# Rotate attachment points
|
||||
sinTheta = sin(actualTheta)
|
||||
cosTheta = cos(actualTheta)
|
||||
sinTheta = math.sin(actualTheta)
|
||||
cosTheta = math.cos(actualTheta)
|
||||
|
||||
for point in self._attachmentPoints:
|
||||
x1 = point._x
|
||||
@@ -2758,7 +2758,7 @@ class PolygonShape(Shape):
|
||||
|
||||
bound_x, bound_y = self.GetBoundingBoxMin()
|
||||
|
||||
dist = 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._originalSize.x = bound_x
|
||||
@@ -3153,7 +3153,7 @@ class PolygonControlPoint(ControlPoint):
|
||||
# Calculate what new size would be, at end of resize
|
||||
def CalculateNewSize(self, x, y):
|
||||
bound_x, bound_y = self.GetShape().GetBoundingBoxMax()
|
||||
dist = 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.y = dist / self._originalDistance * self._originalSize.y
|
||||
@@ -3168,6 +3168,6 @@ class PolygonControlPoint(ControlPoint):
|
||||
def OnEndDragLeft(self, x, y, keys = 0, attachment = 0):
|
||||
self._shape.GetEventHandler().OnSizingEndDragLeft(self, x, y, keys, attachment)
|
||||
|
||||
from canvas import *
|
||||
from lines import *
|
||||
from composit import *
|
||||
from _canvas import *
|
||||
from _lines import *
|
||||
from _composit import *
|
@@ -13,7 +13,7 @@
|
||||
|
||||
from __future__ import division
|
||||
|
||||
from basic import RectangleShape
|
||||
from _basic import RectangleShape
|
||||
|
||||
|
||||
class BitmapShape(RectangleShape):
|
@@ -14,8 +14,8 @@
|
||||
from __future__ import division
|
||||
|
||||
import wx
|
||||
from lines import LineShape
|
||||
from composit import *
|
||||
from _lines import LineShape
|
||||
from _composit import *
|
||||
|
||||
NoDragging, StartDraggingLeft, ContinueDraggingLeft, StartDraggingRight, ContinueDraggingRight = 0, 1, 2, 3, 4
|
||||
|
@@ -16,8 +16,8 @@ from __future__ import division
|
||||
import sys
|
||||
import wx
|
||||
|
||||
from basic import RectangleShape, Shape, ControlPoint
|
||||
from oglmisc import *
|
||||
from _basic import RectangleShape, Shape, ControlPoint
|
||||
from _oglmisc import *
|
||||
|
||||
KEY_SHIFT, KEY_CTRL = 1, 2
|
||||
|
@@ -16,8 +16,8 @@ from __future__ import division
|
||||
import sys
|
||||
import wx
|
||||
|
||||
from basic import ControlPoint, RectangleShape, Shape
|
||||
from oglmisc import *
|
||||
from _basic import ControlPoint, RectangleShape, Shape
|
||||
from _oglmisc import *
|
||||
|
||||
|
||||
|
@@ -14,11 +14,10 @@
|
||||
from __future__ import division
|
||||
|
||||
import sys
|
||||
import math
|
||||
|
||||
from math import sqrt
|
||||
|
||||
from basic import Shape, ShapeRegion, ControlPoint, RectangleShape
|
||||
from oglmisc import *
|
||||
from _basic import Shape, ShapeRegion, ControlPoint, RectangleShape
|
||||
from _oglmisc import *
|
||||
|
||||
# Line alignment flags
|
||||
# Vertical by default
|
||||
@@ -555,7 +554,7 @@ class LineShape(Shape):
|
||||
dx = point2[0]-point1[0]
|
||||
dy = point2[1]-point1[1]
|
||||
|
||||
seg_len = sqrt(dx * dx + dy * dy)
|
||||
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)
|
||||
@@ -613,7 +612,7 @@ class LineShape(Shape):
|
||||
# will be on the line.
|
||||
realOffset = XOffset
|
||||
if proportionalOffset:
|
||||
totalLength = 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)
|
||||
@@ -625,7 +624,7 @@ class LineShape(Shape):
|
||||
# will be on the line.
|
||||
realOffset = XOffset
|
||||
if proportionalOffset:
|
||||
totalLength = 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)
|
||||
@@ -641,7 +640,7 @@ class LineShape(Shape):
|
||||
# will be on the line.
|
||||
realOffset = XOffset
|
||||
if proportionalOffset:
|
||||
totalLength = 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)
|
||||
@@ -658,10 +657,10 @@ class LineShape(Shape):
|
||||
# |d
|
||||
# |
|
||||
# (x1, y1)--------------(x3, y3)------------------(x2, y2)
|
||||
# x4 = x3 - d * sin(theta)
|
||||
# y4 = y3 + d * cos(theta)
|
||||
# x4 = x3 - d * math.sin(theta)
|
||||
# y4 = y3 + d * math.cos(theta)
|
||||
#
|
||||
# Where theta = tan(-1) of (y3-y1) / (x3-x1)
|
||||
# Where theta = math.tan(-1) of (y3-y1) / (x3-x1)
|
||||
x1 = startPositionX
|
||||
y1 = startPositionY
|
||||
x3 = positionOnLineX
|
||||
@@ -671,10 +670,10 @@ class LineShape(Shape):
|
||||
if x3 == x1:
|
||||
theta = pi / 2
|
||||
else:
|
||||
theta = atan((y3-y1) / (x3-x1))
|
||||
theta = math.atan((y3-y1) / (x3-x1))
|
||||
|
||||
x4 = x3-d * sin(theta)
|
||||
y4 = y3 + d * cos(theta)
|
||||
x4 = x3-d * math.sin(theta)
|
||||
y4 = y3 + d * math.cos(theta)
|
||||
|
||||
deltaX = x4-positionOnLineX
|
||||
deltaY = y4-positionOnLineY
|
||||
@@ -749,11 +748,11 @@ class LineShape(Shape):
|
||||
elif x1 == x2 and y2>y1:
|
||||
theta = pi / 2
|
||||
elif x2>x1 and y2 >= y1:
|
||||
theta = atan((y2-y1) / (x2-x1))
|
||||
theta = math.atan((y2-y1) / (x2-x1))
|
||||
elif x2<x1:
|
||||
theta = pi + atan((y2-y1) / (x2-x1))
|
||||
theta = pi + math.atan((y2-y1) / (x2-x1))
|
||||
elif x2>x1 and y2<y1:
|
||||
theta = 2 * pi + atan((y2-y1) / (x2-x1))
|
||||
theta = 2 * pi + math.atan((y2-y1) / (x2-x1))
|
||||
else:
|
||||
raise "Unknown arrowhead rotation case"
|
||||
|
||||
@@ -1439,9 +1438,9 @@ class LineShape(Shape):
|
||||
startX, startY, endX, endY = self.GetEnds()
|
||||
|
||||
# Find distances from centre, start and end. The smallest wins
|
||||
centreDistance = sqrt((x-self._xpos) * (x-self._xpos) + (y-self._ypos) * (y-self._ypos))
|
||||
startDistance = sqrt((x-startX) * (x-startX) + (y-startY) * (y-startY))
|
||||
endDistance = 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:
|
||||
return ARROW_POSITION_MIDDLE
|
@@ -12,7 +12,7 @@
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
from __future__ import division
|
||||
from math import *
|
||||
import math
|
||||
|
||||
import wx
|
||||
|
||||
@@ -339,7 +339,7 @@ def GraphicsStraightenLine(point1, point2):
|
||||
|
||||
|
||||
def GetPointOnLine(x1, y1, x2, y2, length):
|
||||
l = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
|
||||
l = math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
|
||||
if l<0.01:
|
||||
l = 0.01
|
||||
|
||||
@@ -351,7 +351,7 @@ def GetPointOnLine(x1, y1, x2, y2, length):
|
||||
|
||||
|
||||
def GetArrowPoints(x1, y1, x2, y2, length, width):
|
||||
l = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
|
||||
l = math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
|
||||
|
||||
if l<0.01:
|
||||
l = 0.01
|
||||
@@ -374,9 +374,9 @@ def DrawArcToEllipse(x1, y1, width1, height1, x2, y2, x3, y3):
|
||||
if abs(x2 - x3)<0.05:
|
||||
x4 = x2
|
||||
if y3>y2:
|
||||
y4 = y1 - 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 + 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))))
|
||||
return x4, y4
|
||||
|
||||
# Calculate the x and y coordinates of the point where arc intersects ellipse
|
||||
@@ -393,10 +393,10 @@ def DrawArcToEllipse(x1, y1, width1, height1, x2, y2, x3, y3):
|
||||
if K >= 0:
|
||||
# In this case the line intersects the ellipse, so calculate intersection
|
||||
if x2 >= x1:
|
||||
ellipse1_x = ((F*-1) + sqrt(K)) / (2 * E)
|
||||
ellipse1_x = ((F*-1) + math.sqrt(K)) / (2 * E)
|
||||
ellipse1_y = ((H * (ellipse1_x - x2)) + y2)
|
||||
else:
|
||||
ellipse1_x = (((F*-1) - 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
|
||||
@@ -408,7 +408,7 @@ def DrawArcToEllipse(x1, y1, width1, height1, x2, y2, x3, y3):
|
||||
|
||||
|
||||
def FindEndForCircle(radius, x1, y1, x2, y2):
|
||||
H = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
|
||||
H = math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
|
||||
|
||||
if H == 0:
|
||||
return x1, y1
|
Reference in New Issue
Block a user