1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
\r
3 <!-- hennerik CVSweb $Revision$ -->
\r
4 <TITLE>Example</TITLE></HEAD>
\r
5 <BODY BGCOLOR="#eeeeee">
\r
6 <HR noshade><PRE>#%AttributeTreeNode interface(creations/saving/restoring)%
\r
7 #%SALOMEDS methods : FindOrCreateAttribute, NewObject%
\r
8 #%Attribute methods : HasFirst, HasFather, SetPrevious, Next, InsertAfter, GetFather, HasNext, SetValue, Append, NewStudy, Label, IsRoot, Prepend, SetFather, Depth, HasPrevious%
\r
10 child1 = batchmode_geompy.myBuilder.NewObject(batchmode_geompy.father)
\r
11 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child1,"AttributeName")
\r
13 raise RuntimeError, "Can't create AttributeName attribute"
\r
14 A = A._narrow(SALOMEDS.AttributeName)
\r
15 A.SetValue("N1")
\r
16 N1 = batchmode_geompy.myBuilder.FindOrCreateAttribute(child1, "AttributeTreeNode")
\r
18 raise RuntimeError, "Can't create AttributeTreeNode attribute"
\r
20 child2 = batchmode_geompy.myBuilder.NewObject(batchmode_geompy.father)
\r
21 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child2,"AttributeName")
\r
23 raise RuntimeError, "Can't create AttributeName attribute"
\r
24 A = A._narrow(SALOMEDS.AttributeName)
\r
25 A.SetValue("N2")
\r
26 N2 = batchmode_geompy.myBuilder.FindOrCreateAttribute(child2, "AttributeTreeNode")
\r
28 raise RuntimeError, "Can't create AttributeTreeNode attribute"
\r
30 child3 = batchmode_geompy.myBuilder.NewObject(batchmode_geompy.father)
\r
31 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child3,"AttributeName")
\r
33 raise RuntimeError, "Can't create AttributeName attribute"
\r
34 A = A._narrow(SALOMEDS.AttributeName)
\r
35 A.SetValue("N3")
\r
36 N3 = batchmode_geompy.myBuilder.FindOrCreateAttribute(child3, "AttributeTreeNode")
\r
38 raise RuntimeError, "Can't create AttributeTreeNode attribute"
\r
41 child11 = batchmode_geompy.myBuilder.NewObject(child1)
\r
42 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child11,"AttributeName")
\r
44 raise RuntimeError, "Can't create AttributeName attribute"
\r
45 A = A._narrow(SALOMEDS.AttributeName)
\r
46 A.SetValue("N11")
\r
48 N11 = batchmode_geompy.myBuilder.FindOrCreateAttribute(child11, "AttributeTreeNode")
\r
51 raise RuntimeError, "Can't create AttributeTreeNode attribute"
\r
53 child111 = batchmode_geompy.myBuilder.NewObject(child11)
\r
54 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child111, "AttributeName")
\r
56 raise RuntimeError, "Can't create AttributeName attribute"
\r
57 A = A._narrow(SALOMEDS.AttributeName)
\r
58 A.SetValue("N111")
\r
60 N111 = batchmode_geompy.myBuilder.FindOrCreateAttribute(child111, "AttributeTreeNode")
\r
63 raise RuntimeError, "Can't create AttributeTreeNode attribute"
\r
66 child31 = batchmode_geompy.myBuilder.NewObject(child3)
\r
67 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child31,"AttributeName")
\r
69 raise RuntimeError, "Can't create AttributeName attribute"
\r
70 A = A._narrow(SALOMEDS.AttributeName)
\r
71 A.SetValue("N31")
\r
73 N31 = batchmode_geompy.myBuilder.FindOrCreateAttribute(child31, "AttributeTreeNode")
\r
75 raise RuntimeError, "Can't create AttributeTreeNode attribute"
\r
77 child32 = batchmode_geompy.myBuilder.NewObject(child3)
\r
78 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child32,"AttributeName")
\r
80 raise RuntimeError, "Can't create AttributeName attribute"
\r
81 A = A._narrow(SALOMEDS.AttributeName)
\r
82 A.SetValue("N32")
\r
84 N32 = batchmode_geompy.myBuilder.FindOrCreateAttribute(child32, "AttributeTreeNode")
\r
86 raise RuntimeError, "Can't create AttributeTreeNode attribute"
\r
88 child321 = batchmode_geompy.myBuilder.NewObject(child32)
\r
89 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child321,"AttributeName")
\r
91 raise RuntimeError, "Can't create AttributeName attribute"
\r
92 A = A._narrow(SALOMEDS.AttributeName)
\r
93 A.SetValue("N321")
\r
95 N321 = batchmode_geompy.myBuilder.FindOrCreateAttribute(child321, "AttributeTreeNode")
\r
97 raise RuntimeError, "Can't create AttributeTreeNode attribute"
\r
99 child33 = batchmode_geompy.myBuilder.NewObject(child3)
\r
100 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child33,"AttributeName")
\r
102 raise RuntimeError, "Can't create AttributeName attribute"
\r
103 A = A._narrow(SALOMEDS.AttributeName)
\r
104 A.SetValue("N33")
\r
106 N33 = batchmode_geompy.myBuilder.FindOrCreateAttribute(child33, "AttributeTreeNode")
\r
108 raise RuntimeError, "Can't create AttributeTreeNode attribute"
\r
110 child34 = batchmode_geompy.myBuilder.NewObject(child3)
\r
111 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child34,"AttributeName")
\r
113 raise RuntimeError, "Can't create AttributeName attribute"
\r
114 A = A._narrow(SALOMEDS.AttributeName)
\r
115 A.SetValue("N34")
\r
117 N34 = batchmode_geompy.myBuilder.FindOrCreateAttribute(child34, "AttributeTreeNode")
\r
119 raise RuntimeError, "Can't create AttributeTreeNode attribute"
\r
123 #Create links between tree nodes.
\r
126 # | N11__
\r
127 # | N111
\r
128 # --N2
\r
131 # N31
\r
132 # N32__
\r
133 # N321
\r
134 # N33
\r
135 # N34
\r
136
\r
144 N33.InsertAfter(N32)
\r
146 print "------------- ", N1, " ------------- "
\r
147 print "N1.Label() = ", N1.Label() , "IsRoot() = ", N1.IsRoot(), "Depth() = ", N1.Depth()
\r
148 print "N11.Label() = ", N11.Label() , "IsRoot() = ", N11.IsRoot(), "Depth() = ", N11.Depth()
\r
149 print "N111.Label() = ", N111.Label() , "IsRoot() = ", N111.IsRoot(), "Depth() = ", N111.Depth()
\r
150 print "N2.Label() = ", N2.Label() , "IsRoot() = ", N2.IsRoot(), "Depth() = ", N2.Depth()
\r
151 print "N3.Label() = ", N3.Label() , "IsRoot() = ", N3.IsRoot(), "Depth() = ", N3.Depth()
\r
152 print "N31.Label() = ", N31.Label() , "IsRoot() = ", N31.IsRoot(), "Depth() = ", N31.Depth()
\r
153 print "N32.Label() = ", N32.Label() , "IsRoot() = ", N32.IsRoot(), "Depth() = ", N32.Depth()
\r
154 print "N321.Label() = ", N321.Label() , "IsRoot() = ", N321.IsRoot(), "Depth() = ", N321.Depth()
\r
155 print "N33.Label() = ", N33.Label() , "IsRoot() = ", N33.IsRoot(), "Depth() = ", N33.Depth()
\r
156 print "N34.Label() = ", N34.Label() , "IsRoot() = ", N34.IsRoot(), "Depth() = ", N34.Depth()
\r
157 print "N1.IsRoot()=", N1.IsRoot()
\r
159 print "N1.HasNext() = ",N1.HasNext()
\r
160 if N1.HasNext():
\r
161 print N1.Next().Label()
\r
163 print "N32.HasPrevious() = ",N32.HasPrevious()
\r
164 if N32.HasPrevious():
\r
165 print N32.GetPrevious().Label()
\r
167 print "N111.HasFirst()=",N111.HasFirst()
\r
168 print "N111.HasFather()=",N111.HasFather()
\r
169 if N111.HasFather() :
\r
170 print "N111.GetFather().Label()=",N111.GetFather().Label()
\r