Salome HOME
0023299: [CEA] Finalize multi-study removal mpa/23299
authorimn <imn@opencascade.com>
Tue, 18 Oct 2016 13:30:17 +0000 (16:30 +0300)
committerimn <imn@opencascade.com>
Tue, 18 Oct 2016 13:30:17 +0000 (16:30 +0300)
- delete study id parameter

idl/ATOMSOLV.idl
src/ATOMSOLV/ATOMSOLV.cxx
src/ATOMSOLV/ATOMSOLV.hxx
src/ATOMSOLVGUI/ATOMSOLVGUI.cxx
src/ATOMSOLVGUI/ATOMSOLVGUI_DataModel.cxx
src/ATOMSOLVGUI/ATOMSOLVGUI_DataObject.cxx
src/ATOMSOLVGUI/ATOMSOLVGUI_Displayer.cxx

index 145df19cdeed65aef3410edd9c1f4bca247c9cf1..74f4523a821802e8b21461d6a207bade0242fe2c 100644 (file)
@@ -50,17 +50,17 @@ module ATOMSOLV_ORB
     /*!
       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( );
   };
 };
 
index b55c4e6c35e92f4adf12becf1777a6e0bd833e51..b5f510cfdbdf1ac100a8c228f95fa3f248818785 100755 (executable)
@@ -42,7 +42,7 @@ 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();
@@ -50,37 +50,29 @@ CORBA::Boolean ATOMSOLV::setData( CORBA::Long studyID, const ATOMSOLV_ORB::TMole
   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;
 }
 
index 7d7efb996afc9a9c8d8ef36741c27469ae14a02c..2cfde291eccc155450df6e8911af1e7272497645 100644 (file)
@@ -51,13 +51,13 @@ public:
           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"
index 4b51a4e9086d9d83f1d4929f36bd13590536af6d..a3c48bf50987a557bfdafbb1086742c36d9156f1 100644 (file)
@@ -193,7 +193,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 );
@@ -260,7 +260,6 @@ void ATOMSOLVGUI::OnRetrieveData()
     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" ) ) {
@@ -271,7 +270,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 +283,7 @@ void ATOMSOLVGUI::OnRetrieveData()
         outData[ i ] = tmol;
       }
 
-      engine->setData( studyID, outData );
+      engine->setData( outData );
 
       app->updateObjectBrowser();
     }
@@ -297,27 +296,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 );
+              }
         }
       }
     }
index 2a4853f5d939e4008c85a2a444839e2187047743..9de2d1bcf1a9d8a8c6a1045680d2ede3c8ffcbaf 100644 (file)
@@ -49,9 +49,8 @@ void ATOMSOLVGUI_DataModel::build()
   // 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;
     }
index f8c500a3033a8e5d56d34105ba37124db71fb38e..54c929b834da6e71f8ed8f405e2ae08309ec727f 100644 (file)
@@ -102,14 +102,11 @@ ATOMSOLV_ORB::TMolecule ATOMSOLVGUI_DataObject::getTMolecule() const
   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();
 }
index 1ec5d1b4e786c1968aa39ac23f81d0e59252b1a5..f060251d8c8cbb2df40b38bb4dfd976f8be64c8e 100644 (file)
@@ -63,7 +63,7 @@ bool ATOMSOLVGUI_Displayer::canBeDisplayed( const QString& entry, const QString&
   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( "_" );
 
@@ -76,7 +76,7 @@ ATOMGEN_ORB::Atom_ptr getAtom( const QString& entry, const int studyID, double&
 
   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() ) {
@@ -95,27 +95,14 @@ void setTemperature( SALOME_Actor* actor, double temperature )
   }
 }
 
-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
@@ -159,10 +146,9 @@ SALOME_Prs* ATOMSOLVGUI_Displayer::buildPresentation( const QString& entry, SALO
 
 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();
   }