1 #=========================================================================
2 # Initialization of the test
3 #=========================================================================
4 from GeomDataAPI import *
7 __updated__ = "2014-10-28"
9 aSession = ModelAPI_Session.get()
10 aDocument = aSession.moduleDocument()
11 #=========================================================================
12 # Creation of a sketch
13 #=========================================================================
14 aSession.startOperation()
15 aSketchCommonFeature = aDocument.addFeature("Sketch")
16 aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
17 assert (aSketchFeature.getKind() == "Sketch")
18 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
19 origin.setValue(0, 0, 0)
20 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
21 dirx.setValue(1, 0, 0)
22 norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
23 norm.setValue(0, 0, 1)
24 aSession.finishOperation()
25 # check that values have been changed
26 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
27 assert (origin.x() == 0)
28 assert (origin.y() == 0)
29 assert (origin.z() == 0)
30 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
31 assert (dirx.x() == 1)
32 assert (dirx.y() == 0)
33 assert (dirx.z() == 0)
34 norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
35 assert (norm.x() == 0)
36 assert (norm.y() == 0)
37 assert (norm.z() == 1)
38 #=========================================================================
40 #=========================================================================
41 aSession.startOperation()
42 aSketchReflist = aSketchFeature.reflist("Features")
43 assert (not aSketchReflist.isInitialized())
44 assert(aSketchReflist.size() == 0)
45 assert (len(aSketchReflist.list()) == 0)
46 # aSketchPoint = aDocument.addFeature("SketchPoint")
47 aSketchPoint = aSketchFeature.addFeature("SketchPoint")
48 assert (aSketchPoint.getKind() == "SketchPoint")
49 coords = geomDataAPI_Point2D(aSketchPoint.attribute("PointCoordindates"))
50 assert (not coords.isInitialized())
51 # Simulate SketchPlugin_Point::move(...)
52 coords.setValue(10., 10.)
53 assert (coords.isInitialized())
54 aSession.finishOperation()
55 # check that values have been changed
56 aSketchReflist = aSketchFeature.reflist("Features")
57 assert (aSketchReflist.size() == 1)
58 assert (len(aSketchReflist.list()) == 1)
59 coords = geomDataAPI_Point2D(aSketchPoint.attribute("PointCoordindates"))
60 assert (coords.x() == 10.0)
61 assert (coords.y() == 10.0)
62 #=========================================================================
64 #=========================================================================
65 aSession.startOperation()
66 # aSketchLine = aDocument.addFeature("SketchLine")
67 aSketchLine = aSketchFeature.addFeature("SketchLine")
68 assert (aSketchLine.getKind() == "SketchLine")
69 assert (aSketchReflist.size() == 2)
70 assert (len(aSketchReflist.list()) == 2)
71 aLineStartPoint = geomDataAPI_Point2D(aSketchLine.attribute("StartPoint"))
72 aLineEndPoint = geomDataAPI_Point2D(aSketchLine.attribute("EndPoint"))
73 assert (not aLineStartPoint.isInitialized())
74 assert (not aLineEndPoint.isInitialized())
75 # Simulate SketchPlugin_Line::move(...)
76 aLineStartPoint.setValue(50., 50.)
77 aLineEndPoint.setValue(60., 60.)
78 assert (aLineStartPoint.isInitialized())
79 assert (aLineEndPoint.isInitialized())
80 aSession.finishOperation()
81 # check that values have been changed
82 aLineStartPoint = geomDataAPI_Point2D(aSketchLine.attribute("StartPoint"))
83 aLineEndPoint = geomDataAPI_Point2D(aSketchLine.attribute("EndPoint"))
84 assert (aLineStartPoint.x() == 50.0)
85 assert (aLineStartPoint.y() == 50.0)
86 assert (aLineEndPoint.x() == 60.0)
87 assert (aLineEndPoint.y() == 60.0)
88 #=========================================================================
90 #=========================================================================
91 aResult = aSketchLine.firstResult()
92 assert (aResult is not None)
93 aResultConstruction = modelAPI_ResultConstruction(aResult)
94 aShape = aResultConstruction.shape()
95 assert (aShape is not None)
96 assert (not aShape.isNull())
98 from salome.shaper import model
99 assert(model.checkPythonDump())