From 82e818db0f48b19769bea92a4a3607a04b166649 Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 9 Jul 2007 11:42:54 +0000 Subject: [PATCH] Implementation of Save functionality for MultiResult --- src/VISU_I/Makefile.am | 11 ++- src/VISU_I/VISU_Gen_i.cc | 83 +++++++++++------ src/VISU_I/VISU_MultiResult_i.cc | 153 ++++++++++++++++++++++--------- src/VISU_I/VISU_MultiResult_i.hh | 21 ++++- src/VISU_I/VISU_Prs3d_i.hh | 20 +++- src/VISU_I/VISU_Result_i.cc | 107 +++++++++++---------- src/VISU_I/VISU_Result_i.hh | 39 ++++---- 7 files changed, 281 insertions(+), 153 deletions(-) diff --git a/src/VISU_I/Makefile.am b/src/VISU_I/Makefile.am index 2887c6d6..9bc96abd 100644 --- a/src/VISU_I/Makefile.am +++ b/src/VISU_I/Makefile.am @@ -58,6 +58,7 @@ libVISUEngineImpl_la_SOURCES = \ VISU_Result_i.cc \ VISU_ResultUtils.cc \ VISU_MultiResult_i.cc \ + VISU_Gen_i.cc \ VISU_CorbaMedConvertor.cxx \ VISU_PrsObject_i.cc \ VISU_Prs3d_i.cc \ @@ -80,7 +81,6 @@ libVISUEngineImpl_la_SOURCES = \ VISU_TimeAnimation.cxx \ VISU_View_i.cc \ VISU_Table_i.cc \ - VISU_Gen_i.cc \ VISU_DumpPython.cc \ SALOME_GenericObjPointer.cc @@ -116,7 +116,10 @@ libVISUEngineImpl_la_LDFLAGS= \ $(MED_LDFLAGS) \ ../../idl/libSalomeIDLVISU.la -libVISUEngineImpl_la_LIBADD= -lboost_signals@BOOST_LIBSUFFIX@ -lboost_thread@BOOST_LIBSUFFIX@ \ +libVISUEngineImpl_la_LIBADD= \ + -lboost_signals@BOOST_LIBSUFFIX@ \ + -lboost_thread@BOOST_LIBSUFFIX@ \ + -lboost_filesystem@BOOST_LIBSUFFIX@ \ -lSalomeHDFPersist \ -lSalomeGenericObj \ -lSalomeContainer \ @@ -145,7 +148,9 @@ endif bin_PROGRAMS = VISU_I dist_VISU_I_SOURCES=VISU_I.cxx VISU_I_CPPFLAGS=$(libVISUEngineImpl_la_CPPFLAGS) -VISU_I_LDADD=$(libVISUEngineImpl_la_LIBADD) $(libVISUEngineImpl_la_LDFLAGS) \ +VISU_I_LDADD=\ + $(libVISUEngineImpl_la_LIBADD) \ + $(libVISUEngineImpl_la_LDFLAGS) \ $(KERNEL_LDFLAGS) \ -lSALOMEBasics \ -lSalomeCatalog \ diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index c364188f..426b4052 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -82,12 +82,13 @@ UNEXPECT_CATCH(SalomeException, SALOME::SALOME_Exception); // STL Includes #include -using namespace std; +#include +#include +namespace filesystem = boost::filesystem; -static QFileInfo aFileInfo; #ifdef _DEBUG_ -static int MYDEBUG = 0; +static int MYDEBUG = 1; #else static int MYDEBUG = 0; #endif @@ -362,14 +363,14 @@ namespace VISU SALOMEDS::TMPFile* VISU_Gen_i ::Save(SALOMEDS::SComponent_ptr theComponent, - const char* theTmpDir, + const char* theURL, bool theIsMultiFile) { - if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - theTmpDir = '"< TFileNames; - TFileNames aFileNames; - TFileNames aFilePathes; + Result_i::TFileNames aFileNames; + Result_i::TFileNames aFullFileNames; + Result_i::TFileNames aTemporaryDirs; SALOMEDS::Study_var aStudy = theComponent->GetStudy(); SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theComponent); @@ -377,11 +378,12 @@ namespace VISU SALOMEDS::SObject_var aSObject = anIter->Value(); CORBA::Object_var anObj = SObjectToObject(aSObject); if(Result_i* aResult = dynamic_cast(GetServant(anObj).in())){ - std::string aFileName, aFilePath; - if(aResult->Save(theComponent, theTmpDir, theIsMultiFile, aFileName, aFilePath)){ - aFileNames.push_back(aFileName); - aFilePathes.push_back(aFilePath); - } + aResult->Save(theComponent, + theURL, + theIsMultiFile, + aFileNames, + aFullFileNames, + aTemporaryDirs); } } @@ -394,19 +396,27 @@ namespace VISU aListOfFileNames[aCounter-1] = aFileNames[aCounter-1].c_str(); } - SALOMEDS::ListOfFileNames_var aListOfFilePathes = new SALOMEDS::ListOfFileNames; - aListOfFilePathes->length(aFilePathes.size()); - if(!aFilePathes.empty()){ - for(int aCounter = aFileNames.size(); aCounter > 0; aCounter--) - aListOfFilePathes[aCounter-1] = aFilePathes[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::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0); if(theIsMultiFile) - aStreamFile = SALOMEDS_Tool::PutFilesToStream(theTmpDir, aListOfFilePathes.in(), theIsMultiFile); - else - aStreamFile = SALOMEDS_Tool::PutFilesToStream(aListOfFilePathes.in(), aListOfFileNames.in()); - + aStreamFile = SALOMEDS_Tool::PutFilesToStream(theURL, aListOfFullFileNames.in(), theIsMultiFile); + else{ + aStreamFile = SALOMEDS_Tool::PutFilesToStream(aListOfFullFileNames.in(), aListOfFileNames.in()); + Result_i::TFileNames::const_iterator anIter = aTemporaryDirs.begin(); + for(; anIter != aTemporaryDirs.end(); anIter++){ + filesystem::path aDirName(*anIter); + if(filesystem::exists(aDirName)){ + filesystem::remove_all(aDirName); + if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aDirName ='"<Create(theFileName) != NULL) return aResult->_this(); @@ -630,7 +644,10 @@ namespace VISU Result_i* aResult = Result_i::New(myStudyDocument, Result_i::eFile, Result_i::eImportFile, - false); + false, + true, + true, + true); if(aResult->Create(theFileName) != NULL) return aResult->_this(); @@ -651,7 +668,11 @@ namespace VISU Result_i* aResult = Result_i::New(myStudyDocument, Result_i::eRestoredFile, - Result_i::eCopyAndImportFile); + Result_i::eCopyAndImportFile, + true, + true, + true, + true); if(aResult->Create(theFileName) != NULL) return aResult->_this(); else @@ -671,7 +692,11 @@ namespace VISU Result_i* aResult = Result_i::New(myStudyDocument, Result_i::eComponent, - Result_i::eImportMed); + Result_i::eImportMed, + true, + true, + true, + true); if (aResult->Create(theMedSObject) != NULL) return aResult->_this(); else @@ -691,7 +716,11 @@ namespace VISU Result_i* aResult = Result_i::New(myStudyDocument, Result_i::eComponent, - Result_i::eImportMedField); + Result_i::eImportMedField, + true, + true, + true, + true); if (aResult->Create(theField) != NULL) return aResult->_this(); diff --git a/src/VISU_I/VISU_MultiResult_i.cc b/src/VISU_I/VISU_MultiResult_i.cc index cd7ea864..faee5c18 100644 --- a/src/VISU_I/VISU_MultiResult_i.cc +++ b/src/VISU_I/VISU_MultiResult_i.cc @@ -45,6 +45,10 @@ #include +#include +#include +namespace filesystem = boost::filesystem; + #ifdef _DEBUG_ static int MYDEBUG = 1; static int MYTIMEDEBUG = 0; @@ -113,21 +117,21 @@ namespace VISU //--------------------------------------------------------------- inline MultiResult_i::TResolutions - GetResolutions(const MultiResult_i::TMainPart2SubParts& theMainPart2SubParts, + GetResolutions(const MultiResult_i::TMainPart2SubPartNames& theMainPart2SubPartNames, const std::string& thePartName) { MultiResult_i::TResolutions aResolutions; aResolutions.insert(VISU::Result::FULL); MultiResult_i::TPartName aMainPart = ExtractMainPart(thePartName); - MultiResult_i::TMainPart2SubParts::const_iterator anIter = theMainPart2SubParts.find(aMainPart); - if(anIter != theMainPart2SubParts.end()){ - const MultiResult_i::TSubParts& aSubParts = anIter->second; + MultiResult_i::TMainPart2SubPartNames::const_iterator anIter = theMainPart2SubPartNames.find(aMainPart); + if(anIter != theMainPart2SubPartNames.end()){ + const MultiResult_i::TSubPartNames& aSubPartNames = anIter->second; - if(aSubParts.find(aMainPart + "_LOW") != aSubParts.end()) + if(aSubPartNames.find(aMainPart + "_LOW") != aSubPartNames.end()) aResolutions.insert(VISU::Result::LOW); - if(aSubParts.find(aMainPart + "_MED") != aSubParts.end()) + if(aSubPartNames.find(aMainPart + "_MED") != aSubPartNames.end()) aResolutions.insert(VISU::Result::MEDIUM); } return aResolutions; @@ -155,10 +159,10 @@ namespace VISU //--------------------------------------------------------------- inline VISU::Result::Resolution - GetResolution(const MultiResult_i::TMainPart2SubParts& theMainPart2SubParts, + GetResolution(const MultiResult_i::TMainPart2SubPartNames& theMainPart2SubPartNames, const std::string& thePartName) { - MultiResult_i::TResolutions aResolutions = GetResolutions(theMainPart2SubParts, thePartName); + MultiResult_i::TResolutions aResolutions = GetResolutions(theMainPart2SubPartNames, thePartName); if(aResolutions.find(VISU::Result::LOW) != aResolutions.end()) return VISU::Result::LOW; @@ -173,10 +177,10 @@ namespace VISU //--------------------------------------------------------------- inline std::string - GetIconName(const MultiResult_i::TMainPart2SubParts& theMainPart2SubParts, + GetIconName(const MultiResult_i::TMainPart2SubPartNames& theMainPart2SubPartNames, const std::string& thePartName) { - VISU::Result::Resolution aResolution = GetResolution(theMainPart2SubParts, + VISU::Result::Resolution aResolution = GetResolution(theMainPart2SubPartNames, thePartName); if(aResolution == VISU::Result::LOW) return "ICON_MULTIPR_VIEW_LOW"; @@ -196,7 +200,7 @@ namespace VISU MultiResult_i::TPartInfos* thePartInfos, MultiResult_i::TPartName2FileName* thePartName2FileName, MultiResult_i::TPartName2Resolution* thePartName2Resolution, - MultiResult_i::TMainPart2SubParts* theMainPart2SubParts, + MultiResult_i::TMainPart2SubPartNames* theMainPart2SubPartNames, CORBA::Boolean* theIsDone, CORBA::Boolean theIsBuild, _PTR(Study) theStudy) @@ -214,10 +218,10 @@ namespace VISU VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); const VISU::PMesh& aMesh = aMeshMapIter->second; - MultiResult_i::TParts aParts = aMultiprObj.getParts(); + MultiResult_i::TPartNames aPartNames = aMultiprObj.getParts(); QString aComment = "Sub-parts: #"; - aComment += QString::number(aParts.size()); + aComment += QString::number(aPartNames.size()); CreateAttributes(theStudy, aMesh->myPartsEntry, @@ -232,17 +236,17 @@ namespace VISU MultiResult_i::TPartName2FileName& aPartName2FileName = *thePartName2FileName; MultiResult_i::TPartName2Resolution& aPartName2Resolution = *thePartName2Resolution; - MultiResult_i::TMainPart2SubParts& aMainPart2SubParts = *theMainPart2SubParts; + MultiResult_i::TMainPart2SubPartNames& aMainPart2SubPartNames = *theMainPart2SubPartNames; - for (size_t aPartID = 0 ; aPartID < aParts.size() ; aPartID++) { - const MultiResult_i::TPartName& aPartName = aParts[aPartID]; + for (size_t aPartID = 0 ; aPartID < aPartNames.size() ; aPartID++) { + const MultiResult_i::TPartName& aPartName = aPartNames[aPartID]; MultiResult_i::TPartName aMainPart = ExtractMainPart(aPartName); - aMainPart2SubParts[aMainPart].insert(aPartName); + aMainPart2SubPartNames[aMainPart].insert(aPartName); } std::string aLastEntry; - for (size_t aPartID = 0 ; aPartID < aParts.size() ; aPartID++) { - const MultiResult_i::TPartName& aPartName = aParts[aPartID]; + for (size_t aPartID = 0 ; aPartID < aPartNames.size() ; aPartID++) { + const MultiResult_i::TPartName& aPartName = aPartNames[aPartID]; std::string aStringInfo = aMultiprObj.getPartInfo(aPartName.c_str()); MultiResult_i::TPartInfo aPartInfo; @@ -259,11 +263,11 @@ namespace VISU aPartName2FileName[aPartInfo.myName] = aPartInfo.myFileName; QString aComment = ""; - MultiResult_i::TResolutions aResoltutions = GetResolutions(aMainPart2SubParts, aPartInfo.myName); + MultiResult_i::TResolutions aResoltutions = GetResolutions(aMainPart2SubPartNames, aPartInfo.myName); std::string aResoltutionsString = Resolutions2String(aResoltutions); if ( IsFullResolution(aPartInfo.myName) ) { - std::string anIconName = GetIconName(aMainPart2SubParts, aPartInfo.myName); - VISU::Result::Resolution aResolution = GetResolution(aMainPart2SubParts, aPartInfo.myName); + std::string anIconName = GetIconName(aMainPart2SubPartNames, aPartInfo.myName); + VISU::Result::Resolution aResolution = GetResolution(aMainPart2SubPartNames, aPartInfo.myName); aComment.sprintf("myComment=PART;myMeshName=%s;myFile=%s;myResolutions=%s;myState=%c", aPartInfo.myMeshName.c_str(), aPartInfo.myFileName.c_str(), aResoltutionsString.c_str(), aResolution); aLastEntry = CreateAttributes(theStudy, @@ -309,7 +313,7 @@ namespace VISU MultiResult_i::TPartInfos* myPartInfos; MultiResult_i::TPartName2FileName* myPartName2FileName; MultiResult_i::TPartName2Resolution* myPartName2Resolution; - MultiResult_i::TMainPart2SubParts* myMainPart2SubParts; + MultiResult_i::TMainPart2SubPartNames* myMainPart2SubPartNames; CORBA::Boolean* myIsDone; CORBA::Boolean myIsBuild; _PTR(Study) myStudy; @@ -320,7 +324,7 @@ namespace VISU MultiResult_i::TPartInfos* thePartInfos, MultiResult_i::TPartName2FileName* thePartName2FileName, MultiResult_i::TPartName2Resolution* thePartName2Resolution, - MultiResult_i::TMainPart2SubParts* theMainPart2SubParts, + MultiResult_i::TMainPart2SubPartNames* theMainPart2SubPartNames, CORBA::Boolean* theIsDone, CORBA::Boolean theIsBuild, _PTR(Study) theStudy): @@ -330,7 +334,7 @@ namespace VISU myPartInfos(thePartInfos), myPartName2FileName(thePartName2FileName), myPartName2Resolution(thePartName2Resolution), - myMainPart2SubParts(theMainPart2SubParts), + myMainPart2SubPartNames(theMainPart2SubPartNames), myIsDone(theIsDone), myIsBuild(theIsBuild), myStudy(theStudy) @@ -348,7 +352,7 @@ namespace VISU theArgs.myPartInfos, theArgs.myPartName2FileName, theArgs.myPartName2Resolution, - theArgs.myMainPart2SubParts, + theArgs.myMainPart2SubPartNames, theArgs.myIsDone, theArgs.myIsBuild, theArgs.myStudy); @@ -361,13 +365,13 @@ namespace VISU //--------------------------------------------------------------- VISU::MultiResult_i -::MultiResult_i (SALOMEDS::Study_ptr theStudy, - const ESourceId& theSourceId, - const ECreationId& theCreationId, - CORBA::Boolean theIsBuildImmediately, - CORBA::Boolean theIsBuildFields, - CORBA::Boolean theIsBuildMinMax, - CORBA::Boolean theIsBuildGroups): +::MultiResult_i(SALOMEDS::Study_ptr theStudy, + const ESourceId& theSourceId, + const ECreationId& theCreationId, + CORBA::Boolean theIsBuildImmediately, + CORBA::Boolean theIsBuildFields, + CORBA::Boolean theIsBuildMinMax, + CORBA::Boolean theIsBuildGroups): Result_i(theStudy, theSourceId, theCreationId, @@ -378,6 +382,12 @@ VISU::MultiResult_i {} +//--------------------------------------------------------------- +VISU::MultiResult_i +::MultiResult_i() +{} + + //--------------------------------------------------------------- size_t VISU::MultiResult_i @@ -406,7 +416,7 @@ VISU::MultiResult_i &myPartInfos, &myPartName2FileName, &myPartName2Resolution, - &myMainPart2SubParts, + &myMainPart2SubPartNames, &myIsPartsDone, myIsBuildParts, myStudy); @@ -437,7 +447,7 @@ VISU::MultiResult_i &myPartInfos, &myPartName2FileName, &myPartName2Resolution, - &myMainPart2SubParts, + &myMainPart2SubPartNames, &myIsPartsDone, myIsBuildParts, myStudy); @@ -486,6 +496,63 @@ VISU::MultiResult_i } +//--------------------------------------------------------------- +bool +VISU::MultiResult_i +::Save(SALOMEDS::SComponent_ptr theComponent, + const std::string& theURL, + bool theIsMultiFile, + TFileNames& theFileNames, + TFileNames& theFullFileNames, + TFileNames& theTemporaryDirs) +{ + bool anIsDone = Result_i::Save(theComponent, + theURL, + theIsMultiFile, + theFileNames, + theFullFileNames, + theTemporaryDirs); + if(!anIsDone) + return false; + + if(!myMultiprObj.isValidDistributedMEDFile()) + return true; + + // Obtain a temporary directory + filesystem::path aTmpDir = theIsMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir(); + aTmpDir /= GetName(); + cout<<"aTmpDir = '"< TParts; + typedef std::vector TPartNames; typedef size_t TPartID; typedef std::string TPath; - typedef std::string TFileName; typedef std::string TMeshName; struct TPartInfo @@ -110,14 +111,14 @@ namespace VISU typedef std::set TRepresentationKey; typedef std::map TRepresentation2Input; - typedef std::set TSubParts; - typedef std::map TMainPart2SubParts; + typedef std::set TSubPartNames; + typedef std::map TMainPart2SubPartNames; private: multipr::Obj myMultiprObj; TPartName2FileName myPartName2FileName; TPartName2Resolution myPartName2Resolution; - TMainPart2SubParts myMainPart2SubParts; + TMainPart2SubPartNames myMainPart2SubPartNames; TRepresentation2Input myRepresentation2Input; @@ -147,6 +148,16 @@ namespace VISU const std::string& thePrefix, CORBA::Boolean theIsMultiFile); + //--------------------------------------------------------------- + virtual + bool + Save(SALOMEDS::SComponent_ptr theComponent, + const std::string& theURL, + bool theIsMultiFile, + TFileNames& theFileNames, + TFileNames& theFullFileNames, + TFileNames& theTemporaryDirs); + virtual void ToStream(std::ostringstream& theStr); diff --git a/src/VISU_I/VISU_Prs3d_i.hh b/src/VISU_I/VISU_Prs3d_i.hh index 6419d111..969772a7 100644 --- a/src/VISU_I/VISU_Prs3d_i.hh +++ b/src/VISU_I/VISU_Prs3d_i.hh @@ -50,8 +50,19 @@ class vtkDataSet; namespace VISU { + //---------------------------------------------------------------------------- class Result_i; + + //---------------------------------------------------------------------------- + struct TResultObserver: public virtual boost::signalslib::trackable + { + virtual + void + UpdateFromResult(Result_i* theResult) = 0; + }; + + //---------------------------------------------------------------------------- //! Base class for all VTK 3D presentations. /*! @@ -63,11 +74,10 @@ namespace VISU - implement basic actor management (CreateActor, UpdateActor, UpdateActors, RemoveActor and RemoveActors); - implement common 3D functionality like "clipping planes" and offset. */ - class VISU_I_EXPORT Prs3d_i : - public virtual POA_VISU::Prs3d, - public virtual SALOME::GenericObj_i, - public virtual TActorFactory, - public virtual PrsObject_i + class VISU_I_EXPORT Prs3d_i : public virtual POA_VISU::Prs3d, + public virtual SALOME::GenericObj_i, + public virtual TActorFactory, + public virtual PrsObject_i { Prs3d_i(const Prs3d_i&); diff --git a/src/VISU_I/VISU_Result_i.cc b/src/VISU_I/VISU_Result_i.cc index 61236dda..ff1b63f8 100644 --- a/src/VISU_I/VISU_Result_i.cc +++ b/src/VISU_I/VISU_Result_i.cc @@ -26,6 +26,7 @@ #include "VISU_MultiResult_i.hh" #include "VISU_ResultUtils.hh" +#include "VISU_Prs3d_i.hh" #include "VISU_Convertor_impl.hxx" #include "VISU_CorbaMedConvertor.hxx" @@ -59,6 +60,10 @@ // OCCT Includes #include +#include +#include +namespace filesystem = boost::filesystem; + #ifdef _DEBUG_ static int MYDEBUG = 1; @@ -139,13 +144,13 @@ const char* VISU::Result_i::GetComment() const { return myComment.c_str();} //--------------------------------------------------------------- VISU::Result_i -::Result_i (SALOMEDS::Study_ptr theStudy, - const ESourceId& theSourceId, - const ECreationId& theCreationId, - CORBA::Boolean theIsBuildImmediately, - CORBA::Boolean theIsBuildFields, - CORBA::Boolean theIsBuildMinMax, - CORBA::Boolean theIsBuildGroups): +::Result_i(SALOMEDS::Study_ptr theStudy, + const ESourceId& theSourceId, + const ECreationId& theCreationId, + CORBA::Boolean theIsBuildImmediately, + CORBA::Boolean theIsBuildFields, + CORBA::Boolean theIsBuildMinMax, + CORBA::Boolean theIsBuildGroups): myStudyDocument(SALOMEDS::Study::_duplicate(theStudy)), myCreationId(theCreationId), mySourceId(theSourceId), @@ -165,6 +170,12 @@ VISU::Result_i } +//--------------------------------------------------------------- +VISU::Result_i +::Result_i() +{} + + //--------------------------------------------------------------- void VISU::Result_i @@ -481,8 +492,8 @@ VISU::Result_i //--------------------------------------------------------------- VISU::Storable* -VISU::Result_i:: -Create(const char* theFileName) +VISU::Result_i +::Create(const char* theFileName) { try { myFileInfo.setFile(theFileName); @@ -585,25 +596,29 @@ VISU::Result_i bool VISU::Result_i ::Save(SALOMEDS::SComponent_ptr theComponent, - const char* theTmpDir, + const std::string& theURL, bool theIsMultiFile, - std::string& theFileName, - std::string& theFilePath) + TFileNames& theFileNames, + TFileNames& theFullFileNames, + TFileNames& theTemporaryDirs) { switch(GetCreationId()){ case Result_i::eImportFile: case Result_i::eCopyAndImportFile: { - theFileName = std::string("_") + GetName(); - theFilePath = GetFileInfo().filePath().latin1(); + filesystem::path aFileName = std::string("_") + GetName(); + filesystem::path aFilePath = GetFileInfo().filePath().latin1(); if(theIsMultiFile){ CORBA::String_var anURL = GetStudyDocument()->URL(); - theFileName = SALOMEDS_Tool::GetNameFromPath(anURL.in()) + theFileName; - - std::ostringstream aCommand; - aCommand<GetFatherComponent(); + myStudyDocument = theSObject->GetStudy(); + + myCreationId = ECreationId(Storable::FindValue(theMap, "myCreationId").toInt()); + mySourceId = eRestoredFile; + if(myCreationId == eImportMed || myCreationId == eImportMedField) + mySourceId = eRestoredComponent; + + myIsBuildFields = Storable::FindValue(theMap, "myIsBuildFields", "1").toInt(); + myIsBuildMinMax = Storable::FindValue(theMap, "myIsBuildMinMax", "1").toInt(); + myIsBuildGroups = Storable::FindValue(theMap, "myIsBuildGroups", "1").toInt(); + myIsBuildParts = Storable::FindValue(theMap, "myIsBuildParts", "0").toInt(); + + myIsBuildImmediately = true; + try { - mySObject = SALOMEDS::SObject::_duplicate(theSObject); - myStudyDocument = mySObject->GetStudy(); - mySComponent = mySObject->GetFatherComponent(); myName = VISU::Storable::FindValue(theMap, "myName").latin1(); SetFileName(VISU::Storable::FindValue(theMap, "myInitFileName").latin1()); @@ -1279,27 +1307,7 @@ VISU::Result_i const std::string& thePrefix, CORBA::Boolean theIsMultiFile) { - SALOMEDS::Study_var aStudy = theSObject->GetStudy(); - - ECreationId aCreationId = ECreationId(Storable::FindValue(theMap, "myCreationId").toInt()); - ESourceId aSourceId = eRestoredFile; - if(aCreationId == eImportMed || aCreationId == eImportMedField) - aSourceId = eRestoredComponent; - - CORBA::Boolean anIsBuildFields = Storable::FindValue(theMap,"myIsBuildFields","1").toInt(); - CORBA::Boolean anIsBuildMinMax = Storable::FindValue(theMap,"myIsBuildMinMax","1").toInt(); - CORBA::Boolean anIsBuildGroups = Storable::FindValue(theMap,"myIsBuildGroups","1").toInt(); - - VISU::Result_i* aResult = new RESULT_CLASS_NAME(aStudy, - aSourceId, - aCreationId, - true, - anIsBuildFields, - anIsBuildMinMax, - anIsBuildGroups); - if (aResult == NULL) - return NULL; - + VISU::Result_i* aResult = new RESULT_CLASS_NAME(); return aResult->Restore(theSObject, theMap, thePrefix, theIsMultiFile); } @@ -1310,12 +1318,13 @@ 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,"myCreationId",myCreationId); - Storable::DataToStream(theStr,"myIsBuildFields",myIsFieldsDone); - Storable::DataToStream(theStr,"myIsBuildMinMax",myIsMinMaxDone); - Storable::DataToStream(theStr,"myIsBuildGroups",myIsGroupsDone); + Storable::DataToStream(theStr,"myName", myName.c_str()); + Storable::DataToStream(theStr,"myInitFileName", GetFileName().c_str()); + Storable::DataToStream(theStr,"myCreationId", myCreationId); + Storable::DataToStream(theStr,"myIsBuildFields", myIsFieldsDone); + Storable::DataToStream(theStr,"myIsBuildMinMax", myIsMinMaxDone); + Storable::DataToStream(theStr,"myIsBuildGroups", myIsGroupsDone); + Storable::DataToStream(theStr,"myIsBuildParts", myIsBuildParts); } diff --git a/src/VISU_I/VISU_Result_i.hh b/src/VISU_I/VISU_Result_i.hh index 7f2e8962..9b278f27 100644 --- a/src/VISU_I/VISU_Result_i.hh +++ b/src/VISU_I/VISU_Result_i.hh @@ -44,16 +44,7 @@ class VISU_Convertor; namespace VISU { //---------------------------------------------------------------------------- - class Result_i; - - - //---------------------------------------------------------------------------- - struct TResultObserver: public virtual boost::signalslib::trackable - { - virtual - void - UpdateFromResult(Result_i* theResult) = 0; - }; + class TResultObserver; //---------------------------------------------------------------------------- @@ -72,10 +63,10 @@ namespace VISU New(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 void @@ -211,10 +202,12 @@ namespace VISU Result_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); + + Result_i(); virtual ~Result_i(); @@ -291,13 +284,17 @@ namespace VISU ToStream(std::ostringstream& theStr); //--------------------------------------------------------------- + typedef std::string TFileName; + typedef std::vector TFileNames; + virtual bool Save(SALOMEDS::SComponent_ptr theComponent, - const char* theURL, + const std::string& theURL, bool theIsMultiFile, - std::string& theFileName, - std::string& theFilePath); + TFileNames& theFileNames, + TFileNames& theFullFileNames, + TFileNames& theTemporaryDirs); virtual bool -- 2.39.2