From: imn Date: Sat, 20 Feb 2016 12:11:56 +0000 (+0300) Subject: INT PAL 0052944: Multi-file save mode does not work for "light" modules X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e9a5c3d4401b6910384475e9afcbea9778847445;p=modules%2Fgui.git INT PAL 0052944: Multi-file save mode does not work for "light" modules --- diff --git a/src/LightApp/LightApp_Driver.cxx b/src/LightApp/LightApp_Driver.cxx index 59b1af283..e32912cd9 100644 --- a/src/LightApp/LightApp_Driver.cxx +++ b/src/LightApp/LightApp_Driver.cxx @@ -180,6 +180,7 @@ bool LightApp_Driver::ReadDatasFromFile( const char* theFileName, bool isMultiFi // Put buffer to aListOfFiles and set to myMap ListOfFiles aListOfFiles = PutStreamToFiles(aBuffer, aBufferSize, isMultiFile); SetListOfFiles(aModuleName, aListOfFiles); + SetSaveTypeStudy(aModuleName, isMultiFile); delete[] aModuleName; delete[] aBuffer; @@ -224,6 +225,27 @@ void LightApp_Driver::SetListOfFiles( const char* theModuleName, const ListOfFil myMap[aName] = theListOfFiles; } +/*! + \return (single or multi file) type for save by module with name 'theModuleName' +*/ +bool LightApp_Driver::GetSaveTypeStudy( const char* theModuleName ) +{ + bool isMultiFile = false; + std::string aName(theModuleName); + if (mySaveTypeMap.count(aName)) + isMultiFile = mySaveTypeMap[aName]; + return isMultiFile; +} + +/*! + Sets (single or multi file) type for save by module with name 'theModuleName' +*/ +void LightApp_Driver::SetSaveTypeStudy( const char* theModuleName, const bool isMultiFile ) +{ + std::string aName (theModuleName); + mySaveTypeMap[aName] = isMultiFile; +} + /*! Converts files which was created from module into a byte sequence unsigned char */ @@ -467,6 +489,7 @@ void LightApp_Driver::ClearDriverContents() RemoveTemporaryFiles( aModuleName, IsTemporary() ); } myMap.clear(); + mySaveTypeMap.clear(); // Reset the "temporary" flag SetIsTemporary( false ); } diff --git a/src/LightApp/LightApp_Driver.h b/src/LightApp/LightApp_Driver.h index 230ae59ca..ed748bf6e 100644 --- a/src/LightApp/LightApp_Driver.h +++ b/src/LightApp/LightApp_Driver.h @@ -50,6 +50,9 @@ public: ListOfFiles GetListOfFiles (const char* theModuleName); virtual void SetListOfFiles (const char* theModuleName, const ListOfFiles theListOfFiles); + bool GetSaveTypeStudy ( const char* theModuleName ); + virtual void SetSaveTypeStudy ( const char* theModuleName, + const bool isMultiFile); virtual void RemoveTemporaryFiles(const char* theModuleName, const bool IsDirDeleted); void RemoveFiles( const ListOfFiles& theFiles, const bool IsDirDeleted); @@ -69,7 +72,9 @@ protected: protected: typedef std::map MapOfListOfFiles; + typedef std::map MapOfSaveTypeStudy; MapOfListOfFiles myMap; + MapOfSaveTypeStudy mySaveTypeMap; std::string myTmpDir; private: diff --git a/src/LightApp/LightApp_HDFDriver.cxx b/src/LightApp/LightApp_HDFDriver.cxx index 5cba039a5..1ad934442 100644 --- a/src/LightApp/LightApp_HDFDriver.cxx +++ b/src/LightApp/LightApp_HDFDriver.cxx @@ -309,6 +309,7 @@ bool LightApp_HDFDriver::ReadDatasFromFile( const char* theFileName, bool isMult ListOfFiles aListOfFiles = PutStreamToFiles(aStreamFile, aStreamSize, isMultiFile); char* aCompDataType = (char*)(mapEntryName[name].c_str()); SetListOfFiles(aCompDataType, aListOfFiles); + SetSaveTypeStudy(aCompDataType, isMultiFile); delete [] aStreamFile; } diff --git a/src/LightApp/LightApp_Study.cxx b/src/LightApp/LightApp_Study.cxx index 1229f127f..25d7a19d2 100644 --- a/src/LightApp/LightApp_Study.cxx +++ b/src/LightApp/LightApp_Study.cxx @@ -341,6 +341,12 @@ void LightApp_Study::saveModuleData(QString theModuleName, QStringList theListOf anIndex++; } myDriver->SetListOfFiles(theModuleName.toLatin1().constData(), aListOfFiles); + + SUIT_ResourceMgr* resMgr = application()->resourceMgr(); + if( !resMgr ) + return; + bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false ); + myDriver->SetSaveTypeStudy(theModuleName.toLatin1().constData(), isMultiFile); } /*! @@ -438,6 +444,27 @@ void LightApp_Study::SetListOfFiles (const char* theModuleName, const std::vecto myDriver->SetListOfFiles(theModuleName, theListOfFiles); } +/*! + \return (single or multi file) type for save study used by module: to be used by CORBAless modules. + \param theModuleName - name of module +*/ +bool LightApp_Study::GetSaveTypeStudy(const char* theModuleName) const +{ + bool isMultiFile = false; + isMultiFile = myDriver->GetSaveTypeStudy(theModuleName); + return isMultiFile; +} + +/*! + Sets (single or multi file) type for save study used by module: to be used by CORBAless modules. + \param theModuleName - name of module + \param isMultiFile - type for save study +*/ +void LightApp_Study::SetSaveTypeStudy (const char* theModuleName, const bool isMultiFile) +{ + myDriver->SetSaveTypeStudy(theModuleName, isMultiFile); +} + /*! Removes temporary files */ diff --git a/src/LightApp/LightApp_Study.h b/src/LightApp/LightApp_Study.h index d397a110a..49d59fa49 100644 --- a/src/LightApp/LightApp_Study.h +++ b/src/LightApp/LightApp_Study.h @@ -123,6 +123,10 @@ protected: virtual void SetListOfFiles ( const char* theModuleName, const std::vector theListOfFiles ); + virtual bool GetSaveTypeStudy ( const char* theModuleName ) const; + virtual void SetSaveTypeStudy ( const char* theModuleName, + const bool isMultiFile); + virtual void RemoveTemporaryFiles ( const char* theModuleName, const bool isMultiFile ) const; protected: diff --git a/src/SalomeApp/SalomeApp_Engine_i.cxx b/src/SalomeApp/SalomeApp_Engine_i.cxx index a7bbf1af9..c53e53c52 100644 --- a/src/SalomeApp/SalomeApp_Engine_i.cxx +++ b/src/SalomeApp/SalomeApp_Engine_i.cxx @@ -140,6 +140,7 @@ CORBA::Boolean SalomeApp_Engine_i::Load (SALOMEDS::SComponent_ptr theComponent, listOfFiles[i] = std::string(aSeq[i - 1]); SetListOfFiles(listOfFiles, studyId); + SetSaveTypeStudy(isMultiFile, studyId); return true; } @@ -162,6 +163,23 @@ void SalomeApp_Engine_i::SetListOfFiles (const ListOfFiles& theListOfFiles, myMap[theStudyId] = theListOfFiles; } +bool SalomeApp_Engine_i::GetSaveTypeStudy (const int theStudyId) +{ + bool aSaveTypeStudy; + + if (mySaveTypeMap.find(theStudyId) != mySaveTypeMap.end()) + { + aSaveTypeStudy = mySaveTypeMap[theStudyId]; + } + + return aSaveTypeStudy; +} + +void SalomeApp_Engine_i::SetSaveTypeStudy (const bool isMultiFile, + const int theStudyId) +{ + mySaveTypeMap[theStudyId] = isMultiFile; +} /*! * DumpPython implementation for light modules */ diff --git a/src/SalomeApp/SalomeApp_Engine_i.h b/src/SalomeApp/SalomeApp_Engine_i.h index a0be8416d..8f77d5090 100644 --- a/src/SalomeApp/SalomeApp_Engine_i.h +++ b/src/SalomeApp/SalomeApp_Engine_i.h @@ -67,6 +67,10 @@ public: void SetListOfFiles (const ListOfFiles& theListOfFiles, const int theStudyId); + bool GetSaveTypeStudy (const int theStudyId); + void SetSaveTypeStudy (const bool isMultiFile, + const int theStudyId); + static std::string EngineIORForComponent( const char* theComponentName, bool toCreate ); static SalomeApp_Engine_i* GetInstance ( const char* theComponentName, @@ -99,7 +103,9 @@ private: static SALOME_NamingService* namingService(); private: typedef std::map MapOfListOfFiles; + typedef std::map MapOfSaveTypeStudy; MapOfListOfFiles myMap; + MapOfSaveTypeStudy mySaveTypeMap; std::string myComponentName; }; diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index 8598e2bdb..9a5da2e37 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -888,6 +888,12 @@ void SalomeApp_Study::saveModuleData( QString theModuleName, QStringList theList anIndex++; } SetListOfFiles(theModuleName.toStdString().c_str(), aListOfFiles); + + SUIT_ResourceMgr* resMgr = application()->resourceMgr(); + if( !resMgr ) + return; + bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false ); + SetSaveTypeStudy(theModuleName.toStdString().c_str(), isMultiFile); } /*! @@ -919,13 +925,19 @@ bool SalomeApp_Study::saveStudyData( const QString& theFileName ) ModelList list; dataModels( list ); QListIterator it( list ); std::vector listOfFiles(0); + SUIT_ResourceMgr* resMgr = application()->resourceMgr(); + if( !resMgr ) + return false; + bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false ); while ( it.hasNext() ){ LightApp_DataModel* aLModel = dynamic_cast( it.next() ); // It is safe to call SetListOfFiles() for any kind of module // because SetListOfFiles() does nothing for full modules :) - if ( aLModel ) + if ( aLModel ) { SetListOfFiles(aLModel->module()->name().toStdString().c_str(), listOfFiles); + SetSaveTypeStudy(aLModel->module()->name().toStdString().c_str(), isMultiFile); + } } return true; } @@ -1111,7 +1123,7 @@ bool SalomeApp_Study::openDataModel( const QString& studyName, CAM_DataModel* dm if (dm && dm->open(studyName, this, listOfFiles)) { // Remove the files and temporary directory, created // for this module by LightApp_Engine_i::Load() - bool isMultiFile = false; // TODO: decide, how to access this parameter + bool isMultiFile = GetSaveTypeStudy( dm->module()->name().toStdString().c_str() ); RemoveTemporaryFiles( dm->module()->name().toStdString().c_str(), isMultiFile ); // Something has been read -> create data model tree @@ -1152,7 +1164,7 @@ QString SalomeApp_Study::newStudyName() const \return list of files used by module: to be used by CORBAless modules \param theModuleName - name of module */ -std::vector SalomeApp_Study::GetListOfFiles( const char* theModuleName ) const +std::vector SalomeApp_Study::GetListOfFiles( const char* theModuleName ) const { // Issue 21377 - using separate engine for each type of light module SalomeApp_Engine_i* aDefaultEngine = SalomeApp_Engine_i::GetInstance( theModuleName, false ); @@ -1180,6 +1192,31 @@ void SalomeApp_Study::SetListOfFiles ( const char* theModuleName, aDefaultEngine->SetListOfFiles(theListOfFiles, id()); } +/*! + \return (single or multi file) type for save study used by module: to be used by CORBAless modules. + \param theModuleName - name of module +*/ +bool SalomeApp_Study::GetSaveTypeStudy( const char* theModuleName ) const +{ + SalomeApp_Engine_i* aDefaultEngine = SalomeApp_Engine_i::GetInstance( theModuleName, false ); + if (aDefaultEngine) + return aDefaultEngine->GetSaveTypeStudy(id()); + + return false; +} + +/*! + Sets (single or multi file) type for save study used by module: to be used by CORBAless modules. + \param theModuleName - name of module + \param isMultiFile - save type study +*/ +void SalomeApp_Study::SetSaveTypeStudy ( const char* theModuleName, + const bool isMultiFile ) +{ + SalomeApp_Engine_i* aDefaultEngine = SalomeApp_Engine_i::GetInstance( theModuleName, false ); + if (aDefaultEngine) + aDefaultEngine->SetSaveTypeStudy(isMultiFile, id()); +} /*! \return temporary directory for saving files of modules */ diff --git a/src/SalomeApp/SalomeApp_Study.h b/src/SalomeApp/SalomeApp_Study.h index e373b4dfb..70f47ad3b 100644 --- a/src/SalomeApp/SalomeApp_Study.h +++ b/src/SalomeApp/SalomeApp_Study.h @@ -98,6 +98,9 @@ protected: virtual std::vector GetListOfFiles ( const char* theModuleName ) const; virtual void SetListOfFiles ( const char* theModuleName, const std::vector theListOfFiles); + virtual bool GetSaveTypeStudy ( const char* theModuleName ) const; + virtual void SetSaveTypeStudy ( const char* theModuleName, + const bool isMultiFile); virtual void RemoveTemporaryFiles ( const char* theModuleName, const bool isMultiFile) const; protected: