]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Modif for salome gui without neither NS nor other servers. agy/archi5_integ
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 22 Feb 2021 15:22:23 +0000 (16:22 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 24 Feb 2021 06:18:07 +0000 (07:18 +0100)
resources/CMakeLists.txt
src/GEOMGUI/CMakeLists.txt
src/GEOMGUI/GeometryGUI.cxx
src/GEOM_I/CMakeLists.txt
src/GEOM_I/GEOM_Component_Generator.cxx [new file with mode: 0644]
src/GEOM_I/GEOM_Component_Generator.hxx [new file with mode: 0644]
src/GEOM_SWIG/GeomHelper.cxx
src/GEOM_SWIG/GeomHelper.h

index 2c282792b16c45e22f96a5e24df52ca3f35b1281..c17e9819ccac5b32be28307ecff91110d0129a89 100644 (file)
@@ -316,6 +316,7 @@ INSTALL(FILES ${_texture_files} DESTINATION ${SALOME_GEOM_INSTALL_RES_DATA}/text
 
 SALOME_CONFIGURE_FILE(GEOMCatalog.xml.in GEOMCatalog.xml INSTALL ${SALOME_GEOM_INSTALL_RES_DATA})
 SALOME_CONFIGURE_FILE(SalomeApp.xml.in SalomeApp.xml INSTALL ${SALOME_GEOM_INSTALL_RES_DATA})
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/SalomeApp.xml RENAME SalomeAppSL.xml DESTINATION ${SALOME_GEOM_INSTALL_RES_DATA})
 SALOME_CONFIGURE_FILE(Plugin.in Plugin INSTALL ${SALOME_GEOM_INSTALL_RES_DATA})
 
 
index e44a1b6a1e3e0653348dce385bb064be5e63bcfe..e4f0b227f324d7906fd4c7bc555e481d4f49a2bd 100644 (file)
@@ -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}
index bc39a219f804c172070f7c653df9aeab2c547b98..d6889abcdb65986fe8a66cef414d632476da372b 100644 (file)
@@ -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"
 
@@ -87,6 +88,7 @@
 
 #include <SALOMEDSClient_ClientFactory.hxx>
 #include <SALOMEDSClient_IParameters.hxx>
+#include "SALOME_KernelServices.hxx"
 
 #include <SALOMEDS_SObject.hxx>
 
@@ -195,7 +197,7 @@ bool GeometryGUI::IsInGeomComponent( _PTR(SObject) sobject )
 //=======================================================================
 SALOMEDS::Study_var GeometryGUI::getStudyServant()
 {
-  SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
+  SALOME_NamingService_Abstract *aNamingService = SalomeApp_Application::namingService();
   CORBA::Object_var aStudyObject = aNamingService->Resolve("/Study");
   SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(aStudyObject);
   return aStudy._retn();
@@ -216,14 +218,22 @@ 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<SALOME_NamingService *>(ns) )
+    {
+      comp = SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" );
+    }
+    else
+    {
+      comp = RetrieveGEOMInstance();
+      CORBA::Object_var comp2 = CORBA::Object::_narrow(comp);
+      KERNEL::RegisterCompo("GEOM",comp2);
+    }
     myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
   }
 
index bc95fc6f243d332b676266bfe2227d2cba16f659..c0f09fc704a726c4ee6e9bc2da9b1b36acd67003 100644 (file)
@@ -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 (file)
index 0000000..df0a33e
--- /dev/null
@@ -0,0 +1,57 @@
+// 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 <cstring>
+
+static Engines::EngineComponent_var _unique_compo;
+
+Engines::EngineComponent_var RetrieveGEOMInstance()
+{
+  constexpr char COMPO_NAME[]="GEOM";
+  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", COMPO_NAME);
+    PortableServer::ObjectId *zeId = servant->getId();
+    CORBA::Object_var zeRef = poa->id_to_reference(*zeId);
+    KERNEL::RegisterCompo(COMPO_NAME,zeRef);
+    _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 (file)
index 0000000..dc8ecaf
--- /dev/null
@@ -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();
index 1b9eaa27fe880ac404b4505318b68fa8a232e9ed..9633a001b9ecd2c71392f47f2454bab033146c88 100644 (file)
 
 #include "GeomHelper.h"
 
-#include "GEOM_Gen_No_Session_i.hh"
-#include "SALOME_Container_i.hxx"
 #include "SALOME_KernelServices.hxx"
 
-#include <cstring>
+#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);
-    PortableServer::ObjectId_var conId;
-    //
-    {
-        char *argv[4] = {"Container","FactoryServer","GEOM",nullptr};
-        Engines_Container_i *cont = new Engines_Container_i(orb,poa,"FactoryServer",2,argv,false,false);
-        conId = poa->activate_object(cont);
-    }
-    //
-    pman->activate();
-    //
-    GEOM_Gen_No_Session_i *servant = new GEOM_Gen_No_Session_i(orb,poa,const_cast<PortableServer::ObjectId*>(&conId.in()),"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());
+  Engines::EngineComponent_var zeRef = RetrieveGEOMInstance();
+  CORBA::String_var ior = KERNEL::getORB()->object_to_string(zeRef);
+  return std::string(ior.in());
 }
index 92676977c9375a3fa7d1228c3f5277a2a379faef..09bb194222f5348c3a15b71083b3da158ce74580 100644 (file)
@@ -19,4 +19,4 @@
 
 #include <string>
 
-std::string BuildGEOMInstance();
\ No newline at end of file
+std::string BuildGEOMInstance();