Salome HOME
updated copyright message
[modules/shaper.git] / src / SketchPlugin / Test / Test2425.py
1 # Copyright (C) 2017-2023  CEA, EDF
2 #
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.
7 #
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.
12 #
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
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 """
21     Test2425.py
22     Test case for issue #2425 "undo edit parameter - destroy document"
23 """
24
25
26 from salome.shaper import model
27
28 model.begin()
29 partSet = model.moduleDocument()
30 Param = model.addParameter(partSet, "n", "5")
31 Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
32 SketchLine_1 = Sketch_1.addLine(10, 50, 20, 50)
33 SketchLine_2 = Sketch_1.addLine(20, 50, 20, 60)
34 SketchLine_3 = Sketch_1.addLine(20, 60, 10, 60)
35 SketchLine_4 = Sketch_1.addLine(10, 60, 10, 50)
36 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
37 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
38 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
39 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
40 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
41 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
42 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
43 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
44 SketchLine_5 = Sketch_1.addLine(10, 10, 90, 10)
45 SketchMultiTranslation_1_objects = [SketchLine_2.result(), SketchLine_1.result(), SketchLine_3.result(), SketchLine_4.result()]
46 SketchMultiTranslation_1 = Sketch_1.addTranslation(SketchMultiTranslation_1_objects, SketchLine_5.startPoint(), SketchLine_5.endPoint(), "n", True)
47 [SketchLine_6, SketchLine_7, SketchLine_8, SketchLine_9, SketchLine_10, SketchLine_11, SketchLine_12, SketchLine_13, SketchLine_14, SketchLine_15, SketchLine_16, SketchLine_17, SketchLine_18, SketchLine_19, SketchLine_20, SketchLine_21] = SketchMultiTranslation_1.translated()
48 model.do()
49
50 # change parameter, check original lines are not changed
51 Param.setValue(3)
52 assert(SketchLine_1.startPoint().x() == 10 and SketchLine_1.startPoint().y() == 50)
53 assert(SketchLine_1.endPoint().x() == 20 and SketchLine_1.endPoint().y() == 50)
54 assert(SketchLine_2.startPoint().x() == 20 and SketchLine_2.startPoint().y() == 50)
55 assert(SketchLine_2.endPoint().x() == 20 and SketchLine_2.endPoint().y() == 60)
56 assert(SketchLine_3.startPoint().x() == 20 and SketchLine_3.startPoint().y() == 60)
57 assert(SketchLine_3.endPoint().x() == 10 and SketchLine_3.endPoint().y() == 60)
58 assert(SketchLine_4.startPoint().x() == 10 and SketchLine_4.startPoint().y() == 60)
59 assert(SketchLine_4.endPoint().x() == 10 and SketchLine_4.endPoint().y() == 50)
60
61 model.end()
62
63 # undo parameter changing, check original lines are not changed
64 model.undo()
65 assert(SketchLine_1.startPoint().x() == 10 and SketchLine_1.startPoint().y() == 50)
66 assert(SketchLine_1.endPoint().x() == 20 and SketchLine_1.endPoint().y() == 50)
67 assert(SketchLine_2.startPoint().x() == 20 and SketchLine_2.startPoint().y() == 50)
68 assert(SketchLine_2.endPoint().x() == 20 and SketchLine_2.endPoint().y() == 60)
69 assert(SketchLine_3.startPoint().x() == 20 and SketchLine_3.startPoint().y() == 60)
70 assert(SketchLine_3.endPoint().x() == 10 and SketchLine_3.endPoint().y() == 60)
71 assert(SketchLine_4.startPoint().x() == 10 and SketchLine_4.startPoint().y() == 60)
72 assert(SketchLine_4.endPoint().x() == 10 and SketchLine_4.endPoint().y() == 50)