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 *
31 from SALOME_NamingServicePy import *
33 from SALOME_utilities import *
35 #--------------------------------------------------------------------------
37 def DumpComponent(Study, SO, offset):
38 it = Study.NewChildIterator(SO)
39 Builder = Study.NewBuilder()
43 anAttr = Builder.FindOrCreateAttribute(CSO, "AttributeName")
44 AtName = anAttr._narrow(SALOMEDS.AttributeName)
45 t_name = AtName.Value()
52 MESSAGE( a + ">" + str(CSO.GetID()) + " " + str(t_name[1]) )
53 t_RefSO = CSO.ReferencedObject()
61 MESSAGE( a + ">" + str(RefSO.GetID()) )
62 DumpComponent(Study, CSO, offset+2)
64 #--------------------------------------------------------------------------
67 itcomp = Study.NewComponentIterator()
71 name = SC.ComponentDataType()
72 MESSAGE( "-> ComponentDataType is " + name )
73 DumpComponent(Study, SC, 1)
76 #--------------------------------------------------------------------------
78 def ImportComponentGUI(ComponentName):
79 libName = "lib" + ComponentName + "_Swig"
80 command = "from " + libName + " import *"
82 constructor = ComponentName + "_Swig()"
83 command = "gui = " + constructor
87 #--------------------------------------------------------------------------
89 def SalomeGUIgetAllSelected(self):
90 selNumber = self.SelectedCount()
92 for i in range(selNumber):
93 listSelected.append(self.getSelected(i))
96 class SalomeGUI(SALOMEGUI_Swig):
97 getAllSelected = SalomeGUIgetAllSelected
99 #--------------------------------------------------------------------------
103 mySO = myStudy.FindObjectID(id);
105 ok, anAttr = mySO.FindAttribute("AttributeIOR")
107 AtIOR = anAttr._narrow(SALOMEDS.AttributeIOR)
108 if AtIOR.Value() != "":
109 myObj = orb.string_to_object(AtIOR.Value())
112 def ObjectToSObject(obj):
115 ior = orb.object_to_string(obj)
117 mySO = myStudy.FindObjectIOR(ior)
121 mySO = ObjectToSObject(obj)
127 mySO = myStudy.FindObjectID(id);
130 #--------------------------------------------------------------------------
133 orb = CORBA.ORB_init([''], CORBA.ORB_ID)
135 # create an LifeCycleCORBA instance
136 lcc = LifeCycleCORBA(orb)
138 # create an SALOMEGUI_Swig instance
141 #create an naming service instance
142 naming_service = SALOME_NamingServicePy_i(orb)
144 # get active study name and id
145 myStudyName = sg.getActiveStudyName()
146 MESSAGE( myStudyName )
148 myStudyId = sg.getActiveStudyId()
149 MESSAGE( str(myStudyId) )
151 # get Study Manager reference
152 obj = naming_service.Resolve('myStudyManager')
153 myStudyManager = obj._narrow(SALOMEDS.StudyManager)
156 myStudy = myStudyManager.GetStudyByName(myStudyName)