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

allow creation of graphs containing only the modules

parent f0fc9e81
No related branches found
No related tags found
No related merge requests found
......@@ -113,9 +113,16 @@ namespace ChimeraTK {
/** Print the full hierarchy to stdout. */
void dump(const std::string &prefix="") const;
/** Create Graphviz dot graph write to file */
/** Create Graphviz dot graph and write to file. The graph will contain the full hierarchy of modules and
* variables below (and including) this module. Each variable will also show which tags are attached to it.
* ModuleGroups will be drawn with a double line, ApplicationModules with a bold line. Hierarchies which will
* be eliminated in the dynamic information model are shown with a dotted line. */
void dumpGraph(const std::string &fileName="graph.dot") const;
/** Create a Graphiz dot graph similar to the one created with dumpGraph, but just show the modules and not the
* variables. This allows to get an overview over more complex applications. */
void dumpModuleGraph(const std::string &fileName="graph.dot") const;
enum class ModuleType {
ApplicationModule, ModuleGroup, VariableGroup, ControlSystem, Device
};
......@@ -132,7 +139,7 @@ namespace ChimeraTK {
bool eliminateFirstHierarchy=false, bool negate=false) const;
/** Create Graphviz dot graph write to stream, excluding the surrounding digraph command */
void dumpGraphInternal(std::ostream &stream) const;
void dumpGraphInternal(std::ostream &stream, bool showVariables) const;
/** Clean a fully qualified entity name so it can be used as a dot node name (i.e. strip slashes etc.) */
std::string cleanDotNode(std::string fullName) const;
......
......@@ -177,7 +177,17 @@ 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);
dumpGraphInternal(file, true);
file << "}" << std::endl;
file.close();
}
/*********************************************************************************************************************/
void EntityOwner::dumpModuleGraph(const std::string& fileName) const {
std::fstream file(fileName, std::ios_base::out);
file << "digraph G {" << std::endl;
dumpGraphInternal(file, false);
file << "}" << std::endl;
file.close();
}
......@@ -192,7 +202,7 @@ namespace ChimeraTK {
/*********************************************************************************************************************/
void EntityOwner::dumpGraphInternal(std::ostream &stream) const {
void EntityOwner::dumpGraphInternal(std::ostream &stream, bool showVariables) const {
std::string myDotNode = cleanDotNode(getQualifiedName());
......@@ -208,27 +218,31 @@ namespace ChimeraTK {
}
stream << "]" << std::endl;
for(auto &node : getAccessorList()) {
std::string dotNode = cleanDotNode(node.getQualifiedName());
stream << dotNode << "[label=\"{" << node.getName() << "| {";
bool first = true;
for(auto tag : node.getTags()) {
if(!first) {
stream << "|";
if(showVariables) {
for(auto &node : getAccessorList()) {
std::string dotNode = cleanDotNode(node.getQualifiedName());
stream << dotNode << "[label=\"{" << node.getName() << "| {";
bool first = true;
for(auto tag : node.getTags()) {
if(!first) {
stream << "|";
}
else {
first = false;
}
stream << tag;
}
else {
first = false;
}
stream << tag;
stream << "}}\", shape=record]" << std::endl;
stream << " " << myDotNode << " -> " << dotNode << std::endl;
}
stream << "}}\", shape=record]" << std::endl;
stream << " " << myDotNode << " -> " << dotNode << std::endl;
}
for(auto &submodule : getSubmoduleList()) {
for(auto submodule : getSubmoduleList()) {
if(submodule->getModuleType() == ModuleType::Device ||
submodule->getModuleType() == ModuleType::ControlSystem) continue;
std::string dotNode = cleanDotNode(submodule->getQualifiedName());
stream << " " << myDotNode << " -> " << dotNode << std::endl;
submodule->dumpGraphInternal(stream);
submodule->dumpGraphInternal(stream, showVariables);
}
}
......
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