From e61c3f5e439eae3822cb22176c5493668e5a7df5 Mon Sep 17 00:00:00 2001 From: imn Date: Thu, 13 Oct 2016 12:45:45 +0300 Subject: [PATCH] 0023299: [CEA] Finalize multi-study removal - update python scripts and examples --- bin/runConsole.py | 2 +- bin/runSalome.py | 4 +- doc/salome/examples/example1 | 4 +- doc/salome/examples/example10 | 4 +- doc/salome/examples/example11 | 4 +- doc/salome/examples/example12 | 4 +- doc/salome/examples/example13 | 4 +- doc/salome/examples/example14 | 4 +- doc/salome/examples/example15 | 4 +- doc/salome/examples/example16 | 12 +- doc/salome/examples/example19 | 26 ++-- doc/salome/examples/example20 | 4 +- doc/salome/examples/example21 | 4 +- doc/salome/examples/example22 | 4 +- doc/salome/examples/example3 | 4 +- doc/salome/examples/example4 | 4 +- doc/salome/examples/example5 | 4 +- doc/salome/examples/example6 | 4 +- doc/salome/examples/example7 | 4 +- doc/salome/examples/example8 | 4 +- doc/salome/examples/example9 | 4 +- doc/salome/kernel_salome.dox | 74 ++------- doc/salome/kernel_services.dox | 1 - doc/salome/salome_application.dox | 3 +- idl/SALOME_Component.idl | 2 - src/Container/SALOME_ComponentPy.py | 8 +- src/Container/SALOME_ContainerPy.py | 61 ++++---- src/KERNEL_PY/Help.py | 6 +- src/KERNEL_PY/PyInterp.py | 16 +- src/KERNEL_PY/__init__.py | 50 +----- src/KERNEL_PY/batchmode_salome.py | 31 ++-- .../kernel/parametric/study_exchange_vars.py | 6 +- src/KERNEL_PY/kernel/services.py | 26 ++-- src/KERNEL_PY/kernel/studyedit.py | 76 ++------- src/KERNEL_PY/salome_iapp.py | 13 +- src/KERNEL_PY/salome_study.py | 147 ++++-------------- src/KERNEL_PY/salome_test.py | 2 +- src/Launcher/Test/test_launcher.py | 2 - 38 files changed, 190 insertions(+), 446 deletions(-) diff --git a/bin/runConsole.py b/bin/runConsole.py index bb2192c86..718321094 100644 --- a/bin/runConsole.py +++ b/bin/runConsole.py @@ -162,7 +162,7 @@ def start_client(): if session_server: session = clt.waitNS("/Kernel/Session") catalog = clt.waitNS("/Kernel/ModulCatalog") - studyMgr = clt.waitNS("/myStudyManager") + study = clt.waitNS("/Study") import salome salome.salome_init() diff --git a/bin/runSalome.py b/bin/runSalome.py index c8a092a3a..b547c3703 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -502,9 +502,9 @@ def startSalome(args, modules_list, modules_root_dir): myServer=SalomeDSServer(args) myServer.run() if sys.platform == "win32": - clt.waitNS("/myStudyManager") + clt.waitNS("/Study") else: - clt.waitNSPID("/myStudyManager",myServer.PID) + clt.waitNSPID("/Study",myServer.PID) # # Launch LauncherServer diff --git a/doc/salome/examples/example1 b/doc/salome/examples/example1 index eae882cae..709216610 100644 --- a/doc/salome/examples/example1 +++ b/doc/salome/examples/example1 @@ -21,8 +21,8 @@ file = str+"/test.hdf" print " ------- We will save to", file, "-----------" -batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) -openedStudy=batchmode_geompy.myStudyManager.Open(file) +batchmode_geompy.myStudy.SaveAs(file) +openedStudy=batchmode_geompy.myStudy.Open(file) if openedStudy == None: raise RuntimeError, "Can't open saved study!" diff --git a/doc/salome/examples/example10 b/doc/salome/examples/example10 index 756e4a3f1..3c2345d9c 100644 --- a/doc/salome/examples/example10 +++ b/doc/salome/examples/example10 @@ -22,8 +22,8 @@ if str == None: str = "/tmp" file = str+"/test.hdf" -batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) -openedStudy = batchmode_geompy.myStudyManager.Open(file); +batchmode_geompy.myStudy.SaveAs(file) +openedStudy = batchmode_geompy.myStudy.Open(file); if openedStudy == None: raise RuntimeError, "Can't open saved study!" diff --git a/doc/salome/examples/example11 b/doc/salome/examples/example11 index 4cfd732fd..99dac3761 100644 --- a/doc/salome/examples/example11 +++ b/doc/salome/examples/example11 @@ -22,8 +22,8 @@ if str == None: str = "/tmp" file = str+"/test.hdf" -batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) -openedStudy=batchmode_geompy.myStudyManager.Open(file); +batchmode_geompy.myStudy.SaveAs(file) +openedStudy=batchmode_geompy.myStudy.Open(file); if openedStudy == None: raise RuntimeError, "Can't open saved study!" diff --git a/doc/salome/examples/example12 b/doc/salome/examples/example12 index 760587736..7b69a136b 100644 --- a/doc/salome/examples/example12 +++ b/doc/salome/examples/example12 @@ -28,8 +28,8 @@ if str == None: str = "/tmp" file = str+"/test.hdf" -batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) -openedStudy = batchmode_geompy.myStudyManager.Open(file); +batchmode_geompy.myStudy.SaveAs(file) +openedStudy = batchmode_geompy.myStudy.Open(file); if openedStudy == None: raise RuntimeError, "Can't open saved study!" diff --git a/doc/salome/examples/example13 b/doc/salome/examples/example13 index c05aaff52..ced0f5a5f 100644 --- a/doc/salome/examples/example13 +++ b/doc/salome/examples/example13 @@ -29,8 +29,8 @@ if str == None: str = "/tmp" file = str+"/test.hdf" -batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) -openedStudy=batchmode_geompy.myStudyManager.Open(file); +batchmode_geompy.myStudy.SaveAs(file) +openedStudy=batchmode_geompy.myStudy.Open(file); if openedStudy == None: raise RuntimeError, "Can't open saved study!" diff --git a/doc/salome/examples/example14 b/doc/salome/examples/example14 index a0acf346d..384ae8fc7 100644 --- a/doc/salome/examples/example14 +++ b/doc/salome/examples/example14 @@ -19,8 +19,8 @@ if str == None: str = "/tmp" file = str+"/test.hdf" -batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) -openedStudy = batchmode_geompy.myStudyManager.Open(file); +batchmode_geompy.myStudy.SaveAs(file) +openedStudy = batchmode_geompy.myStudy.Open(file); if openedStudy == None: raise RuntimeError, "Can't open saved study!" diff --git a/doc/salome/examples/example15 b/doc/salome/examples/example15 index 42493fe01..c959cd7ee 100644 --- a/doc/salome/examples/example15 +++ b/doc/salome/examples/example15 @@ -18,8 +18,8 @@ if str == None: str = "/tmp" file = str+"/test.hdf" -batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) -openedStudy = batchmode_geompy.myStudyManager.Open(file); +batchmode_geompy.myStudy.SaveAs(file) +openedStudy = batchmode_geompy.myStudy.Open(file); if openedStudy == None: raise RuntimeError, "Can't open saved study!" diff --git a/doc/salome/examples/example16 b/doc/salome/examples/example16 index 3be50d9b6..724fb89fd 100644 --- a/doc/salome/examples/example16 +++ b/doc/salome/examples/example16 @@ -39,7 +39,7 @@ if A.Value(1) != 100 or A.Value(2) != 300 or A.Value(3) != 400 or A.Value(4) != raise RuntimeError, "Wrong value of AttributeSequenceOfInteger" file1 = dir + "/test1.hdf" -batchmode_geompy.myStudyManager.SaveAs(file1, batchmode_geompy.myStudy) +batchmode_geompy.myStudy.SaveAs(file1) # 1st Undo --------------------------------------- batchmode_geompy.myBuilder.Undo() @@ -53,7 +53,7 @@ if A.Value(1) != 100 or A.Value(2) != 300 or A.Value(3) != 500 or A.Value(4) != raise RuntimeError, "Wrong value of AttributeSequenceOfInteger after the first 'undo'!" # save file2 = dir + "/test2.hdf" -batchmode_geompy.myStudyManager.SaveAs(file2, batchmode_geompy.myStudy) +batchmode_geompy.myStudy.SaveAs(file2) #------------------------------------------------- # 2nd Undo --------------------------------------- batchmode_geompy.myBuilder.Undo() @@ -61,7 +61,7 @@ res, attr = batchmode_geompy.myBuilder.FindAttribute(batchmode_geompy.father, "A if res !=0 or attr != None : raise RuntimeError, "After the second 'undo' AttributeSequenceOfInteger exists but must not!" file3 = dir + "/test3.hdf" -batchmode_geompy.myStudyManager.SaveAs(file3, batchmode_geompy.myStudy) +batchmode_geompy.myStudy.SaveAs(file3) #------------------------------------------------- #make redo twice --------------------------------- @@ -79,7 +79,7 @@ if A.Value(1) != 100 or A.Value(2) != 300 or A.Value(3) != 400 or A.Value(4) != #---------------------------------------------------------------------- -openedStudy=batchmode_geompy.myStudyManager.Open(file1); +openedStudy=batchmode_geompy.myStudy.Open(file1); if openedStudy == None: raise RuntimeError, "Can't open saved study!" @@ -104,7 +104,7 @@ if A.Length() != 4: if A.Value(1) != 100 or A.Value(2) != 300 or A.Value(3) != 400 or A.Value(4) != 500: print "Wrong value of AttributeSequenceOfInteger" #---------------------------------------------------------------------- -openedStudy=batchmode_geompy.myStudyManager.Open(file2); +openedStudy=batchmode_geompy.myStudy.Open(file2); if openedStudy == None: raise RuntimeError, "Can't open saved study!" @@ -130,7 +130,7 @@ if A.Value(1) != 100 or A.Value(2) != 300 or A.Value(3) != 500 or A.Value(4) != raise RuntimeError, "Wrong value of AttributeSequenceOfInteger after the first 'undo'!" #---------------------------------------------------------------------- -openedStudy=batchmode_geompy.myStudyManager.Open(file3); +openedStudy=batchmode_geompy.myStudy.Open(file3); if openedStudy == None: raise RuntimeError, "Can't open saved study!" diff --git a/doc/salome/examples/example19 b/doc/salome/examples/example19 index 4cf37eb34..dbbd80e52 100644 --- a/doc/salome/examples/example19 +++ b/doc/salome/examples/example19 @@ -60,7 +60,7 @@ idedge= batchmode_geompy.addToStudyInFather(face,edge,name) smesh = batchmode_smesh.smesh # -- Init -- shape = batchmode_geompy.IDToObject(idbox) -mesh=smesh.Init(geom, batchmode_geompy.myStudyId, shape) +mesh=smesh.Init(geom, shape) orb = batchmode_geompy.orb @@ -72,7 +72,7 @@ batchmode_smesh.SetShape(idbox, idmesh); print "-------------------------- create Hypothesis ----------------------" print "-------------------------- LocalLength" -hyp1 = smesh.CreateHypothesis("LocalLength", batchmode_geompy.myStudyId ) +hyp1 = smesh.CreateHypothesis("LocalLength") hypLen1 = hyp1._narrow(SMESH.SMESH_LocalLength) hypLen1.SetLength(100) print hypLen1.GetName() @@ -83,7 +83,7 @@ idlength = batchmode_smesh.AddNewHypothesis( orb.object_to_string(hypLen1) ); batchmode_smesh.SetName(idlength, "Local_Length_100"); print "-------------------------- NumberOfSegments" -hyp2 = smesh.CreateHypothesis("NumberOfSegments", batchmode_geompy.myStudyId ) +hyp2 = smesh.CreateHypothesis("NumberOfSegments") hypNbSeg1=hyp2._narrow(SMESH.SMESH_NumberOfSegments) hypNbSeg1.SetNumberOfSegments(7) print hypNbSeg1.GetName() @@ -94,7 +94,7 @@ idseg = batchmode_smesh.AddNewHypothesis( orb.object_to_string(hypNbSeg1) ); batchmode_smesh.SetName(idseg, "NumberOfSegments_7"); print "-------------------------- MaxElementArea" -hyp3 = smesh.CreateHypothesis("MaxElementArea", batchmode_geompy.myStudyId) +hyp3 = smesh.CreateHypothesis("MaxElementArea") hypArea1=hyp3._narrow(SMESH.SMESH_MaxElementArea) hypArea1.SetMaxElementArea(2500) print hypArea1.GetName() @@ -105,7 +105,7 @@ idarea1 = batchmode_smesh.AddNewHypothesis( orb.object_to_string(hypArea1) ); batchmode_smesh.SetName(idarea1, "MaxElementArea_2500"); print "-------------------------- MaxElementArea" -hyp3 = smesh.CreateHypothesis("MaxElementArea", batchmode_geompy.myStudyId) +hyp3 = smesh.CreateHypothesis("MaxElementArea") hypArea2 = hyp3._narrow(SMESH.SMESH_MaxElementArea) hypArea2.SetMaxElementArea(500) print hypArea2.GetName() @@ -116,7 +116,7 @@ idarea2 = batchmode_smesh.AddNewHypothesis( orb.object_to_string(hypArea2) ); batchmode_smesh.SetName(idarea2, "MaxElementArea_500"); print "-------------------------- Regular_1D" -alg1 = smesh.CreateHypothesis("Regular_1D", batchmode_geompy.myStudyId) +alg1 = smesh.CreateHypothesis("Regular_1D") algo1 = alg1._narrow(SMESH.SMESH_Algo) listHyp = algo1.GetCompatibleHypothesis() for hyp in listHyp: @@ -129,7 +129,7 @@ idreg = batchmode_smesh.AddNewAlgorithms( orb.object_to_string(algoReg) ); batchmode_smesh.SetName(idreg, "Regular_1D"); print "-------------------------- MEFISTO_2D" -alg2 = smesh.CreateHypothesis("MEFISTO_2D", batchmode_geompy.myStudyId) +alg2 = smesh.CreateHypothesis("MEFISTO_2D") algo2 = alg2._narrow(SMESH.SMESH_Algo) listHyp=algo2.GetCompatibleHypothesis() for hyp in listHyp: @@ -328,8 +328,8 @@ file = str+"/test.hdf" #================================================== print " ------- We will save to", file, "-----------" -batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) -batchmode_geompy.myStudyManager.Close(batchmode_geompy.myStudy) +batchmode_geompy.myStudy.SaveAs(file) +batchmode_geompy.myStudy.Clear() #rename the file and try to reread it again @@ -345,7 +345,7 @@ os.rename(file, str+"/test_dir/test_new.hdf") print " ------- We try to open " + str + "/test_dir/test_new.hdf" try: - openedStudy=batchmode_geompy.myStudyManager.Open(str+"/test_dir/test_new.hdf") + openedStudy=batchmode_geompy.myStudy.Open(str+"/test_dir/test_new.hdf") except Exception: raise RuntimeError, "Can't open saved study!" @@ -441,13 +441,13 @@ if names != Names : #================================================== #4. Save #================================================== -batchmode_geompy.myStudyManager.Save(openedStudy) -batchmode_geompy.myStudyManager.Close(openedStudy) +batchmode_geompy.myStudy.Save() +batchmode_geompy.myStudy.Clear() #================================================== #5. Open #================================================== try: - openedStudy = batchmode_geompy.myStudyManager.Open(str+"/test_dir/test_new.hdf") + openedStudy = batchmode_geompy.myStudy.Open(str+"/test_dir/test_new.hdf") except Exception: raise RuntimeError, "Can't open saved study!" diff --git a/doc/salome/examples/example20 b/doc/salome/examples/example20 index 9326da115..20affe6dc 100644 --- a/doc/salome/examples/example20 +++ b/doc/salome/examples/example20 @@ -65,7 +65,7 @@ file = str+"/test.hdf" print " ------- We will save to", file, "-----------" -batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) +batchmode_geompy.myStudy.SaveAs(file) #--------------------------------------------------------------------------# @@ -74,7 +74,7 @@ batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) print" -------------- Open " + file + "-------------- " -openedStudy = batchmode_geompy.myStudyManager.Open(file) +openedStudy = batchmode_geompy.myStudy.Open(file) if openedStudy == None: raise RuntimeError, "Can't open saved study!" diff --git a/doc/salome/examples/example21 b/doc/salome/examples/example21 index 33526d956..9d456d04b 100644 --- a/doc/salome/examples/example21 +++ b/doc/salome/examples/example21 @@ -79,7 +79,7 @@ file = str+"/test.hdf" print " ------- We will save to", file, "-----------" -batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) +batchmode_geompy.myStudy.SaveAs(file) #--------------------------------------------------------------------------# #---------------------------- Open file -----------------------------------# @@ -87,7 +87,7 @@ batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) print" -------------- Open " + file + "-------------- " -openedStudy=batchmode_geompy.myStudyManager.Open(file) +openedStudy=batchmode_geompy.myStudy.Open(file) if openedStudy == None: raise RuntimeError, "Can't open saved study!" diff --git a/doc/salome/examples/example22 b/doc/salome/examples/example22 index bba273be6..6f9eee0a9 100644 --- a/doc/salome/examples/example22 +++ b/doc/salome/examples/example22 @@ -80,7 +80,7 @@ file = str+"/test.hdf" print " ------- We will save to", file, "-----------" -batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) +batchmode_geompy.myStudy.SaveAs(file) #--------------------------------------------------------------------------# #---------------------------- Open file -----------------------------------# @@ -88,7 +88,7 @@ batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) print" -------------- Open " + file + "-------------- " -openedStudy = batchmode_geompy.myStudyManager.Open(file) +openedStudy = batchmode_geompy.myStudy.Open(file) if openedStudy == None: raise RuntimeError, "Can't open saved study!" diff --git a/doc/salome/examples/example3 b/doc/salome/examples/example3 index 95e18e8e7..2aff52ed1 100644 --- a/doc/salome/examples/example3 +++ b/doc/salome/examples/example3 @@ -31,8 +31,8 @@ if str == None: str = "/tmp" file = str+"/test.hdf" -batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) -openedStudy=batchmode_geompy.myStudyManager.Open(file); +batchmode_geompy.myStudy.SaveAs(file) +openedStudy=batchmode_geompy.myStudy.Open(file); if openedStudy == None: raise RuntimeError, "Can't open saved study!" diff --git a/doc/salome/examples/example4 b/doc/salome/examples/example4 index 2dd1966db..a9669304e 100644 --- a/doc/salome/examples/example4 +++ b/doc/salome/examples/example4 @@ -30,8 +30,8 @@ str= os.getenv("TmpDir") if str == None: str = "/tmp" file = str+"/test.hdf" -batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) -openedStudy=batchmode_geompy.myStudyManager.Open(file); +batchmode_geompy.myStudy.SaveAs(file) +openedStudy=batchmode_geompy.myStudy.Open(file); if openedStudy == None: raise RuntimeError, "Can't open saved study!" diff --git a/doc/salome/examples/example5 b/doc/salome/examples/example5 index 59e3bc6a0..47263aa2f 100644 --- a/doc/salome/examples/example5 +++ b/doc/salome/examples/example5 @@ -21,8 +21,8 @@ if str == None: str = "/tmp" file = str+"/test.hdf" -batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) -openedStudy = batchmode_geompy.myStudyManager.Open(file); +batchmode_geompy.myStudy.SaveAs(file) +openedStudy = batchmode_geompy.myStudy.Open(file); if openedStudy == None: raise RuntimeError, "Can't open saved study!" diff --git a/doc/salome/examples/example6 b/doc/salome/examples/example6 index 71a5859e7..4685f2b7a 100644 --- a/doc/salome/examples/example6 +++ b/doc/salome/examples/example6 @@ -19,8 +19,8 @@ if str == None: str = "/tmp" file = str+"/test.hdf" -batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) -openedStudy = batchmode_geompy.myStudyManager.Open(file); +batchmode_geompy.myStudy.SaveAs(file) +openedStudy = batchmode_geompy.myStudy.Open(file); if openedStudy == None: raise RuntimeError, "Can't open saved study!" diff --git a/doc/salome/examples/example7 b/doc/salome/examples/example7 index 8ddf8bb2b..2477a3e07 100644 --- a/doc/salome/examples/example7 +++ b/doc/salome/examples/example7 @@ -18,8 +18,8 @@ if str == None: str = "/tmp" file = str+"/test.hdf" -batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) -openedStudy = batchmode_geompy.myStudyManager.Open(file); +batchmode_geompy.myStudy.SaveAs(file) +openedStudy = batchmode_geompy.myStudy.Open(file); if openedStudy == None: raise RuntimeError, "Can't open saved study!" diff --git a/doc/salome/examples/example8 b/doc/salome/examples/example8 index eadb13feb..3d79cab44 100644 --- a/doc/salome/examples/example8 +++ b/doc/salome/examples/example8 @@ -26,8 +26,8 @@ if str == None: str = "/tmp" file = str+"/test.hdf" -batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) -openedStudy=batchmode_geompy.myStudyManager.Open(file); +batchmode_geompy.myStudy.SaveAs(file) +openedStudy=batchmode_geompy.myStudy.Open(file); if openedStudy == None: raise RuntimeError, "Can't open saved study!" diff --git a/doc/salome/examples/example9 b/doc/salome/examples/example9 index d29c9bab7..68d9394d3 100644 --- a/doc/salome/examples/example9 +++ b/doc/salome/examples/example9 @@ -22,8 +22,8 @@ if str == None: str = "/tmp" file = str+"/test.hdf" -batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy) -openedStudy = batchmode_geompy.myStudyManager.Open(file); +batchmode_geompy.myStudy.SaveAs(file) +openedStudy = batchmode_geompy.myStudy.Open(file); if openedStudy == None: raise RuntimeError, "Can't open saved study!" diff --git a/doc/salome/kernel_salome.dox b/doc/salome/kernel_salome.dox index 75deb2960..1ca301802 100644 --- a/doc/salome/kernel_salome.dox +++ b/doc/salome/kernel_salome.dox @@ -72,46 +72,6 @@ geom = salome.lcc.FindOrLoadComponent('FactoryServer', 'GEOM') \b Note, that in the above example, \e "FactoryServer" is a name of the SALOME container, where Geometry module engine should be loaded. -\li \b myStudyManager Reference to the study manager - -SALOMEDS Study manager is used to manipulate with the studies: create, -open, save, close. It also can be used to find the study by its -numerical ID or name. The code below demonstrates main -functionalities of a study manager: -\code -# create new study with the name "MyStudy" -new_study = salome.myStudyManager.NewStudy("MyStudy") - -# open study from file /home/user/MyStudy.hdf -study = salome.myStudyManager.OpenStudy("/home/user/MyStudy.hdf") - -# save study -salome.myStudyManager.Save(study, False) # not using multifile save mode - -# save study in ASCII format -salome.myStudyManager.SaveASCII(study, True) # using multifile save mode - -# save study with the new file path -salome.myStudyManager.SaveAs("/home/user/MyStudy.hdf", study, False) - -# save study with the new file path in ASCII format -salome.myStudyManager.SaveAsASCII("/home/user/MyStudy.hdf", study, False) - -# close study -salome.myStudyManager.Close(study) - -# get list of all opened studies -studies = salome.myStudyManager.GetOpenStudies() - -# find study by its numerical ID (integer value starting from 1) -study = salome.myStudyManager.GetStudyByID(studyID) - -# find study by its name -study = salome.myStudyManager.GetStudyByName("/home/user/MyStudy.hdf") - -# ... -\endcode - \anchor salome_myStudy \li \b myStudy Reference to the current (active) study @@ -136,8 +96,23 @@ documentation. # get study name studyName = salome.myStudy._get_Name() -# get study numerical ID -studyID = salome.myStudy._get_StudyId() +# open study from file /home/user/MyStudy.hdf +study = salome.myStudy.OpenStudy("/home/user/MyStudy.hdf") + +# save study +salome.myStudy.Save(study, False) # not using multifile save mode + +# save study in ASCII format +salome.myStudy.SaveASCII(study, True) # using multifile save mode + +# save study with the new file path +salome.myStudy.SaveAs("/home/user/MyStudy.hdf", study, False) + +# save study with the new file path in ASCII format +salome.myStudy.SaveAsASCII("/home/user/MyStudy.hdf", study, False) + +# clear study +salome.myStudy.Clear() # find SALOMEDS component by its type scomponent = FindComponent("MyComponent") @@ -192,12 +167,6 @@ while iter.More(): # ... \endcode -\li \b myStudyId Identifier of the current (active) study - -This variable contains the numerical identifier of the current -(active) study. It is an equivalent of \c -salome.myStudy._get_StudyId() code. - \li \b myStudyName Name of the current (active) study This variable contains the name of the current (active) study. It is @@ -279,15 +248,6 @@ else: entry = "" \endcode -\li \b createNewStudy() Create new study - -This function can be used to create new SALOME study. Returns an ID of -the created study. -\code -studyId = salome.createNewStudy() -study = salome.myStudyManager.GetStudyByID(s) -\endcode - \li \b generateName() Generate unique name This function adds random numerical suffix to the passed string diff --git a/doc/salome/kernel_services.dox b/doc/salome/kernel_services.dox index d68ced648..211b4dd2e 100644 --- a/doc/salome/kernel_services.dox +++ b/doc/salome/kernel_services.dox @@ -135,7 +135,6 @@ Study.dir extStudy_1.object extStudy_2.object extStudy_3.object -myStudyManager.object SalomeAppEngine.object \endcode diff --git a/doc/salome/salome_application.dox b/doc/salome/salome_application.dox index bd79433d9..e1661dee4 100644 --- a/doc/salome/salome_application.dox +++ b/doc/salome/salome_application.dox @@ -289,8 +289,7 @@ python \endcode Import salome module. salome_init() without arguments creates a new study -in the running session (note: salome_init(n) attachs to a running session whose -studyId is n): +in the running session: \code import salome diff --git a/idl/SALOME_Component.idl b/idl/SALOME_Component.idl index 012cfc644..c18277c90 100644 --- a/idl/SALOME_Component.idl +++ b/idl/SALOME_Component.idl @@ -101,8 +101,6 @@ module Engines Warning: no internal registration is done, so it is up to the caller to manage the various instanciation. \param serviceName Name of the service - - >0 otherwise (== study id) \param reason in case of error (return void string) a string explaining the error \return the IOR of the loaded service. */ diff --git a/src/Container/SALOME_ComponentPy.py b/src/Container/SALOME_ComponentPy.py index 5386477ce..89d1ab0aa 100755 --- a/src/Container/SALOME_ComponentPy.py +++ b/src/Container/SALOME_ComponentPy.py @@ -59,7 +59,6 @@ class SALOME_ComponentPy_i (Engines__POA.EngineComponent): _orb = None _poa = None _fieldsDict = [] - _studyId = -1 #------------------------------------------------------------------------- @@ -301,17 +300,12 @@ class SALOME_ComponentPy_i (Engines__POA.EngineComponent): #------------------------------------------------------------------------- - def getStudyId(self): - return self._studyId - - #------------------------------------------------------------------------- - def hasObjectInfo(self): return 0 #------------------------------------------------------------------------- - def getObjectInfo(self, studyId, entry): + def getObjectInfo(self, entry): return "" #------------------------------------------------------------------------- diff --git a/src/Container/SALOME_ContainerPy.py b/src/Container/SALOME_ContainerPy.py index 4da4bacad..3a8b2bf40 100755 --- a/src/Container/SALOME_ContainerPy.py +++ b/src/Container/SALOME_ContainerPy.py @@ -199,40 +199,36 @@ class SALOME_ContainerPy_i (Engines__POA.Container): #------------------------------------------------------------------------- - def create_component_instance_env(self, componentName, studyId, env): - return self.create_component_instance(componentName, studyId), "" - - def create_component_instance(self, componentName, studyId): - MESSAGE( "SALOME_ContainerPy_i::create_component_instance ==> " + str(componentName) + ' ' + str(studyId) ) - if studyId < 0: - MESSAGE( "Study ID is lower than 0!" ) - return None - else: - self._numInstance = self._numInstance +1 - instanceName = componentName + "_inst_" + `self._numInstance` - comp_iors="" - try: - component=__import__(componentName) - factory=getattr(component,componentName) - comp_i=factory(self._orb, - self._poa, - self._this(), - self._containerName, - instanceName, - componentName) - - MESSAGE( "SALOME_Container_i::create_component_instance : OK") - comp_o = comp_i._this() - self._listInstances_map[instanceName] = comp_i - except: - import traceback - traceback.print_exc() - MESSAGE( "SALOME_Container_i::create_component_instance : NOT OK") - return comp_o + def create_component_instance_env(self, componentName, env): + return self.create_component_instance(componentName), "" + + def create_component_instance(self, componentName): + MESSAGE( "SALOME_ContainerPy_i::create_component_instance ==> " + str(componentName) ) + self._numInstance = self._numInstance +1 + instanceName = componentName + "_inst_" + `self._numInstance` + comp_iors="" + try: + component=__import__(componentName) + factory=getattr(component,componentName) + comp_i=factory(self._orb, + self._poa, + self._this(), + self._containerName, + instanceName, + componentName) + + MESSAGE( "SALOME_Container_i::create_component_instance : OK") + comp_o = comp_i._this() + self._listInstances_map[instanceName] = comp_i + except: + import traceback + traceback.print_exc() + MESSAGE( "SALOME_Container_i::create_component_instance : NOT OK") + return comp_o #------------------------------------------------------------------------- - def find_component_instance(self, registeredName, studyId): + def find_component_instance(self, registeredName): anEngine = None keysList = self._listInstances_map.keys() i = 0 @@ -240,8 +236,7 @@ class SALOME_ContainerPy_i (Engines__POA.Container): instance = keysList[i] if find(instance,registeredName) == 0: anEngine = self._listInstances_map[instance] - if studyId == anEngine.getStudyId(): - return anEngine._this() + return anEngine._this() i = i + 1 return anEngine._this() diff --git a/src/KERNEL_PY/Help.py b/src/KERNEL_PY/Help.py index 7948abe7f..d349d3f2f 100755 --- a/src/KERNEL_PY/Help.py +++ b/src/KERNEL_PY/Help.py @@ -53,8 +53,7 @@ variables: salome.sg methods: updateObjBrowser(bool): - getActiveStudyId(): - getActiveStudyName(): + getStudyName(): SelectedCount(): returns number of selected objects getSelected(i): returns entry of selected object number i @@ -71,8 +70,7 @@ variables: IDToObject(Entry): returns CORBA reference from entry - salome.myStudyName : active Study Name - salome.myStudyId : active Study Id + salome.myStudyName : the Study Name salome.myStudy : the active Study itself (CORBA ior) methods : defined in SALOMEDS.idl diff --git a/src/KERNEL_PY/PyInterp.py b/src/KERNEL_PY/PyInterp.py index f10973927..8e4595e65 100755 --- a/src/KERNEL_PY/PyInterp.py +++ b/src/KERNEL_PY/PyInterp.py @@ -88,16 +88,10 @@ sg = SALOMEGUI_Swig() #create an naming service instance naming_service = SALOME_NamingServicePy_i(orb) -# get active study name and id -myStudyName = sg.getActiveStudyName() +# get active study name +myStudyName = sg.getStudyName() print myStudyName -myStudyId = sg.getActiveStudyId() -print myStudyId - -# get Study Manager reference -obj = naming_service.Resolve('myStudyManager') -myStudyManager = obj._narrow(SALOMEDS.StudyManager) - -# get active study -myStudy = myStudyManager.GetStudyByName(myStudyName) +# get Study reference +obj = naming_service.Resolve('Study') +myStudy = obj._narrow(SALOMEDS.Study) diff --git a/src/KERNEL_PY/__init__.py b/src/KERNEL_PY/__init__.py index 84f40c655..5d0cb75e7 100755 --- a/src/KERNEL_PY/__init__.py +++ b/src/KERNEL_PY/__init__.py @@ -46,8 +46,6 @@ variables: - salome.sg : salome object to communicate with the graphical user interface (if any) - methods: - updateObjBrowser(bool): - - getActiveStudyId(): - - getActiveStudyName(): - SelectedCount(): returns number of selected objects - getSelected(i): returns entry of selected object number i @@ -65,7 +63,6 @@ variables: - IDToObject(Entry): returns CORBA reference from entry - salome.myStudyName : active Study Name - - salome.myStudyId : active Study Id - salome.myStudy : the active Study itself (CORBA ior) - methods : defined in SALOMEDS.idl @@ -78,7 +75,6 @@ variables: # \param salome.lcc : instance of lifeCycleCORBA class (SALOME_LifeCycleCORBA) # \param salome.sg : Salome object to communicate with the graphical user interface, if running (see interface in salome_iapp::SalomeOutsideGUI) # \param salome.myStudyName : active Study Name -# \param salome.myStudyId : active Study Id # \param salome.myStudy : the active Study (interface SALOMEDS::Study) # @@ -166,62 +162,32 @@ if not flags: # pass orb, lcc, naming_service, cm,sg=None,None,None,None,None -myStudyManager, myStudyId, myStudy, myStudyName=None,None,None,None - -def setCurrentStudy(theStudy): - """ - Change current study : an existing one given by a study object. - - :param theStudy: the study CORBA object to set as current study - """ - global myStudyId, myStudy, myStudyName - myStudyId, myStudy, myStudyName =salome_study.setCurrentStudy(theStudy) - -def setCurrentStudyId(theStudyId=0): - """ - Change current study : an existing or new one given by Id. - - :param theStudyId: the study Id (optional argument) - 0 : create a new study (default). - n (>0) : try connection to study with Id = n, or create a new one - if study not found. - """ - global myStudyId, myStudy, myStudyName - myStudyId, myStudy, myStudyName =salome_study.setCurrentStudyId(theStudyId) +myStudy, myStudyName=None,None salome_initial=1 -def salome_init(theStudyId=0,embedded=0): +def salome_init(embedded=0): """ Performs only once SALOME general purpose intialisation for scripts. - optional argument : theStudyId - When in embedded interpreter inside IAPP, theStudyId is not used - When used without GUI (external interpreter) - 0 : create a new study (default). - n (>0) : try connection to study with Id = n, or create a new one - if study not found. - If study creation, its Id may be different from theStudyId ! Provides: orb reference to CORBA lcc a LifeCycleCorba instance naming_service a naming service instance cm reference to the container manager sg access to SALOME GUI (when linked with IAPP GUI) - myStudyManager the study manager - myStudyId active study identifier myStudy active study itself (CORBA reference) myStudyName active study name """ global salome_initial global orb, lcc, naming_service, cm global sg - global myStudyManager, myStudyId, myStudy, myStudyName + global myStudy, myStudyName try: if salome_initial: salome_initial=0 sg = salome_iapp_init(embedded) orb, lcc, naming_service, cm = salome_kernel_init() - myStudyManager, myStudyId, myStudy, myStudyName = salome_study_init(theStudyId) + myStudy, myStudyName = salome_study_init() pass pass except RuntimeError, inst: @@ -240,16 +206,16 @@ def salome_init(theStudyId=0,embedded=0): raise def salome_close(): - global salome_initial, myStudy, myStudyId, myStudyName + global salome_initial, myStudy, myStudyName try: - # study can be closed either from GUI or directly with salome.myStudy.Close() - myStudy.Close() + # study can be clear either from GUI or directly with salome.myStudy.Clear() + myStudy.Clear() except: pass salome_initial=1 salome_iapp_close() salome_study_close() - myStudyId, myStudy, myStudyName=None,None,None + myStudy, myStudyName=None,None pass diff --git a/src/KERNEL_PY/batchmode_salome.py b/src/KERNEL_PY/batchmode_salome.py index 7a7ae9e81..9e036ec88 100755 --- a/src/KERNEL_PY/batchmode_salome.py +++ b/src/KERNEL_PY/batchmode_salome.py @@ -180,14 +180,14 @@ def CheckCopyPaste(theSO, theInfo ,theComponentPaste): aTree = GetTree(aRoot) aStudyPersist = PersistentPresentation(myStudy, aRoot, 1) - if not myStudyManager.CanCopy(theSO): + if not myStudy.CanCopy(theSO): raise RuntimeError, " for "+theInfo+" returns false" - if not myStudyManager.Copy(theSO): + if not myStudy.Copy(theSO): raise RuntimeError, " for "+theInfo+" returns false" - if not myStudyManager.CanPaste(theSO): + if not myStudy.CanPaste(theSO): raise RuntimeError, " for "+theInfo+" returns false" # check: before paste study is not changed check @@ -198,7 +198,7 @@ def CheckCopyPaste(theSO, theInfo ,theComponentPaste): if theComponentPaste: aSObj = theSO.GetFatherComponent() theInfo = theInfo + "(paste for component)" - if myStudyManager.Paste(aSObj) == None: + if myStudy.Paste(aSObj) == None: raise RuntimeError, " for "+theInfo+" returns None object" aNewTree = GetTree(aRoot) aLen = len(aTree) @@ -269,14 +269,14 @@ if lcc is None: #create a naming service instance naming_service = SALOME_NamingServicePy_i(orb) -# get Study Manager reference +# get Study reference obj = None step = 0 sleeping_time = 0.01 sleeping_time_max = 1.0 while 1: - obj = naming_service.Resolve('myStudyManager') + obj = naming_service.Resolve('Study') if obj is not None:break step = step + 1 if step > 100: break @@ -284,22 +284,9 @@ while 1: sleeping_time = max(sleeping_time_max, 2*sleeping_time) pass -myStudyManager = obj._narrow(SALOMEDS.StudyManager) +myStudy = obj._narrow(SALOMEDS.Study) -if myStudyManager is None: - print "Warning: SALOMEDS.StudyManager has not been created !!!" - -# create new study -aListOfOpenStudies = myStudyManager.GetOpenStudies(); -myStudy = None; -if len(aListOfOpenStudies) == 0 : - myStudy = myStudyManager.NewStudy("Study1") -else: - myStudyName = aListOfOpenStudies[0] - myStudy = myStudyManager.GetStudyByName(myStudyName) +if myStudy is None: + print "Warning: SALOMEDS.Study has not been created !!!" myStudyName = myStudy._get_Name() - -myStudyId = myStudy._get_StudyId() -#print myStudyId - diff --git a/src/KERNEL_PY/kernel/parametric/study_exchange_vars.py b/src/KERNEL_PY/kernel/parametric/study_exchange_vars.py index 0ac0490fc..7b7fdf887 100644 --- a/src/KERNEL_PY/kernel/parametric/study_exchange_vars.py +++ b/src/KERNEL_PY/kernel/parametric/study_exchange_vars.py @@ -182,8 +182,7 @@ def createSObjectForExchangeVariables(fatherSobj, exchangeVariables, :return: the newly created SObject. """ - studyId = fatherSobj.GetStudy()._get_StudyId() - editor = getStudyEditor(studyId) + editor = getStudyEditor() sobj = editor.createItem(fatherSobj, name = name, icon = icon, @@ -210,8 +209,7 @@ def updateSObjectForExchangeVariables(sobj, exchangeVariables, other parameters. """ - studyId = sobj.GetStudy()._get_StudyId() - editor = getStudyEditor(studyId) + editor = getStudyEditor() editor.setItem(sobj, name = name, icon = icon, typeId = typeId) editor.builder.RemoveAttribute(sobj, "AttributeParameter") _setSObjectForExchangeVariables(editor, sobj, exchangeVariables) diff --git a/src/KERNEL_PY/kernel/services.py b/src/KERNEL_PY/kernel/services.py index a2d4feaa6..b1b3db9c1 100644 --- a/src/KERNEL_PY/kernel/services.py +++ b/src/KERNEL_PY/kernel/services.py @@ -47,8 +47,8 @@ if not is_called_by_sphinx() and salome.lcc is None: # Note that the salome module provides you with standard SALOME # objects: CORBA broker (orb): salome.orb lyfe cycle (lcc) : -# salome.lcc naming service : salome.naming_service study manager : -# salome.myStudyManager The default study : salome.myStudy +# salome.lcc naming service : salome.naming_service +# The default study : salome.myStudy # # Alternatively, you may obtain these objects directly with the # following instructions: @@ -123,27 +123,21 @@ def getComponentList(): raise RuntimeError, "Can't accesss module catalog" return catalog.GetComponentList() -## Get a study manager to create and manage %SALOME studies -# \ingroup service -def getStudyManager(): - """Get a study manager to create and manage SALOME studies""" - return salome.myStudyManager - import SALOMEDS -## Get a study manager to create and manage SALOME studies. -# \warning you should use instead the variable salome.myStudyManager. +## Get a study to create SALOME study. +# \warning you should use instead the variable salome.myStudy. # This function is given for illustration of usage of the naming service # \ingroup service -def __getStudyManager_demo(): +def __getStudy_demo(): """ - Get a study manager to create and manage SALOME studies. WARN: you - should use instead the variable salome.myStudyManager. This + Get a study to create SALOME study. WARN: you + should use instead the variable salome.myStudy. This function is given for illustration of usage of the naming service """ naming_service = SALOME_NamingServicePy_i( orb ) - obj = naming_service.Resolve( '/myStudyManager' ) - studyManager = obj._narrow( SALOMEDS.StudyManager) - return studyManager + obj = naming_service.Resolve( '/Study' ) + study = obj._narrow( SALOMEDS.Study) + return study # diff --git a/src/KERNEL_PY/kernel/studyedit.py b/src/KERNEL_PY/kernel/studyedit.py index 463b70fb8..499a18392 100644 --- a/src/KERNEL_PY/kernel/studyedit.py +++ b/src/KERNEL_PY/kernel/studyedit.py @@ -36,68 +36,31 @@ from salome.kernel.logger import Logger from salome.kernel import termcolor logger = Logger("salome.kernel.studyedit", color = termcolor.PURPLE) -_editors = {} +_editor = None _DEFAULT_CONTAINER = "FactoryServer" # The codec to use for strings that are displayed in Salome study tree is Latin-1 ENCODING_FOR_SALOME_STUDY = "iso-8859-1" -## Return the ID of the active study. In GUI mode, this function is equivalent -# to salome.sg.getActiveStudyId(). Outside GUI, it returns salome.myStudyId -# variable. -# \ingroup studyedit -def getActiveStudyId(): - """ - Return the ID of the active study. In GUI mode, this function is equivalent - to ``salome.sg.getActiveStudyId()``. Outside GUI, it returns - ``salome.myStudyId`` variable. - """ - salome.salome_init() - # Warning: we don't use salome.getActiveStudy() here because it doesn't - # work properly when called from Salome modules (multi-study interpreter - # issue) - if salome.hasDesktop(): - return salome.sg.getActiveStudyId() - else: - return salome.myStudyId - -def getActiveStudy(): - return getStudyFromStudyId(getActiveStudyId()) - -def getStudyFromStudyId(studyId): - salome.salome_init() - study = salome.myStudyManager.GetStudyByID(studyId) - return study - -def getStudyIdFromStudy(study): - studyId = study._get_StudyId() - return studyId - -## Return a \b StudyEditor instance to edit the study with ID studyId. -# If \b studyId is \b None, return an editor for the current study. +def getStudy(): + return salome.myStudy + +## Return a \b StudyEditor instance to edit the study. # \ingroup studyedit -def getStudyEditor(studyId = None): +def getStudyEditor(): """ - Return a :class:`StudyEditor` instance to edit the study with ID - `studyId`. If `studyId` is :const:`None`, return an editor for the current - study. + Return a :class:`StudyEditor` instance to edit the study. """ - if studyId is None: - studyId = getActiveStudyId() - if not _editors.has_key(studyId): - _editors[studyId] = StudyEditor(studyId) - return _editors[studyId] + if _editor is None: + _editor = StudyEditor() + return _editor ## This class provides utility methods to complement \b Study and # \b StudyBuilder classes. Those methods may be moved in those classes -# in the future. The parameter \b studyId defines the ID of the study to -# edit. If it is \em None, the edited study will be the current study. +# in the future. # The preferred way to get a StudyEditor object is through the method # \b getStudyEditor which allows to reuse existing instances. # -# \param studyId This instance attribute contains the ID of the edited study. -# This attribute should not be modified. -# # \param study This instance attribute contains the underlying \b Study object. # It can be used to access the study but the attribute itself should not # be modified. @@ -110,16 +73,10 @@ class StudyEditor: """ This class provides utility methods to complement :class:`Study` and :class:`StudyBuilder` classes. Those methods may be moved in those classes - in the future. The parameter `studyId` defines the ID of the study to - edit. If it is :const:`None`, the edited study will be the current study. + in the future. The preferred way to get a StudyEditor object is through the method :meth:`getStudyEditor` which allows to reuse existing instances. - .. attribute:: studyId - - This instance attribute contains the ID of the edited study. This - attribute should not be modified. - .. attribute:: study This instance attribute contains the underlying :class:`Study` object. @@ -133,15 +90,12 @@ class StudyEditor: should not be modified. """ - def __init__(self, studyId = None): + def __init__(self): salome.salome_init() - if studyId is None: - studyId = getActiveStudyId() - self.studyId = studyId - self.study = salome.myStudyManager.GetStudyByID(studyId) + self.study = salome.myStudy if self.study is None: raise Exception("Can't create StudyEditor object: " - "Study %d doesn't exist" % studyId) + "Study doesn't exist") self.builder = self.study.NewBuilder() ## Find a component corresponding to the Salome module \b moduleName in diff --git a/src/KERNEL_PY/salome_iapp.py b/src/KERNEL_PY/salome_iapp.py index 283c5685c..ac3c674ef 100755 --- a/src/KERNEL_PY/salome_iapp.py +++ b/src/KERNEL_PY/salome_iapp.py @@ -71,7 +71,7 @@ class SalomeOutsideGUI(object): Provides a replacement for class SalomeGUI outside GUI process. Do almost nothing """ - global myStudyId, myStudyName + global myStudyName def hasDesktop(self): """Indicate if GUI is running""" @@ -82,14 +82,9 @@ class SalomeOutsideGUI(object): print "SalomeOutsideGUI: no objectBrowser update outside GUI" pass - def getActiveStudyId(self): - """Get the active study id""" - print "SalomeOutsideGUI.getActiveStudyId: avoid use outside GUI" - return myStudyId - - def getActiveStudyName(self): - """Get the active study name""" - print "SalomeOutsideGUI.getActiveStudyName: avoid use outside GUI" + def getStudyName(self): + """Get the study name""" + print "SalomeOutsideGUI.getStudyName: avoid use outside GUI" return myStudyName def SelectedCount(self): diff --git a/src/KERNEL_PY/salome_study.py b/src/KERNEL_PY/salome_study.py index c08437325..7269f8b1c 100755 --- a/src/KERNEL_PY/salome_study.py +++ b/src/KERNEL_PY/salome_study.py @@ -31,8 +31,6 @@ import SALOMEDS import salome_iapp from launchConfigureParser import verbose -myStudyManager = None -myStudyId = None myStudy = None myStudyName = None @@ -71,17 +69,6 @@ def DumpStudy(Study): DumpComponent(Study, SC,Builder, 1) itcomp.Next() -def DumpStudies(): - """ - Dump all studies in a StudyManager - """ - global myStudyManager - for name in myStudyManager.GetOpenStudies(): - s = myStudyManager.GetStudyByName(name) - print "study:",name, s._get_StudyId() - DumpStudy(s) - - #-------------------------------------------------------------------------- def IDToObject(id): @@ -197,7 +184,7 @@ def GetTree(theSO): #-------------------------------------------------------------------------- def CheckCopyPaste(theSO, theInfo ,theComponentPaste): - global myStudyManager, myStudy + global myStudy aRoot = theSO while aRoot.GetID() != "0:": @@ -205,14 +192,14 @@ def CheckCopyPaste(theSO, theInfo ,theComponentPaste): aTree = GetTree(aRoot) aStudyPersist = PersistentPresentation(myStudy, aRoot, 1) - if not myStudyManager.CanCopy(theSO): + if not myStudy.CanCopy(theSO): raise RuntimeError, " for "+theInfo+" returns false" - if not myStudyManager.Copy(theSO): + if not myStudy.Copy(theSO): raise RuntimeError, " for "+theInfo+" returns false" - if not myStudyManager.CanPaste(theSO): + if not myStudy.CanPaste(theSO): raise RuntimeError, " for "+theInfo+" returns false" # check: before paste study is not changed check @@ -223,7 +210,7 @@ def CheckCopyPaste(theSO, theInfo ,theComponentPaste): if theComponentPaste: aSObj = theSO.GetFatherComponent() theInfo = theInfo + "(paste for component)" - if myStudyManager.Paste(aSObj) == None: + if myStudy.Paste(aSObj) == None: raise RuntimeError, " for "+theInfo+" returns None object" aNewTree = GetTree(aRoot) aLen = len(aTree) @@ -279,33 +266,6 @@ def FindFileInDataDir(filename): #-------------------------------------------------------------------------- -salome_study_ID = -1 - -# *args are used here to support backward compatibility -# previously it was possible to pass theStudyId parameter to this function -# which is no more supported. -def getActiveStudy(*args): - global myStudyManager - global salome_study_ID - - if not myStudyManager: - print "No active study" - return None - pass - - if verbose(): print "getActiveStudy" - if salome_study_ID == -1: - listOpenStudies = myStudyManager.GetOpenStudies() - if len(listOpenStudies) == 0: - return None - else: - s = myStudyManager.GetStudyByName(listOpenStudies[0]) - salome_study_ID = s._get_StudyId() - if verbose(): print"--- Study Id ", salome_study_ID - return salome_study_ID - - #-------------------------------------------------------------------------- - def setCurrentStudy(theStudy): """ Change current study : an existing one given by a study object. @@ -317,59 +277,28 @@ def setCurrentStudy(theStudy): corresponds to the currently opened study. Kept for backward compatibility only. """ - global myStudyId, myStudy, myStudyName - global salome_study_ID + global myStudy, myStudyName myStudy = theStudy - myStudyId = theStudy._get_StudyId() myStudyName = theStudy._get_Name() - return myStudyId, myStudy, myStudyName - - #-------------------------------------------------------------------------- - -# *args are used here to support backward compatibility -# previously it was possible to pass theStudyId parameter to this function -# which is no more supported. -def setCurrentStudyId(*args): - """ - Change current study : an existing or new one. - - This function connects to the single opened study if there is any; otherwise - new empty study is created. - - Obsolete: only one study can be opened at the moment. - Kept for backward compatibility only. - """ - global myStudyManager, myStudyId, myStudy, myStudyName - global salome_study_ID - salome_study_ID = -1 - myStudyId = getActiveStudy() - if not myStudyId: - myStudyId = createNewStudy() - if verbose(): print "myStudyId",myStudyId - myStudy = myStudyManager.GetStudyByID(myStudyId) - myStudyName = myStudy._get_Name() - return myStudyId, myStudy, myStudyName - - #-------------------------------------------------------------------------- - -def createNewStudy(): - global myStudyManager - print "createNewStudy" - aStudyName = "extStudy" - theStudy = myStudyManager.NewStudy(aStudyName) - theStudyId = theStudy._get_StudyId() - print aStudyName, theStudyId - return theStudyId + return myStudy, myStudyName #-------------------------------------------------------------------------- def openStudy(theStudyPath): - global myStudyManager + global myStudy print "openStudy" - theStudy = myStudyManager.Open(theStudyPath) - theStudyId = theStudy._get_StudyId() - print theStudyPath, theStudyId - return theStudyId + theStudy = myStudy.Open(theStudyPath) + theStudyName = theStudy._get_Name() + print theStudyPath, theStudyName + return theStudyName + + #-------------------------------------------------------------------------- +def clearStudy(): + global myStudy + print "clearStudy" + myStudy.Clear() + myStudy = None + pass #-------------------------------------------------------------------------- @@ -381,40 +310,26 @@ def salome_study_init(theStudyPath=None): create new empty study if there is active study (str) : open study with the given file name """ - global myStudyManager, myStudyId, myStudy, myStudyName + global myStudy, myStudyName global orb, lcc, naming_service, cm if verbose(): print "theStudyPath:", theStudyPath - if not myStudyManager: + if not myStudy: orb, lcc, naming_service, cm = salome_kernel.salome_kernel_init() - # get Study Manager reference - if verbose(): print "looking for studyManager ..." - obj = naming_service.Resolve('myStudyManager') - myStudyManager = obj._narrow(SALOMEDS.StudyManager) - if verbose(): print "studyManager found" + # get Study reference + if verbose(): print "looking for study..." + obj = naming_service.Resolve('Study') + myStudy = obj._narrow(SALOMEDS.Study) + if verbose(): print "Study found" pass - # get active study Id, ref and name - myStudy = None - myStudyId = getActiveStudy() - if myStudyId == None : - import types - if theStudyPath and type(theStudyPath) == types.StringType: - myStudyId = openStudy(theStudyPath) - else: - myStudyId = createNewStudy() - if verbose(): print "myStudyId", myStudyId - - if myStudy == None: - myStudy = myStudyManager.GetStudyByID(myStudyId) + # get study name myStudyName = myStudy._get_Name() - return myStudyManager, myStudyId, myStudy, myStudyName + return myStudy, myStudyName def salome_study_close(): - global salome_study_ID - global myStudyId, myStudy, myStudyName - salome_study_ID = -1 - myStudyId, myStudy, myStudyName = None, None, None + global myStudy, myStudyName + myStudy, myStudyName = None, None pass diff --git a/src/KERNEL_PY/salome_test.py b/src/KERNEL_PY/salome_test.py index c70a0f5b3..5628182c5 100755 --- a/src/KERNEL_PY/salome_test.py +++ b/src/KERNEL_PY/salome_test.py @@ -178,7 +178,7 @@ from salome.smesh import smeshBuilder smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") if salome.hasDesktop(): smeshgui = salome.ImportComponentGUI("SMESH") - smeshgui.Init(salome.myStudyId); + smeshgui.Init(); else: smesh = smeshBuilder.New(salome.myStudy) diff --git a/src/Launcher/Test/test_launcher.py b/src/Launcher/Test/test_launcher.py index 53fe67af5..61915baf1 100755 --- a/src/Launcher/Test/test_launcher.py +++ b/src/Launcher/Test/test_launcher.py @@ -262,7 +262,6 @@ f.close() # job script script_text = """ - @@ -367,7 +366,6 @@ f.close() # job script script_text = """ - -- 2.39.2