From b748001d9b82eb04ddc955df60675dad06497705 Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 22 Oct 2018 16:02:52 +0300 Subject: [PATCH] Use compressing for saving SHAPER files --- src/PartSet/PartSet_Tools.cpp | 3 +- src/SHAPERGUI/SHAPERGUI.cpp | 2 + src/SHAPERGUI/SHAPERGUI_DataModel.cpp | 58 ++++++++++++++++----------- src/SHAPERGUI/SHAPERGUI_DataModel.h | 2 +- src/XGUI/XGUI_Workshop.cpp | 2 - 5 files changed, 40 insertions(+), 27 deletions(-) diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 7e030c5aa..16a0d0faa 100755 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -761,7 +761,8 @@ void PartSet_Tools::getFirstAndLastIndexInFolder(const ObjectPtr& theFolder, if (!aFolder.get()) return; - AttributeReferencePtr aFirstFeatAttr = aFolder->data()->reference(ModelAPI_Folder::FIRST_FEATURE_ID()); + AttributeReferencePtr aFirstFeatAttr = + aFolder->data()->reference(ModelAPI_Folder::FIRST_FEATURE_ID()); FeaturePtr aFirstFeatureInFolder = ModelAPI_Feature::feature(aFirstFeatAttr->value()); if (!aFirstFeatureInFolder.get()) { theFirst = -1; diff --git a/src/SHAPERGUI/SHAPERGUI.cpp b/src/SHAPERGUI/SHAPERGUI.cpp index 64fb21b92..e7189ffd8 100644 --- a/src/SHAPERGUI/SHAPERGUI.cpp +++ b/src/SHAPERGUI/SHAPERGUI.cpp @@ -137,6 +137,8 @@ SHAPERGUI::SHAPERGUI() //****************************************************** SHAPERGUI::~SHAPERGUI() { + delete myWorkshop; + delete myProxyViewer; } //****************************************************** diff --git a/src/SHAPERGUI/SHAPERGUI_DataModel.cpp b/src/SHAPERGUI/SHAPERGUI_DataModel.cpp index f3d8fe4b8..304dc616c 100644 --- a/src/SHAPERGUI/SHAPERGUI_DataModel.cpp +++ b/src/SHAPERGUI/SHAPERGUI_DataModel.cpp @@ -76,20 +76,23 @@ bool SHAPERGUI_DataModel::open(const QString& thePath, CAM_Study* theStudy, QStr QString aFileName = *anIt; QString aCurrentFile = SUIT_Tools::addSlash(aTmpDir) + aFileName; - QString aNewFile = SUIT_Tools::addSlash(aNewTmpDir) + aFileName; - if (!QFile::copy(aCurrentFile, aNewFile)) - isDone = false; - } - if (isDone) { - myTmpDirectory = aNewTmpDir; - } - else { - removeDirectory(aNewTmpDir); - myTmpDirectory = ""; + XGUI_Workshop* aWorkShop = myModule->workshop(); + aWorkShop->openFile(aCurrentFile); + //QString aNewFile = SUIT_Tools::addSlash(aNewTmpDir) + aFileName; + //if (!QFile::copy(aCurrentFile, aNewFile)) + // isDone = false; } + //if (isDone) { + // myTmpDirectory = aNewTmpDir; + //} + //else { + // removeDirectory(aNewTmpDir); + // myTmpDirectory = ""; + //} + + //SessionPtr aMgr = ModelAPI_Session::get(); + //aMgr->load(qPrintable(aNewTmpDir)); - SessionPtr aMgr = ModelAPI_Session::get(); - aMgr->load(qPrintable(aNewTmpDir)); myModule->setIsOpened(true); return true; } @@ -111,20 +114,29 @@ bool SHAPERGUI_DataModel::save(QStringList& theFiles) std::string aTmpDir = aStudy->GetTmpDir(qPrintable(myStudyPath), isMultiFile); //std::string aTmpDir = aStudy->GetTmpDir("", false);//true ); - theFiles.append(QString(aTmpDir.c_str())); + QString aTmp = QString(aTmpDir.c_str()); + theFiles.append(aTmp); SessionPtr aMgr = ModelAPI_Session::get(); if (aMgr->isAutoUpdateBlocked()) aMgr->blockAutoUpdate(false); - aWorkShop->saveDocument(QString(aTmpDir.c_str()), aFileNames); - std::list::iterator aIt; - for (aIt = aFileNames.begin(); aIt != aFileNames.end(); ++aIt) { - QString aName((*aIt).c_str()); - aName.replace(QChar('\\'), QChar('/')); - int aN = aName.lastIndexOf('/'); - theFiles.append(aName.right(aName.length() - aN - 1)); - } + //aWorkShop->saveDocument(QString(aTmpDir.c_str()), aFileNames); + aWorkShop->setCurrentDataFile(aTmp + "shaper.opp"); + aWorkShop->onSave(); + QString aName = aWorkShop->currentDataFile(); + std::string aa = aName.toStdString(); + aName.replace(QChar('\\'), QChar('/')); + int aN = aName.lastIndexOf('/'); + theFiles.append(aName.right(aName.length() - aN - 1)); + + //std::list::iterator aIt; + //for (aIt = aFileNames.begin(); aIt != aFileNames.end(); ++aIt) { + // QString aName((*aIt).c_str()); + // aName.replace(QChar('\\'), QChar('/')); + // int aN = aName.lastIndexOf('/'); + // theFiles.append(aName.right(aName.length() - aN - 1)); + //} return true; } @@ -137,8 +149,8 @@ bool SHAPERGUI_DataModel::saveAs(const QString& thePath, CAM_Study* theStudy, QS bool SHAPERGUI_DataModel::close() { myModule->workshop()->closeDocument(); - removeDirectory(myTmpDirectory); - myTmpDirectory = ""; + //removeDirectory(myTmpDirectory); + //myTmpDirectory = ""; return LightApp_DataModel::close(); } diff --git a/src/SHAPERGUI/SHAPERGUI_DataModel.h b/src/SHAPERGUI/SHAPERGUI_DataModel.h index f0858a987..e95824ae7 100644 --- a/src/SHAPERGUI/SHAPERGUI_DataModel.h +++ b/src/SHAPERGUI/SHAPERGUI_DataModel.h @@ -93,7 +93,7 @@ protected: QString myStudyPath; /// a path to the temporary directory, created by opening a document file - QString myTmpDirectory; + //QString myTmpDirectory; /// it should be created because the files reading is postponed in the module. The directory // should be removed after the model document is closed. diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 030a3b896..2a4f57be2 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -289,8 +289,6 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) //IMP: an attempt to use result selection with other selection modes myViewerSelMode.append(ModuleBase_ResultPrs::Sel_Result);//TopAbs_VERTEX); myViewerSelMode.append(TopAbs_COMPSOLID); - - qDebug("### Tmp: %s", qPrintable(myTmpDir.path())); } //****************************************************** -- 2.39.2