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