+ fixes #0001501: Add Ability to Export Dependency Graph as SVG and PNG

This commit is contained in:
wmayer
2014-04-07 14:26:43 +02:00
parent c68b8ab9b2
commit 5096be5a26
6 changed files with 323 additions and 54 deletions

View File

@@ -201,6 +201,32 @@ void Document::writeDependencyGraphViz(std::ostream &out)
out << "}" << endl;
}
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);
}
}
if (!names.empty())
boost::write_graphviz(out, DepList, boost::make_label_writer(&(names[0])));
}
//bool _has_cycle_dfs(const DependencyList & g, vertex_t u, default_color_type * color)
//{
// color[u] = gray_color;
@@ -906,32 +932,6 @@ 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);
}
}
if (!names.empty())
boost::write_graphviz(out, DepList, boost::make_label_writer(&(names[0])));
}
bool Document::saveAs(const char* file)
{
Base::FileInfo fi(file);