1 ## Copyright (C) 2017 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
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
22 Test movement of the sketch point
26 from GeomDataAPI import geomDataAPI_Point2D
27 from salome.shaper import model
29 __updated__ = "2017-05-11"
31 class TestMovePoint(unittest.TestCase):
34 self.myDocument = model.moduleDocument()
35 self.mySketch = model.addSketch(self.myDocument, model.defaultPlane("XOY"))
36 self.myOrigin = self.mySketch.addPoint(model.selection("VERTEX", "Origin"))
37 self.myPoint = self.mySketch.addPoint(70, 50)
38 self.myPointCoordinates = geomDataAPI_Point2D(self.myPoint.coordinates())
46 assert(model.checkPythonDump())
49 self.assertEqual(model.dof(self.mySketch), self.myDOF)
51 def test_move_free_point(self):
52 """ Test 1. Movement of free point
54 newPosition = [100., 100.]
55 self.mySketch.move(self.myPoint, newPosition[0], newPosition[1])
57 self.assertAlmostEqual(self.myPointCoordinates.x(), newPosition[0])
58 self.assertAlmostEqual(self.myPointCoordinates.y(), newPosition[1])
60 def test_move_fixed_x(self):
61 """ Test 2. Movement of partially fixed point (fixed x coordinate)
64 horizDistance = self.mySketch.setHorizontalDistance(self.myOrigin.result(), self.myPoint.coordinates(), DISTANCE)
69 newPosition = [100., 100.]
70 self.mySketch.move(self.myPoint, newPosition[0], newPosition[1])
72 self.assertAlmostEqual(self.myPointCoordinates.x(), DISTANCE)
73 self.assertAlmostEqual(self.myPointCoordinates.y(), newPosition[1])
75 def test_move_fixed_y(self):
76 """ Test 3. Movement of partially fixed point (fixed y coordinate)
79 vertDistance = self.mySketch.setVerticalDistance(self.myOrigin.result(), self.myPoint.coordinates(), DISTANCE)
84 newPosition = [100., 100.]
85 self.mySketch.move(self.myPoint, newPosition[0], newPosition[1])
87 self.assertAlmostEqual(self.myPointCoordinates.x(), newPosition[0])
88 self.assertAlmostEqual(self.myPointCoordinates.y(), DISTANCE)
90 def test_move_fully_fixed(self):
91 """ Test 4. Movement of fully fixed point (should not be changed)
93 coord = [self.myPointCoordinates.x(), self.myPointCoordinates.y()]
95 fixed = self.mySketch.setFixed(self.myPoint.result())
100 newPosition = [100., 100.]
101 self.mySketch.move(self.myPoint, newPosition[0], newPosition[1])
103 self.assertAlmostEqual(self.myPointCoordinates.x(), coord[0])
104 self.assertAlmostEqual(self.myPointCoordinates.y(), coord[1])
107 if __name__ == "__main__":
108 test_program = unittest.main(exit=False)
109 assert test_program.result.wasSuccessful(), "Test failed"