Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/gui.git] / src / SALOME_SWIG / test_many_objects.py
1 # Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either 
6 # version 2.1 of the License.
7 #
8 # This library is distributed in the hope that it will be useful 
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public  
14 # License along with this library; if not, write to the Free Software 
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 #  File   : visu_many_objects.py
20 #  Author : Vadim SANDLER
21 #  Module : SALOME
22 #  $Header$
23
24 import salome
25 import SALOMEDS
26
27 # >>> Getting study builder ==================================================
28 myStudy = salome.myStudy
29 myBuilder = myStudy.NewBuilder()
30
31 # >>> Creating virtual component =============================================
32 myComponent = myBuilder.NewComponent("VIRTUAL")
33 AName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
34 AName.SetValue("Virtual")
35 ACmt = myBuilder.FindOrCreateAttribute(myComponent, "AttributeComment")
36 ACmt.SetValue("Virtual")
37
38 # >>> Creating objects =======================================================
39 # TO CHANGE TOTAL NUMBER OF OBJECTS, SET PROPER <myNb1>, <myNb2>, <myNb3>
40 # IF YOU DON'T WANT TO ADD REFERENCES, SET <myAddRef> = 0
41 myNb1 = 20
42 myNb2 = 5
43 myNb3 = 3
44 myAddRef = 1
45
46 if myAddRef == 1:
47     myContainer =  myBuilder.NewObject(myComponent)
48     AName = myBuilder.FindOrCreateAttribute(myContainer, "AttributeName")
49     AName.SetValue("References")
50     ACmt = myBuilder.FindOrCreateAttribute(myContainer, "AttributeComment")
51     ACmt.SetValue("Container for objects")
52
53 for i in range(0,myNb1):
54     myObject1 = myBuilder.NewObject(myComponent)
55     AName = myBuilder.FindOrCreateAttribute(myObject1, "AttributeName")
56     AName.SetValue("Object "+str(i))
57     ACmt = myBuilder.FindOrCreateAttribute(myObject1, "AttributeComment")
58     ACmt.SetValue("Virtual object "+str(i))
59     if myAddRef == 1:
60         myRefObject = myBuilder.NewObject(myContainer)
61         myBuilder.Addreference(myRefObject,myObject1);
62
63     for j in range(0,myNb2):
64         myObject2 = myBuilder.NewObject(myObject1)
65         AName = myBuilder.FindOrCreateAttribute(myObject2, "AttributeName")
66         AName.SetValue("Object "+str(i)+"-"+str(j))
67         ACmt = myBuilder.FindOrCreateAttribute(myObject2, "AttributeComment")
68         ACmt.SetValue("Virtual object "+str(i)+"-"+str(j))
69         if myAddRef == 1:
70             myRefObject = myBuilder.NewObject(myContainer)
71             myBuilder.Addreference(myRefObject,myObject2);
72
73         for k in range(0,myNb3):
74             myObject3 = myBuilder.NewObject(myObject2)
75             AName = myBuilder.FindOrCreateAttribute(myObject3, "AttributeName")
76             AName.SetValue("Object "+str(i)+"-"+str(j)+"-"+str(k))
77             ACmt = myBuilder.FindOrCreateAttribute(myObject3, "AttributeComment")
78             ACmt.SetValue("Virtual object "+str(i)+"-"+str(j)+"-"+str(k))
79             if myAddRef == 1:
80                 myRefObject = myBuilder.NewObject(myContainer)
81                 myBuilder.Addreference(myRefObject,myObject3);
82
83 # >>> Updating Object Browser ================================================
84 salome.sg.updateObjBrowser(1)
85
86 # ============================================================================
87
88