+ if (theDoc.get() && theSendSignal) {
+ // syncronize the document: it may be just opened or opened but removed before
+ std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(theDoc);
+ if (aDoc.get()) {
+ bool aWasChecked = myCheckTransactions;
+ setCheckTransactions(false);
+ TDF_LabelList anEmptyUpdated;
+ aDoc->objects()->synchronizeFeatures(anEmptyUpdated, true, true);
+ if (aWasChecked)
+ setCheckTransactions(true);
+ }
+ static std::shared_ptr<Events_Message> aMsg(
+ new Events_Message(Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED)));
+ Events_Loop::loop()->send(aMsg);
+ }
+ // make the current state correct and synchronised in the module and sub-documents
+ if (isOperation()) { // do it only in transaction, not on opening of document
+ if (myCurrentDoc == moduleDocument()) {
+ // make the current feature the latest in root, in previous root current become also last
+ makeCurrentLast(aPrevious);
+ makeCurrentLast(myCurrentDoc);
+ } else {
+ // make the current feature the latest in sub, root current feature becomes this sub
+ makeCurrentLast(myCurrentDoc);
+ DocumentPtr aRoot = moduleDocument();
+ ResultPtr aPartRes = ModelAPI_Tools::findPartResult(aRoot, myCurrentDoc);
+ if (aPartRes.get()) {
+ FeaturePtr aPartFeat = aRoot->feature(aPartRes);
+ if (aPartFeat.get()) {
+ aRoot->setCurrentFeature(aPartFeat, false);
+ }
+ }
+ }
+ }
+ }
+}
+
+std::list<std::shared_ptr<ModelAPI_Document> > Model_Session::allOpenedDocuments()
+{
+ list<std::shared_ptr<ModelAPI_Document> > aResult;
+ aResult.push_back(moduleDocument());
+ // add subs recursively
+ list<std::shared_ptr<ModelAPI_Document> >::iterator aDoc = aResult.begin();
+ for(; aDoc != aResult.end(); aDoc++) {
+ DocumentPtr anAPIDoc = *aDoc;
+ std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(anAPIDoc);
+ if (aDoc) {
+ const std::set<std::string> aSubs = aDoc->subDocuments(true);
+ std::set<std::string>::const_iterator aSubIter = aSubs.cbegin();
+ for(; aSubIter != aSubs.cend(); aSubIter++) {
+ if (!Model_Application::getApplication()->isLoadByDemand(*aSubIter)) {
+ aResult.push_back(Model_Application::getApplication()->getDocument(*aSubIter));
+ }
+ }
+ }