From 5534e5c4aa6d3e4ec45c8e121026774617ff5017 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Tue, 23 Feb 2021 08:57:14 +0100 Subject: [PATCH] GEOM is in GUI standalone mode --- src/GEOMGUI/CMakeLists.txt | 2 + src/GEOMGUI/GeometryGUI.cxx | 17 +++++--- src/GEOM_I/CMakeLists.txt | 2 + src/GEOM_I/GEOM_Component_Generator.cxx | 55 +++++++++++++++++++++++++ src/GEOM_I/GEOM_Component_Generator.hxx | 28 +++++++++++++ src/GEOM_SWIG/GeomHelper.cxx | 35 ++++------------ src/GEOM_SWIG/GeomHelper.h | 2 +- 7 files changed, 109 insertions(+), 32 deletions(-) create mode 100644 src/GEOM_I/GEOM_Component_Generator.cxx create mode 100644 src/GEOM_I/GEOM_Component_Generator.hxx diff --git a/src/GEOMGUI/CMakeLists.txt b/src/GEOMGUI/CMakeLists.txt index e44a1b6a1..e4f0b227f 100644 --- a/src/GEOMGUI/CMakeLists.txt +++ b/src/GEOMGUI/CMakeLists.txt @@ -36,6 +36,7 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/GEOMClient ${PROJECT_SOURCE_DIR}/src/GEOMImpl ${PROJECT_SOURCE_DIR}/src/GEOMUtils + ${PROJECT_SOURCE_DIR}/src/GEOM_I ${CMAKE_CURRENT_SOURCE_DIR} ) @@ -55,6 +56,7 @@ SET(_link_LIBRARIES Material GEOMImpl GEOMUtils + GEOMEngine ${KERNEL_SALOMELocalTrace} ${KERNEL_SalomeDS} ${KERNEL_SalomeDSClient} diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 0b9482dfb..0ecafd3da 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -41,6 +41,7 @@ #include "GEOMUtils_XmlHandler.hxx" #include "GEOMGUI_AnnotationMgr.h" #include "GEOMGUI_TextTreeSelector.h" +#include "GEOM_Component_Generator.hxx" #include "GEOM_Actor.h" @@ -216,14 +217,20 @@ void GeometryGUI::Modified (bool theIsUpdateActions) // function : GeometryGUI::GeometryGUI() // purpose : Constructor //======================================================================= -GeometryGUI::GeometryGUI() : - SalomeApp_Module( "GEOM" ), - myTopLevelIOList() +GeometryGUI::GeometryGUI() : SalomeApp_Module( "GEOM" ) { if ( CORBA::is_nil( myComponentGeom ) ) { - Engines::EngineComponent_var comp = - SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" ); + SALOME_NamingService_Abstract *ns = SalomeApp_Application::namingService(); + Engines::EngineComponent_var comp; + if( dynamic_cast(ns) ) + { + comp = SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" ); + } + else + { + comp = RetrieveGEOMInstance(); + } myComponentGeom = GEOM::GEOM_Gen::_narrow( comp ); } diff --git a/src/GEOM_I/CMakeLists.txt b/src/GEOM_I/CMakeLists.txt index bc95fc6f2..c0f09fc70 100644 --- a/src/GEOM_I/CMakeLists.txt +++ b/src/GEOM_I/CMakeLists.txt @@ -79,6 +79,7 @@ SET(GEOMEngine_HEADERS GEOM_Gen_No_Session_i.hh GEOM_GEOM_I.hxx GEOM_wrap.hxx + GEOM_Component_Generator.hxx ) # --- sources --- @@ -104,6 +105,7 @@ SET(GEOMEngine_SOURCES GEOM_Gen_Session_i.cc GEOM_Gen_No_Session_i.cc GEOM_DumpPython.cc + GEOM_Component_Generator.cxx ) # --- rules --- diff --git a/src/GEOM_I/GEOM_Component_Generator.cxx b/src/GEOM_I/GEOM_Component_Generator.cxx new file mode 100644 index 000000000..c05e2597c --- /dev/null +++ b/src/GEOM_I/GEOM_Component_Generator.cxx @@ -0,0 +1,55 @@ +// Copyright (C) 2021 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "GEOM_Component_Generator.hxx" + +#include "GEOM_Gen_No_Session_i.hh" +#include "SALOME_Container_i.hxx" +#include "SALOME_KernelServices.hxx" + +#include + +static Engines::EngineComponent_var _unique_compo; + +Engines::EngineComponent_var RetrieveGEOMInstance() +{ + if (CORBA::is_nil(_unique_compo)) + { + CORBA::ORB_var orb; + { + int argc(0); + orb = CORBA::ORB_init(argc, nullptr); + } + CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); + PortableServer::POA_var poa = PortableServer::POA::_narrow(obj); + PortableServer::POAManager_var pman = poa->the_POAManager(); + CORBA::PolicyList policies; + policies.length(0); + Engines_Container_i *cont(KERNEL::getContainerSA()); + PortableServer::ObjectId *conId(cont->getCORBAId()); + // + pman->activate(); + // + GEOM_Gen_No_Session_i *servant = new GEOM_Gen_No_Session_i(orb, poa, conId, "GEOM_inst_2", "GEOM"); + PortableServer::ObjectId *zeId = servant->getId(); + CORBA::Object_var zeRef = poa->id_to_reference(*zeId); + _unique_compo = Engines::EngineComponent::_narrow(zeRef); + } + return _unique_compo; +} diff --git a/src/GEOM_I/GEOM_Component_Generator.hxx b/src/GEOM_I/GEOM_Component_Generator.hxx new file mode 100644 index 000000000..dc8ecaf3b --- /dev/null +++ b/src/GEOM_I/GEOM_Component_Generator.hxx @@ -0,0 +1,28 @@ +// Copyright (C) 2021 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#pragma once + +#include "GEOM_GEOM_I.hxx" + +#include "SALOMEconfig.h" + +#include CORBA_SERVER_HEADER(GEOM_Gen) + +GEOM_I_EXPORT Engines::EngineComponent_var RetrieveGEOMInstance(); diff --git a/src/GEOM_SWIG/GeomHelper.cxx b/src/GEOM_SWIG/GeomHelper.cxx index c0601f7ff..f4e6251a9 100644 --- a/src/GEOM_SWIG/GeomHelper.cxx +++ b/src/GEOM_SWIG/GeomHelper.cxx @@ -19,33 +19,16 @@ #include "GeomHelper.h" -#include "GEOM_Gen_No_Session_i.hh" -#include "SALOME_Container_i.hxx" -#include "SALOME_KernelServices.hxx" - -#include +#include "GEOM_Component_Generator.hxx" std::string BuildGEOMInstance() { - CORBA::ORB_var orb; - { int argc(0); orb = CORBA::ORB_init(argc,nullptr); } - CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); - PortableServer::POA_var poa = PortableServer::POA::_narrow(obj); - PortableServer::POAManager_var pman = poa->the_POAManager(); - CORBA::PolicyList policies; - policies.length(0); - Engines_Container_i *cont( KERNEL::getContainerSA() ); - PortableServer::ObjectId * conId ( cont->getCORBAId() ); - // - pman->activate(); - // - GEOM_Gen_No_Session_i *servant = new GEOM_Gen_No_Session_i(orb,poa,conId,"GEOM_inst_2","GEOM"); - PortableServer::ObjectId *zeId = servant->getId(); - CORBA::Object_var zeRef = poa->id_to_reference(*zeId); - char *interfaceName = servant->interfaceName(); - std::string interfaceNameCpp(interfaceName); - CORBA::string_free(interfaceName); - KERNEL::RegisterCompo(interfaceNameCpp,zeRef); - CORBA::String_var ior = orb->object_to_string(zeRef); - return std::string(ior.in()); + CORBA::ORB_var orb; + { + int argc(0); + orb = CORBA::ORB_init(argc, nullptr); + } + Engines::EngineComponent_var zeRef = RetrieveGEOMInstance(); + CORBA::String_var ior = orb->object_to_string(zeRef); + return std::string(ior.in()); } diff --git a/src/GEOM_SWIG/GeomHelper.h b/src/GEOM_SWIG/GeomHelper.h index 92676977c..09bb19422 100644 --- a/src/GEOM_SWIG/GeomHelper.h +++ b/src/GEOM_SWIG/GeomHelper.h @@ -19,4 +19,4 @@ #include -std::string BuildGEOMInstance(); \ No newline at end of file +std::string BuildGEOMInstance(); -- 2.39.2