Salome HOME
Merge branch 'master' into Dev_1.1.0
[modules/shaper.git] / src / Model / Model_Session.cpp
index 8e0d971254fa9f113b3afdeced8c9d8c168e79cc..e7f21bf88a8470860d5c3bfba731f94b743dc564 100644 (file)
@@ -51,9 +51,10 @@ void Model_Session::closeAll()
   Model_Application::getApplication()->deleteAllDocuments();
 }
 
-void Model_Session::startOperation()
+void Model_Session::startOperation(const std::string& theId)
 {
   ROOT_DOC->startOperation();
+  ROOT_DOC->operationId(theId);
   static std::shared_ptr<Events_Message> aStartedMsg
     (new Events_Message(Events_Loop::eventByName("StartOperation")));
   Events_Loop::loop()->send(aStartedMsg);
@@ -119,6 +120,17 @@ void Model_Session::redo()
   setCheckTransactions(true);
 }
 
+//! Returns stack of performed operations
+std::list<std::string> Model_Session::undoList()
+{
+  return ROOT_DOC->undoList();
+}
+//! Returns stack of rolled back operations
+std::list<std::string> Model_Session::redoList()
+{
+  return ROOT_DOC->redoList();
+}
+
 FeaturePtr Model_Session::createFeature(string theFeatureID)
 {
   if (this != myImpl) {
@@ -161,8 +173,18 @@ FeaturePtr Model_Session::createFeature(string theFeatureID)
 
 std::shared_ptr<ModelAPI_Document> Model_Session::moduleDocument()
 {
-  return std::shared_ptr<ModelAPI_Document>(
+  bool aFirstCall = !Model_Application::getApplication()->hasDocument("root");
+  if (aFirstCall) {
+    // creation of the root document is always outside of the transaction, so, avoid checking it
+    setCheckTransactions(false);
+  }
+  std::shared_ptr<ModelAPI_Document> aDoc = std::shared_ptr<ModelAPI_Document>(
       Model_Application::getApplication()->getDocument("root"));
+  if (aFirstCall) {
+    // creation of the root document is always outside of the transaction, so, avoid checking it
+    setCheckTransactions(true);
+  }
+  return aDoc;
 }
 
 std::shared_ptr<ModelAPI_Document> Model_Session::document(std::string theDocID)
@@ -288,7 +310,10 @@ void Model_Session::processEvent(const std::shared_ptr<Events_Message>& theMessa
         if(aMsgAttr->isConcealment()) {
           validators()->registerConcealment(aMsgAttr->featureId(), aMsgAttr->attributeId());
         }
-        
+        if (!aMsgAttr->caseId().empty()) {
+          validators()->registerCase(aMsgAttr->featureId(), aMsgAttr->attributeId(),
+            aMsgAttr->switchId(), aMsgAttr->caseId());
+        }
       }
     }
     // plugins information was started to load, so, it will be loaded