/*!
Set internal data structure from external source (ATOMGEN component, for example).
*/
- boolean setData( in long studyID, in TMoleculeList theData );
+ boolean setData( in TMoleculeList theData );
/*!
Get internal data structure
*/
- boolean getData( in long studyID, out TMoleculeList outData );
+ boolean getData( out TMoleculeList outData );
/*!
Perform action on the atomic data
*/
- boolean processData( in long studyID );
+ boolean processData( );
};
};
MESSAGE("activate object");
_thisObj = this ;
_id = _poa->activate_object(_thisObj);
+ myData = new ATOMSOLV_ORB::TMoleculeList();
}
ATOMSOLV::~ATOMSOLV()
{
}
-CORBA::Boolean ATOMSOLV::setData( CORBA::Long studyID, const ATOMSOLV_ORB::TMoleculeList& theData )
+CORBA::Boolean ATOMSOLV::setData( const ATOMSOLV_ORB::TMoleculeList& theData )
{
const int n = theData.length();
ATOMSOLV_ORB::TMoleculeList_var data = new ATOMSOLV_ORB::TMoleculeList();
for ( int i = 0; i < n; i++ )
data[ i ] = theData[ i ];
- // printf( " -- ATOMSOLV::setData( %d ) length = %d\n", studyID, data->length() );
- myData[ studyID ] = data._retn();
+ // printf( " -- ATOMSOLV::setData() length = %d\n", data->length() );
+ myData = data._retn();
return (bool)n;
}
-CORBA::Boolean ATOMSOLV::getData( CORBA::Long studyID, ATOMSOLV_ORB::TMoleculeList_out outData )
+CORBA::Boolean ATOMSOLV::getData( ATOMSOLV_ORB::TMoleculeList_out outData )
{
- if ( myData.find( studyID ) != myData.end() ) {
- ATOMSOLV_ORB::TMoleculeList* data = myData[ studyID ];
-
- // printf( " -- ATOMSOLV::getData( %d ) length = %d\n", studyID, data->length() );
- const int n = data->length();
- outData = new ATOMSOLV_ORB::TMoleculeList();
- outData->length( n );
-
- for ( int i = 0; i < n; i++ )
- (*outData)[ i ] = (*data)[ i ];
-
- return true;
- }
- return false;
+ ATOMSOLV_ORB::TMoleculeList* data = myData;
+ // printf( " -- ATOMSOLV::getData() length = %d\n", data->length() );
+ const int n = data->length();
+ outData = new ATOMSOLV_ORB::TMoleculeList();
+ outData->length( n );
+ for ( int i = 0; i < n; i++ )
+ (*outData)[ i ] = (*data)[ i ];
+ return true;
}
-CORBA::Boolean ATOMSOLV::processData( CORBA::Long studyID )
+CORBA::Boolean ATOMSOLV::processData()
{
- if ( myData.find( studyID ) != myData.end() ) {
- ATOMSOLV_ORB::TMoleculeList* data = myData[ studyID ];
- for ( int i = 0, n = data->length(); i < n; i++ )
- (*data)[i].temperature = rand();
- }
+ ATOMSOLV_ORB::TMoleculeList* data = myData;
+ for ( int i = 0, n = data->length(); i < n; i++ )
+ (*data)[i].temperature = rand();
return true;
}
const char *interfaceName);
virtual ~ATOMSOLV();
- CORBA::Boolean setData( CORBA::Long studyID, const ATOMSOLV_ORB::TMoleculeList& theData );
- CORBA::Boolean getData( CORBA::Long studyID, ATOMSOLV_ORB::TMoleculeList_out outData );
- CORBA::Boolean processData( CORBA::Long studyID );
+ CORBA::Boolean setData( const ATOMSOLV_ORB::TMoleculeList& theData );
+ CORBA::Boolean getData( ATOMSOLV_ORB::TMoleculeList_out outData );
+ CORBA::Boolean processData();
virtual char* getVersion();
private:
- std::map<long, ATOMSOLV_ORB::TMoleculeList*> myData;
+ ATOMSOLV_ORB::TMoleculeList* myData;
};
extern "C"
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 );
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" ) ) {
}
// 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();
outData[ i ] = tmol;
}
- engine->setData( studyID, outData );
+ engine->setData( outData );
app->updateObjectBrowser();
}
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 );
+ }
}
}
}
// create 'molecule' objects under model root object and 'atom' objects under 'molecule'-s
ATOMSOLV_ORB::ATOMSOLV_Gen_var engine = ATOMSOLVGUI::GetATOMSOLVGen();
if ( !CORBA::is_nil( engine ) ) {
- const int studyID = getStudy()->id();
ATOMSOLV_ORB::TMoleculeList_var molecules;
- if ( !engine->getData( studyID, molecules ) ) {
+ if ( !engine->getData( molecules ) ) {
// printf( " -- DataModel: getData() returned false! \n" );
return;
}
ATOMSOLV_ORB::ATOMSOLV_Gen_var engine = ATOMSOLVGUI::GetATOMSOLVGen();
LightApp_RootObject* rootObj = dynamic_cast<LightApp_RootObject*> ( root() );
if ( rootObj && !CORBA::is_nil( engine ) ) {
- const int studyID = rootObj->study()->id();
- if ( studyID > 0 ) {
- ATOMSOLV_ORB::TMoleculeList_var molecules;
- if ( engine->getData( studyID, molecules ) &&
- myMoleculeIndex > -1 &&
- myMoleculeIndex < molecules->length() )
+ ATOMSOLV_ORB::TMoleculeList_var molecules;
+ if ( engine->getData( molecules ) &&
+ myMoleculeIndex > -1 &&
+ myMoleculeIndex < molecules->length() )
return molecules[ myMoleculeIndex ];
- }
}
return ATOMSOLV_ORB::TMolecule();
}
return result; // entry of an atom for sure
}
-ATOMGEN_ORB::Atom_ptr getAtom( const QString& entry, const int studyID, double& temprature )
+ATOMGEN_ORB::Atom_ptr getAtom( const QString& entry, double& temprature )
{
QStringList es = entry.split( "_" );
ATOMSOLV_ORB::ATOMSOLV_Gen_var engine = ATOMSOLVGUI::GetATOMSOLVGen();
ATOMSOLV_ORB::TMoleculeList_var molecules;
- if ( engine->getData( studyID, molecules ) && molID >= 0 && molID < molecules->length() ) {
+ if ( engine->getData( molecules ) && molID >= 0 && molID < molecules->length() ) {
ATOMSOLV_ORB::TMolecule tmol = molecules[ molID ];
ATOMGEN_ORB::Molecule_var mol = tmol.molecule;
if ( atomID < mol->getNbAtoms() ) {
}
}
-int getStudyID()
-{
- int studyID = -1;
- if ( SUIT_Application* app = SUIT_Session::session()->activeApplication() )
- if ( SUIT_Study* study = app->activeStudy() )
- studyID = study->id();
- return studyID;
-}
-
SALOME_Prs* ATOMSOLVGUI_Displayer::buildPresentation( const QString& entry, SALOME_View* view )
{
- const int studyID = getStudyID();
- if ( studyID == -1 )
- return 0;
-
SVTK_Prs* prs = dynamic_cast<SVTK_Prs*>( LightApp_Displayer::buildPresentation( entry, view ) );
if ( !prs ) return 0;
double temperature;
- ATOMGEN_ORB::Atom_var atom = getAtom( entry, studyID, temperature );
+ ATOMGEN_ORB::Atom_var atom = getAtom( entry, temperature );
if ( !CORBA::is_nil( atom ) ) {
// PRESENTATION FOR OCC VIEWER
void ATOMSOLVGUI_Displayer::updateActor( SALOME_Actor* actor )
{
- const int studyID = getStudyID();
- if ( actor && actor->hasIO() && studyID >= 0 ) {
+ if ( actor && actor->hasIO() ) {
double temperature;
- getAtom( actor->getIO()->getEntry(), studyID, temperature );
+ getAtom( actor->getIO()->getEntry(), temperature );
setTemperature( actor, temperature );
actor->Update();
}