diff --git a/src/complex/DataStructure/DataStructure.cpp b/src/complex/DataStructure/DataStructure.cpp index 6665602ab0..454c1e7e61 100644 --- a/src/complex/DataStructure/DataStructure.cpp +++ b/src/complex/DataStructure/DataStructure.cpp @@ -870,72 +870,74 @@ void DataStructure::resetIds(DataObject::IdType startingId) m_RootGroup.updateIds(updatedIds); } -void DataStructure::exportHeirarchyAsGraphViz(std::ostream& outputStream) const +void DataStructure::exportHierarchyAsGraphViz(std::ostream& outputStream) const { // initialize dot file outputStream << "digraph DataGraph {\n" << "\tlabelloc =\"t\"\n" - << "\trankdir=LR;\n\n"; - + << "\trankdir=LR;\n" + << "\tlabel=\"DataStructure Hierarchy\"\n" + << "\tlabelloc=\"t\"\n" + << "\tfontcolor=\"#FFFFFA\"\n" + << "\tfontsize=12\n" + << "\tgraph [splines=true bgcolor=\"#242627\"]\n" + << "\tnode [shape=record style=\"filled\" fillcolor=\"#1D7ECD\" fontsize=12 fontcolor=\"#FFFFFA\"]\n" + << "\tedge [dir=front arrowtail=empty style=\"\" color=\"#FFFFFA\"]\n\n"; // set base case for(const auto* object : getTopLevelData()) { auto topLevelPath = DataPath::FromString(object->getDataPaths()[0].getTargetName()).value(); auto optionalDataPaths = GetAllChildDataPaths(*this, topLevelPath); + outputStream << "\n/* Top level DataObject: " << topLevelPath.getTargetName() << " */\n\"" << topLevelPath.getTargetName() << "\";\n"; - if(!optionalDataPaths.has_value() || optionalDataPaths.value().size() == 0) + if(optionalDataPaths.has_value() && !optionalDataPaths.value().empty()) { - outputStream << "\"" << topLevelPath.getTargetName() << "\";\n\n"; + // Begin recursion + recurseHierarchyToGraphViz(outputStream, optionalDataPaths.value(), topLevelPath.getTargetName()); } - - // Begin recursion - recurseHeirarchyToGraphViz(outputStream, optionalDataPaths.value(), topLevelPath.getTargetName()); } // close dot file - outputStream << "}" << std::endl; // for readability + outputStream << "}\n"; // for readability } -void DataStructure::recurseHeirarchyToGraphViz(std::ostream& outputStream, const std::vector paths, const std::string& parent) const +void DataStructure::exportHierarchyAsText(std::ostream& outputStream) const { - for(const auto& path : paths) + // set base case + for(const auto* object : getTopLevelData()) { - // Output parent node, child node, and edge connecting them in .dot format - outputStream << "\"" << parent << "\" -> \"" << path.getTargetName() << "\"\n"; + auto topLevelPath = DataPath::FromString(object->getDataPaths()[0].getTargetName()).value(); + outputStream << k_Delimiter << topLevelPath.getTargetName() << "\n"; + auto optionalChildPaths = GetAllChildDataPaths(*this, topLevelPath); - // pull child paths or skip to next iteration - auto optionalChildPaths = GetAllChildDataPaths(*this, path); - if(!optionalChildPaths.has_value() || optionalChildPaths.value().size() == 0) + if(optionalChildPaths.has_value() && !optionalChildPaths.value().empty()) { - continue; + // Begin recursion + recurseHierarchyToText(outputStream, optionalChildPaths.value(), ""); } - - // recurse - recurseHeirarchyToGraphViz(outputStream, optionalChildPaths.value(), path.getTargetName()); } - outputStream << "\n"; // for readability + outputStream << '\n'; // for readability } -void DataStructure::exportHeirarchyAsText(std::ostream& outputStream) const +void DataStructure::recurseHierarchyToGraphViz(std::ostream& outputStream, const std::vector paths, const std::string& parent) const { - // set base case - for(const auto* object : getTopLevelData()) + for(const auto& path : paths) { - auto topLevelPath = DataPath::FromString(object->getDataPaths()[0].getTargetName()).value(); - auto optionalDataPaths = GetAllChildDataPaths(*this, topLevelPath); - - outputStream << k_Delimiter << topLevelPath.getTargetName() << "\n"; + auto* dataObjectPtr = getData(path); + // Output parent node, child node, and edge connecting them in .dot format + outputStream << "\"" << parent << "\" -> \"" << path.getTargetName() << "\"\n"; - if(optionalDataPaths.has_value() || optionalDataPaths.value().size() != 0) + // pull child paths or skip to next iteration + auto optionalChildPaths = GetAllChildDataPaths(*this, path); + if(optionalChildPaths.has_value() && !optionalChildPaths.value().empty()) { // Begin recursion - recurseHeirarchyToText(outputStream, optionalDataPaths.value(), ""); + recurseHierarchyToGraphViz(outputStream, optionalChildPaths.value(), path.getTargetName()); } } - outputStream << std::endl; // for readability } -void DataStructure::recurseHeirarchyToText(std::ostream& outputStream, const std::vector paths, std::string indent) const +void DataStructure::recurseHierarchyToText(std::ostream& outputStream, const std::vector paths, std::string indent) const { indent += " "; @@ -946,13 +948,13 @@ void DataStructure::recurseHeirarchyToText(std::ostream& outputStream, const std // pull child paths or skip to next iteration auto optionalChildPaths = GetAllChildDataPaths(*this, path); - if(!optionalChildPaths.has_value() || optionalChildPaths.value().size() == 0) + if(!optionalChildPaths.has_value() || optionalChildPaths.value().empty()) { continue; } // recurse - recurseHeirarchyToText(outputStream, optionalChildPaths.value(), indent); + recurseHierarchyToText(outputStream, optionalChildPaths.value(), indent); } } diff --git a/src/complex/DataStructure/DataStructure.hpp b/src/complex/DataStructure/DataStructure.hpp index c1e0016a6c..3a9af13e1b 100644 --- a/src/complex/DataStructure/DataStructure.hpp +++ b/src/complex/DataStructure/DataStructure.hpp @@ -665,14 +665,14 @@ class COMPLEX_EXPORT DataStructure * @param outputStream the child class of ostream to output dot syntax to * @return */ - void exportHeirarchyAsGraphViz(std::ostream& outputStream) const; + void exportHierarchyAsGraphViz(std::ostream& outputStream) const; /** * @brief Outputs data graph in console readable format * @param outputStream the child class of ostream to output to * @return */ - void exportHeirarchyAsText(std::ostream& outputStream) const; + void exportHierarchyAsText(std::ostream& outputStream) const; /** * @brief Copy assignment operator. The copied DataStructure's observers are not retained. @@ -800,7 +800,7 @@ class COMPLEX_EXPORT DataStructure * @param parent name of the calling parent to output * @return */ - void recurseHeirarchyToGraphViz(std::ostream& outputStream, const std::vector paths, const std::string& parent) const; + void recurseHierarchyToGraphViz(std::ostream& outputStream, const std::vector paths, const std::string& parent) const; /** * @brief The recursive function to parse graph and dump names to and output stream in @@ -810,7 +810,7 @@ class COMPLEX_EXPORT DataStructure * @param indent the indent for the heirarchy * @return */ - void recurseHeirarchyToText(std::ostream& outputStream, const std::vector paths, std::string indent) const; + void recurseHierarchyToText(std::ostream& outputStream, const std::vector paths, std::string indent) const; /** * @brief Notifies observers to the provided message.