]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To customize persistent functionality
authorapo <apo@opencascade.com>
Mon, 2 Jul 2007 12:37:39 +0000 (12:37 +0000)
committerapo <apo@opencascade.com>
Mon, 2 Jul 2007 12:37:39 +0000 (12:37 +0000)
16 files changed:
src/VISU_I/VISUConfig.cc
src/VISU_I/VISUConfig.hh
src/VISU_I/VISU_ColoredPrs3dCache_i.cc
src/VISU_I/VISU_ColoredPrs3dCache_i.hh
src/VISU_I/VISU_ColoredPrs3dHolder_i.cc
src/VISU_I/VISU_ColoredPrs3dHolder_i.hh
src/VISU_I/VISU_ColoredPrs3d_i.hh
src/VISU_I/VISU_Gen_i.cc
src/VISU_I/VISU_Mesh_i.cc
src/VISU_I/VISU_Mesh_i.hh
src/VISU_I/VISU_MultiResult_i.cc
src/VISU_I/VISU_MultiResult_i.hh
src/VISU_I/VISU_Result_i.cc
src/VISU_I/VISU_Result_i.hh
src/VISU_I/VISU_Table_i.cc
src/VISU_I/VISU_Table_i.hh

index bcde9828c47e2c44098f4b942eee6f5af307fc7b..03eb570918e10343fca02fb5409e9eefb48f439e 100644 (file)
@@ -39,7 +39,7 @@
 
 #include <qregexp.h>
 
-using namespace std;
+#include <fstream>
 
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
@@ -47,7 +47,9 @@ static int MYDEBUG = 0;
 static int MYDEBUG = 0;
 #endif
 
-namespace VISU{
+
+namespace VISU
+{
 
   SUIT_Session*
   GetSession()
@@ -103,7 +105,7 @@ namespace VISU{
 
 
   //---------------------------------------------------------------------------
-  static Storable::TCallbackMap VisuStoreMap;
+  Storable::TStorableEngineMap Storable::myStorableEngineMap;
 
   std::string 
   Storable
@@ -118,16 +120,74 @@ namespace VISU{
   }
 
 
+  //---------------------------------------------------------------
+  CORBA::Boolean 
+  Storable
+  ::CanCopy(SALOMEDS::SObject_ptr theObject) 
+  {
+    return false;
+  }
+
+
+  //---------------------------------------------------------------
+  bool 
+  Storable
+  ::CopyFrom(SALOMEDS::SObject_ptr theObject, 
+            CORBA::Long& theObjectID,
+            const std::string& theTmpDir,
+            TFileNames& theFileNames)
+  {
+    TFileName aFileName("copy_persistent");
+    std::string aCopyPersist =  theTmpDir + aFileName;
+    std::ofstream anOutputFileStream(aCopyPersist.c_str(), ios::out);
+    anOutputFileStream<<ToString()<<endl;
+
+    theFileNames.push_back(aFileName);
+    theObjectID = 1;
+
+    return true;
+  }
+
+
   //---------------------------------------------------------------
   void 
   Storable
-  ::Registry(const std::string& theComment, 
-            TStorableEngine theEngine)
+  ::RegistryStorableEngine(const std::string& theComment, 
+                          TStorableEngine theEngine)
   {
-    if(!VisuStoreMap.insert(TCallbackMap::value_type(theComment,theEngine)).second){
-      if(MYDEBUG) MESSAGE("Storable::Registry >> dupliacte registring !!!");
+    if(!myStorableEngineMap.insert(TStorableEngineMap::value_type(theComment, theEngine)).second)
       throw std::logic_error("Storable::Registry >> dupliacte registring !!!");
+  }
+
+
+  //---------------------------------------------------------------
+  Storable* 
+  Storable
+  ::Create(SALOMEDS::SObject_ptr theSObject,
+          const std::string& theLocalPersistentID, 
+          const std::string& thePrefix,
+          CORBA::Boolean theIsMultiFile)
+  {
+    try{
+      QString aString( CorrectPersistentString( theLocalPersistentID ) );
+      TRestoringMap aRestoringMap;
+      StringToMap(aString, aRestoringMap);
+      bool anIsExists;
+      QString aComment = VISU::Storable::FindValue(aRestoringMap, "myComment", &anIsExists);
+      if ( anIsExists ) {
+       TStorableEngineMap::const_iterator anIter = myStorableEngineMap.find(aComment.latin1());
+       if(MYDEBUG) MESSAGE("Storable::Create - "<<aComment.latin1()<<" "<<(anIter != myStorableEngineMap.end()));
+       if(anIter == myStorableEngineMap.end()) 
+         return NULL;
+       TStorableEngine aStorableEngine = anIter->second;
+       return aStorableEngine(theSObject, aRestoringMap, thePrefix, theIsMultiFile);
+      }
+    }catch(std::exception& exc){
+      INFOS("Follow exception was occured :\n"<<exc.what());
+    }catch(...){
+      INFOS("Unknown exception was occured!");
     }
+    return NULL;
   }
 
 
@@ -394,36 +454,6 @@ namespace VISU{
   }
 
 
-  //---------------------------------------------------------------
-  Storable* 
-  Storable
-  ::Create(SALOMEDS::SObject_ptr theSObject,
-          const std::string& thePrefix, 
-          const std::string& theLocalPersistentID)
-  {
-    try{
-      QString aString( CorrectPersistentString( theLocalPersistentID ) );
-      TRestoringMap aRestoringMap;
-      StringToMap(aString, aRestoringMap);
-      bool anIsExists;
-      QString aComment = VISU::Storable::FindValue(aRestoringMap, "myComment", &anIsExists);
-      if ( anIsExists ) {
-       TCallbackMap::const_iterator anIter = VisuStoreMap.find(aComment.latin1());
-       if(MYDEBUG) MESSAGE("Storable::Create - "<<aComment.latin1()<<" "<<(anIter != VisuStoreMap.end()));
-       if(anIter == VisuStoreMap.end()) 
-         return NULL;
-       TStorableEngine aStorableEngine = anIter->second;
-       return aStorableEngine(theSObject, thePrefix, aRestoringMap);
-      }
-    }catch(std::exception& exc){
-      INFOS("Follow exception was occured :\n"<<exc.what());
-    }catch(...){
-      INFOS("Unknown exception was occured!");
-    }
-    return NULL;
-  }
-
-
   //---------------------------------------------------------------
   QString
   Storable
@@ -465,7 +495,8 @@ namespace VISU{
   PortableServer::ServantBase_var
   GetServant(CORBA::Object_ptr theObject)
   {
-    if(CORBA::is_nil(theObject))  return NULL;
+    if(CORBA::is_nil(theObject))  
+      return NULL;
     try{
       PortableServer::POA_ptr aPOA = Base_i::GetPOA();
       PortableServer::Servant aServant = aPOA->reference_to_servant(theObject);
index 58206b2a31d6f63169f5b4af66cca3ebab2b97ba..f83ec1c0a183aa32b2056bd8a5819722424993e7 100644 (file)
@@ -119,8 +119,6 @@ namespace VISU
   //===========================================================================
   class VISU_I_EXPORT Storable : public virtual Base_i 
   {
-  protected:
-    virtual void ToStream(std::ostringstream& theStr) = 0;
   public:
     std::string
     ToString();
@@ -129,13 +127,31 @@ namespace VISU
     const char* 
     GetComment() const = 0;
 
+
+    //---------------------------------------------------------------
     typedef std::map<std::string, QString> TRestoringMap;
 
     typedef Storable* (*TStorableEngine)(SALOMEDS::SObject_ptr theSObject,
+                                        const TRestoringMap& theMap,
                                         const std::string& thePrefix,
-                                        const TRestoringMap& theMap);
-    typedef std::map<std::string,TStorableEngine> TCallbackMap;
+                                        CORBA::Boolean theIsMultiFile);
+
+    typedef std::map<std::string, TStorableEngine> TStorableEngineMap;
 
+    static 
+    void
+    RegistryStorableEngine(const std::string& theComment, 
+                          TStorableEngine theEngine);
+
+    static
+    Storable* 
+    Create(SALOMEDS::SObject_ptr theSObject,
+          const std::string& theLocalPersistentID, 
+          const std::string& thePrefix,
+          CORBA::Boolean theIsMultiFile);
+
+
+    //---------------------------------------------------------------
     static 
     VISU::VISUType
     Comment2Type(const std::string& theComment);
@@ -163,17 +179,6 @@ namespace VISU
              const TRestoringMap& theRestoringMap, 
              int IsAllLevels = true);
   
-    static 
-    void
-    Registry(const std::string& theComment, 
-            TStorableEngine theEngine);
-
-    static
-    Storable* 
-    Create(SALOMEDS::SObject_ptr, 
-          const std::string& thePrefix, 
-          const std::string& theString);
-
     static 
     QString 
     FindValue(const TRestoringMap& theMap, 
@@ -216,13 +221,34 @@ namespace VISU
     DataToStream(std::ostringstream& theStr, 
                 const QString& theName, 
                 const double theVal);
+
+    //---------------------------------------------------------------
+    virtual 
+    CORBA::Boolean 
+    CanCopy(SALOMEDS::SObject_ptr theObject);
+
+    typedef std::string TFileName;
+    typedef std::vector<TFileName> TFileNames;
+
+    virtual 
+    bool 
+    CopyFrom(SALOMEDS::SObject_ptr theObject, 
+            CORBA::Long& theObjectID,
+            const std::string& theTmpDir,
+            TFileNames& theFileNames);
+
+
+    //---------------------------------------------------------------
+  protected:
+    virtual 
+    void 
+    ToStream(std::ostringstream& theStr) = 0;
+
+  private:
+    static TStorableEngineMap myStorableEngineMap;
   };
 
   //===========================================================================
-  VISU_I_EXPORT 
-  const CORBA::Boolean 
-  IsMultifile();
-
   VISU_I_EXPORT
   QString
   GenerateName(const std::string& theFmt, int theId);
index 2485fe3ba50e3befa4430895abf64bbac2c92b10..595fd30a7822c8d11fc386f6a3156b84e6944db4 100644 (file)
@@ -806,23 +806,23 @@ VISU::ColoredPrs3dCache_i
 VISU::Storable*
 VISU::ColoredPrs3dCache_i
 ::Restore(SALOMEDS::SObject_ptr theSObject,
-         const Storable::TRestoringMap& theMap,
-         const string& thePrefix)
+         const Storable::TRestoringMap& theMap)
 {
   SetMemoryMode( (VISU::ColoredPrs3dCache::MemoryMode)VISU::Storable::FindValue( theMap, "myMemoryMode" ).toInt() );
   SetLimitedMemory( VISU::Storable::FindValue( theMap, "myLimitedMemory" ).toInt() );
-
+  
   return this;
 }
 
 //---------------------------------------------------------------
 VISU::Storable*
 VISU::ColoredPrs3dCache_i
-::Restore(SALOMEDS::SObject_ptr theSObject,
-         const string& thePrefix,
-         const Storable::TRestoringMap& theMap)
+::StorableEngine(SALOMEDS::SObject_ptr theSObject,
+                const Storable::TRestoringMap& theMap,
+                const std::string& thePrefix,
+                CORBA::Boolean theIsMultiFile)
 {
   SALOMEDS::Study_var aStudy = theSObject->GetStudy();
   VISU::ColoredPrs3dCache_i* aCache = new VISU::ColoredPrs3dCache_i(aStudy, false);
-  return aCache->Restore(theSObject,theMap,thePrefix);
+  return aCache->Restore(theSObject, theMap);
 }
index 56ab4a22005ef6fe193a3c27c0d56dc2f2bc0ce1..ead208074d4678cd5cc7cef1a1b6cdd7829908e4 100644 (file)
@@ -189,14 +189,14 @@ namespace VISU
     virtual
     Storable*
     Restore(SALOMEDS::SObject_ptr theSObject,
-           const Storable::TRestoringMap& theMap,
-           const std::string& thePrefix);
+           const Storable::TRestoringMap& theMap);
 
     static
     Storable*
-    Restore(SALOMEDS::SObject_ptr theSObject,
-           const std::string& thePrefix,
-           const Storable::TRestoringMap& theMap);
+    StorableEngine(SALOMEDS::SObject_ptr theSObject,
+                  const Storable::TRestoringMap& theMap,
+                  const std::string& thePrefix,
+                  CORBA::Boolean theIsMultiFile);
 
     //----------------------------------------------------------------------------
     //! Finds or creates instance of the ColoredPrs3dCache in the given SALOMEDS::Study
index 1adcba4db6b22416356ee5e7b050ca7c0454637c..9441e5431354aaedfdce305aa271531639feb0ac 100644 (file)
@@ -240,9 +240,10 @@ VISU::ColoredPrs3dHolder_i
 //---------------------------------------------------------------
 VISU::Storable*
 VISU::ColoredPrs3dHolder_i
-::Restore(SALOMEDS::SObject_ptr theSObject,
-         const string& thePrefix,
-         const Storable::TRestoringMap& theMap)
+::StorableEngine(SALOMEDS::SObject_ptr theSObject,
+                const Storable::TRestoringMap& theMap,
+                const std::string& thePrefix,
+                CORBA::Boolean theIsMultiFile)
 {
   using namespace VISU;
   SALOMEDS::Study_var aStudy = theSObject->GetStudy();
index bdf2c2da15d2d6a18c6987e2f93a1ee8b09ed339..840d537e459a190d94a7d2fbd1d2484a059876d2 100644 (file)
@@ -125,9 +125,10 @@ namespace VISU
 
     static
     Storable*
-    Restore(SALOMEDS::SObject_ptr theSObject,
-           const std::string& thePrefix,
-           const Storable::TRestoringMap& theMap);
+    StorableEngine(SALOMEDS::SObject_ptr theSObject,
+                  const Storable::TRestoringMap& theMap,
+                  const std::string& thePrefix,
+                  CORBA::Boolean theIsMultiFile);
 
     virtual
     QString 
index 3a5d0202f5d8bfc2a6e50baad94193f62812f63d..d1e64283c3233ae76750aa2622d2fe2626628d11 100644 (file)
@@ -513,9 +513,10 @@ namespace VISU
   //----------------------------------------------------------------------------
   template<class TColoredPrs3d>
   Storable* 
-  Restore(SALOMEDS::SObject_ptr theSObject,
-         const std::string& thePrefix,
-         const Storable::TRestoringMap& theMap)
+  StorableEngine(SALOMEDS::SObject_ptr theSObject,
+                const Storable::TRestoringMap& theMap,
+                const std::string& thePrefix,
+                CORBA::Boolean theIsMultiFile)
   {
     TColoredPrs3d* aColoredPrs3d = new TColoredPrs3d(ColoredPrs3d_i::EDoNotPublish);
     return aColoredPrs3d->Restore(theSObject, theMap);
index fe61c34fed1daeac545bf2835b7933c42f6b59ba..c364188fcafb13eb14209d6403edb7796b038600 100644 (file)
@@ -111,7 +111,10 @@ namespace VISU
   static std::string VISU_TMP_DIR;
 
   static CORBA::Boolean myIsMultiFile;
-  const CORBA::Boolean IsMultifile() { return myIsMultiFile;}
+  const CORBA::Boolean IsMultiFile() 
+  { 
+    return myIsMultiFile;
+  }
 
   //----------------------------------------------------------------------------
   _PTR(SComponent) 
@@ -192,23 +195,27 @@ namespace VISU
   void
   RegistryStorable() 
   {
-    Storable::Registry(Result_i::myComment.c_str(),&(Result_i::Restore));
-    Storable::Registry(Mesh_i::myComment.c_str(),&(Mesh_i::Restore));
-    Storable::Registry(ScalarMap_i::myComment.c_str(),&(Restore<ScalarMap_i>));
-    Storable::Registry(GaussPoints_i::myComment.c_str(),&(Restore<GaussPoints_i>));
-    Storable::Registry(DeformedShape_i::myComment.c_str(),&(Restore<DeformedShape_i>));
-    Storable::Registry(CutPlanes_i::myComment.c_str(),&(Restore<CutPlanes_i>));
-    Storable::Registry(CutLines_i::myComment.c_str(),&(Restore<CutLines_i>));
-    Storable::Registry(IsoSurfaces_i::myComment.c_str(),&(Restore<IsoSurfaces_i>));
-    Storable::Registry(StreamLines_i::myComment.c_str(),&(Restore<StreamLines_i>));
-    Storable::Registry(Plot3D_i::myComment.c_str(),&(Restore<Plot3D_i>));
-    Storable::Registry(Vectors_i::myComment.c_str(),&(Restore<Vectors_i>));
-    Storable::Registry(Table_i::myComment.c_str(),&(Table_i::Restore));
-    Storable::Registry(Curve_i::myComment.c_str(),&(Curve_i::Restore));
-    Storable::Registry(Container_i::myComment.c_str(),&(Container_i::Restore));
-    Storable::Registry(ScalarMapOnDeformedShape_i::myComment.c_str(),&(Restore<ScalarMapOnDeformedShape_i>));
-    Storable::Registry(ColoredPrs3dHolder_i::myComment.c_str(),&(ColoredPrs3dHolder_i::Restore));
-    Storable::Registry(ColoredPrs3dCache_i::myComment.c_str(),&(ColoredPrs3dCache_i::Restore));
+    Storable::RegistryStorableEngine(Result_i::myComment.c_str(),&(Result_i::StorableEngine));
+
+    Storable::RegistryStorableEngine(Mesh_i::myComment.c_str(),&(Mesh_i::StorableEngine));
+
+    Storable::RegistryStorableEngine(ScalarMap_i::myComment.c_str(),&(StorableEngine<ScalarMap_i>));
+    Storable::RegistryStorableEngine(GaussPoints_i::myComment.c_str(),&(StorableEngine<GaussPoints_i>));
+    Storable::RegistryStorableEngine(DeformedShape_i::myComment.c_str(),&(StorableEngine<DeformedShape_i>));
+    Storable::RegistryStorableEngine(CutPlanes_i::myComment.c_str(),&(StorableEngine<CutPlanes_i>));
+    Storable::RegistryStorableEngine(CutLines_i::myComment.c_str(),&(StorableEngine<CutLines_i>));
+    Storable::RegistryStorableEngine(IsoSurfaces_i::myComment.c_str(),&(StorableEngine<IsoSurfaces_i>));
+    Storable::RegistryStorableEngine(StreamLines_i::myComment.c_str(),&(StorableEngine<StreamLines_i>));
+    Storable::RegistryStorableEngine(Plot3D_i::myComment.c_str(),&(StorableEngine<Plot3D_i>));
+    Storable::RegistryStorableEngine(Vectors_i::myComment.c_str(),&(StorableEngine<Vectors_i>));
+    Storable::RegistryStorableEngine(ScalarMapOnDeformedShape_i::myComment.c_str(),&(StorableEngine<ScalarMapOnDeformedShape_i>));
+
+    Storable::RegistryStorableEngine(ColoredPrs3dHolder_i::myComment.c_str(),&(ColoredPrs3dHolder_i::StorableEngine));
+    Storable::RegistryStorableEngine(ColoredPrs3dCache_i::myComment.c_str(),&(ColoredPrs3dCache_i::StorableEngine));
+
+    Storable::RegistryStorableEngine(Table_i::myComment.c_str(),&(Table_i::StorableEngine));
+    Storable::RegistryStorableEngine(Curve_i::myComment.c_str(),&(Curve_i::StorableEngine));
+    Storable::RegistryStorableEngine(Container_i::myComment.c_str(),&(Container_i::StorableEngine));
   }
 
 
@@ -296,7 +303,7 @@ namespace VISU
   ::Load(SALOMEDS::SComponent_ptr theComponent,
         const SALOMEDS::TMPFile & theStream,
         const char* theURL,
-        bool theIsMultiFile)
+        CORBA::Boolean theIsMultiFile)
   {
     Mutex mt(myMutex);
     SALOMEDS::Study_var aStudy = theComponent->GetStudy();
@@ -334,15 +341,16 @@ namespace VISU
   char* 
   VISU_Gen_i
   ::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
-                          const char* aLocalPersistentID,
+                          const char* theLocalPersistentID,
                           CORBA::Boolean theIsMultiFile,
                           CORBA::Boolean theIsASCII)
   {
     CORBA::String_var aString("");
-    if(strcmp(aLocalPersistentID,"") != 0) {
-      Mutex mt(myMutex);
-      Storable* aStorable =
-       Storable::Create(theSObject, VISU_TMP_DIR.c_str(), aLocalPersistentID);
+    if(strcmp(theLocalPersistentID,"") != 0) {
+      Storable* aStorable = Storable::Create(theSObject, 
+                                            theLocalPersistentID,
+                                            VISU_TMP_DIR,
+                                            theIsMultiFile);
       if(aStorable != NULL) 
        aString = aStorable->GetID();
     }
@@ -354,45 +362,26 @@ namespace VISU
   SALOMEDS::TMPFile* 
   VISU_Gen_i
   ::Save(SALOMEDS::SComponent_ptr theComponent,
-        const char* theURL,
+        const char* theTmpDir,
         bool theIsMultiFile)
   {
-    Mutex mt(myMutex);
-    string aTmpDir = theURL;
-    if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<<aTmpDir);
+    if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - theTmpDir = '"<<theTmpDir<<"'");
     
     typedef std::vector<std::string> TFileNames;
     TFileNames aFileNames;
-    TFileNames aFiles;
+    TFileNames aFilePathes;
 
     SALOMEDS::Study_var aStudy = theComponent->GetStudy();
     SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theComponent);
     for (; anIter->More(); anIter->Next()) {
-      SALOMEDS::SObject_var gotBranch = anIter->Value();
-      CORBA::Object_var anObj = SObjectToObject(gotBranch);
-      if(CORBA::is_nil(anObj)) continue;
+      SALOMEDS::SObject_var aSObject = anIter->Value();
+      CORBA::Object_var anObj = SObjectToObject(aSObject);
       if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(anObj).in())){
-       switch(aResult->GetCreationId()){
-       case Result_i::eImportFile:
-       case Result_i::eCopyAndImportFile: {
-         const QFileInfo& aFileInfo = aResult->GetFileInfo();
-         const std::string& aName = aResult->GetName();
-         std::string aFileName = std::string("_") + aName;
-         std::string aFile = aFileInfo.filePath().latin1();
-         if(theIsMultiFile){
-           aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()) + aFileName;
-
-           std::ostringstream aStream;
-           aStream<<"cp "<<aFile<<" "<<aTmpDir<<aFileName;
-           std::string aCommand = aStream.str();
-           if(system(aCommand.c_str()) != 0){
-             INFOS("VISU_Gen_i::Save - Cann't execute the command :"<<aCommand);
-             continue;
-           }
-         }
+       std::string aFileName, aFilePath;
+       if(aResult->Save(theComponent, theTmpDir, theIsMultiFile, aFileName, aFilePath)){
          aFileNames.push_back(aFileName);
-         aFiles.push_back(aFile);
-       }}
+         aFilePathes.push_back(aFilePath);
+       }
       }
     }
 
@@ -405,18 +394,18 @@ namespace VISU
        aListOfFileNames[aCounter-1] = aFileNames[aCounter-1].c_str();
     }
 
-    SALOMEDS::ListOfFileNames_var aListOfFiles = new SALOMEDS::ListOfFileNames;
-    aListOfFiles->length(aFiles.size());
-    if(!aFiles.empty()){
+    SALOMEDS::ListOfFileNames_var aListOfFilePathes = new SALOMEDS::ListOfFileNames;
+    aListOfFilePathes->length(aFilePathes.size());
+    if(!aFilePathes.empty()){
       for(int aCounter = aFileNames.size(); aCounter > 0; aCounter--)
-       aListOfFiles[aCounter-1] = aFiles[aCounter-1].c_str();
+       aListOfFilePathes[aCounter-1] = aFilePathes[aCounter-1].c_str();
     }
 
     SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
     if(theIsMultiFile)
-      aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir, aListOfFiles.in(), theIsMultiFile);
+      aStreamFile = SALOMEDS_Tool::PutFilesToStream(theTmpDir, aListOfFilePathes.in(), theIsMultiFile);
     else
-      aStreamFile = SALOMEDS_Tool::PutFilesToStream(aListOfFiles.in(), aListOfFileNames.in());
+      aStreamFile = SALOMEDS_Tool::PutFilesToStream(aListOfFilePathes.in(), aListOfFileNames.in());
 
     return aStreamFile._retn();
   }
@@ -426,48 +415,26 @@ namespace VISU
   SALOMEDS::TMPFile* 
   VISU_Gen_i
   ::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
-             const char* theURL,
+             const char* theTmpDir,
              bool theIsMultiFile)
   {
-    Mutex mt(myMutex);
-    string aDir = theIsMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
-    TCollection_AsciiString aTmpDir (const_cast<char*>(aDir.c_str()));
+    std::string aTmpDir = theIsMultiFile ? theTmpDir : SALOMEDS_Tool::GetTmpDir();
     if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<<aTmpDir);
     int aCounter = 0;
     TColStd_SequenceOfAsciiString aFileNames;
     SALOMEDS::Study_var aStudy = theComponent->GetStudy();
-    SALOMEDS::ChildIterator_var itBig = aStudy->NewChildIterator(theComponent);
-    for (; itBig->More(); itBig->Next()) {
-      SALOMEDS::SObject_var gotBranch = itBig->Value();
+    SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theComponent);
+    for (; anIter->More(); anIter->Next()) {
+      SALOMEDS::SObject_var gotBranch = anIter->Value();
       CORBA::Object_var anObj = SObjectToObject(gotBranch);
-      if(CORBA::is_nil(anObj)) continue;
-      if(Result_i* pResult = dynamic_cast<Result_i*>(GetServant(anObj).in())){
-       switch(pResult->GetCreationId()){
-       case Result_i::eImportFile:
-       case Result_i::eCopyAndImportFile: {
-         const QFileInfo& aFileInfo = pResult->GetFileInfo();
-         QString aPrefix("");
-         if (theIsMultiFile) aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()).c_str();
-         QString aFileName = aPrefix + "_" + (pResult->GetName()).c_str();
-               QString tmpDir = QDir::convertSeparators( QString(aTmpDir.ToCString()) );;
-         static QString aCommand;
-         aCommand.sprintf(" %s %s%s",aFileInfo.filePath().latin1(),tmpDir.latin1(),aFileName.latin1());
-         aCommand = QDir::convertSeparators( aCommand );
-         aCommand.prepend( COPY_COMMAND );
-         
-         if(system(aCommand.latin1())){
-           if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - Can't execute the command :"<<aCommand);
-           continue;
-         }else
-           if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<<aCommand);
-
-         QString studyPath = tmpDir.append(aFileName);
-         TCollection_AsciiString aString((char *)(aFileName.latin1()));
-         
-         HDFascii::ConvertFromHDFToASCII(strdup(studyPath.latin1()), true);
-
+      if(CORBA::is_nil(anObj)) 
+       continue;
+      if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(anObj).in())){
+       std::string aFileName;
+       if(aResult->SaveASCII(theComponent, aTmpDir, theIsMultiFile, aFileName)){
+         TCollection_AsciiString aString(const_cast<char*>(aFileName.c_str()));
          aFileNames.Append(aString);
-       }}
+       }
       }
     }
     SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
@@ -477,9 +444,9 @@ namespace VISU
       aSeq->length(aFileNames.Length());
       for(aCounter = aFileNames.Length(); aCounter > 0; aCounter--)
        aSeq[aCounter-1] = CORBA::string_dup(aFileNames.Value(aCounter).ToCString());
-      aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq.in(), theIsMultiFile);
+      aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir, aSeq.in(), theIsMultiFile);
       if(!theIsMultiFile)
-       SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true);
+       SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeq.in(), true);
     }
     return aStreamFile._retn();
   }
@@ -489,20 +456,16 @@ namespace VISU
   char* 
   VISU_Gen_i
   ::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
-                          const char* IORString,
+                          const char* theIORString,
                           CORBA::Boolean theIsMultiFile,
                           CORBA::Boolean theIsASCII)
   {
-    CORBA::String_var aString(IORString);
-    if(strcmp(IORString,"") != 0){
-      CORBA::ORB_ptr anORB = GetORB();
-      CORBA::Object_var anObj = anORB->string_to_object(aString);
-      if(!CORBA::is_nil(anObj)){
-       if(Storable* pStorable = dynamic_cast<Storable*>(GetServant(anObj).in())){
-         Mutex mt(myMutex);
-         aString = pStorable->ToString().c_str();
-         return aString._retn();
-       }
+    CORBA::String_var aString("");
+    if(strcmp(theIORString, "") != 0){
+      CORBA::Object_var anObj = GetORB()->string_to_object(theIORString);
+      if(Storable* aStorable = dynamic_cast<Storable*>(GetServant(anObj).in())){
+       aString = aStorable->ToString().c_str();
+       return aString._retn();
       }
     }
     return aString._retn();
@@ -1256,32 +1219,10 @@ namespace VISU
   VISU_Gen_i
   ::CanCopy(SALOMEDS::SObject_ptr theObject) 
   {
-    Mutex mt(myMutex);
-    SALOMEDS::GenericAttribute_var anAttr;
-    if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return false;
-    try {
-      SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-      CORBA::String_var aValue = anIOR->Value();
-      if(strcmp(aValue,"") != 0){
-       CORBA::Object_ptr anObj = GetORB()->string_to_object(aValue);
-       if (!CORBA::is_nil(anObj)){
-         Result_var aResultObj = Result::_narrow(anObj);
-         if(!aResultObj->_is_nil()){
-           if(Result_i* pResult = dynamic_cast<Result_i*>(GetServant(aResultObj).in())){
-             switch(pResult->GetCreationId()){
-             case Result_i::eImportFile:
-             case Result_i::eCopyAndImportFile:
-               return true;
-             }
-           }
-         }
-       }
-      }
-    }catch(std::exception& exc){
-      INFOS("Follow exception was occured :\n"<<exc.what());
-    }catch (...){
-      INFOS("Unknown exception was occured!");
-    }
+    CORBA::Object_var anObj = SObjectToObject(theObject);
+    if (Storable* aStorable = dynamic_cast<Storable*>(GetServant(anObj).in()))
+      return aStorable->CanCopy(theObject);
+
     return false;
   }
 
@@ -1289,72 +1230,31 @@ namespace VISU
   //---------------------------------------------------------------
   SALOMEDS::TMPFile* 
   VISU_Gen_i
-  ::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) 
+  ::CopyFrom(SALOMEDS::SObject_ptr theObject, 
+            CORBA::Long& theObjectID) 
   {
-    Mutex mt(myMutex);
     theObjectID = 0;
     SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile;
-    SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
 
-    SALOMEDS::GenericAttribute_var anAttr;
-    if (!theObject->FindAttribute(anAttr,"AttributeIOR")) 
-      return NULL;
-    SALOMEDS::AttributeIOR_var anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
-    CORBA::Object_var aCorbaObj;
-    try {
-      aCorbaObj = GetORB()->string_to_object(anIORAttr->Value());
-    } catch(...) {
+    CORBA::Object_var anObj = SObjectToObject(theObject);
+    if (CORBA::is_nil(anObj)) {
       aStreamFile->length(1);
-      aStreamFile[0] = strdup("E")[0];
-      return aStreamFile._retn();
-    }
-    if (CORBA::is_nil(aCorbaObj)) {
-      return NULL;
-    }
-
-    Storable* pStorable = dynamic_cast<Storable*>(GetServant(aCorbaObj).in());
-    if (!pStorable) {
-      return NULL;
-    }
+      aStreamFile[0] = CORBA::string_dup("E")[0];
+    } else if (Storable* aStorable = dynamic_cast<Storable*>(GetServant(anObj).in())) {
+      std::string aTmpDir = SALOMEDS_Tool::GetTmpDir();
+      Storable::TFileNames aFileNames;
+      bool anIsDone = aStorable->CopyFrom(theObject, theObjectID, aTmpDir, aFileNames);
 
-    string aTmpDir = SALOMEDS_Tool::GetTmpDir();
-    string aCopyPersist =  aTmpDir + "copy_persistent";
-
-    ofstream stmOut2(aCopyPersist.c_str(),ios::out);
-    string aStr = pStorable->ToString().c_str();
-    stmOut2<<aStr<<endl;
-    stmOut2.close();
-
-    if (Result_i* aResultObj = dynamic_cast<Result_i*>(GetServant(aCorbaObj).in())) {
-      string aFileName = string(SALOMEDS_Tool::GetNameFromPath(theObject->GetStudy()->URL())) + "_";
-      if(strlen(aFileName.c_str()) == 1) aFileName="";
-      const QFileInfo& aFileInfo = aResultObj->GetFileInfo();
-      aFileName += aFileInfo.fileName().latin1();
-      static QString aCommand;
-      string aFullFileName =  aTmpDir + aFileName;
-      aCommand.sprintf(" %s %s",aFileInfo.filePath().latin1(), aFullFileName.c_str() );
-      aCommand = QDir::convertSeparators( aCommand );
-      aCommand.prepend( COPY_COMMAND );
-
-      if(system(aCommand.latin1()) == -1) {
-       if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<<aCommand);
-       return NULL;
-      }
-      aSeq->length(2);
-      aSeq[0] = "copy_persistent";
-      aSeq[1] = aFileName.c_str();
-    } else {
-      aSeq->length(1);
-      aSeq[0] = "copy_persistent";
-    }
-
-    aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.c_str(), aSeq.in(), false);
-    SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true);
+      SALOMEDS::ListOfFileNames_var aListOfFileNames = new SALOMEDS::ListOfFileNames;
+      aListOfFileNames->length(aFileNames.size());
+      for(size_t anId = 0; anId < aFileNames.size(); anId++)
+       aListOfFileNames[anId] = aFileNames[anId].c_str();
 
-    // Assign an ID = 1 the the type VISU::Result
-    theObjectID = 1;
+      if(anIsDone)
+       aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir, aListOfFileNames.in(), false);
 
-    SALOMEDS::SComponent_var aSComponent = theObject->GetStudy()->FindComponent("VISU");
+      SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aListOfFileNames.in(), true);
+    }
     return aStreamFile._retn();
   }
 
@@ -1364,10 +1264,10 @@ namespace VISU
   VISU_Gen_i
   ::CanPaste(const char* theComponentName, CORBA::Long theObjectID) {
     // The VISU component can paste only objects copied by VISU component
-    // and with the object type = 1
-    if (strcmp(theComponentName, ComponentDataType()) != 0 || theObjectID != 1)
-      return false;
-    return true;
+    CORBA::String_var aString = ComponentDataType();
+    if (strcmp(theComponentName, aString.in()) == 0 && theObjectID == 1)
+      return true;
+    return false;
   }
 
 
@@ -1376,59 +1276,55 @@ namespace VISU
   VISU_Gen_i
   ::PasteInto(const SALOMEDS::TMPFile& theStream,
              CORBA::Long theObjectID,
-             SALOMEDS::SObject_ptr theObject)
+             SALOMEDS::SObject_ptr theSObject)
   {
-    Mutex mt(myMutex);
-    SALOMEDS::SObject_var aResultSO;
     if (theObjectID != 1)
-      return aResultSO._retn();
-
-    string aTmpDir = SALOMEDS_Tool::GetTmpDir();
-    SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir.c_str(), false);
-
-    ifstream stmIn((aTmpDir + string("copy_persistent")).c_str());
-    stmIn.seekg(0, ios::end);
-    int aLength = stmIn.tellg();
-    stmIn.seekg(0, ios::beg);
-    char* aString = new char[aLength+1];
-    stmIn.read(aString, aLength);
-    stmIn.close();
-    aString[aLength] = 0;
-    myIsMultiFile = false;
-
-    string aFileName(aTmpDir);
-    string aBasicFileName;
-    if(aSeq->length() > 1) {
-      aBasicFileName = aSeq[1].in();
-      aFileName += aBasicFileName;
-    }
+      return SALOMEDS::SObject::_nil();
 
-    SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent();
-    SALOMEDS::Study_var aStudy = theObject->GetStudy();
+    SALOMEDS::SComponent_var aComponent = theSObject->GetFatherComponent();
+    SALOMEDS::Study_var aStudy = theSObject->GetStudy();
     SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
-    CORBA::String_var aComponentID(aComponent->GetID()), aSObjID(theObject->GetID());
-
-    if (strcmp(aComponentID, aSObjID) == 0) //create the new result SObject
-      aResultSO = aStudyBuilder->NewObject(aComponent);
+    CORBA::String_var aComponentID(aComponent->GetID());
+    CORBA::String_var aSObjectID(theSObject->GetID());
+    
+    SALOMEDS::SObject_var aSObject;
+    if (strcmp(aComponentID, aSObjectID) == 0) //create the new result SObject
+      aSObject = aStudyBuilder->NewObject(aComponent);
     else
-      aResultSO = SALOMEDS::SObject::_duplicate(theObject);
-
+      aSObject = SALOMEDS::SObject::_duplicate(theSObject);
+    
+    std::string aTmpDir = SALOMEDS_Tool::GetTmpDir();
+    SALOMEDS::ListOfFileNames_var aListOfFileNames = 
+      SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir, false);
+    if(MYDEBUG) MESSAGE("Result_i::PasteInto - aListOfFileNames->length() = "<<aListOfFileNames->length());
+    
+    std::string aLocalPersistentID;
+    {
+      std::string aCopyPersist =  aTmpDir + "copy_persistent";
+      std::ifstream anInputFileStream(aCopyPersist.c_str());
+      anInputFileStream>>aLocalPersistentID;
+      anInputFileStream.close();
+    }
+    
     //Just for Result::Restore to find the Comment attribute :(
-    SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeString");
-
-    Storable* aStorable = Storable::Create(aResultSO,aFileName,aString);
-
-    SALOMEDS::ListOfFileNames_var aSeqToRm = new SALOMEDS::ListOfFileNames;
-    aSeqToRm->length(1);
-    aSeqToRm[0] = "copy_persistent";
-
-    SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeqToRm.in(), true);
-
-    anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
+    SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeString");
+    
+    std::string aFileName(aTmpDir);
+    if(aListOfFileNames->length() > 1)
+      aFileName += aListOfFileNames[1].in();
+    Storable* aStorable = Storable::Create(aSObject, aLocalPersistentID, aFileName, false);
+    
+    SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
+    aFilesToRemove->length(1);
+    aFilesToRemove[0] = aListOfFileNames[0];
+    SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aFilesToRemove.in(), true);
+    
+    anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeIOR");
     SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
     CORBA::String_var anIORValue(aStorable->GetID());
     anIOR->SetValue(anIORValue);
-    return aResultSO._retn();
+    
+    return aSObject._retn();
   }
 
 
index 5df41e26ef7618508f1985433fde49ef8d589ca9..01496c584eb6e5c96659037f24b4c3522b4df349 100644 (file)
@@ -454,9 +454,10 @@ VISU::Mesh_i
 //----------------------------------------------------------------------------
 VISU::Storable*
 VISU::Mesh_i
-::Restore(SALOMEDS::SObject_ptr theSObject,
-         const string& thePrefix,
-         const Storable::TRestoringMap& theMap)
+::StorableEngine(SALOMEDS::SObject_ptr theSObject,
+                const Storable::TRestoringMap& theMap,
+                const std::string& thePrefix,
+                CORBA::Boolean theIsMultiFile)
 {
   Mesh_i* aMesh = new Mesh_i();
   return aMesh->Restore(theSObject, theMap);
index a6b452211d18278f78f97be49a4e514c781c661f..6576b7be3263801fe6335447d79819c686e53453 100644 (file)
@@ -167,9 +167,10 @@ namespace VISU
 
     static 
     Storable* 
-    Restore(SALOMEDS::SObject_ptr theSObject,
-           const std::string& thePrefix,
-           const Storable::TRestoringMap& theMap);
+    StorableEngine(SALOMEDS::SObject_ptr theSObject,
+                  const Storable::TRestoringMap& theMap,
+                  const std::string& thePrefix,
+                  CORBA::Boolean theIsMultiFile);
     
     virtual
     VISU_Actor* 
index ff71ddce1b8ed65eb11b997e0652129ce1bd8966..1b5af1c680ad457f424d2677fb9a7d485d312326 100644 (file)
@@ -460,9 +460,10 @@ VISU::Storable*
 VISU::MultiResult_i
 ::Restore(SALOMEDS::SObject_ptr theSObject,
          const Storable::TRestoringMap& theMap,
-         const string& thePrefix)
+         const std::string& thePrefix,
+         CORBA::Boolean theIsMultiFile)
 {
-  if(!TSuperClass::Restore(theSObject, theMap, thePrefix))
+  if(!TSuperClass::Restore(theSObject, theMap, thePrefix, theIsMultiFile))
     return NULL;
 
   QStringList aResolutions = QStringList::split("|", VISU::Storable::FindValue(theMap, "myResolutions"));
index 49d6bc890007d43cf8e364886be33e44ce8b43a2..fe100b8c5a18d2ff95632bac7fccf8a568b404e1 100644 (file)
@@ -49,10 +49,10 @@ namespace VISU
     MultiResult_i(SALOMEDS::Study_ptr theStudy,
                  const ESourceId& theSourceId,
                  const ECreationId& theCreationId,
-                 CORBA::Boolean theIsBuildImmediately = true,
-                 CORBA::Boolean theIsBuildFields = true,
-                 CORBA::Boolean theIsBuildMinMax = true,
-                 CORBA::Boolean theIsBuildGroups = true);
+                 CORBA::Boolean theIsBuildImmediately,
+                 CORBA::Boolean theIsBuildFields,
+                 CORBA::Boolean theIsBuildMinMax,
+                 CORBA::Boolean theIsBuildGroups);
 
     virtual
     ~MultiResult_i();
@@ -115,7 +115,8 @@ namespace VISU
     Storable*
     Restore(SALOMEDS::SObject_ptr theSObject,
            const Storable::TRestoringMap& theMap,
-           const std::string& thePrefix);
+           const std::string& thePrefix,
+           CORBA::Boolean theIsMultiFile);
 
     virtual
     void
index c199ec628d074981c1d4efd81bae5b2b0793428a..d5ab7ab56d4d435b805b3afed6c274a96766557a 100644 (file)
@@ -585,12 +585,135 @@ VISU::Result_i
 }
 
 
+//---------------------------------------------------------------
+bool
+VISU::Result_i
+::Save(SALOMEDS::SComponent_ptr theComponent,
+       const char* theTmpDir,
+       bool theIsMultiFile,
+       std::string& theFileName,
+       std::string& theFilePath)
+{
+  switch(GetCreationId()){
+  case Result_i::eImportFile:
+  case Result_i::eCopyAndImportFile: {
+    theFileName = std::string("_") + GetName();
+    theFilePath = GetFileInfo().filePath().latin1();
+    if(theIsMultiFile){
+      CORBA::String_var anURL = GetStudyDocument()->URL();
+      theFileName = SALOMEDS_Tool::GetNameFromPath(anURL.in()) + theFileName;
+
+      std::ostringstream aCommand;
+      aCommand<<COPY_COMMAND<<theFilePath<<" "<<theTmpDir<<theFileName;
+      if(system(aCommand.str().c_str()) != 0)
+       return false;
+    }
+    return true;
+  }}
+
+  return false;
+}
+
+
+//---------------------------------------------------------------
+bool
+VISU::Result_i
+::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
+           const std::string& theTmpDir,
+           bool theIsMultiFile,
+           std::string& theFileName)
+{
+  switch(GetCreationId()){
+  case Result_i::eImportFile:
+  case Result_i::eCopyAndImportFile: {
+    std::string aPrefix;
+    if (theIsMultiFile) {
+      CORBA::String_var anURL = GetStudyDocument()->URL();
+      aPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
+    }
+    theFileName = aPrefix + "_" + GetName();
+
+    QString aTmpDir = QDir::convertSeparators(theTmpDir.c_str());
+    QString aCommand;
+    aCommand.sprintf("%s %s%s",
+                    GetFileInfo().filePath().latin1(),
+                    aTmpDir.latin1(),
+                    theFileName.c_str());
+    aCommand = QDir::convertSeparators( aCommand );
+    aCommand.prepend( COPY_COMMAND );
+         
+    if(system(aCommand.latin1())){
+      if(MYDEBUG) MESSAGE("Result_i::SaveASCII - Can't execute the command :"<<aCommand);
+      return false;
+    }else
+      if(MYDEBUG) MESSAGE("Result_i::SaveASCII - "<<aCommand);
+
+    QString aStudyPath = aTmpDir.append(theFileName.c_str());
+    HDFascii::ConvertFromHDFToASCII(const_cast<char*>(aStudyPath.latin1()), true);
+    return true;
+  }}
+
+  return false;
+}
+
+
+//---------------------------------------------------------------
+CORBA::Boolean 
+VISU::Result_i
+::CanCopy(SALOMEDS::SObject_ptr theObject) 
+{
+  switch(GetCreationId()){
+  case Result_i::eImportFile:
+  case Result_i::eCopyAndImportFile: 
+    return true;
+  }
+  
+  return false;
+}
+
+
+//---------------------------------------------------------------
+bool
+VISU::Result_i
+::CopyFrom(SALOMEDS::SObject_ptr theObject, 
+          CORBA::Long& theObjectID,
+          const std::string& theTmpDir,
+          TFileNames& theFileNames) 
+{
+  if(!Storable::CopyFrom(theObject, theObjectID, theTmpDir, theFileNames))
+    return false;
+  
+  SALOMEDS::Study_var aStudy = theObject->GetStudy();
+  CORBA::String_var anURL = aStudy->URL();
+  std::string aPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
+  std::string aFileName = aPrefix + GetFileInfo().fileName().latin1();
+
+  static QString aCommand;
+  std::string aFilePath =  theTmpDir + aFileName;
+  aCommand.sprintf(" %s %s", GetFileInfo().filePath().latin1(), aFilePath.c_str());
+  aCommand = QDir::convertSeparators( aCommand );
+  aCommand.prepend( COPY_COMMAND );
+
+  if(system(aCommand.latin1()) != 0) {
+    if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<<aCommand);
+    return false;
+  }
+
+  SALOMEDS::SComponent_var aSComponent = aStudy->FindComponent("VISU");
+
+  theFileNames.push_back(aFileName);
+
+  return true;
+}
+
+
 //---------------------------------------------------------------
 VISU::Storable*
 VISU::Result_i
 ::Restore(SALOMEDS::SObject_ptr theSObject,
          const Storable::TRestoringMap& theMap,
-         const string& thePrefix)
+         const string& thePrefix,
+         CORBA::Boolean theIsMultiFile)
 {
   if(MYDEBUG) MESSAGE("Result_i::Restore - " << thePrefix);
   try {
@@ -636,7 +759,7 @@ VISU::Result_i
       myFileInfo.setFile(thePrefix.c_str());
 
       string aStudyPrefix ("");
-      if (IsMultifile())
+      if (theIsMultiFile)
        aStudyPrefix = SALOMEDS_Tool::GetNameFromPath(myStudyDocument->URL());
       if (!myFileInfo.isFile()) {
        string aFileName = thePrefix + aStudyPrefix + "_" + myName;
@@ -653,7 +776,7 @@ VISU::Result_i
        char* aHDFFileName = new char[strlen(aResultPath) + 19];
        sprintf(aHDFFileName, "%shdf_from_ascii.hdf", aResultPath);
        
-       if (IsMultifile()) { // set this file as new - temporary
+       if (theIsMultiFile) { // set this file as new - temporary
          static QString aCommand;
          aCommand.sprintf(" %s %s%s",aHDFFileName, aResultPath, myFileInfo.baseName().latin1());
          aCommand = QDir::convertSeparators( aCommand );
@@ -684,7 +807,7 @@ VISU::Result_i
        mySourceId = eRestoredFile;
        delete(aResultPath);
        delete(aHDFFileName);
-      } else if (!IsMultifile()) {
+      } else if (!theIsMultiFile) {
        mySourceId = eRestoredFile;
       } else {
        mySourceId = eFile;
@@ -833,9 +956,10 @@ VISU::Result_i
 //---------------------------------------------------------------
 VISU::Storable*
 VISU::Result_i
-::Restore(SALOMEDS::SObject_ptr theSObject,
-         const string& thePrefix,
-         const Storable::TRestoringMap& theMap)
+::StorableEngine(SALOMEDS::SObject_ptr theSObject,
+                const Storable::TRestoringMap& theMap,
+                const std::string& thePrefix,
+                CORBA::Boolean theIsMultiFile)
 {
   SALOMEDS::Study_var aStudy = theSObject->GetStudy();
 
@@ -851,13 +975,14 @@ VISU::Result_i
   VISU::Result_i* aResult = new RESULT_CLASS_NAME(aStudy,
                                                  aSourceId,
                                                  aCreationId,
+                                                 true,
                                                  anIsBuildFields,
                                                  anIsBuildMinMax,
                                                  anIsBuildGroups);
   if (aResult == NULL)
     return NULL;
 
-  return aResult->Restore(theSObject, theMap, thePrefix);
+  return aResult->Restore(theSObject, theMap, thePrefix, theIsMultiFile);
 }
 
 
index 191dafd38b432a4ca53a911f08f46e7eb9d09edc..c4a14f5b61d2b88d1b874af827ac0fe6f61a5005 100644 (file)
@@ -218,18 +218,49 @@ namespace VISU
     Storable* 
     Restore(SALOMEDS::SObject_ptr theSObject,
            const Storable::TRestoringMap& theMap,
-           const std::string& thePrefix);
+           const std::string& thePrefix,
+           CORBA::Boolean theIsMultiFile);
 
     static 
     Storable* 
-    Restore(SALOMEDS::SObject_ptr theSObject,
-           const std::string& thePrefix,
-           const Storable::TRestoringMap& theMap);
+    StorableEngine(SALOMEDS::SObject_ptr theSObject,
+                  const Storable::TRestoringMap& theMap,
+                  const std::string& thePrefix,
+                  CORBA::Boolean theIsMultiFile);
 
     virtual 
     void
     ToStream(std::ostringstream& theStr);
 
+    //---------------------------------------------------------------
+    virtual 
+    bool
+    Save(SALOMEDS::SComponent_ptr theComponent,
+        const char* theURL,
+        bool theIsMultiFile,
+        std::string& theFileName,
+        std::string& theFilePath);
+
+    virtual 
+    bool
+    SaveASCII(SALOMEDS::SComponent_ptr theComponent,
+             const std::string& theURL,
+             bool theIsMultiFile,
+             std::string& theFileName);
+
+    //---------------------------------------------------------------
+    virtual 
+    CORBA::Boolean 
+    CanCopy(SALOMEDS::SObject_ptr theObject);
+
+    virtual 
+    bool 
+    CopyFrom(SALOMEDS::SObject_ptr theObject, 
+            CORBA::Long& theObjectID,
+            const std::string& theTmpDir,
+            TFileNames& theFileNames);
+
+    //---------------------------------------------------------------
     virtual
     const char* 
     GetComment() const;
index 5e037ba1dab12deae800fa74c80dda60325954b0..2d1854bc37e2771f1810b3156202975002268340 100644 (file)
@@ -292,8 +292,10 @@ void VISU::Table_i::ToStream( std::ostringstream& theStr )
 /*!
   Called from engine to restore table from the file
 */
-VISU::Storable* VISU::Table_i::Restore(SALOMEDS::SObject_ptr theSObject,
-                                      const string& thePrefix, const Storable::TRestoringMap& theMap)
+VISU::Storable* VISU::Table_i::StorableEngine(SALOMEDS::SObject_ptr theSObject,
+                                             const Storable::TRestoringMap& theMap,
+                                             const std::string& thePrefix,
+                                             CORBA::Boolean theIsMultiFile)
 {
   SALOMEDS::Study_var aStudy = theSObject->GetStudy();
   VISU::Table_i* pResent = new VISU::Table_i( aStudy, "" );
@@ -843,8 +845,10 @@ const char* VISU::Curve_i::GetTableID() {
 /*!
   Called from engine to restore curve from the file
 */
-VISU::Storable* VISU::Curve_i::Restore(SALOMEDS::SObject_ptr theSObject,
-                                      const string& thePrefix, const Storable::TRestoringMap& theMap)
+VISU::Storable* VISU::Curve_i::StorableEngine(SALOMEDS::SObject_ptr theSObject,
+                                             const Storable::TRestoringMap& theMap,
+                                             const std::string& thePrefix,
+                                             CORBA::Boolean theIsMultiFile)
 {
   SALOMEDS::Study_var aStudy = theSObject->GetStudy();
   VISU::Table_i* pTable = GetTable(aStudy, theSObject->GetFather());
@@ -1136,8 +1140,10 @@ void VISU::Container_i::ToStream( std::ostringstream& theStr )
 /*!
   Called from engine to restore container from the file
 */
-VISU::Storable* VISU::Container_i::Restore(SALOMEDS::SObject_ptr theSObject,
-                                          const string& thePrefix, const Storable::TRestoringMap& theMap)
+VISU::Storable* VISU::Container_i::StorableEngine(SALOMEDS::SObject_ptr theSObject,
+                                                 const Storable::TRestoringMap& theMap,
+                                                 const std::string& thePrefix,
+                                                 CORBA::Boolean theIsMultiFile)
 {
   SALOMEDS::Study_var aStudy = theSObject->GetStudy();
   VISU::Container_i* pResent = new VISU::Container_i( aStudy );
index b241a6b9a5649bd09895538eaf6de77db9010fc8..04806091745191ce88ef82a5861d97df1250af9f 100644 (file)
@@ -71,9 +71,10 @@ namespace VISU{
     virtual Storable* Restore( const Storable::TRestoringMap& theMap,
                               SALOMEDS::SObject_ptr SO);
 
-    static Storable* Restore(SALOMEDS::SObject_ptr theSObject,
-                            const std::string& thePrefix,
-                            const Storable::TRestoringMap& theMap);
+    static Storable* StorableEngine(SALOMEDS::SObject_ptr theSObject,
+                                   const Storable::TRestoringMap& theMap,
+                                   const std::string& thePrefix,
+                                   CORBA::Boolean theIsMultiFile);
 
     virtual void ToStream( std::ostringstream& theStr );
     static const std::string myComment;
@@ -140,9 +141,10 @@ namespace VISU{
 
     virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr theSO);
 
-    static Storable* Restore(SALOMEDS::SObject_ptr theSObject,
-                            const std::string& thePrefix,
-                            const Storable::TRestoringMap& theMap);
+    static Storable* StorableEngine(SALOMEDS::SObject_ptr theSObject,
+                                   const Storable::TRestoringMap& theMap,
+                                   const std::string& thePrefix,
+                                   CORBA::Boolean theIsMultiFile);
 
     virtual void ToStream( std::ostringstream& theStr );
     static const std::string myComment;
@@ -194,9 +196,10 @@ namespace VISU{
     virtual Storable* Create();
     virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO );
 
-    static Storable* Restore(SALOMEDS::SObject_ptr theSObject,
-                            const std::string& thePrefix,
-                            const Storable::TRestoringMap& theMap);
+    static Storable* StorableEngine(SALOMEDS::SObject_ptr theSObject,
+                                   const Storable::TRestoringMap& theMap,
+                                   const std::string& thePrefix,
+                                   CORBA::Boolean theIsMultiFile);
 
     virtual void ToStream( std::ostringstream& theStr );
     static const std::string myComment;