]> SALOME platform Git repositories - modules/parametric.git/commitdiff
Salome HOME
CSV export is now done directly by the engine
authorRenaud Barate <renaud.barate@edf.fr>
Fri, 1 Mar 2013 16:32:52 +0000 (17:32 +0100)
committerRenaud Barate <renaud.barate@edf.fr>
Fri, 1 Mar 2013 16:32:52 +0000 (17:32 +0100)
idl/PARAMETRIC_Gen.idl
src/PARAMETRIC/PARAMETRIC.py
src/PARAMETRICGUI/PARAMETRICGUI.py

index 0888f8311833a996054cf8c969acc420c42b2c17..26073a479e655b5b697b523466d37543a7a1c46c 100644 (file)
@@ -42,6 +42,11 @@ interface PARAMETRIC_Gen : Engines::EngineComponent, SALOMEDS::Driver
     void RunStudy(in long salomeStudyID,
                   in SALOMEDS::ID entry)
       raises (SALOME::SALOME_Exception);
+
+    void ExportToCSV(in long salomeStudyID,
+                     in SALOMEDS::ID entry,
+                     in string filePath)
+      raises (SALOME::SALOME_Exception);
 };
 
 };
index a0ed4be61b5fe3ff6cb359ba4a25f4cd5707ed7e..36ff11a6d65f49475f694c42448c5fb8350638af 100644 (file)
@@ -307,6 +307,24 @@ class PARAMETRIC(PARAMETRIC_ORB__POA.PARAMETRIC_Gen, SALOME_ComponentPy_i, SALOM
     except:
       self._raiseSalomeError()
 
+  def ExportToCSV(self, salomeStudyID, entry, filePath):
+    try:
+      self.beginService("PARAMETRIC.ExportToCSV")
+
+      PARAMETRIC.lock.acquire()
+      salome.salome_init()
+      PARAMETRIC.lock.release()
+
+      # Get parametric study from the case in Salome study
+      param_study = self._get_parametric_study(salomeStudyID, entry)
+      
+      # Export parametric study to CSV file
+      param_study.export_data_to_csv_file(filePath)
+
+      self.endService("PARAMETRIC.ExportToCSV")
+    except:
+      self._raiseSalomeError()
+
   def Save(self, theComponent, theURL, isMultiFile):
     try:
       # Select parametric studies to save
index 934d9c0eb3bbec56a67067372974b66c22ffd0be..5106f3855853f7b9b72f1312d9d99a9f1a6e117a 100644 (file)
@@ -224,13 +224,23 @@ def export_to_csv():
                                                filter = qapp.translate("export_to_csv", "CSV files (*.csv)"))
   if filename is not None and len(filename) > 0:
     try:
-        qapp.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))
-        study_id = sgPyQt.getStudyId()
-        entry = salome.sg.getSelected(0)
-        ed = ParametricStudyEditor(study_id)
-        param_study = ed.get_parametric_study(entry)
-        param_study.export_data_to_csv_file(filename)
-        qapp.restoreOverrideCursor()
+      filename = str(filename)
+      if not filename.endswith(".csv"):
+        filename += ".csv"
+      qapp.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))
+      study_id = sgPyQt.getStudyId()
+      entry = salome.sg.getSelected(0)
+      ed = ParametricStudyEditor(study_id)
+      engine = ed.find_or_create_engine()
+      engine.ExportToCSV(ed.study_id, entry, filename)
+      qapp.restoreOverrideCursor()
+    except SALOME.SALOME_Exception, exc:
+      qapp.restoreOverrideCursor()
+      logger.exception("An error happened while trying to export to CSV file.")
+      QtGui.QMessageBox.critical(sgPyQt.getDesktop(),
+          qapp.translate("export_to_csv", "Error"),
+          qapp.translate("export_to_csv", "An error happened while trying to "
+                         "export parametric study to CSV file: %s" % exc.details.text))
     except Exception, exc:
       qapp.restoreOverrideCursor()
       logger.exception("Export to CSV file failed")