X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FATOMSOLVGUI%2FATOMSOLVGUI.cxx;h=749ec35abf948ac990e24029842ac52bd4efffc0;hb=547f34e17f207cc0801e5322205d7d4980e4f02a;hp=379cc61f20b7e218944b8d5d3ecb8e96b9e89ee6;hpb=048feae8518d2fb595bb4412f2caa1eeea11d9c9;p=samples%2Fatomsolv.git diff --git a/src/ATOMSOLVGUI/ATOMSOLVGUI.cxx b/src/ATOMSOLVGUI/ATOMSOLVGUI.cxx index 379cc61..749ec35 100644 --- a/src/ATOMSOLVGUI/ATOMSOLVGUI.cxx +++ b/src/ATOMSOLVGUI/ATOMSOLVGUI.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2023 CEA, EDF, 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. +// 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 @@ -36,6 +36,9 @@ #include #include +#include "SALOME_NamingService_Abstract.hxx" +#include "SALOME_KernelServices.hxx" + #include #include #include @@ -56,7 +59,7 @@ #include #include -using namespace std; +#include ATOMSOLV_ORB::ATOMSOLV_Gen_var ATOMSOLVGUI::myEngine = ATOMSOLV_ORB::ATOMSOLV_Gen::_nil(); @@ -72,6 +75,7 @@ void ATOMSOLVGUI::InitATOMSOLVGen( SalomeApp_Application* app ) if ( !app ) myEngine = ATOMSOLV_ORB::ATOMSOLV_Gen::_nil(); else { + SALOME_NamingService_Abstract *ns = SalomeApp_Application::namingService(); Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer", "ATOMSOLV" ); ATOMSOLV_ORB::ATOMSOLV_Gen_ptr atomGen = ATOMSOLV_ORB::ATOMSOLV_Gen::_narrow(comp); ASSERT( !CORBA::is_nil( atomGen ) ); @@ -114,7 +118,7 @@ void ATOMSOLVGUI::initialize( CAM_Application* app ) createMenu( ProcessData, aMenuId, 10 ); // create toolbars - int aToolId = createTool ( tr( "TOOL_ATOMSOLV" ) ); + int aToolId = createTool ( tr( "TOOL_ATOMSOLV" ), QString( "AtomSolv" ) ); createTool( RetrieveData, aToolId ); createTool( ProcessData, aToolId ); @@ -193,7 +197,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 +207,9 @@ void ATOMSOLVGUI::studyClosed( SUIT_Study* theStudy ) void ATOMSOLVGUI::windows( QMap& 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 +260,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" ) ) { @@ -269,7 +274,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 +287,7 @@ void ATOMSOLVGUI::OnRetrieveData() outData[ i ] = tmol; } - engine->setData( studyID, outData ); + engine->setData( outData ); app->updateObjectBrowser(); } @@ -295,27 +300,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 ); + } } } } @@ -426,11 +429,12 @@ void ATOMSOLVGUI::preferencesChanged( const QString& group, const QString& param // Export the module extern "C" { + ATOMSOLVGUI_EXPORT CAM_Module* createModule() { return new ATOMSOLVGUI(); } - + ATOMSOLVGUI_EXPORT char* getModuleVersion() { return (char*)ATOMSOLV_VERSION_STR;