Export object dependencies to graphviz file

This commit is contained in:
wmayer
2012-06-12 19:03:29 +02:00
parent 6621c00c10
commit 9170bfe045
7 changed files with 131 additions and 3 deletions

View File

@@ -847,6 +847,31 @@ unsigned int Document::getMemSize (void) const
return size;
}
void Document::exportGraphviz(std::ostream& out)
{
std::vector<std::string> names;
names.reserve(d->objectMap.size());
DependencyList DepList;
std::map<DocumentObject*,Vertex> VertexObjectList;
// Filling up the adjacency List
for (std::map<std::string,DocumentObject*>::const_iterator It = d->objectMap.begin(); It != d->objectMap.end();++It) {
// add the object as Vertex and remember the index
VertexObjectList[It->second] = add_vertex(DepList);
names.push_back(It->second->Label.getValue());
}
// add the edges
for (std::map<std::string,DocumentObject*>::const_iterator It = d->objectMap.begin(); It != d->objectMap.end();++It) {
std::vector<DocumentObject*> OutList = It->second->getOutList();
for (std::vector<DocumentObject*>::const_iterator It2=OutList.begin();It2!=OutList.end();++It2) {
if (*It2)
add_edge(VertexObjectList[It->second],VertexObjectList[*It2],DepList);
}
}
boost::write_graphviz(out, DepList, boost::make_label_writer(&(names[0])));
}
// Save the document under the name it has been opened
bool Document::save (void)
{