+// t oredirect all calls to the root document
+#define ROOT_DOC std::dynamic_pointer_cast<Model_Document>(moduleDocument())
+
+bool Model_Session::load(const char* theFileName)
+{
+ bool aRes = ROOT_DOC->load(theFileName, "root", ROOT_DOC);
+ return aRes;
+}
+
+bool Model_Session::save(const char* theFileName, std::list<std::string>& theResults)
+{
+ return ROOT_DOC->save(theFileName, "root", theResults);
+}
+
+void Model_Session::closeAll()
+{
+ Model_Application::getApplication()->deleteAllDocuments();
+}
+
+void Model_Session::startOperation(const std::string& theId, const bool theAttachedToNested)
+{
+ myOperationAttachedToNext = theAttachedToNested;
+ 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);
+ // remove all useless documents that has been closed: on start of operation undo/redo is cleared
+ // MPV: this code is dangerous now because it may close the document that is activated right now
+ // but not in the list of the opened documents yet (create, delete, undo, activate Part)
+ // later this must be updated by correct usage of uniques IDs of documents, not names of results
+ //std::list<std::shared_ptr<ModelAPI_Document> > aUsedDocs = allOpenedDocuments();
+ //Model_Application::getApplication()->removeUselessDocuments(aUsedDocs);
+}
+
+void Model_Session::finishOperation()
+{
+ setCheckTransactions(false);
+ ROOT_DOC->finishOperation();
+ if (myOperationAttachedToNext) { // twice, with nested
+ ROOT_DOC->finishOperation();
+ myOperationAttachedToNext = false;
+ }
+ setCheckTransactions(true);
+}
+
+void Model_Session::abortOperation()
+{
+ setCheckTransactions(false);
+ ROOT_DOC->abortOperation();
+ if (myOperationAttachedToNext) { // twice, with nested
+ ROOT_DOC->abortOperation();
+ myOperationAttachedToNext = false;
+ }
+ setCheckTransactions(true);
+ // here the update mechanism may work after abort, so, supress the warnings about
+ // modifications outside of the transactions
+ bool aWasCheck = myCheckTransactions;
+ myCheckTransactions = false;
+ static std::shared_ptr<Events_Message> anAbortMsg
+ (new Events_Message(Events_Loop::eventByName("AbortOperation")));
+ Events_Loop::loop()->send(anAbortMsg);
+ myCheckTransactions = true;
+ myCheckTransactions = aWasCheck;
+}
+
+bool Model_Session::isOperation()
+{
+ return ROOT_DOC->isOperation();
+}
+
+bool Model_Session::isModified()
+{
+ return ROOT_DOC->isModified();
+}
+
+bool Model_Session::canUndo()
+{
+ return ROOT_DOC->canUndo();
+}
+
+void Model_Session::undo()
+{
+ setCheckTransactions(false);
+ ROOT_DOC->undo();
+ setCheckTransactions(true);
+}
+
+bool Model_Session::canRedo()
+{
+ return ROOT_DOC->canRedo();
+}
+
+void Model_Session::redo()
+{
+ setCheckTransactions(false);
+ ROOT_DOC->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, Model_Document* theDocOwner)