]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To finilize persistent for MULTIPR/VISU extension
authorapo <apo@opencascade.com>
Fri, 13 Jul 2007 07:26:25 +0000 (07:26 +0000)
committerapo <apo@opencascade.com>
Fri, 13 Jul 2007 07:26:25 +0000 (07:26 +0000)
src/VISU_I/VISU_Gen_i.cc
src/VISU_I/VISU_MultiResult_i.cc
src/VISU_I/VISU_MultiResult_i.hh
src/VISU_I/VISU_Prs3d_i.cc
src/VISU_I/VISU_PrsObject_i.cc
src/VISU_I/VISU_PrsObject_i.hh
src/VISU_I/VISU_Result_i.cc
src/VISU_I/VISU_Result_i.hh

index 36438e8f7cae91c2e8ebe9e4ca4306e90d47ba73..487bbd48409e5b78ca434e0de5e05e549eb43957 100644 (file)
@@ -88,7 +88,7 @@ namespace filesystem = boost::filesystem;
 
 
 #ifdef _DEBUG_
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
 #else
 static int MYDEBUG = 0;
 #endif
@@ -427,7 +427,7 @@ namespace VISU
     std::string anURL = theIsMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
     if(MYDEBUG) MESSAGE("VISU_Gen_i::SaveASCII - "<<anURL);
 
-   Result_i::TFileNames aFileNames;
+    Result_i::TFileNames aFileNames;
     Result_i::TFileNames aFiles;
 
     SALOMEDS::Study_var aStudy = theComponent->GetStudy();
index e89e5d81fbd94d4e46b97595243396d8670d7ddc..e4832781ec48f60abd50adcfbe9d7f052856c017 100644 (file)
@@ -43,7 +43,7 @@
 #include <strstream>
 
 #ifdef _DEBUG_
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
 static int MYTIMEDEBUG = 0;
 #else
 static int MYDEBUG = 0;
@@ -564,7 +564,8 @@ VISU::MultiResult_i
     myMultiprObj.create(theFileName);
     if (myMultiprObj.isValidDistributedMEDFile()) {
       aTargetFileName = myMultiprObj.getSequentialMEDFilename();
-      SetFileName(aFileInfo.filePath().latin1());
+      SetInitFileName(aFileInfo.filePath().latin1());
+      SetName(VISU::GenerateName(aFileInfo.fileName()).latin1(), false);
       myIsBuildParts = true;
     }
   }
@@ -606,7 +607,7 @@ VISU::MultiResult_i
   }
 
   std::string aBase, aSuffix;
-  SplitName(GetName(), aBase, aSuffix);
+  SplitName(GetFileName(), aBase, aSuffix);
   BEGMSG(MYDEBUG, "aBase = '"<<aBase<<"'; aSuffix = '"<<aSuffix<<"'\n");
 
   aPrefix = aPrefix + "_" + aBase;
@@ -632,15 +633,16 @@ VISU::MultiResult_i
     aFileName = aFileName + aSuffix;
     INITMSG(MYDEBUG, "aFileName = '"<<aFileName<<"'\n");
 
-    std::string aPathToCopy(theURL + aFileName);
-    BEGMSG(MYDEBUG, "aPathToCopy = '"<<aPathToCopy<<"'\n");
-
-    if(theIsMultiFile)
+    if(theIsMultiFile || theIsASCII){
+      std::string aPathToCopy(theURL + aFileName);
+      BEGMSG(MYDEBUG, "aPathToCopy = '"<<aPathToCopy<<"'\n");
+      
       if(!VISU::CopyFile(aFile, aPathToCopy))
        return false;
 
-    if(theIsMultiFile || theIsASCII)
-      HDFascii::ConvertFromHDFToASCII(const_cast<char*>(aPathToCopy.c_str()), true);
+      if(theIsASCII)
+       HDFascii::ConvertFromHDFToASCII(const_cast<char*>(aPathToCopy.c_str()), true);
+    }
 
     theFileNames.push_back(aFileName);
     theFiles.push_back(aFile);
@@ -650,6 +652,18 @@ VISU::MultiResult_i
 }
 
 
+//---------------------------------------------------------------
+CORBA::Boolean 
+VISU::MultiResult_i
+::CanCopy(SALOMEDS::SObject_ptr theObject) 
+{
+  if(!myIsPartsDone)
+    return Result_i::CanCopy(theObject);
+
+  return false;
+}
+
+
 //---------------------------------------------------------------
 void 
 VISU::MultiResult_i
@@ -679,7 +693,7 @@ VISU::MultiResult_i
 
   {
     std::string aBase, aSuffix;
-    SplitName(GetName(), aBase, aSuffix);
+    SplitName(GetFileName(), aBase, aSuffix);
     INITMSG(MYDEBUG, "aBase = '"<<aBase<<"'; aSuffix = '"<<aSuffix<<"'\n");
 
     QFileInfo aFileInfo(myMultiprObj.getSequentialMEDFilename());
@@ -734,7 +748,7 @@ VISU::MultiResult_i
   }
   
   std::string aBase, aSuffix;
-  SplitName(GetName(), aBase, aSuffix);
+  SplitName(GetFileName(), aBase, aSuffix);
   INITMSGA(MYDEBUG, 0, "aBase = '"<<aBase<<"'; aSuffix = '"<<aSuffix<<"'\n");
 
   std::string aSourceFileName = GetFileInfo().absFilePath().latin1();
@@ -1072,7 +1086,7 @@ VISU::MultiResult_i
   TRepresentation2Input::iterator anIter = myRepresentation2Input.find(aRepresentationKey);
   if(anIter == myRepresentation2Input.end()){
     INITMSG(MYDEBUG, "MultiResult_i::GetInput - this = "<<this<<"\n");
-    std::string aFileName = SALOMEDS_Tool::GetTmpDir() + "tmp.med";
+    std::string aFileName = SALOMEDS_Tool::GetTmpDir() + "multipr_merge.med";
     if(MYDEBUG){
       INITMSG(MYDEBUG, "aFileName = '"<<aFileName<<"':\n");
       TFileNames::const_iterator anIter = aFileNames.begin();
index beec3bb6fe2f6d575182ebda23f879c85826fa6b..18598c861ba61137df4d359dc3a5f5c720722979 100644 (file)
@@ -158,6 +158,10 @@ namespace VISU
         TFileNames& theFileNames,
         TFileNames& theFiles);
 
+    virtual 
+    CORBA::Boolean 
+    CanCopy(SALOMEDS::SObject_ptr theObject);
+
     virtual
     void
     ToStream(std::ostringstream& theStr);
index 3665a1e14e1a2d56ba84c5ebcdb8b95ca0b664d9..e80b960a5149bf26d72f555b9d3acb86b47916df 100644 (file)
@@ -40,7 +40,7 @@
 #include <boost/bind.hpp>
 
 #ifdef _DEBUG_
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
 #else
 static int MYDEBUG = 0;
 #endif
index 2ebbadd5f93b4534dc3b03d9afcede1c846d621c..a87ca5e855b5b81855bfa99bf0e505d9ce050305 100644 (file)
@@ -68,7 +68,7 @@ VISU::RemovableObject_i
 
 
 //---------------------------------------------------------------
-const std::string&
+std::string
 VISU::RemovableObject_i
 ::GetName() const 
 { 
@@ -77,7 +77,7 @@ VISU::RemovableObject_i
 
 
 //---------------------------------------------------------------
-const SALOMEDS::Study_var& 
+SALOMEDS::Study_var
 VISU::RemovableObject_i
 ::GetStudyDocument() const 
 { 
index de524352fd638dbfc3182d84e4020ff596e0c63d..3fe235541cd18578be18a53368a1d62fa4958756 100644 (file)
@@ -41,7 +41,7 @@ namespace VISU
     virtual 
     ~RemovableObject_i();
 
-    const SALOMEDS::Study_var& 
+    SALOMEDS::Study_var
     GetStudyDocument() const;
 
     virtual
@@ -49,7 +49,7 @@ namespace VISU
     GetEntry();
 
     virtual 
-    const std::string&
+    std::string
     GetName() const;
 
     virtual 
index 86be74bb98f07655f90f317e35139776ccf8f9c5..08b9fab4c4476d0f9d8535346bc0a40393ca65d3 100644 (file)
@@ -61,7 +61,7 @@
 #include <Bnd_Box.hxx>
 
 #ifdef _DEBUG_
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
 #else
 static int MYDEBUG = 0;
 #endif
@@ -385,13 +385,13 @@ VISU::Result_i
   aComment.sprintf("myComment=%s;myFileName=%s;myInitFileName=%s",
                   GetComment(),
                   myFileInfo.filePath().latin1(),
-                  GetFileName().c_str()); // Restoring of Python dump
+                  GetInitFileName().c_str()); // Restoring of Python dump
   std::string aResultEntry = 
     CreateAttributes(myStudy,
                     aSComponentEntry.in(),
                     NO_ICON,
                     anIOR.in(),
-                    myName,
+                    GetName(),
                     NO_PERFSITENT_REF,
                     aComment.latin1(),
                     true);
@@ -499,23 +499,23 @@ VISU::Result_i
 {      
   try {
     myFileInfo.setFile(theFileName);
-    if(!myIsBuildParts)
-      SetFileName(myFileInfo.filePath().latin1());
-    myName = VISU::GenerateName(myFileInfo.fileName()).latin1();
+    myFileName = myFileInfo.fileName().latin1();
+
+    if(!myIsBuildParts){
+      SetInitFileName(myFileInfo.filePath().latin1());
+      SetName(VISU::GenerateName(myFileInfo.fileName()).latin1(), false);
+    }
+
     if(mySourceId == eRestoredFile){
-      std::string aTmpDir(SALOMEDS_Tool::GetTmpDir());
-      static QString aCommand;
-      aCommand.sprintf(" %s %s", myFileInfo.absFilePath().latin1(), aTmpDir.c_str() );
-      aCommand = QDir::convertSeparators( aCommand );
-      aCommand.prepend( COPY_COMMAND );
-
-      if(system(aCommand.latin1()) == -1){
-       MESSAGE("Create - Can't execute the command :"<<aCommand);
+      QString aTmpDir(SALOMEDS_Tool::GetTmpDir().c_str());
+      QString aSuffix = QString::number(size_t(this));
+      QString aPathToCopy(aTmpDir + myFileInfo.fileName() + ":" + aSuffix);
+      if(!VISU::CopyFile(myFileInfo.absFilePath().latin1(), aPathToCopy.latin1()))
        return NULL;
-      }
-      if(MYDEBUG) MESSAGE("Result_i::Create - aCommand = "<<aCommand);
-      myFileInfo.setFile(QString(aTmpDir.c_str()) + myFileInfo.fileName());
-    }
+
+      myFileInfo.setFile(aPathToCopy);
+      myFileName = myFileInfo.fileName().latin1();
+   }
 
     myInput.reset(CreateConvertor(myFileInfo.absFilePath().latin1()));
 
@@ -548,9 +548,9 @@ VISU::Result_i
 
     string aCompDataType = GetComponentDataType(theMedSObject);
     myFileInfo.setFile(aCompDataType.c_str());
-    SetFileName(aCompDataType);
+    SetInitFileName(aCompDataType);
 
-    myName = VISU::GenerateName("aResult").latin1();
+    myFileName = VISU::GenerateName("aResult").latin1();
 
     return Build(theMedSObject);
   }catch(std::exception& exc){
@@ -577,9 +577,9 @@ VISU::Result_i
 
     string aCompDataType = "MED";
     myFileInfo.setFile(aCompDataType.c_str());
-    SetFileName(aCompDataType);
+    SetInitFileName(aCompDataType);
 
-    myName = VISU::GenerateName("aResult").latin1();
+    myFileName = VISU::GenerateName("aResult").latin1();
 
     CORBA::String_var anIOR = myStudyDocument->ConvertObjectToIOR(theField);
     SALOMEDS::SObject_var aFieldSObject = myStudyDocument->FindObjectIOR(anIOR);
@@ -616,21 +616,22 @@ VISU::Result_i
       aPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
     }
 
-    std::string aFileName = aPrefix + "_" + GetName();
+    std::string aFileName = aPrefix + "_" + GetFileName();
     BEGMSG(MYDEBUG, "aFileName = '"<<aFileName<<"'\n");
 
     std::string aFile = GetFileInfo().filePath().latin1();
     BEGMSG(MYDEBUG, "aFile = '"<<aFile<<"'\n");
 
-    std::string aPathToCopy(theURL + aFileName);
-    BEGMSG(MYDEBUG, "aPathToCopy = '"<<aPathToCopy<<"'\n");
-
-    if(theIsMultiFile || theIsASCII)
+    if(theIsMultiFile || theIsASCII){
+      std::string aPathToCopy(theURL + aFileName);
+      BEGMSG(MYDEBUG, "aPathToCopy = '"<<aPathToCopy<<"'\n");
+      
       if(!VISU::CopyFile(aFile, aPathToCopy))
        return false;
 
-    if(theIsASCII)
-      HDFascii::ConvertFromHDFToASCII(const_cast<char*>(aPathToCopy.c_str()), true);
+      if(theIsASCII)
+       HDFascii::ConvertFromHDFToASCII(const_cast<char*>(aPathToCopy.c_str()), true);
+    }
 
     theFileNames.push_back(aFileName);
     theFiles.push_back(aFile);
@@ -718,9 +719,8 @@ VISU::Result_i
   myIsBuildImmediately = true;
 
   try {
-    myName = VISU::Storable::FindValue(theMap, "myName").latin1();
-    VISU::GenerateName(myName); // To register the name in global naming map
-    SetFileName(VISU::Storable::FindValue(theMap, "myInitFileName").latin1());
+    myFileName = VISU::Storable::FindValue(theMap, "myName").latin1();
+    SetInitFileName(VISU::Storable::FindValue(theMap, "myInitFileName").latin1());
     
     SALOMEDS::SObject_var aRefSObj, aTargetRefSObj;
     if (theSObject->FindSubObject(1, aRefSObj) && aRefSObj->ReferencedObject(aTargetRefSObj)) {
@@ -761,7 +761,7 @@ VISU::Result_i
        aStudyPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
       }
       if (!myFileInfo.isFile()) {
-       string aFileName = thePrefix + aStudyPrefix + "_" + myName;
+       std::string aFileName = thePrefix + aStudyPrefix + "_" + myFileName;
        myFileInfo.setFile(aFileName.c_str());
       }
       if(MYDEBUG)
@@ -832,7 +832,7 @@ VISU::Result_i
       aComment.sprintf("myComment=%s;myFileName=%s;myInitFileName=%s",
                       GetComment(), 
                       myFileInfo.filePath().latin1(),
-                      GetFileName().c_str()); // Restoring of Python dump
+                      GetInitFileName().c_str()); // Restoring of Python dump
       SALOMEDS::GenericAttribute_var anAttr;
       if (!theSObject->FindAttribute(anAttr, "AttributeString"))
        throw std::runtime_error("Build - There is no AttributeString for the SObject !!!");
@@ -1292,9 +1292,8 @@ void
 VISU::Result_i
 ::ToStream(std::ostringstream& theStr)
 {
-  if(MYDEBUG) MESSAGE(GetComment());
-  Storable::DataToStream(theStr,"myName", myName.c_str());
-  Storable::DataToStream(theStr,"myInitFileName", GetFileName().c_str());
+  Storable::DataToStream(theStr,"myName", GetFileName().c_str());
+  Storable::DataToStream(theStr,"myInitFileName", GetInitFileName().c_str());
   Storable::DataToStream(theStr,"myCreationId", myCreationId);
   Storable::DataToStream(theStr,"myIsBuildFields", myIsFieldsDone);
   Storable::DataToStream(theStr,"myIsBuildMinMax", myIsMinMaxDone);
@@ -1303,9 +1302,9 @@ VISU::Result_i
 
 
 //---------------------------------------------------------------
-const std::string&
+std::string
 VISU::Result_i
-::GetFileName() const
+::GetInitFileName() const
 {
   return myInitFileName;
 }
@@ -1313,29 +1312,32 @@ VISU::Result_i
 
 void 
 VISU::Result_i
-::SetFileName(const std::string& theFileName)
+::SetInitFileName(const std::string& theFileName)
 {
   myInitFileName = theFileName;
 }
 
 
 //---------------------------------------------------------------
-const std::string&
+std::string
 VISU::Result_i
-::GetName() const
+::GetFileName() const
 {
-  return myName;
+  if(GetSourceId() == eFile)
+    return QString("%1:%2").arg(myFileName.c_str()).arg(size_t(this)).latin1();
+  
+  return myFileName;
 }
 
 
-const QFileInfo&
+QFileInfo
 VISU::Result_i
 ::GetFileInfo() const
 {
   return myFileInfo;
 }
 
-const VISU::Result_i::ECreationId&
+VISU::Result_i::ECreationId
 VISU::Result_i
 ::GetCreationId() const
 {
@@ -1343,7 +1345,7 @@ VISU::Result_i
 }
 
 
-const VISU::Result_i::ESourceId&
+VISU::Result_i::ESourceId
 VISU::Result_i
 ::GetSourceId() const
 {
@@ -1360,14 +1362,14 @@ VISU::Result_i
   return anEntry.in();
 }
 
-const SALOMEDS::SObject_var& 
+SALOMEDS::SObject_var
 VISU::Result_i
 ::GetSObject() const 
 { 
   return mySObject;
 }
 
-const SALOMEDS::Study_var& 
+SALOMEDS::Study_var
 VISU::Result_i
 ::GetStudyDocument() const 
 { 
@@ -1381,7 +1383,7 @@ VISU::Result_i
   return myStudy;
 }
 
-const SALOMEDS::SComponent_var& 
+SALOMEDS::SComponent_var
 VISU::Result_i
 ::GetSComponent() const
 {
index b0131f861c0a17eed9da2f1e95eebebe1d1d6bfe..17d35e2b0fdf12d6647d8b2d6117bfd8be78ba46 100644 (file)
@@ -194,7 +194,7 @@ namespace VISU
     ECreationId myCreationId;
 
     PInput myInput;
-    std::string myName;
+    std::string myFileName;
     QFileInfo myFileInfo;
     std::string myInitFileName;
 
@@ -225,7 +225,7 @@ namespace VISU
     Storable* 
     BuildAll(SALOMEDS::SObject_ptr theSObject) ;
 
-    const ESourceId& 
+    ESourceId
     GetSourceId() const;
        
     _PTR(Study) myStudy;
@@ -323,20 +323,21 @@ namespace VISU
             CORBA::Long theTimeStampNumber = -1);
 
     virtual
-    const std::string& 
-    GetFileName() const;
+    std::string
+    GetInitFileName() const;
 
     virtual
     void 
-    SetFileName(const std::string& theFileName);
+    SetInitFileName(const std::string& theFileName);
 
-    const std::string& 
-    GetName() const;
+    virtual
+    std::string
+    GetFileName() const;
 
-    const QFileInfo& 
+    QFileInfo
     GetFileInfo() const;
 
-    const ECreationId& 
+    ECreationId
     GetCreationId() const;
        
   private:
@@ -348,16 +349,16 @@ namespace VISU
     std::string
     GetEntry();
 
-    const SALOMEDS::SObject_var& 
+    SALOMEDS::SObject_var
     GetSObject() const;
 
-    const SALOMEDS::Study_var& 
+    SALOMEDS::Study_var
     GetStudyDocument() const;
 
     _PTR(Study) 
     GetStudy() const;
 
-    const SALOMEDS::SComponent_var& 
+    SALOMEDS::SComponent_var
     GetSComponent() const;
 
     std::string
@@ -381,7 +382,8 @@ namespace VISU
   };
 
   //! To find Result object as published on father of the given SObject
-  VISU_I_EXPORT Result_var 
+  VISU_I_EXPORT
+  Result_var 
   FindResult(SALOMEDS::SObject_ptr theSObject);
 
   //! To get VISU::Result object published on the given SALOMEDS::SObject