]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To improve naming of stored files
authorapo <apo@opencascade.com>
Thu, 19 Jul 2007 11:16:02 +0000 (11:16 +0000)
committerapo <apo@opencascade.com>
Thu, 19 Jul 2007 11:16:02 +0000 (11:16 +0000)
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
src/VISU_I/VISU_Result_i.hh

index 3a2ee40550777291bd77a98620f94a0dfa57de14..8f211473ef48228efc5450b4d1dcd5bc8ef7e430 100644 (file)
@@ -683,7 +683,7 @@ VISU::MultiResult_i
 
   {
     std::string aBase, aSuffix;
-    SplitName(GetFileName(), aBase, aSuffix);
+    VISU::SplitName(GetFileName(), aBase, aSuffix);
     INITMSG(MYDEBUG, "aBase = '"<<aBase<<"'; aSuffix = '"<<aSuffix<<"'\n");
 
     QFileInfo aFileInfo(myMultiprObj.getSequentialMEDFilename());
index fd2be078ec2db41969c9dff36be311511b24aaa4..9f8d37d046f45aed3ec419bd2dfc4de267fab611 100644 (file)
@@ -155,7 +155,7 @@ namespace VISU
            std::string& theSuffix,
            char theDelimeter)
   {
-    size_t aPosition = theName.find(theDelimeter);
+    size_t aPosition = theName.rfind(theDelimeter);
     if(aPosition == std::string::npos){
       theBase = theName;
       theSuffix = "";
@@ -168,9 +168,21 @@ namespace VISU
   }
   
 
+  //----------------------------------------------------------------------------
+  std::string
+  MakeFileName(const std::string& theName,
+              const void* thePointer)
+  {
+    std::ostringstream aStream;    
+    aStream<<theName<<":"<<thePointer;
+    return aStream.str();
+  }
+  
+
   //----------------------------------------------------------------------------
   QString 
-  GenerateFieldName (const string& theName, const string& theUnits)
+  GenerateFieldName(const std::string& theName, 
+                   const std::string& theUnits)
   {
     QString aName;
     const string tmp (theUnits.size(),' ');
@@ -186,8 +198,8 @@ namespace VISU
   //----------------------------------------------------------------------------
   void
   CreateReference(_PTR(Study) theStudyDocument,
-                 const string& theFatherEntry, 
-                 const string& theRefEntry)
+                 const std::string& theFatherEntry, 
+                 const std::string& theRefEntry)
   {
     _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
     _PTR(SObject) aFather = theStudyDocument->FindObjectID(theFatherEntry);
@@ -644,6 +656,9 @@ namespace VISU
   {
     QFileInfo aSourceFileInfo(theSourceFileName);
     QFileInfo aTargetFileInfo(theTargetFileName);
+    if(aSourceFileInfo.absFilePath() == aTargetFileInfo.absFilePath())
+      return true;
+
     QString aCommand;
     aCommand.sprintf("%s %s %s",
                     COPY_COMMAND,
index f6807a7b9a694dbd47bbe31bb38ef525b3d87314..357dfd498b4e5d97c9be6d358078b0175f0c29bf 100644 (file)
@@ -82,6 +82,12 @@ namespace VISU
            char theDelimeter = ':');
 
 
+  //----------------------------------------------------------------------------
+  std::string
+  MakeFileName(const std::string& theName,
+              const void* thePointer);
+    
+    
   //----------------------------------------------------------------------------
   void
   BuildEntities(Result_i* theResult,
index 08b9fab4c4476d0f9d8535346bc0a40393ca65d3..12fad523931381e41e151f353758347bde2449c3 100644 (file)
@@ -508,8 +508,8 @@ VISU::Result_i
 
     if(mySourceId == eRestoredFile){
       QString aTmpDir(SALOMEDS_Tool::GetTmpDir().c_str());
-      QString aSuffix = QString::number(size_t(this));
-      QString aPathToCopy(aTmpDir + myFileInfo.fileName() + ":" + aSuffix);
+      std::string aFileName = VISU::MakeFileName(myFileInfo.fileName().latin1(), this);
+      QString aPathToCopy(aTmpDir + aFileName.c_str());
       if(!VISU::CopyFile(myFileInfo.absFilePath().latin1(), aPathToCopy.latin1()))
        return NULL;
 
@@ -809,7 +809,7 @@ VISU::Result_i
       } else if (!theIsMultiFile) {
        mySourceId = eRestoredFile;
       } else {
-       mySourceId = eFile;
+       mySourceId = eSavedFile;
       }
       if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - mySourceId = " << mySourceId);
       myInput.reset(CreateConvertor(myFileInfo.filePath().latin1()));
@@ -1324,8 +1324,8 @@ VISU::Result_i
 ::GetFileName() const
 {
   if(GetSourceId() == eFile)
-    return QString("%1:%2").arg(myFileName.c_str()).arg(size_t(this)).latin1();
-  
+    return VISU::MakeFileName(myFileName, this);
+
   return myFileName;
 }
 
@@ -1405,9 +1405,8 @@ VISU::Result_i
 ::~Result_i()
 {
   MESSAGE("Result_i::~Result_i() - this = "<<this);
-  if (GetSourceId() == eRestoredFile) {
+  if (GetSourceId() == eRestoredFile) 
     VISU::RemoveFile(myFileInfo.filePath().latin1());
-  }
 }
 
 //=======================================================================
index 17d35e2b0fdf12d6647d8b2d6117bfd8be78ba46..40eff416ff9e7d4ce1714fb7e8f9c6e18821d9bc 100644 (file)
@@ -55,8 +55,20 @@ namespace VISU
     Result_i(const Result_i &);
 
   public:
-    enum ESourceId {eRestoredComponent = -2, eRestoredFile = -1, eFile = 1, eComponent = 2};
-    enum ECreationId {eImportFile, eCopyAndImportFile, eImportMed, eImportMedField};
+    enum ESourceId {
+      eRestoredComponent = -2, 
+      eRestoredFile = -1,  
+      eSavedFile = 0, 
+      eFile = 1, 
+      eComponent = 2
+    };
+
+    enum ECreationId {
+      eImportFile, 
+      eCopyAndImportFile, 
+      eImportMed, 
+      eImportMedField
+    };
 
     static
     Result_i*