Back to index

salome-gui  6.5.0
test_many_objects.py
Go to the documentation of this file.
00001 #  -*- coding: iso-8859-1 -*-
00002 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00003 #
00004 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00005 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00006 #
00007 # This library is free software; you can redistribute it and/or
00008 # modify it under the terms of the GNU Lesser General Public
00009 # License as published by the Free Software Foundation; either
00010 # version 2.1 of the License.
00011 #
00012 # This library is distributed in the hope that it will be useful,
00013 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 # Lesser General Public License for more details.
00016 #
00017 # You should have received a copy of the GNU Lesser General Public
00018 # License along with this library; if not, write to the Free Software
00019 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00020 #
00021 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00022 #
00023 
00024 # File   : visu_many_objects.py
00025 # Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
00026 #
00027 import salome
00028 import SALOMEDS
00029 
00030 # >>> Getting study builder ==================================================
00031 myStudy = salome.myStudy
00032 myBuilder = myStudy.NewBuilder()
00033 
00034 # >>> Creating virtual component =============================================
00035 myComponent = myBuilder.NewComponent("VIRTUAL")
00036 AName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
00037 AName.SetValue("Virtual")
00038 ACmt = myBuilder.FindOrCreateAttribute(myComponent, "AttributeComment")
00039 ACmt.SetValue("Virtual")
00040 
00041 # >>> Creating objects =======================================================
00042 # TO CHANGE TOTAL NUMBER OF OBJECTS, SET PROPER <myNb1>, <myNb2>, <myNb3>
00043 # IF YOU DON'T WANT TO ADD REFERENCES, SET <myAddRef> = 0
00044 myNb1 = 20
00045 myNb2 = 5
00046 myNb3 = 3
00047 myAddRef = 1
00048 
00049 if myAddRef == 1:
00050     myContainer =  myBuilder.NewObject(myComponent)
00051     AName = myBuilder.FindOrCreateAttribute(myContainer, "AttributeName")
00052     AName.SetValue("References")
00053     ACmt = myBuilder.FindOrCreateAttribute(myContainer, "AttributeComment")
00054     ACmt.SetValue("Container for objects")
00055 
00056 for i in range(0,myNb1):
00057     myObject1 = myBuilder.NewObject(myComponent)
00058     AName = myBuilder.FindOrCreateAttribute(myObject1, "AttributeName")
00059     AName.SetValue("Object "+str(i))
00060     ACmt = myBuilder.FindOrCreateAttribute(myObject1, "AttributeComment")
00061     ACmt.SetValue("Virtual object "+str(i))
00062     if myAddRef == 1:
00063         myRefObject = myBuilder.NewObject(myContainer)
00064         myBuilder.Addreference(myRefObject,myObject1);
00065 
00066     for j in range(0,myNb2):
00067         myObject2 = myBuilder.NewObject(myObject1)
00068         AName = myBuilder.FindOrCreateAttribute(myObject2, "AttributeName")
00069         AName.SetValue("Object "+str(i)+"-"+str(j))
00070         ACmt = myBuilder.FindOrCreateAttribute(myObject2, "AttributeComment")
00071         ACmt.SetValue("Virtual object "+str(i)+"-"+str(j))
00072         if myAddRef == 1:
00073             myRefObject = myBuilder.NewObject(myContainer)
00074             myBuilder.Addreference(myRefObject,myObject2);
00075 
00076         for k in range(0,myNb3):
00077             myObject3 = myBuilder.NewObject(myObject2)
00078             AName = myBuilder.FindOrCreateAttribute(myObject3, "AttributeName")
00079             AName.SetValue("Object "+str(i)+"-"+str(j)+"-"+str(k))
00080             ACmt = myBuilder.FindOrCreateAttribute(myObject3, "AttributeComment")
00081             ACmt.SetValue("Virtual object "+str(i)+"-"+str(j)+"-"+str(k))
00082             if myAddRef == 1:
00083                 myRefObject = myBuilder.NewObject(myContainer)
00084                 myBuilder.Addreference(myRefObject,myObject3);
00085 
00086 # >>> Updating Object Browser ================================================
00087 salome.sg.updateObjBrowser(1)
00088 
00089 # ============================================================================
00090 
00091