+ static Events_Message aMsg(Events_Loop::eventByName("CurrentDocumentChanged"));
+ Events_Loop::loop()->send(aMsg);
+}
+
+boost::shared_ptr<ModelAPI_Document> Model_PluginManager::copy(
+ boost::shared_ptr<ModelAPI_Document> theSource, std::string theID)
+{
+ // create a new document
+ boost::shared_ptr<Model_Document> aNew = boost::dynamic_pointer_cast<Model_Document>(
+ Model_Application::getApplication()->getDocument(theID));
+ // make a copy of all labels
+ TDF_Label aSourceRoot =
+ boost::dynamic_pointer_cast<Model_Document>(theSource)->document()->Main().Father();
+ TDF_Label aTargetRoot = aNew->document()->Main().Father();
+ Handle(TDF_DataSet) aDS = new TDF_DataSet;
+ aDS->AddLabel(aSourceRoot);
+ TDF_ClosureTool::Closure(aDS);
+ Handle(TDF_RelocationTable) aRT = new TDF_RelocationTable;
+ aRT->SetRelocation(aSourceRoot, aTargetRoot);
+ TDF_CopyTool::Copy(aDS, aRT);
+
+ aNew->synchronizeFeatures();
+ return aNew;