DAG: Change object graph handling to be bidirectional

This commit is contained in:
Stefan Tröger
2016-12-25 20:14:58 +01:00
committed by wmayer
parent 041cafe6ad
commit 49716393c6
11 changed files with 613 additions and 52 deletions

View File

@@ -490,6 +490,38 @@ Py::List DocumentPy::getObjects(void) const
return res;
}
Py::List DocumentPy::getToplogicalSortedObjects(void) const
{
#if USE_OLD_DAG == 0
std::vector<DocumentObject*> objs = getDocumentPtr()->topologicalSort();
Py::List res;
for (std::vector<DocumentObject*>::const_iterator It = objs.begin(); It != objs.end(); ++It)
//Note: Here we must force the Py::Object to own this Python object as getPyObject() increments the counter
res.append(Py::Object((*It)->getPyObject(), true));
return res;
#else
return Py::List();
#endif
}
Py::List DocumentPy::getRootObjects(void) const
{
#if USE_OLD_DAG == 0
std::vector<DocumentObject*> objs = getDocumentPtr()->getRootObjects();
Py::List res;
for (std::vector<DocumentObject*>::const_iterator It = objs.begin(); It != objs.end(); ++It)
//Note: Here we must force the Py::Object to own this Python object as getPyObject() increments the counter
res.append(Py::Object((*It)->getPyObject(), true));
return res;
#else
return Py::List();
#endif
}
Py::Int DocumentPy::getUndoMode(void) const
{
return Py::Int(getDocumentPtr()->getUndoMode());