]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Implementation of muti-save mode support for usual mode persistent (non-ASCII)
authorapo <apo@opencascade.com>
Thu, 12 Jul 2007 09:47:09 +0000 (09:47 +0000)
committerapo <apo@opencascade.com>
Thu, 12 Jul 2007 09:47:09 +0000 (09:47 +0000)
src/VISU_I/Makefile.am
src/VISU_I/VISU_Gen_i.cc
src/VISU_I/VISU_MultiResult_i.cc
src/VISU_I/VISU_ResultUtils.cc
src/VISU_I/VISU_ResultUtils.hh
src/VISU_I/VISU_Result_i.cc

index 9bc96abd24364fa76ccf749fc1713c7b94b2109d..7b3701574ac48378c38c6dea997fc280b743612f 100644 (file)
@@ -101,7 +101,11 @@ libVISUEngineImpl_la_CPPFLAGS= \
        $(MED_CXXFLAGS) \
        $(GUI_CXXFLAGS) \
        $(CORBA_CXXFLAGS) $(CORBA_INCLUDES) \
-       -I$(srcdir)/../CONVERTOR -I$(srcdir)/../PIPELINE -I$(srcdir)/../OBJECT -I$(srcdir)/../VVTK -I$(srcdir)/../GUITOOLS \
+       -I$(srcdir)/../CONVERTOR \
+       -I$(srcdir)/../PIPELINE \
+       -I$(srcdir)/../OBJECT \
+       -I$(srcdir)/../VVTK \
+       -I$(srcdir)/../GUITOOLS \
        -I$(top_builddir)/idl \
        -I$(top_builddir)/salome_adm/unix
 
@@ -119,7 +123,6 @@ libVISUEngineImpl_la_LDFLAGS= \
 libVISUEngineImpl_la_LIBADD= \
        -lboost_signals@BOOST_LIBSUFFIX@ \
        -lboost_thread@BOOST_LIBSUFFIX@ \
-       -lboost_filesystem@BOOST_LIBSUFFIX@ \
        -lSalomeHDFPersist \
        -lSalomeGenericObj \
        -lSalomeContainer \
index 249561fe43c866d5b7ad69ccc26ba98a486341a3..7354538953c5fcce7f33c6eb2d8c5c322f811322 100644 (file)
@@ -369,7 +369,7 @@ namespace VISU
     if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - theURL = '"<<theURL<<"'");
 
     Result_i::TFileNames aFileNames;
-    Result_i::TFileNames aFullFileNames;
+    Result_i::TFileNames aFiles;
 
     SALOMEDS::Study_var aStudy = theComponent->GetStudy();
     SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theComponent);
@@ -381,7 +381,7 @@ namespace VISU
                      theURL, 
                      theIsMultiFile, 
                      aFileNames, 
-                     aFullFileNames);
+                     aFiles);
       }
     }
 
@@ -394,18 +394,18 @@ namespace VISU
        aListOfFileNames[aCounter-1] = aFileNames[aCounter-1].c_str();
     }
 
-    SALOMEDS::ListOfFileNames_var aListOfFullFileNames = new SALOMEDS::ListOfFileNames;
-    if(!aFullFileNames.empty()){
-      aListOfFullFileNames->length(aFullFileNames.size());
-      for(int aCounter = aFullFileNames.size(); aCounter > 0; aCounter--)
-       aListOfFullFileNames[aCounter-1] = aFullFileNames[aCounter-1].c_str();
+    SALOMEDS::ListOfFileNames_var aListOfFiles = new SALOMEDS::ListOfFileNames;
+    if(!aFiles.empty()){
+      aListOfFiles->length(aFiles.size());
+      for(int aCounter = aFiles.size(); aCounter > 0; aCounter--)
+       aListOfFiles[aCounter-1] = aFiles[aCounter-1].c_str();
     }
 
     SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
     if(theIsMultiFile)
-      aStreamFile = SALOMEDS_Tool::PutFilesToStream(theURL, aListOfFullFileNames.in(), theIsMultiFile);
+      aStreamFile = SALOMEDS_Tool::PutFilesToStream(theURL, aListOfFiles.in(), theIsMultiFile);
     else
-      aStreamFile = SALOMEDS_Tool::PutFilesToStream(aListOfFullFileNames.in(), aListOfFileNames.in());
+      aStreamFile = SALOMEDS_Tool::PutFilesToStream(aListOfFiles.in(), aListOfFileNames.in());
 
     return aStreamFile._retn();
   }
index d114f15b2c0f6c4319dce9864edd095b59b95a20..7c094e265df7e67d7d3866e8efbef77dbf6f7e79 100644 (file)
 
 #include <strstream>
 
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem/operations.hpp>
-namespace filesystem = boost::filesystem;
-
 #ifdef _DEBUG_
 static int MYDEBUG = 1;
 static int MYTIMEDEBUG = 0;
@@ -583,7 +579,7 @@ VISU::MultiResult_i
        const std::string& theURL,
        bool theIsMultiFile,
        TFileNames& theFileNames,
-       TFileNames& theFullFileNames)
+       TFileNames& theFiles)
 {
   INITMSG(MYDEBUG, "MultiResult_i::Save - this = "<<this<<"\n");
 
@@ -591,7 +587,7 @@ VISU::MultiResult_i
                                 theURL, 
                                 theIsMultiFile, 
                                 theFileNames, 
-                                theFullFileNames);
+                                theFiles);
   if(!anIsDone)
     return false;
 
@@ -624,14 +620,25 @@ VISU::MultiResult_i
     MultiResult_i::TPartInfo aPartInfo = GetPartInfo(myMultiprObj, aPartName);
 
     QFileInfo aFileInfo(aPartInfo.myFileName.c_str());
-    theFullFileNames.push_back(aFileInfo.absFilePath());
+    std::string aFile = aFileInfo.absFilePath().latin1();
 
     std::string aFileName = aFileInfo.fileName().latin1();
     VISU::TSubString(aFileName, aFilePrefix) = aPrefix;
     VISU::TSubString(aFileName, aSuffix) = "";
     aFileName = aFileName + aSuffix;
     INITMSG(MYDEBUG, "aFileName = '"<<aFileName<<"'\n");
-    theFileNames.push_back(aFileName);
+
+    if(theIsMultiFile){
+      std::string aPathToCopy(theURL + aFileName);
+      BEGMSG(MYDEBUG, "aPathToCopy = '"<<aPathToCopy<<"'\n");
+      if(!VISU::CopyFile(aFile, aPathToCopy))
+       return false;
+    }
+
+    if(!theIsMultiFile)
+      theFileNames.push_back(aFileName);
+
+    theFiles.push_back(aFile);
   }
   
   return true;
@@ -683,6 +690,7 @@ VISU::MultiResult_i
       QFileInfo aFileInfo(aPartInfo.myFileName.c_str());
       std::string aFileName = aFileInfo.fileName().latin1();
       VISU::TSubString(aFileName, aFilePrefix + "_") = "";      
+      VISU::TSubString(aFileName, aSuffix) = "";
       aPartInfo.myFileName = aFileName + aSuffix;
       aPartInfos<<aPartInfo<<"|";
 
index bdcef89877825322bdc824489215560ea58ff7be..fd2be078ec2db41969c9dff36be311511b24aaa4 100644 (file)
 #include <boost/thread/thread.hpp>
 #include <boost/bind.hpp>
 
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem/operations.hpp>
-namespace filesystem = boost::filesystem;
-
 #ifdef _DEBUG_
 static int MYTIMEDEBUG = 0;
 #else
@@ -641,5 +637,22 @@ namespace VISU
   }
 
 
+  //----------------------------------------------------------------------------
+  bool
+  CopyFile(const std::string& theSourceFileName,
+          const std::string& theTargetFileName)
+  {
+    QFileInfo aSourceFileInfo(theSourceFileName);
+    QFileInfo aTargetFileInfo(theTargetFileName);
+    QString aCommand;
+    aCommand.sprintf("%s %s %s",
+                    COPY_COMMAND,
+                    aSourceFileInfo.filePath().latin1(),
+                    aTargetFileInfo.filePath().latin1());
+
+    return system(aCommand.latin1()) == 0;
+  }
+
+
   //----------------------------------------------------------------------------
 }
index 335849f1289ddd00bdc5164072112169d59f50d3..f6807a7b9a694dbd47bbe31bb38ef525b3d87314 100644 (file)
@@ -139,6 +139,11 @@ namespace VISU
             bool theRemoveEmptyDir = true);
 
   //----------------------------------------------------------------------------
+  bool
+  CopyFile(const std::string& theSourceFileName,
+          const std::string& theTargetFileName);
+
+  //----------------------------------------------------------------------------
 }
 
 
index f07256d4fd4c4e86d1a35eb068e4502c26253459..951a5b5242edf607afa92bffa929b56aad40975b 100644 (file)
 // OCCT Includes
 #include <Bnd_Box.hxx>
 
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem/operations.hpp>
-namespace filesystem = boost::filesystem;
-
-
 #ifdef _DEBUG_
 static int MYDEBUG = 1;
 #else
@@ -606,11 +601,13 @@ VISU::Result_i
        const std::string& theURL,
        bool theIsMultiFile,
        TFileNames& theFileNames,
-       TFileNames& theFullFileNames)
+       TFileNames& theFiles)
 {
   switch(GetCreationId()){
   case Result_i::eImportFile:
   case Result_i::eCopyAndImportFile: {
+    INITMSG(MYDEBUG, "Result::Save - this = "<<this<<"\n");
+
     std::string aPrefix;
     if (theIsMultiFile) {
       CORBA::String_var anURL = GetStudyDocument()->URL();
@@ -618,25 +615,22 @@ VISU::Result_i
     }
 
     std::string aFileName = aPrefix + "_" + GetName();
-    std::string aFilePath = GetFileInfo().filePath().latin1();
+    BEGMSG(MYDEBUG, "aFileName = '"<<aFileName<<"'\n");
 
-    if(theIsMultiFile){
-      CORBA::String_var anURL = GetStudyDocument()->URL();
-      aFilePath = SALOMEDS_Tool::GetNameFromPath(anURL.in()) + aFilePath;
+    std::string aFile = GetFileInfo().filePath().latin1();
+    BEGMSG(MYDEBUG, "aFile = '"<<aFile<<"'\n");
 
-      filesystem::path aPathToCopy = filesystem::path(theURL) / aFileName;
-      filesystem::copy_file(aFilePath, aPathToCopy);
-      if(!filesystem::exists(aPathToCopy))
+    if(theIsMultiFile){
+      std::string aPathToCopy(theURL + aFileName);
+      BEGMSG(MYDEBUG, "aPathToCopy = '"<<aPathToCopy<<"'\n");
+      if(!VISU::CopyFile(aFile, aPathToCopy))
        return false;
     }
 
-    if(MYDEBUG){
-      MESSAGE("Result_i::Save - aFileName  ='"<<aFileName<<"'");
-      MESSAGE("Result_i::Save - aFilePath  ='"<<aFileName<<"'");
-    }
+    if(!theIsMultiFile)
+      theFileNames.push_back(aFileName);
 
-    theFileNames.push_back(aFileName);
-    theFullFileNames.push_back(aFilePath);
+    theFiles.push_back(aFile);
 
     return true;
   }}