Salome HOME
Speed up the redraw of sketch with constraints moved by the point of the line
[modules/shaper.git] / src / Model / Model_Application.cpp
index df32ef977d7c599acfbb7dbadc23c99492533fb7..6f315ee0ebd58b3ade943dba1e30af618981d7c7 100644 (file)
@@ -19,17 +19,20 @@ Handle(Model_Application) Model_Application::getApplication()
 }
 
 //=======================================================================
-const boost::shared_ptr<Model_Document>& Model_Application::getDocument(string theDocID)
+const std::shared_ptr<Model_Document>& Model_Application::getDocument(string theDocID)
 {
   if (myDocs.find(theDocID) != myDocs.end())
     return myDocs[theDocID];
 
-  boost::shared_ptr<Model_Document> aNew(new Model_Document(theDocID));
+  static const std::string thePartSetKind("PartSet");
+  static const std::string thePartKind("Part");
+  std::shared_ptr<Model_Document> aNew(
+    new Model_Document(theDocID, theDocID == "root" ? thePartSetKind : thePartKind));
   myDocs[theDocID] = aNew;
   // load it if it must be loaded by demand
   if (myLoadedByDemand.find(theDocID) != myLoadedByDemand.end() && !myPath.empty()) {
     aNew->load(myPath.c_str());
-    myLoadedByDemand.erase(theDocID); // done, don't do it anymore
+    myLoadedByDemand.erase(theDocID);  // done, don't do it anymore
   }
 
   return myDocs[theDocID];
@@ -37,7 +40,17 @@ const boost::shared_ptr<Model_Document>& Model_Application::getDocument(string t
 
 void Model_Application::deleteDocument(string theDocID)
 {
-  myDocs.erase(theDocID);
+  if (myDocs.find(theDocID) != myDocs.end()) {
+    myDocs[theDocID]->close(true);
+    myDocs.erase(theDocID);
+  }
+  myLoadedByDemand.clear();
+}
+
+void Model_Application::deleteAllDocuments()
+{
+  myDocs.clear();
+  myLoadedByDemand.clear();
 }
 
 //=======================================================================
@@ -58,6 +71,12 @@ void Model_Application::setLoadByDemand(std::string theID)
   myLoadedByDemand.insert(theID);
 }
 
+//=======================================================================
+bool Model_Application::isLoadByDemand(std::string theID)
+{
+  return myLoadedByDemand.find(theID) != myLoadedByDemand.end();
+}
+
 //=======================================================================
 Model_Application::Model_Application()
 {
@@ -69,7 +88,7 @@ Model_Application::Model_Application()
 //=======================================================================
 void Model_Application::Formats(TColStd_SequenceOfExtendedString& theFormats)
 {
-  theFormats.Append(TCollection_ExtendedString("BinOcaf")); // standard binary schema
+  theFormats.Append(TCollection_ExtendedString("BinOcaf"));  // standard binary schema
 }
 
 //=======================================================================