2 Test movement of the sketch arc of circle
6 from GeomDataAPI import geomDataAPI_Point2D
7 from salome.shaper import model
9 __updated__ = "2017-05-11"
11 class TestMoveArc(unittest.TestCase):
14 self.myDocument = model.moduleDocument()
15 self.mySketch = model.addSketch(self.myDocument, model.defaultPlane("XOY"))
16 self.myCenter = [50., 50.]
17 self.myStart = [70., 50.]
18 self.myEnd = [50., 70.]
19 self.myArc = self.mySketch.addArc(self.myCenter[0], self.myCenter[1], self.myStart[0], self.myStart[1], self.myEnd[0], self.myEnd[1], False)
25 model.assertArcValidity(self.myArc)
28 assert(model.checkPythonDump())
31 self.assertEqual(model.dof(self.mySketch), self.myDOF)
33 def checkPointCoordinates(self, thePoint, theCoordinates):
34 self.assertAlmostEqual(thePoint.x(), theCoordinates[0])
35 self.assertAlmostEqual(thePoint.y(), theCoordinates[1])
37 def checkPointOnArc(self, theCoordinates):
38 distPC = model.distancePointPoint(self.myArc.center(), theCoordinates)
39 radius = model.distancePointPoint(self.myArc.center(), self.myArc.startPoint())
40 self.assertAlmostEqual(distPC, radius)
42 def checkArcRadius(self):
43 radius = model.distancePointPoint(self.myArc.center(), self.myArc.startPoint())
44 self.assertAlmostEqual(radius, self.myRadius)
46 def fixArcRadius(self):
48 self.mySketch.setRadius(self.myArc.results()[1], self.myRadius)
53 def fixPoint(self, thePoint):
54 self.mySketch.setFixed(thePoint)
60 self.mySketch.setFixed(self.myArc.results()[1])
66 def test_move_center_of_free_arc(self):
67 """ Test 1. Movement of center of a free arc
69 newPosition = [self.myCenter[0] + 10., self.myCenter[1] - 15.]
70 self.mySketch.move(self.myArc.center(), newPosition[0], newPosition[1])
72 self.checkPointCoordinates(self.myArc.center(), newPosition)
74 def test_move_start_of_free_arc(self):
75 """ Test 2. Movement of start point of a free arc
77 newPosition = [self.myStart[0] - 10., self.myStart[1] + 5.]
78 self.mySketch.move(self.myArc.startPoint(), newPosition[0], newPosition[1])
80 self.checkPointCoordinates(self.myArc.center(), self.myCenter)
81 self.checkPointCoordinates(self.myArc.startPoint(), newPosition)
83 def test_move_end_of_free_arc(self):
84 """ Test 3. Movement of end point of a free arc
86 newPosition = [self.myEnd[0] + 10., self.myEnd[1] + 5.]
87 self.mySketch.move(self.myArc.endPoint(), newPosition[0], newPosition[1])
89 self.checkPointCoordinates(self.myArc.center(), self.myCenter)
90 self.checkPointCoordinates(self.myArc.endPoint(), newPosition)
92 def test_move_free_arc(self):
93 """ Test 4. Movement of a free arc dragging the edge
95 newPosition = [100., 80.]
96 self.mySketch.move(self.myArc.defaultResult(), newPosition[0], newPosition[1])
98 self.checkPointOnArc(newPosition)
99 self.checkPointCoordinates(self.myArc.center(), self.myCenter)
101 def test_move_center_of_arc_fixed_center(self):
102 """ Test 5. Movement of center of the arc with fixed center (nothing should be changed)
104 self.fixPoint(self.myArc.center())
106 newPosition = [self.myCenter[0] + 10., self.myCenter[1] - 15.]
107 self.mySketch.move(self.myArc.center(), newPosition[0], newPosition[1])
109 self.checkPointCoordinates(self.myArc.center(), self.myCenter)
111 def test_move_start_of_arc_fixed_center(self):
112 """ Test 6. Movement of start point of the arc with fixed center
114 self.fixPoint(self.myArc.center())
116 newPosition = [self.myStart[0] - 10., self.myStart[1] + 5.]
117 self.mySketch.move(self.myArc.startPoint(), newPosition[0], newPosition[1])
119 self.checkPointCoordinates(self.myArc.center(), self.myCenter)
120 self.checkPointCoordinates(self.myArc.startPoint(), newPosition)
122 def test_move_end_of_arc_fixed_center(self):
123 """ Test 7. Movement of end point of the arc with fixed center
125 self.fixPoint(self.myArc.center())
127 newPosition = [self.myEnd[0] + 10., self.myEnd[1] + 5.]
128 self.mySketch.move(self.myArc.endPoint(), newPosition[0], newPosition[1])
130 self.checkPointCoordinates(self.myArc.center(), self.myCenter)
131 self.checkPointCoordinates(self.myArc.endPoint(), newPosition)
133 def test_move_arc_fixed_center(self):
134 """ Test 8. Movement of the arc with fixed center dragging the edge
136 self.fixPoint(self.myArc.center())
138 newPosition = [100., 80.]
139 self.mySketch.move(self.myArc.defaultResult(), newPosition[0], newPosition[1])
141 self.checkPointOnArc(newPosition)
142 self.checkPointCoordinates(self.myArc.center(), self.myCenter)
144 def test_move_center_of_arc_fixed_start(self):
145 """ Test 9. Movement of center of the arc with fixed start point
147 self.fixPoint(self.myArc.startPoint())
149 newPosition = [self.myCenter[0] + 10., self.myCenter[1] - 15.]
150 self.mySketch.move(self.myArc.center(), newPosition[0], newPosition[1])
152 self.checkPointCoordinates(self.myArc.center(), newPosition)
153 self.checkPointCoordinates(self.myArc.startPoint(), self.myStart)
155 def test_move_start_of_arc_fixed_start(self):
156 """ Test 10. Movement of start point of the arc with fixed start point (nothing should be changed)
158 self.fixPoint(self.myArc.startPoint())
160 newPosition = [self.myStart[0] - 10., self.myStart[1] + 5.]
161 self.mySketch.move(self.myArc.startPoint(), newPosition[0], newPosition[1])
163 self.checkPointCoordinates(self.myArc.center(), self.myCenter)
164 self.checkPointCoordinates(self.myArc.startPoint(), self.myStart)
165 self.checkPointCoordinates(self.myArc.endPoint(), self.myEnd)
167 def test_move_end_of_arc_fixed_start(self):
168 """ Test 11. Movement of end point of the arc with fixed start point
170 self.fixPoint(self.myArc.startPoint())
172 newPosition = [self.myEnd[0] + 10., self.myEnd[1] + 5.]
173 self.mySketch.move(self.myArc.endPoint(), newPosition[0], newPosition[1])
175 self.checkPointCoordinates(self.myArc.startPoint(), self.myStart)
176 self.assertNotEqual(self.myArc.center().x(), self.myCenter[0])
177 self.assertNotEqual(self.myArc.center().y(), self.myCenter[1])
179 def test_move_arc_fixed_start(self):
180 """ Test 12. Movement of the arc with fixed start point dragging the edge
182 self.fixPoint(self.myArc.startPoint())
184 newPosition = [100., 80.]
185 self.mySketch.move(self.myArc.defaultResult(), newPosition[0], newPosition[1])
187 self.checkPointCoordinates(self.myArc.startPoint(), self.myStart)
188 self.assertNotEqual(self.myArc.center().x(), self.myCenter[0])
189 self.assertNotEqual(self.myArc.center().y(), self.myCenter[1])
191 def test_move_center_of_arc_fixed_end(self):
192 """ Test 13. Movement of center of the arc with fixed end point
194 self.fixPoint(self.myArc.endPoint())
196 newPosition = [self.myCenter[0] + 10., self.myCenter[1] - 15.]
197 self.mySketch.move(self.myArc.center(), newPosition[0], newPosition[1])
199 self.checkPointCoordinates(self.myArc.center(), newPosition)
200 self.checkPointCoordinates(self.myArc.endPoint(), self.myEnd)
202 def test_move_start_of_arc_fixed_end(self):
203 """ Test 14. Movement of start point of the arc with fixed end point
205 self.fixPoint(self.myArc.endPoint())
207 newPosition = [self.myStart[0] - 10., self.myStart[1] + 5.]
208 self.mySketch.move(self.myArc.startPoint(), newPosition[0], newPosition[1])
210 self.checkPointCoordinates(self.myArc.endPoint(), self.myEnd)
211 self.assertNotEqual(self.myArc.center().x(), self.myCenter[0])
212 self.assertNotEqual(self.myArc.center().y(), self.myCenter[1])
214 def test_move_end_of_arc_fixed_end(self):
215 """ Test 15. Movement of end point of the arc with fixed end point (nothing should be changed)
217 self.fixPoint(self.myArc.endPoint())
219 newPosition = [self.myEnd[0] + 10., self.myEnd[1] + 5.]
220 self.mySketch.move(self.myArc.endPoint(), newPosition[0], newPosition[1])
222 self.checkPointCoordinates(self.myArc.center(), self.myCenter)
223 self.checkPointCoordinates(self.myArc.startPoint(), self.myStart)
224 self.checkPointCoordinates(self.myArc.endPoint(), self.myEnd)
226 def test_move_arc_fixed_end(self):
227 """ Test 16. Movement of the arc with fixed end point dragging the edge
229 self.fixPoint(self.myArc.endPoint())
231 newPosition = [100., 80.]
232 self.mySketch.move(self.myArc.defaultResult(), newPosition[0], newPosition[1])
234 self.checkPointCoordinates(self.myArc.endPoint(), self.myEnd)
235 self.assertNotEqual(self.myArc.center().x(), self.myCenter[0])
236 self.assertNotEqual(self.myArc.center().y(), self.myCenter[1])
238 def test_move_center_of_arc_fixed_radius(self):
239 """ Test 17. Movement of center of the arc with fixed radius
243 newPosition = [self.myCenter[0] + 10., self.myCenter[1] - 15.]
244 self.mySketch.move(self.myArc.center(), newPosition[0], newPosition[1])
246 self.checkPointCoordinates(self.myArc.center(), newPosition)
247 self.checkArcRadius()
249 def test_move_start_of_arc_fixed_radius(self):
250 """ Test 18. Movement of start point of the arc with fixed radius
254 newPosition = [self.myStart[0] - 10., self.myStart[1] + 5.]
255 self.mySketch.move(self.myArc.startPoint(), newPosition[0], newPosition[1])
257 self.checkArcRadius()
259 def test_move_end_of_arc_fixed_radius(self):
260 """ Test 19. Movement of end point of the arc with fixed radius
264 newPosition = [self.myEnd[0] + 10., self.myEnd[1] + 5.]
265 self.mySketch.move(self.myArc.endPoint(), newPosition[0], newPosition[1])
267 self.checkArcRadius()
269 def test_move_arc_fixed_radius(self):
270 """ Test 20. Movement of the arc with fixed radius dragging the edge
274 newPosition = [100., 80.]
275 self.mySketch.move(self.myArc.defaultResult(), newPosition[0], newPosition[1])
277 self.checkArcRadius()
279 def test_move_center_of_fixed_arc(self):
280 """ Test 21. Movement of center of fully fixed arc (nothing should be changed)
284 newPosition = [self.myCenter[0] + 10., self.myCenter[1] - 15.]
285 self.mySketch.move(self.myArc.center(), newPosition[0], newPosition[1])
287 self.checkPointCoordinates(self.myArc.center(), self.myCenter)
288 self.checkPointCoordinates(self.myArc.startPoint(), self.myStart)
289 self.checkPointCoordinates(self.myArc.endPoint(), self.myEnd)
291 def test_move_start_of_fixed_arc(self):
292 """ Test 22. Movement of start point of fully fixed arc (nothing should be changed)
296 newPosition = [self.myStart[0] - 10., self.myStart[1] + 5.]
297 self.mySketch.move(self.myArc.startPoint(), newPosition[0], newPosition[1])
299 self.checkPointCoordinates(self.myArc.center(), self.myCenter)
300 self.checkPointCoordinates(self.myArc.startPoint(), self.myStart)
301 self.checkPointCoordinates(self.myArc.endPoint(), self.myEnd)
303 def test_move_end_of_fixed_arc(self):
304 """ Test 23. Movement of end point of fully fixed arc (nothing should be changed)
308 newPosition = [self.myEnd[0] + 10., self.myEnd[1] + 5.]
309 self.mySketch.move(self.myArc.endPoint(), newPosition[0], newPosition[1])
311 self.checkPointCoordinates(self.myArc.center(), self.myCenter)
312 self.checkPointCoordinates(self.myArc.startPoint(), self.myStart)
313 self.checkPointCoordinates(self.myArc.endPoint(), self.myEnd)
315 def test_move_fixed_arc(self):
316 """ Test 24. Movement of fully fixed arc (nothing should be changed)
320 newPosition = [100., 80.]
321 self.mySketch.move(self.myArc.defaultResult(), newPosition[0], newPosition[1])
323 self.checkPointCoordinates(self.myArc.center(), self.myCenter)
324 self.checkPointCoordinates(self.myArc.startPoint(), self.myStart)
325 self.checkPointCoordinates(self.myArc.endPoint(), self.myEnd)
328 if __name__ == '__main__':