Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/kernel.git] / src / SALOME_SWIG / PyInterp.py
1 #==============================================================================
2 #  File      : PyInterp.py
3 #  Created   : mer oct 17 08:42:01 CEST 2001
4 #  Author    : Paul RASCLE, EDF
5 #  Project   : SALOME
6 #  Copyright : EDF 2001
7 #  $Header$
8 #==============================================================================
9
10 import sys
11 from omniORB import CORBA
12 from LifeCycleCORBA import *
13 from libSALOME_Swig import *
14 import SALOMEDS
15 from SALOME_NamingServicePy import *
16
17     #--------------------------------------------------------------------------
18
19 def DumpComponent(Study, SO, offset):
20     it = Study.NewChildIterator(SO)
21     Builder = Study.NewBuilder()
22     while it.More():
23         CSO = it.Value()
24         it.Next()
25         anAttr = Builder.FindOrCreateAttribute(CSO, "AttributeName")
26         AtName = anAttr._narrow(SALOMEDS.AttributeName)
27         t_name = AtName.Value()
28         if t_name[0] == 1:
29             ofs = 1
30             a = ""
31             while ofs <= offset:
32                 a = a + "--"
33                 ofs = ofs +1
34             print a + ">" + CSO.GetID() + " " + t_name[1]
35         t_RefSO = CSO.ReferencedObject()
36         if t_RefSO[0] == 1:
37             RefSO = t_RefSO[1]
38             ofs = 1
39             a = ""
40             while ofs <= offset:
41                 a = a + "  "
42                 ofs = ofs +1
43             print a + ">" + RefSO.GetID()
44         DumpComponent(Study, CSO, offset+2)
45
46     #--------------------------------------------------------------------------
47
48 def DumpStudy(Study):
49     itcomp = Study.NewComponentIterator()
50     while itcomp.More():
51         SC = itcomp.Value()
52         itcomp.Next()
53         name = SC.ComponentDataType()
54         print "-> ComponentDataType is " + name
55         DumpComponent(Study, SC, 1)
56         
57
58     #--------------------------------------------------------------------------
59
60 # initialise the ORB
61 orb = CORBA.ORB_init([''], CORBA.ORB_ID)
62
63 # create an LifeCycleCORBA instance
64 lcc = LifeCycleCORBA(orb)
65
66 # create an SALOMEGUI_Swig instance
67 sg = SALOMEGUI_Swig()
68
69 #create an naming service instance
70 naming_service = SALOME_NamingServicePy_i(orb)
71
72 # get active study name and id
73 myStudyName = sg.getActiveStudyName()
74 print myStudyName
75
76 myStudyId = sg.getActiveStudyId()
77 print myStudyId
78
79 # get Study Manager reference
80 obj = naming_service.Resolve('myStudyManager')
81 myStudyManager = obj._narrow(SALOMEDS.StudyManager)
82
83 # get active study
84 myStudy = myStudyManager.GetStudyByName(myStudyName)
85