Salome HOME
HYDRO bug 17: add HYDRO version in About dialog.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_DataModel.cxx
index 798cf88ed181a2ca635233e75e260fc7e699509d..e72d9488163a46cac9d7c3e38bcad4d7852a9836 100644 (file)
@@ -53,6 +53,9 @@
 #include <TDF_Delta.hxx>
 #include <TDF_ListIteratorOfDeltaList.hxx>
 
+#include <QApplication>
+#include <QDir>
+
 HYDROGUI_DataModel::HYDROGUI_DataModel( CAM_Module* theModule )
 : LightApp_DataModel( theModule )
 {
@@ -148,6 +151,33 @@ bool HYDROGUI_DataModel::close()
   return true;
 }
 
+bool HYDROGUI_DataModel::dumpPython( const QString& theURL,
+                                     CAM_Study*     theStudy,
+                                     bool           isMultiFile,
+                                     QStringList&   theListOfFiles )
+{
+  LightApp_DataModel::dumpPython( theURL, theStudy, isMultiFile, theListOfFiles );
+
+  int aStudyId = theStudy->id();
+
+  LightApp_Study* aStudy = ::qobject_cast<LightApp_Study*>( theStudy );
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId );
+  if ( aDocument.IsNull() || !aStudy )
+    return false;
+
+  QString aFileToExport = aStudy->GetTmpDir( theURL.toLatin1().constData(), isMultiFile ).c_str();
+  aFileToExport += QString( QDir::separator() ) + "HYDRO.py";
+
+  bool aRes = aDocument->DumpToPython( aFileToExport );
+
+  if ( aRes )
+  {
+    theListOfFiles.append( aFileToExport );
+  }
+
+  return aRes;
+}
+
 bool HYDROGUI_DataModel::isModified() const
 {
   return getDocument()->IsModified();
@@ -199,9 +229,9 @@ void HYDROGUI_DataModel::update( const int theStudyId )
       {
         for( int anIndex = 0, aNbRef = anImageObj->NbReferences(); anIndex < aNbRef; anIndex++ )
         {
-          Handle(HYDROData_Image) aRefImageObj = anImageObj->Reference( anIndex );
-          if( !aRefImageObj.IsNull() && !aRefImageObj->IsRemoved() )
-            createObject( anImageDataObj, aRefImageObj, anImageDataObj->entry() );
+          Handle(HYDROData_Object) aRefObj = anImageObj->Reference( anIndex );
+          if( !aRefObj.IsNull() && !aRefObj->IsRemoved() )
+            createObject( anImageDataObj, aRefObj, anImageDataObj->entry() );
         }
       }
     }