From 294f92ee45e9ae9e0ca46b7f364aebafdb8fd697 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Wed, 13 Jan 2021 16:45:47 +0100 Subject: [PATCH] TODO : Move myStudy from GEOM to KERNEL --- src/GEOM_SWIG/CMakeLists.txt | 2 +- src/GEOM_SWIG/GeomHelper.cxx | 10 ++++++++++ src/GEOM_SWIG/GeomHelper.h | 1 + src/GEOM_SWIG/GeomHelper.i | 10 ++++++++++ src/GEOM_SWIG/geomBuilder.py | 3 ++- 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/GEOM_SWIG/CMakeLists.txt b/src/GEOM_SWIG/CMakeLists.txt index d3c4aeb3c..e506f9020 100644 --- a/src/GEOM_SWIG/CMakeLists.txt +++ b/src/GEOM_SWIG/CMakeLists.txt @@ -141,7 +141,7 @@ IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") ELSE() SWIG_ADD_LIBRARY(GeomHelper LANGUAGE python SOURCES ${GeomHelper_SOURCES}) ENDIF() -SWIG_LINK_LIBRARIES(GeomHelper ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} GEOMEngine ) +SWIG_LINK_LIBRARIES(GeomHelper ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} GEOMEngine ${KERNEL_SalomeKernelHelpers} ${KERNEL_SalomeDS} ) install(TARGETS _GeomHelper DESTINATION ${SALOME_INSTALL_LIBS}) install(FILES ${GeomHelper_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) SALOME_INSTALL_SCRIPTS("${_swig_SCRIPTS}" ${SALOME_INSTALL_BINS} EXTRA_DPYS "${SWIG_MODULE_GeomHelper_REAL_NAME}") diff --git a/src/GEOM_SWIG/GeomHelper.cxx b/src/GEOM_SWIG/GeomHelper.cxx index f68bb062f..25b717079 100644 --- a/src/GEOM_SWIG/GeomHelper.cxx +++ b/src/GEOM_SWIG/GeomHelper.cxx @@ -21,6 +21,8 @@ #include "GEOM_Gen_i.hh" #include "SALOME_Container_i.hxx" +#include "SALOME_KernelServices.hxx" +#include "SALOMEDS_Study_i.hxx" #include @@ -50,3 +52,11 @@ std::string BuildGEOMInstance() CORBA::String_var ior = orb->object_to_string(zeRef); return std::string(ior.in()); } + +std::string GetSessionInstance() +{ + SALOMEDS::Study_var study = KERNEL::getStudyServantSA(); + CORBA::ORB_ptr orb = KERNEL::getORB(); + CORBA::String_var ior = orb->object_to_string(study); + return std::string(ior.in()); +} diff --git a/src/GEOM_SWIG/GeomHelper.h b/src/GEOM_SWIG/GeomHelper.h index 09bb19422..0224e0c1f 100644 --- a/src/GEOM_SWIG/GeomHelper.h +++ b/src/GEOM_SWIG/GeomHelper.h @@ -20,3 +20,4 @@ #include std::string BuildGEOMInstance(); +std::string GetSessionInstance(); \ No newline at end of file diff --git a/src/GEOM_SWIG/GeomHelper.i b/src/GEOM_SWIG/GeomHelper.i index 64d70cad9..735be9c2d 100644 --- a/src/GEOM_SWIG/GeomHelper.i +++ b/src/GEOM_SWIG/GeomHelper.i @@ -24,4 +24,14 @@ %inline { std::string BuildGEOMInstance(); + std::string GetSessionInstance(); } +%pythoncode %{ + +def myStudy(): + import SALOMEDS + import CORBA + orb=CORBA.ORB_init(['']) + return orb.string_to_object(GetSessionInstance()) + +%} \ No newline at end of file diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py index 95e3952cb..2e256ddb9 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -837,7 +837,8 @@ class geomBuilder(GEOM._objref_GEOM_Gen): ## @addtogroup l1_geomBuilder_auxiliary ## @{ def init_geom(self): - self.myStudy = salome.myStudy + import GeomHelper + self.myStudy = GeomHelper.myStudy() self.myBuilder = self.myStudy.NewBuilder() # load data from the study file, if necessary -- 2.39.2