X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FATOMSOLVGUI%2FATOMSOLVGUI.cxx;h=3206e8f48a3c6a9b44e183cad40f9e558f2644dd;hb=eb8cd5566bc667daec7874ed9f681d59b2198914;hp=4b51a4e9086d9d83f1d4929f36bd13590536af6d;hpb=08c057b11b1f7d20af3a973912fecb4949f91f29;p=samples%2Fatomsolv.git diff --git a/src/ATOMSOLVGUI/ATOMSOLVGUI.cxx b/src/ATOMSOLVGUI/ATOMSOLVGUI.cxx index 4b51a4e..3206e8f 100644 --- a/src/ATOMSOLVGUI/ATOMSOLVGUI.cxx +++ b/src/ATOMSOLVGUI/ATOMSOLVGUI.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 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 @@ -36,6 +37,9 @@ #include #include +#include "SALOME_NamingService_Abstract.hxx" +#include "SALOME_KernelServices.hxx" + #include #include #include @@ -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 ); @@ -256,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( 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" ) ) { @@ -271,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(); @@ -284,7 +298,7 @@ void ATOMSOLVGUI::OnRetrieveData() outData[ i ] = tmol; } - engine->setData( studyID, outData ); + engine->setData( outData ); app->updateObjectBrowser(); } @@ -297,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::iterator it = vmans.begin(); it != vmans.end(); ++it ) { - QVector views = (*it)->getViews(); - for ( int i = 0; i < views.size(); i++ ) { - if ( SVTK_ViewWindow* svtkView = dynamic_cast( 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::iterator it = vmans.begin(); it != vmans.end(); ++it ) { + QVector views = (*it)->getViews(); + for ( int i = 0; i < views.size(); i++ ) { + if ( SVTK_ViewWindow* svtkView = dynamic_cast( 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 ); + } } } }