- added additional tests per shape

This commit is contained in:
Werner F Bruhin
2015-02-05 11:23:19 +01:00
parent f081eb9ba7
commit 0b0d7f3d89

View File

@@ -5,7 +5,6 @@ import wx
import wx.lib.ogl as ogl
class lib_ogl_Tests(wtc.WidgetTestCase):
def test_lib_oglCtor(self):
@@ -19,12 +18,151 @@ class lib_ogl_Tests(wtc.WidgetTestCase):
aShape.SetCanvas(osc)
self.diagram.AddShape(aShape)
def test_lib_oglRectangle(self):
ogl.OGLInitialize()
osc = ogl.ShapeCanvas(self.frame)
self.diagram = ogl.Diagram()
osc.SetDiagram(self.diagram)
self.diagram.SetCanvas(osc)
aShape = ogl.RectangleShape(w=50, h=50)
aShape.SetCanvas(osc)
self.diagram.AddShape(aShape)
def test_lib_oglPolygonShape(self):
ogl.OGLInitialize()
osc = ogl.ShapeCanvas(self.frame)
self.diagram = ogl.Diagram()
osc.SetDiagram(self.diagram)
self.diagram.SetCanvas(osc)
aShape = ogl.PolygonShape()
w, h = 60, 60
points = [(0.0, -h/2.0),
(w/2.0, 0.0),
(0.0, h/2.0),
(-w/2.0, 0.0),
]
aShape.Create(points)
aShape.SetCanvas(osc)
self.diagram.AddShape(aShape)
def test_lib_oglCircle(self):
ogl.OGLInitialize()
osc = ogl.ShapeCanvas(self.frame)
self.diagram = ogl.Diagram()
osc.SetDiagram(self.diagram)
self.diagram.SetCanvas(osc)
aShape = ogl.CircleShape(50)
aShape.SetCanvas(osc)
self.diagram.AddShape(aShape)
def test_lib_oglEllipseShape(self):
ogl.OGLInitialize()
osc = ogl.ShapeCanvas(self.frame)
self.diagram = ogl.Diagram()
osc.SetDiagram(self.diagram)
self.diagram.SetCanvas(osc)
aShape = ogl.EllipseShape(50, 50)
aShape.SetCanvas(osc)
self.diagram.AddShape(aShape)
def test_lib_oglTextShape(self):
ogl.OGLInitialize()
osc = ogl.ShapeCanvas(self.frame)
self.diagram = ogl.Diagram()
osc.SetDiagram(self.diagram)
self.diagram.SetCanvas(osc)
aShape = ogl.TextShape(50, 50)
aShape.SetCanvas(osc)
aShape.AddText("Some nice text here")
self.diagram.AddShape(aShape)
def test_lib_oglLineShape(self):
ogl.OGLInitialize()
osc = ogl.ShapeCanvas(self.frame)
self.diagram = ogl.Diagram()
osc.SetDiagram(self.diagram)
self.diagram.SetCanvas(osc)
fromShape = ogl.RectangleShape(w=50, h=50)
fromShape.SetCanvas(osc)
self.diagram.AddShape(fromShape)
toShape = ogl.RectangleShape(w=50, h=50)
toShape.SetCanvas(osc)
self.diagram.AddShape(toShape)
lShape = ogl.LineShape()
lShape.SetCanvas(osc)
lShape.MakeLineControlPoints(2)
fromShape.AddLine(lShape, toShape)
self.diagram.AddShape(lShape)
lShape.Show(True)
def test_lib_oglShapeRegion(self):
ogl.OGLInitialize()
osc = ogl.ShapeCanvas(self.frame)
self.diagram = ogl.Diagram()
osc.SetDiagram(self.diagram)
self.diagram.SetCanvas(osc)
aShape = ogl.RectangleShape(w=50, h=50)
aShape.SetCanvas(osc)
self.diagram.AddShape(aShape)
region1 = ogl.ShapeRegion()
region1.SetText('DividedShape')
region1.SetProportions(0.0, 0.2)
region1.SetFormatMode(ogl.FORMAT_CENTRE_HORIZ)
aShape.AddRegion(region1)
def test_lib_oglDivisonShape(self):
ogl.OGLInitialize()
osc = ogl.ShapeCanvas(self.frame)
self.diagram = ogl.Diagram()
osc.SetDiagram(self.diagram)
self.diagram.SetCanvas(osc)
aShape = ogl.CompositeShape()
aShape.SetCanvas(osc)
self.diagram.AddShape(aShape)
# create a division in the composite
aShape.MakeContainer()
# add a shape to the original division
shape2 = ogl.RectangleShape(40, 60)
aShape.GetDivisions()[0].AddChild(shape2)
def test_lib_oglCompositeShape(self):
ogl.OGLInitialize()
osc = ogl.ShapeCanvas(self.frame)
self.diagram = ogl.Diagram()
osc.SetDiagram(self.diagram)
self.diagram.SetCanvas(osc)
aShape = ogl.CompositeShape()
aShape.SetCanvas(osc)
self.diagram.AddShape(aShape)
constraining_shape = ogl.RectangleShape(120, 100)
constrained_shape1 = ogl.CircleShape(50)
constrained_shape2 = ogl.RectangleShape(80, 20)
aShape.AddChild(constraining_shape)
aShape.AddChild(constrained_shape1)
aShape.AddChild(constrained_shape2)
constraint = ogl.Constraint(ogl.CONSTRAINT_MIDALIGNED_BOTTOM,
constraining_shape,
[constrained_shape1, constrained_shape2])
aShape.AddConstraint(constraint)
aShape.Recompute()
def test_lib_ogl_Constants(self):
ogl.CONSTRAINT_CENTRED_VERTICALLY
@@ -83,11 +221,10 @@ class lib_ogl_Tests(wtc.WidgetTestCase):
ogl.LINE_ALIGNMENT_VERT
ogl.LINE_ALIGNMENT_TO_NEXT_HANDLE
ogl.LINE_ALIGNMENT_NONE
# keys
ogl.KEY_SHIFT
ogl.KEY_CTRL
#---------------------------------------------------------------------------