Salome HOME
bos #26460 Add SSL mode
[samples/atomsolv.git] / src / ATOMSOLVGUI / ATOMSOLVGUI.cxx
index e90c822678d12bc1493aec012ae3521f76a46438..3206e8f48a3c6a9b44e183cad40f9e558f2644dd 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-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
@@ -22,6 +22,7 @@
 #include "ATOMSOLVGUI_Displayer.h"
 #include "ATOMSOLVGUI_Selection.h"
 #include "ATOMSOLVGUI_TransparencyDlg.h"
+#include "ATOMSOLV_Component_Generator.hxx"
 
 #include <ATOMSOLV_version.h>
 
@@ -36,6 +37,9 @@
 #include <SalomeApp_Application.h>
 #include <SalomeApp_Study.h>
 
+#include "SALOME_NamingService_Abstract.hxx"
+#include "SALOME_KernelServices.hxx"
+
 #include <LightApp_DataOwner.h>
 #include <LightApp_SelectionMgr.h>
 #include <LightApp_Preferences.h>
@@ -72,7 +76,18 @@ void ATOMSOLVGUI::InitATOMSOLVGen( SalomeApp_Application* app )
   if ( !app )
     myEngine = ATOMSOLV_ORB::ATOMSOLV_Gen::_nil();
   else {
-    Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer", "ATOMSOLV" );
+    SALOME_NamingService_Abstract *ns = SalomeApp_Application::namingService();
+    Engines::EngineComponent_var comp;
+    if(ns->IsTrueNS())
+    {
+      comp = app->lcc()->FindOrLoad_Component( "FactoryServer", "ATOMSOLV" );
+    }
+    else
+    {
+      comp = RetrieveATOMSOLVInstance();
+      CORBA::Object_var comp2 = CORBA::Object::_narrow(comp);
+      KERNEL::RegisterCompo("ATOMSOLV",comp2);
+    }
     ATOMSOLV_ORB::ATOMSOLV_Gen_ptr atomGen = ATOMSOLV_ORB::ATOMSOLV_Gen::_narrow(comp);
     ASSERT( !CORBA::is_nil( atomGen ) );
     myEngine = atomGen;
@@ -193,7 +208,7 @@ void ATOMSOLVGUI::studyClosed( SUIT_Study* theStudy )
     ATOMSOLV_ORB::ATOMSOLV_Gen_var engine = GetATOMSOLVGen();
     ATOMSOLV_ORB::TMoleculeList lst;
     lst.length( 0 );
-    engine->setData( theStudy->id(), lst );
+    engine->setData( lst );
   }
 
   SalomeApp_Module::studyClosed( theStudy );
@@ -203,7 +218,9 @@ void ATOMSOLVGUI::studyClosed( SUIT_Study* theStudy )
 void ATOMSOLVGUI::windows( QMap<int, int>& theMap ) const
 {
   theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
+#ifndef DISABLE_PYCONSOLE
   theMap.insert( SalomeApp_Application::WT_PyConsole,     Qt::BottomDockWidgetArea );
+#endif
 }
 
 // Default view managers
@@ -254,11 +271,10 @@ void ATOMSOLVGUI::OnRetrieveData()
   ATOMSOLV_ORB::ATOMSOLV_Gen_var engine = GetATOMSOLVGen();
   SalomeApp_Application* app = getApp();
   if ( !CORBA::is_nil( engine ) && app ) {
-    Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServerPy","ATOMGEN" );
+    Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer","ATOMGEN" );
     ATOMGEN_ORB::ATOMGEN_Gen_var atomGen = ATOMGEN_ORB::ATOMGEN_Gen::_narrow( comp );
     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
     if ( !CORBA::is_nil( atomGen ) && appStudy ) {
-      const int studyID = appStudy->id();
       // in case current study is not loaded by ATOMGEN component - call Load on it
       if ( _PTR( Study ) studyDS = appStudy->studyDS() ) {
         if ( _PTR( SComponent ) atomGenSComp = studyDS->FindComponent( "ATOMGEN" ) ) {
@@ -269,7 +285,7 @@ void ATOMSOLVGUI::OnRetrieveData()
       }
 
       // retrieve data from ATOMGEN
-      ATOMGEN_ORB::MoleculeList_var inData = atomGen->getData( studyID );
+      ATOMGEN_ORB::MoleculeList_var inData = atomGen->getData();
 
       // "convert" Molecules to TMolecules, set default temperature of '0'
       const int n = inData->length();
@@ -282,7 +298,7 @@ void ATOMSOLVGUI::OnRetrieveData()
         outData[ i ] = tmol;
       }
 
-      engine->setData( studyID, outData );
+      engine->setData( outData );
 
       app->updateObjectBrowser();
     }
@@ -295,27 +311,25 @@ void ATOMSOLVGUI::OnProcessData()
   ATOMSOLV_ORB::ATOMSOLV_Gen_var engine = GetATOMSOLVGen();
   SalomeApp_Application* app = getApp();
   if ( !CORBA::is_nil( engine ) && app ) {
-    if ( const int studyID = app->activeStudy()->id() > 0 ) {
-      // call processData on engine
-      engine->processData( studyID );
-      // update data objects in object browser
-      updateObjBrowser();
-      // redisplay atoms that are already displayed (as their temperature changed..)
-      ViewManagerList vmans;
-      getApp()->viewManagers( SVTK_Viewer::Type(), vmans );
-      for ( QList<SUIT_ViewManager*>::iterator it = vmans.begin(); it != vmans.end(); ++it ) {
-        QVector<SUIT_ViewWindow*> views = (*it)->getViews();
-        for ( int i = 0; i < views.size(); i++ ) {
-          if ( SVTK_ViewWindow* svtkView = dynamic_cast<SVTK_ViewWindow*>( views[ i ] ) ) {
-            vtkActorCollection* actors = svtkView->getRenderer()->GetActors();
-            actors->InitTraversal();
-            while ( vtkActor* actor = actors->GetNextActor() )
-              if ( SALOME_Actor* salomeActor = SALOME_Actor::SafeDownCast( actor ) )
-                if ( salomeActor->hasIO() ) {
-                  //                  printf( " -- must redisplay actor salomeActor: %s\n", salomeActor->getIO()->getEntry() );
-                  ATOMSOLVGUI_Displayer().updateActor( salomeActor );
-                }
-          }
+    // call processData on engine
+    engine->processData();
+    // update data objects in object browser
+    updateObjBrowser();
+    // redisplay atoms that are already displayed (as their temperature changed..)
+    ViewManagerList vmans;
+    getApp()->viewManagers( SVTK_Viewer::Type(), vmans );
+    for ( QList<SUIT_ViewManager*>::iterator it = vmans.begin(); it != vmans.end(); ++it ) {
+      QVector<SUIT_ViewWindow*> views = (*it)->getViews();
+      for ( int i = 0; i < views.size(); i++ ) {
+        if ( SVTK_ViewWindow* svtkView = dynamic_cast<SVTK_ViewWindow*>( views[ i ] ) ) {
+          vtkActorCollection* actors = svtkView->getRenderer()->GetActors();
+          actors->InitTraversal();
+          while ( vtkActor* actor = actors->GetNextActor() )
+            if ( SALOME_Actor* salomeActor = SALOME_Actor::SafeDownCast( actor ) )
+              if ( salomeActor->hasIO() ) {
+                //                  printf( " -- must redisplay actor salomeActor: %s\n", salomeActor->getIO()->getEntry() );
+                ATOMSOLVGUI_Displayer().updateActor( salomeActor );
+              }
         }
       }
     }