2 Test movement of the sketch point
6 from GeomDataAPI import geomDataAPI_Point2D
7 from salome.shaper import model
9 __updated__ = "2017-05-11"
11 class TestMovePoint(unittest.TestCase):
14 self.myDocument = model.moduleDocument()
15 self.mySketch = model.addSketch(self.myDocument, model.defaultPlane("XOY"))
16 self.myOrigin = self.mySketch.addPoint(model.selection("VERTEX", "Origin"))
17 self.myPoint = self.mySketch.addPoint(70, 50)
18 self.myPointCoordinates = geomDataAPI_Point2D(self.myPoint.coordinates())
26 assert(model.checkPythonDump())
29 self.assertEqual(model.dof(self.mySketch), self.myDOF)
31 def test_move_free_point(self):
32 """ Test 1. Movement of free point
34 newPosition = [100., 100.]
35 self.mySketch.move(self.myPoint, newPosition[0], newPosition[1])
37 self.assertAlmostEqual(self.myPointCoordinates.x(), newPosition[0])
38 self.assertAlmostEqual(self.myPointCoordinates.y(), newPosition[1])
40 def test_move_fixed_x(self):
41 """ Test 2. Movement of partially fixed point (fixed x coordinate)
44 horizDistance = self.mySketch.setHorizontalDistance(self.myOrigin.result(), self.myPoint.coordinates(), DISTANCE)
49 newPosition = [100., 100.]
50 self.mySketch.move(self.myPoint, newPosition[0], newPosition[1])
52 self.assertAlmostEqual(self.myPointCoordinates.x(), DISTANCE)
53 self.assertAlmostEqual(self.myPointCoordinates.y(), newPosition[1])
55 def test_move_fixed_y(self):
56 """ Test 3. Movement of partially fixed point (fixed y coordinate)
59 vertDistance = self.mySketch.setVerticalDistance(self.myOrigin.result(), self.myPoint.coordinates(), DISTANCE)
64 newPosition = [100., 100.]
65 self.mySketch.move(self.myPoint, newPosition[0], newPosition[1])
67 self.assertAlmostEqual(self.myPointCoordinates.x(), newPosition[0])
68 self.assertAlmostEqual(self.myPointCoordinates.y(), DISTANCE)
70 def test_move_fully_fixed(self):
71 """ Test 4. Movement of fully fixed point (should not be changed)
73 coord = [self.myPointCoordinates.x(), self.myPointCoordinates.y()]
75 fixed = self.mySketch.setFixed(self.myPoint.result())
80 newPosition = [100., 100.]
81 self.mySketch.move(self.myPoint, newPosition[0], newPosition[1])
83 self.assertAlmostEqual(self.myPointCoordinates.x(), coord[0])
84 self.assertAlmostEqual(self.myPointCoordinates.y(), coord[1])
87 if __name__ == '__main__':