1 # Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
23 # Author : Paul RASCLE, EDF
27 from omniORB import CORBA
28 from LifeCycleCORBA import *
29 from libSALOME_Swig import *
32 from SALOME_NamingServicePy import *
34 from SALOME_utilities import *
36 #--------------------------------------------------------------------------
38 def DumpComponent(Study, SO, offset):
39 it = Study.NewChildIterator(SO)
40 Builder = Study.NewBuilder()
44 anAttr = Builder.FindOrCreateAttribute(CSO, "AttributeName")
45 AtName = anAttr._narrow(SALOMEDS.AttributeName)
46 t_name = AtName.Value()
53 MESSAGE( a + ">" + str(CSO.GetID()) + " " + str(t_name[1]) )
54 t_RefSO = CSO.ReferencedObject()
62 MESSAGE( a + ">" + str(RefSO.GetID()) )
63 DumpComponent(Study, CSO, offset+2)
65 #--------------------------------------------------------------------------
68 itcomp = Study.NewComponentIterator()
72 name = SC.ComponentDataType()
73 MESSAGE( "-> ComponentDataType is " + name )
74 DumpComponent(Study, SC, 1)
77 #--------------------------------------------------------------------------
79 def ImportComponentGUI(ComponentName):
80 libName = "lib" + ComponentName + "_Swig"
81 command = "from " + libName + " import *"
83 constructor = ComponentName + "_Swig()"
84 command = "gui = " + constructor
88 #--------------------------------------------------------------------------
90 def SalomeGUIgetAllSelected(self):
91 selNumber = self.SelectedCount()
93 for i in range(selNumber):
94 listSelected.append(self.getSelected(i))
97 class SalomeGUI(SALOMEGUI_Swig):
98 getAllSelected = SalomeGUIgetAllSelected
100 #--------------------------------------------------------------------------
104 mySO = myStudy.FindObjectID(id);
106 ok, anAttr = mySO.FindAttribute("AttributeIOR")
108 AtIOR = anAttr._narrow(SALOMEDS.AttributeIOR)
109 if AtIOR.Value() != "":
110 myObj = orb.string_to_object(AtIOR.Value())
113 def ObjectToSObject(obj):
116 ior = orb.object_to_string(obj)
118 mySO = myStudy.FindObjectIOR(ior)
122 mySO = ObjectToSObject(obj)
128 mySO = myStudy.FindObjectID(id);
131 #--------------------------------------------------------------------------
134 orb = CORBA.ORB_init([''], CORBA.ORB_ID)
136 # create an LifeCycleCORBA instance
137 lcc = LifeCycleCORBA(orb)
139 # create an SALOMEGUI_Swig instance
142 #create an naming service instance
143 naming_service = SALOME_NamingServicePy_i(orb)
145 # get active study name and id
146 myStudyName = sg.getActiveStudyName()
147 MESSAGE( myStudyName )
149 myStudyId = sg.getActiveStudyId()
150 MESSAGE( str(myStudyId) )
152 # get Study Manager reference
153 obj = naming_service.Resolve('myStudyManager')
154 myStudyManager = obj._narrow(SALOMEDS.StudyManager)
157 myStudy = myStudyManager.GetStudyByName(myStudyName)
159 # get Container Manager
160 obj = naming_service.Resolve('/ContainerManager')
161 cm = obj._narrow(Engines.ContainerManager)