Salome HOME
Copyright update 2022
[modules/paravis.git] / src / PVGUI / PVGUI_DataModel.cxx
index 1473313fc3ab9b5b16adbf2aeb5f00879c72cad6..994e1fde6ff558aba58552fe00ed6dcf61579a8c 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2010-2015  CEA/DEN, EDF R&D
+// Copyright (C) 2010-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -45,7 +45,7 @@
 // ParaView include
 #include <pqApplicationCore.h>
 #include <pqServer.h>
-#include <pqFixPathsInStateFilesBehavior.h>
+#include <vtkOutputWindow.h>
 
 const QString PVGUI_DataModel::RESTORE_FLAG_FILE = "do_restore_paravis_references.par";
 
@@ -54,9 +54,29 @@ const QString PVGUI_DataModel::RESTORE_FLAG_FILE = "do_restore_paravis_reference
  */
 namespace {
 
+  QStringList multiFormats()
+  {
+    static QStringList formats;
+    if ( formats.isEmpty() )
+      formats << "vtm" << "lata" << "pvd";
+    return formats;
+  }
+  void warning( const QString& message )
+  {
+    vtkOutputWindow* vtkWindow = vtkOutputWindow::GetInstance();
+    if ( vtkWindow )
+    {
+      vtkWindow->DisplayWarningText( qPrintable( message ) );
+    }
+  }
+
   void processElements(QDomNode& thePropertyNode, QStringList& theFileNames,
                        const QString& theNewPath, bool theRestore)
   {
+    QDomElement aProperty = thePropertyNode.toElement();
+    int aNbElements = aProperty.attribute("number_of_elements").toInt();
+    if ( aNbElements > 1 )
+      warning( QString("You save data file with number of entities > 1 (%1); some data may be lost!").arg(aNbElements) );
     QDomNode aElementNode = thePropertyNode.firstChild();
     while (aElementNode.isElement()) {
       QDomElement aElement = aElementNode.toElement();
@@ -68,6 +88,9 @@ namespace {
             if (theNewPath.isEmpty()) {
               QFileInfo aFInfo(aValue);
               if (aFInfo.exists()) {
+                QString ext = aFInfo.suffix();
+                if ( multiFormats().contains(aFInfo.suffix()) )
+                  warning( QString("You save data in multiple file format (%1); some data may be not saved!").arg(ext) );
                 theFileNames<<aValue;
                 aElement.setAttribute("value", aFInfo.fileName());
               }
@@ -209,7 +232,7 @@ bool PVGUI_DataModel::dumpPython( const QString& path, CAM_Study* std,
   if (isMultiFile)
     {
       QStringList abuffer;
-      abuffer.push_back(QString("def RebuildData( theStudy ):"));
+      abuffer.push_back(QString("def RebuildData():"));
       QStringList lst(trace.split("\n"));
       foreach(QString elem, lst)
         {
@@ -265,9 +288,7 @@ bool PVGUI_DataModel::open( const QString& theName, CAM_Study* theStudy, QString
               processAllFilesInState(aFullPath, srcFilesEmpty, aTmpDir.toStdString().c_str(), true);
             }
 
-          pqFixPathsInStateFilesBehavior::blockDialog(true);
           mod->loadParaviewState(aFullPath);
-          pqFixPathsInStateFilesBehavior::blockDialog(false);
           ret = true;
         }
       ret = true;
@@ -304,7 +325,7 @@ bool PVGUI_DataModel::createAndCheckRestoreFlag(const QString& tmpdir, QStringLi
 
 /*!
   \brief Save data model (write ParaView pipeline to the files).
-  \param listOfFiles returning list of the (temporary) files with saved data
+  \param theListOfFiles returning list of the (temporary) files with saved data
   \return operation status (\c true on success and \c false on error)
 */
 bool PVGUI_DataModel::save( QStringList& theListOfFiles)
@@ -386,10 +407,10 @@ bool PVGUI_DataModel::save( QStringList& theListOfFiles)
   \brief Save data model (write ParaView pipeline state to the files).
   \param url study file path
   \param study study pointer
-  \param listOfFiles returning list of the (temporary) files with saved data
+  \param theListOfFiles returning list of the (temporary) files with saved data
   \return operation status (\c true on success and \c false on error)
 */
-bool PVGUI_DataModel::saveAs( const QString& url, CAM_Study* study, QStringList& theListOfFiles)
+bool PVGUI_DataModel::saveAs( const QString& url, CAM_Study* /*study*/, QStringList& theListOfFiles)
 {
   myStudyURL = url;
   return save( theListOfFiles );