0024927: Getting rid of "Persistent" functionality -- Tests
[occt.git] / tests / caf / xlink / C1
1 #INTERFACE CAF
2 # XLink attributes
3 #
4 # Testing attribute: TDocStd_XLink
5 #
6 # Testing command:   UpdateXLinks
7 #
8
9 puts "caf004-C1"
10
11 # 1. Create two new documents Doc1, Doc2
12 NewDocument Doc1 BinOcaf
13 NewDocument Doc2 BinOcaf
14
15 # 2. Set UndoLimit for them
16 UndoLimit Doc1 100
17 UndoLimit Doc2 100
18
19 # 3. Set a shape in Doc1 to label 'SLabel'
20 set aLabel1 0:2
21 Label Doc1 ${aLabel1}
22 SetName Doc1 ${aLabel1} SLabel
23
24 set aSetX1 10
25 set aSetY1 20
26 set aSetZ1 30
27 set aSetDX1 100
28 set aSetDY1 200
29 set aSetDZ1 300
30
31 box aBox1 ${aSetX1} ${aSetY1} ${aSetZ1} ${aSetDX1} ${aSetDY1} ${aSetDZ1}
32
33 set aBoundingBox1 [bounding aBox1]
34 set X1_Box1 [lindex ${aBoundingBox1} 0]
35 set Y1_Box1 [lindex ${aBoundingBox1} 1]
36 set Z1_Box1 [lindex ${aBoundingBox1} 2]
37 set X2_Box1 [lindex ${aBoundingBox1} 3]
38 set Y2_Box1 [lindex ${aBoundingBox1} 4]
39 set Z2_Box1 [lindex ${aBoundingBox1} 5]
40
41 SetShape Doc1 ${aLabel1} aBox1
42
43 # 4. Create a new label 'TLabel1' in Doc1
44 set aLabel2 0:3
45 Label Doc1 ${aLabel2}
46 SetName Doc1 ${aLabel2} TLabel1
47
48 # 5. Open transaction in Doc1
49 NewCommand Doc1
50
51 # 6. Copy 'SLabel' to the label 'TLabel1' with link
52 CopyWithLink Doc1 ${aLabel2} Doc1 ${aLabel1}
53
54 # 7. Close/Open transaction
55 NewCommand Doc1
56
57 # 8. Set new shape in Doc1 to label 'SLabel'
58 set aRadius 70
59 psphere aSphere ${aRadius}
60 SetShape Doc1 ${aLabel2} aSphere
61
62 # 10. Update link in Doc1
63 UpdateXLinks Doc1 ${aLabel2}
64
65 # 7. Close/Open transaction
66 NewCommand Doc1
67
68 # 9. Undo Doc1
69 Undo Doc1
70
71 # 10. Redo Doc1
72 Redo Doc1
73
74 # 11. Get a shape from 'TLabel1'
75 GetShape Doc1 ${aLabel2} aBox2
76
77 set aBoundingBox2 [bounding aBox2]
78 set X1_Box2 [lindex ${aBoundingBox2} 0]
79 set Y1_Box2 [lindex ${aBoundingBox2} 1]
80 set Z1_Box2 [lindex ${aBoundingBox2} 2]
81 set X2_Box2 [lindex ${aBoundingBox2} 3]
82 set Y2_Box2 [lindex ${aBoundingBox2} 4]
83 set Z2_Box2 [lindex ${aBoundingBox2} 5]
84
85 if { ${X1_Box1} == ${X1_Box2} || 
86      ${Y1_Box1} == ${Y1_Box2} || 
87      ${Z1_Box1} == ${Z1_Box2} || 
88      ${X2_Box1} == ${X2_Box2} || 
89      ${Y2_Box1} == ${Y2_Box2} || 
90      ${Z2_Box1} == ${Z2_Box2} } {
91         puts "X1_Box1=${X1_Box1} Y1_Box1=${Y1_Box1} Z1_Box1=${Z1_Box1} X2_Box1=${X2_Box1} Y2_Box1=${Y2_Box1} Z2_Box1=${Z2_Box1}"
92         puts "X1_Box2=${X1_Box2} Y1_Box2=${Y1_Box2} Z1_Box2=${Z1_Box2} X2_Box2=${X2_Box2} Y2_Box2=${Y2_Box2} Z2_Box2=${Z2_Box2}"
93         puts "Updating a link between attributes of the same document: Error"
94         return
95 }
96
97 puts "Updating a link between attributes of the same document: OK"