Salome HOME
Dump Image data to python script (Feature #13).
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_DataModel.cxx
index 798cf88ed181a2ca635233e75e260fc7e699509d..0991095322c92b49950f6d8d1de81d722096d64c 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();