1 # Copyright (C) 2017-2019 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 Test movement of the sketch point
25 from GeomDataAPI import geomDataAPI_Point2D
26 from salome.shaper import model
28 __updated__ = "2017-05-11"
30 class TestMovePoint(unittest.TestCase):
33 self.myDocument = model.moduleDocument()
34 self.mySketch = model.addSketch(self.myDocument, model.defaultPlane("XOY"))
35 self.myOrigin = self.mySketch.addPoint(model.selection("VERTEX", "Origin"))
36 self.myPoint = self.mySketch.addPoint(70, 50)
37 self.myPointCoordinates = geomDataAPI_Point2D(self.myPoint.coordinates())
45 assert(model.checkPythonDump())
48 self.assertEqual(model.dof(self.mySketch), self.myDOF)
50 def test_move_free_point(self):
51 """ Test 1. Movement of free point
53 newPosition = [100., 100.]
54 self.mySketch.move(self.myPoint, newPosition[0], newPosition[1])
56 self.assertAlmostEqual(self.myPointCoordinates.x(), newPosition[0])
57 self.assertAlmostEqual(self.myPointCoordinates.y(), newPosition[1])
59 def test_move_fixed_x(self):
60 """ Test 2. Movement of partially fixed point (fixed x coordinate)
63 horizDistance = self.mySketch.setHorizontalDistance(self.myOrigin.result(), self.myPoint.coordinates(), DISTANCE)
68 newPosition = [100., 100.]
69 self.mySketch.move(self.myPoint, newPosition[0], newPosition[1])
71 self.assertAlmostEqual(self.myPointCoordinates.x(), DISTANCE)
72 self.assertAlmostEqual(self.myPointCoordinates.y(), newPosition[1])
74 def test_move_fixed_y(self):
75 """ Test 3. Movement of partially fixed point (fixed y coordinate)
78 vertDistance = self.mySketch.setVerticalDistance(self.myOrigin.result(), self.myPoint.coordinates(), DISTANCE)
83 newPosition = [100., 100.]
84 self.mySketch.move(self.myPoint, newPosition[0], newPosition[1])
86 self.assertAlmostEqual(self.myPointCoordinates.x(), newPosition[0])
87 self.assertAlmostEqual(self.myPointCoordinates.y(), DISTANCE)
89 def test_move_fully_fixed(self):
90 """ Test 4. Movement of fully fixed point (should not be changed)
92 coord = [self.myPointCoordinates.x(), self.myPointCoordinates.y()]
94 fixed = self.mySketch.setFixed(self.myPoint.result())
99 newPosition = [100., 100.]
100 self.mySketch.move(self.myPoint, newPosition[0], newPosition[1])
102 self.assertAlmostEqual(self.myPointCoordinates.x(), coord[0])
103 self.assertAlmostEqual(self.myPointCoordinates.y(), coord[1])
106 if __name__ == "__main__":
107 test_program = unittest.main(exit=False)
108 assert test_program.result.wasSuccessful(), "Test failed"