Salome HOME
0021419: [CEA 516] Invalid tree representation of ATOMIC light-component
authorvsr <vsr@opencascade.com>
Mon, 7 Nov 2011 14:52:15 +0000 (14:52 +0000)
committervsr <vsr@opencascade.com>
Mon, 7 Nov 2011 14:52:15 +0000 (14:52 +0000)
src/ATOMICGUI/ATOMICGUI_DataModel.cxx

index aab24856ae49907d50ef385210b02dadc4ff4523..19a45cdb9b2f290b229e92aee23d396f658eb58b 100644 (file)
@@ -62,6 +62,8 @@ ATOMICGUI_DataModel::~ATOMICGUI_DataModel()
 /*! Open Data Model.  Build data structure from the given list of files. */
 bool ATOMICGUI_DataModel::open( const QString& URL, CAM_Study* study, QStringList listOfFiles )
 {
+  myMolecules.clear();
+
   LightApp_Study* aDoc = dynamic_cast<LightApp_Study*>( study );
   if ( !aDoc )
     return false;
@@ -118,13 +120,14 @@ bool ATOMICGUI_DataModel::saveAs ( const QString& URL, CAM_Study* study, QString
 bool ATOMICGUI_DataModel::close()
 {
   myStudyURL = "";
-  myMolecules.clear();
+  //myMolecules.clear();
   return LightApp_DataModel::close();
 }
 
 /*! Called on Study creation */
 bool ATOMICGUI_DataModel::create( CAM_Study* study )
 {
+  myMolecules.clear();
   return true;
 }
 
@@ -143,9 +146,14 @@ bool ATOMICGUI_DataModel::isSaved() const
 /*! Called on update of the structure of Data Objects */
 void ATOMICGUI_DataModel::build()
 {
-  ATOMICGUI_ModuleObject* modelRoot = dynamic_cast<ATOMICGUI_ModuleObject*>( root() );
+  //VSR: module object should be created in a different way for "full" and "light" SALOME
+  //ATOMICGUI_ModuleObject* modelRoot = dynamic_cast<ATOMICGUI_ModuleObject*>( root() );
+  CAM_ModuleObject* modelRoot = dynamic_cast<CAM_ModuleObject*>( root() );
   if( !modelRoot )  {  // root is not set yet
-    modelRoot = new ATOMICGUI_ModuleObject( this, 0 );
+    //VSR: module object should be created in a different way for "full" and "light" SALOME
+    //modelRoot = new ATOMICGUI_ModuleObject( this, 0 );
+    LightApp_Study* study = dynamic_cast<LightApp_Study*>( module()->application()->activeStudy() );
+    modelRoot = createModuleObject( study->root() );
     setRoot( modelRoot );
   }