Skip to content
Snippets Groups Projects
Commit b2766ecd authored by Martin Christoph Hierholzer's avatar Martin Christoph Hierholzer
Browse files

allow creation of a dot graph containing the variable model

parent dde7837d
No related branches found
No related tags found
No related merge requests found
......@@ -109,6 +109,12 @@ namespace ChimeraTK {
/** Print the full hierarchy to stdout. */
void dump(const std::string &prefix="") const;
/** Create Graphviz dot graph write to file */
void dumpGraph(const std::string &fileName="graph.dot") const;
/** Create Graphviz dot graph write to stream, excluding the surrounding digraph command */
void dumpGraphInternal(std::ostream &stream) const;
protected:
......
......@@ -146,6 +146,52 @@ namespace ChimeraTK {
/*********************************************************************************************************************/
void EntityOwner::dumpGraph(const std::string& fileName) const {
std::fstream file(fileName, std::ios_base::out);
file << "digraph G {" << std::endl;
dumpGraphInternal(file);
file << "}" << std::endl;
file.close();
std::cout << "HIER " << fileName << std::endl;
}
/*********************************************************************************************************************/
void EntityOwner::dumpGraphInternal(std::ostream &stream) const {
std::string myDotNode = getQualifiedName();
std::replace(myDotNode.begin(), myDotNode.end(), '/', '_');
stream << myDotNode << "[label=\"" << getName() << "\"]" << std::endl;
for(auto &node : getAccessorList()) {
std::string dotNode = node.getQualifiedName();
std::replace(dotNode.begin(), dotNode.end(), '/', '_');
stream << dotNode << "[label=\"{" << node.getName() << "| {";
bool first = true;
for(auto tag : node.getTags()) {
if(!first) {
stream << "|";
}
else {
first = false;
}
stream << tag;
}
stream << "}}\", shape=record]" << std::endl;
stream << " " << myDotNode << " -> " << dotNode << std::endl;
}
for(auto &submodule : getSubmoduleList()) {
std::string dotNode = submodule->getQualifiedName();
std::replace(dotNode.begin(), dotNode.end(), '/', '_');
stream << " " << myDotNode << " -> " << dotNode << std::endl;
submodule->dumpGraphInternal(stream);
}
}
/*********************************************************************************************************************/
void EntityOwner::addTag(const std::string &tag) {
for(auto &node : getAccessorList()) node.addTag(tag);
for(auto &submodule : getSubmoduleList()) submodule->addTag(tag);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment