Salome HOME
Merge commit 'refs/tags/V9_2_0^{}'
[modules/shaper.git] / src / SHAPERGUI / SHAPERGUI_DataModel.cpp
index 8b2eedd403a5d1930fef55bfb1c79746139310ad..a799ef0444b06d26ca63878f0fad4b4751fe8832 100644 (file)
@@ -76,20 +76,10 @@ 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);
   }
 
-  SessionPtr aMgr = ModelAPI_Session::get();
-  aMgr->load(qPrintable(aNewTmpDir));
   myModule->setIsOpened(true);
   return true;
 }
@@ -110,17 +100,21 @@ bool SHAPERGUI_DataModel::save(QStringList& theFiles)
   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);
-  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));
-  }
+  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);
+  aWorkShop->setCurrentDataFile(aTmp + "shaper.shaper");
+  aWorkShop->onSave();
+  QString aName = aWorkShop->currentDataFile();
+  aName.replace(QChar('\\'), QChar('/'));
+  int aN = aName.lastIndexOf('/');
+  theFiles.append(aName.right(aName.length() - aN - 1));
+
   return true;
 }
 
@@ -133,8 +127,6 @@ bool SHAPERGUI_DataModel::saveAs(const QString& thePath, CAM_Study* theStudy, QS
 bool SHAPERGUI_DataModel::close()
 {
   myModule->workshop()->closeDocument();
-  removeDirectory(myTmpDirectory);
-  myTmpDirectory = "";
   return LightApp_DataModel::close();
 }
 
@@ -202,6 +194,11 @@ bool SHAPERGUI_DataModel::dumpPython(const QString& thePath, CAM_Study* theStudy
     aAttr = aFeature->string(ExchangePlugin_Dump::FILE_FORMAT_ID());
     if (aAttr.get())
       aAttr->setValue(".py");
+
+    AttributeStringPtr aTypeAttr = aFeature->string(ExchangePlugin_Dump::SELECTION_TYPE_ID());
+    if (aTypeAttr.get())
+      aTypeAttr->setValue(ExchangePlugin_Dump::TOPOLOGICAL_NAMING_DUMP_ID());
+
     ModelAPI_Session::get()->finishOperation();
 
     if (QFile::exists(aFileName.c_str())) {