From 04bd01d1bc4084ad3e3ca3dc7268d2b16621aeac Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 18 Dec 2014 18:07:55 +0300 Subject: [PATCH] Persistent correction in full Salome mode. --- msvc10_env.bat | 2 +- src/NewGeom/NewGeom_DataModel.cpp | 49 ++++++++++++++++++++++++++----- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/msvc10_env.bat b/msvc10_env.bat index ee0c3adc7..613e31478 100644 --- a/msvc10_env.bat +++ b/msvc10_env.bat @@ -26,7 +26,7 @@ set PATH=%CMAKEDIR%\bin;%PATH% @REM ------------------------- @REM CASCADE -@SET CAS_ROOT_DIR=%PDIR%\OCCT-6.7.1 +@SET CAS_ROOT_DIR=%PDIR%\OCCT-6.8.0 @SET CASROOT=%CAS_ROOT_DIR% @REM ------------------------- diff --git a/src/NewGeom/NewGeom_DataModel.cpp b/src/NewGeom/NewGeom_DataModel.cpp index ce65398c6..34922cbbd 100644 --- a/src/NewGeom/NewGeom_DataModel.cpp +++ b/src/NewGeom/NewGeom_DataModel.cpp @@ -10,12 +10,13 @@ #include #include #include +#include #include - +#include NewGeom_DataModel::NewGeom_DataModel(NewGeom_Module* theModule) - : LightApp_DataModel(theModule), myModule(theModule) + : LightApp_DataModel(theModule), myStudyPath(""), myModule(theModule) { } @@ -29,12 +30,37 @@ bool NewGeom_DataModel::open(const QString& thePath, CAM_Study* theStudy, QStrin if (theFiles.size() == 0) return false; - QString aFile = theFiles.first(); + myStudyPath = thePath; + + // If the file is Multi(contain all module files inside), the open SALOME functionality creates + // these files in a temporary directory. After the open functionality is finished, it removes + // these files (in the full SALOME mode). + // The postponed loading of the files is realized in the NewGEOM module. So, it is important do + // not remove the opened files. + // The following code creates a new tmp directory with a copy of files. + QString aTmpDir = theFiles.first(); + + //LightApp_Driver aDriver; + //QString aNewTmpDir = QString(aDriver.GetTmpDir("", false).c_str()); + LightApp_Study* aStudy = dynamic_cast( myModule->application()->activeStudy() ); + QString aNewTmpDir = aStudy->GetTmpDir("", false).c_str(); + + bool isDone = true; + QDir aDir(aTmpDir); + QStringList aFiles = aDir.entryList(QDir::Files); + QStringList::const_iterator anIt = aFiles.begin(), aLast = aFiles.end(); + for (; anIt != aLast; anIt++) { + QString aFileName = *anIt; + + QString aCurrentFile = SUIT_Tools::addSlash(aTmpDir) + aFileName; + QString aNewFile = SUIT_Tools::addSlash(aNewTmpDir) + aFileName; + if (!QFile::copy(aCurrentFile, aNewFile)) + isDone = false; + } SessionPtr aMgr = ModelAPI_Session::get(); - aMgr->load(qPrintable(aFile)); + aMgr->load(qPrintable(aNewTmpDir)); myModule->setIsOpened(true); - myStudyPath = aFile; return true; } @@ -44,8 +70,17 @@ bool NewGeom_DataModel::save(QStringList& theFiles) XGUI_Workshop* aWorkShop = myModule->workshop(); std::list aFileNames; - LightApp_Study* aStudy = dynamic_cast( myModule->application()->activeStudy() ); - std::string aTmpDir = aStudy->GetTmpDir(qPrintable(myStudyPath), true ); + CAM_Application* anApp = myModule->application(); + LightApp_Study* aStudy = dynamic_cast(anApp->activeStudy()); + SUIT_ResourceMgr* aResMgr = anApp->resourceMgr(); + + // it is important to check whether the file is saved in the multi-files mode in order to save + // files in temporary directories, which are removed in the full SALOME mode after copiying + // the files content in a result file. + bool isMultiFile = aResMgr ? aResMgr->booleanValue("Study", "multi_file", false) : false; + + std::string aTmpDir = aStudy->GetTmpDir(qPrintable(myStudyPath), isMultiFile); + //std::string aTmpDir = aStudy->GetTmpDir("", false);//true ); theFiles.append(QString(aTmpDir.c_str())); aWorkShop->saveDocument(QString(aTmpDir.c_str()), aFileNames); -- 2.39.2