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