]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Use compressing for saving SHAPER files
authorvsv <vsv@opencascade.com>
Mon, 22 Oct 2018 13:02:52 +0000 (16:02 +0300)
committervsv <vsv@opencascade.com>
Mon, 22 Oct 2018 13:02:52 +0000 (16:02 +0300)
src/PartSet/PartSet_Tools.cpp
src/SHAPERGUI/SHAPERGUI.cpp
src/SHAPERGUI/SHAPERGUI_DataModel.cpp
src/SHAPERGUI/SHAPERGUI_DataModel.h
src/XGUI/XGUI_Workshop.cpp

index 7e030c5aa470a4c8e0eb5850731eede4c11d9ef8..16a0d0faaf09c0ab942858d44edc5a4b472be7ea 100755 (executable)
@@ -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;
index 64fb21b920cd6bc2ce62014eb03ad61712bc8006..e7189ffd8e38023950240ac34bb8d7198691c283 100644 (file)
@@ -137,6 +137,8 @@ SHAPERGUI::SHAPERGUI()
 //******************************************************
 SHAPERGUI::~SHAPERGUI()
 {
+  delete myWorkshop;
+  delete myProxyViewer;
 }
 
 //******************************************************
index f3d8fe4b80e52e84994a69c359c49b3ab3a24358..304dc616c4b9652c432d99e6e65736658ce22567 100644 (file)
@@ -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<std::string>::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<std::string>::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();
 }
 
index f0858a9878ed980f1106935146b4514bb88a8bf9..e95824ae7b02b84f5d70c371cae025dcce30845c 100644 (file)
@@ -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.
index 030a3b896e2c5b5b8e10bad0ec644e784ba42f4d..2a4f57be2429682bd006a8093f124ec76f917d86 100755 (executable)
@@ -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()));
 }
 
 //******************************************************