Back to index

salome-kernel  6.5.0
PyInterp.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   : PyInterp.py
00025 #  Author : Paul RASCLE, EDF
00026 #  Module : SALOME
00027 #  $Header: /home/server/cvs/KERNEL/KERNEL_SRC/src/KERNEL_PY/PyInterp.py,v 1.4.2.2.14.2.12.1 2012-04-12 14:05:13 vsr Exp $
00028 #
00029 import sys
00030 from omniORB import CORBA
00031 from LifeCycleCORBA import *
00032 from libSALOME_Swig import *
00033 import SALOMEDS
00034 from SALOME_NamingServicePy import *
00035 
00036     #--------------------------------------------------------------------------
00037 
00038 def DumpComponent(Study, SO, offset):
00039     it = Study.NewChildIterator(SO)
00040     Builder = Study.NewBuilder()
00041     while it.More():
00042         CSO = it.Value()
00043         it.Next()
00044         anAttr = Builder.FindOrCreateAttribute(CSO, "AttributeName")
00045         AtName = anAttr._narrow(SALOMEDS.AttributeName)
00046         t_name = AtName.Value()
00047         if t_name[0] == 1:
00048             ofs = 1
00049             a = ""
00050             while ofs <= offset:
00051                 a = a + "--"
00052                 ofs = ofs +1
00053             print a + ">" + CSO.GetID() + " " + t_name[1]
00054         t_RefSO = CSO.ReferencedObject()
00055         if t_RefSO[0] == 1:
00056             RefSO = t_RefSO[1]
00057             ofs = 1
00058             a = ""
00059             while ofs <= offset:
00060                 a = a + "  "
00061                 ofs = ofs +1
00062             print a + ">" + RefSO.GetID()
00063         DumpComponent(Study, CSO, offset+2)
00064 
00065     #--------------------------------------------------------------------------
00066 
00067 def DumpStudy(Study):
00068     itcomp = Study.NewComponentIterator()
00069     while itcomp.More():
00070         SC = itcomp.Value()
00071         itcomp.Next()
00072         name = SC.ComponentDataType()
00073         print "-> ComponentDataType is " + name
00074         DumpComponent(Study, SC, 1)
00075         
00076 
00077     #--------------------------------------------------------------------------
00078 
00079 # initialise the ORB
00080 orb = CORBA.ORB_init([''], CORBA.ORB_ID)
00081 
00082 # create an LifeCycleCORBA instance
00083 lcc = LifeCycleCORBA(orb)
00084 
00085 # create an SALOMEGUI_Swig instance
00086 sg = SALOMEGUI_Swig()
00087 
00088 #create an naming service instance
00089 naming_service = SALOME_NamingServicePy_i(orb)
00090 
00091 # get active study name and id
00092 myStudyName = sg.getActiveStudyName()
00093 print myStudyName
00094 
00095 myStudyId = sg.getActiveStudyId()
00096 print myStudyId
00097 
00098 # get Study Manager reference
00099 obj = naming_service.Resolve('myStudyManager')
00100 myStudyManager = obj._narrow(SALOMEDS.StudyManager)
00101 
00102 # get active study
00103 myStudy = myStudyManager.GetStudyByName(myStudyName)