486b4ed988fc0ddb483dafe8a32eb51a244dd7f7
[occt.git] / tests / caf / xlink / D2
1 #INTERFACE CAF
2 # XLink attributes
3 #
4 # Testing attribute: TDocStd_XLink
5 #
6 # Testing command:   UpdateLink
7 #
8
9 puts "caf004-D2"
10
11 # Create two new documents Doc1, Doc2
12 NewDocument Doc1 BinOcaf
13 NewDocument Doc2 BinOcaf
14
15 # Set UndoLimit for them
16 UndoLimit Doc1 100
17 UndoLimit Doc2 100
18
19 # 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 # Set a shape in Doc1 to label 'S2Label'
44 set aLabel12 0:22
45 Label Doc1 ${aLabel12}
46 SetName Doc1 ${aLabel12} S2Label
47
48 set aSetX12 210
49 set aSetY12 220
50 set aSetZ12 230
51 set aSetDX12 2100
52 set aSetDY12 2200
53 set aSetDZ12 2300
54
55 box aBox12 ${aSetX12} ${aSetY12} ${aSetZ12} ${aSetDX12} ${aSetDY12} ${aSetDZ12}
56
57 set aBoundingBox12 [bounding aBox12]
58 set X1_Box12 [lindex ${aBoundingBox12} 0]
59 set Y1_Box12 [lindex ${aBoundingBox12} 1]
60 set Z1_Box12 [lindex ${aBoundingBox12} 2]
61 set X2_Box12 [lindex ${aBoundingBox12} 3]
62 set Y2_Box12 [lindex ${aBoundingBox12} 4]
63 set Z2_Box12 [lindex ${aBoundingBox12} 5]
64
65 SetShape Doc1 ${aLabel12} aBox12
66
67 # Create a new label 'TLabel1' in Doc2
68 set aLabel2 0:3
69 Label Doc2 ${aLabel2}
70 SetName Doc2 ${aLabel2} TLabel1
71
72 # Create a new label 'T2Label1' in Doc2
73 set aLabel22 0:32
74 Label Doc2 ${aLabel22}
75 SetName Doc2 ${aLabel22} T2Label1
76
77 # Open transaction in Doc2
78 NewCommand Doc2
79
80 # Copy 'SLabel' to the label 'TLabel1' with link
81 CopyWithLink Doc2 ${aLabel2} Doc1 ${aLabel1}
82
83 # Copy 'S2Label' to the label 'T2Label1' with link
84 CopyWithLink Doc2 ${aLabel22} Doc1 ${aLabel12}
85
86 # Close/Open transaction in Doc2
87 NewCommand Doc2
88
89 # Set new shape in Doc1 to label 'SLabel'
90 set aRadius 70
91 psphere aSphere ${aRadius}
92 SetShape Doc1 ${aLabel1} aSphere
93
94 # Set new shape in Doc1 to label 'SLabel'
95 set aRadius 270
96 psphere aSphere ${aRadius}
97 SetShape Doc1 ${aLabel12} aSphere
98
99 # Update all links in Doc2
100 UpdateLink Doc2
101
102 # Close/Open transaction in Doc2
103 NewCommand Doc2
104
105 # Undo Doc2
106 Undo Doc2
107
108 # Redo Doc2
109 Redo Doc2
110
111 # Get a shape from 'TLabel1'
112 GetShape Doc2 ${aLabel2} aBox2
113
114 set aBoundingBox2 [bounding aBox2]
115 set X1_Box2 [lindex ${aBoundingBox2} 0]
116 set Y1_Box2 [lindex ${aBoundingBox2} 1]
117 set Z1_Box2 [lindex ${aBoundingBox2} 2]
118 set X2_Box2 [lindex ${aBoundingBox2} 3]
119 set Y2_Box2 [lindex ${aBoundingBox2} 4]
120 set Z2_Box2 [lindex ${aBoundingBox2} 5]
121
122 # Get a shape from 'T2Label1'
123 GetShape Doc2 ${aLabel22} aBox22
124
125 set aBoundingBox22 [bounding aBox22]
126 set X1_Box22 [lindex ${aBoundingBox22} 0]
127 set Y1_Box22 [lindex ${aBoundingBox22} 1]
128 set Z1_Box22 [lindex ${aBoundingBox22} 2]
129 set X2_Box22 [lindex ${aBoundingBox22} 3]
130 set Y2_Box22 [lindex ${aBoundingBox22} 4]
131 set Z2_Box22 [lindex ${aBoundingBox22} 5]
132
133 if { ${X1_Box1} == ${X1_Box2} || 
134      ${Y1_Box1} == ${Y1_Box2} || 
135      ${Z1_Box1} == ${Z1_Box2} || 
136      ${X2_Box1} == ${X2_Box2} || 
137      ${Y2_Box1} == ${Y2_Box2} || 
138      ${Z2_Box1} == ${Z2_Box2} ||
139
140      ${X1_Box12} == ${X1_Box22} || 
141      ${Y1_Box12} == ${Y1_Box22} || 
142      ${Z1_Box12} == ${Z1_Box22} || 
143      ${X2_Box12} == ${X2_Box22} || 
144      ${Y2_Box12} == ${Y2_Box22} || 
145      ${Z2_Box12} == ${Z2_Box22} ||
146
147      ${X1_Box2} == ${X1_Box22} || 
148      ${Y1_Box2} == ${Y1_Box22} || 
149      ${Z1_Box2} == ${Z1_Box22} || 
150      ${X2_Box2} == ${X2_Box22} || 
151      ${Y2_Box2} == ${Y2_Box22} || 
152      ${Z2_Box2} == ${Z2_Box22} } {
153
154         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}"
155         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}"
156         puts "X1_Box12=${X1_Box12} Y1_Box12=${Y1_Box12} Z1_Box12=${Z1_Box12} X2_Box12=${X2_Box12} Y2_Box12=${Y2_Box12} Z2_Box12=${Z2_Box12}"
157         puts "X1_Box22=${X1_Box22} Y1_Box22=${Y1_Box22} Z1_Box22=${Z1_Box22} X2_Box22=${X2_Box22} Y2_Box22=${Y2_Box22} Z2_Box22=${Z2_Box22}"
158         puts "Updating all links between attributes of the same document: Error"
159         return
160 }
161
162 puts "Updating all links between attributes of the same document: OK"