From b91c9bbd910d3aae2479e8fe2bc5227095bdf191 Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Wed, 7 Aug 2013 23:42:46 +0100 Subject: [PATCH] Issue #39. Added saving of the graph for visualisation purposes. Still haven't figured out that crash bug. --- src/gui/main.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/gui/main.cpp b/src/gui/main.cpp index 99d4f19f..e5f88c6a 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -607,7 +607,8 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { //Now that we have the non-master plugin's vertex, create an edge between the two. BOOST_LOG_TRIVIAL(trace) << "Adding edge from \"" << it->Name() << "\" to \"" << jt->Name() << "\"."; - boost::add_edge(vertex, childVertex, graph); + if (!boost::edge(vertex, childVertex, graph).second) //To avoid duplicates (helps visualisation). + boost::add_edge(vertex, childVertex, graph); } } @@ -620,7 +621,8 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { continue; //Add the vertex (again assuming that duplicates won't be created). boss::vertex_t parentVertex = boost::vertex( std::distance(beginIt, result), graph); - boost::add_edge(parentVertex, vertex, graph); + if (!boost::edge(parentVertex, vertex, graph).second) //To avoid duplicates (helps visualisation). + boost::add_edge(parentVertex, vertex, graph); } //Now add requirements. @@ -634,7 +636,8 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { continue; //Add the vertex (again assuming that duplicates won't be created). boss::vertex_t parentVertex = boost::vertex( std::distance(beginIt, result), graph); - boost::add_edge(parentVertex, vertex, graph); + if (!boost::edge(parentVertex, vertex, graph).second) //To avoid duplicates (helps visualisation). + boost::add_edge(parentVertex, vertex, graph); } } @@ -649,7 +652,8 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { continue; //Add the vertex (again assuming that duplicates won't be created). boss::vertex_t parentVertex = boost::vertex( std::distance(beginIt, result), graph); - boost::add_edge(parentVertex, vertex, graph); + if (!boost::edge(parentVertex, vertex, graph).second) //To avoid duplicates (helps visualisation). + boost::add_edge(parentVertex, vertex, graph); } } @@ -670,6 +674,14 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { } } + //Just for fun - output the graph as a ".dot" file for external rendering. If I can get this pretty, I might add it to a tab in the BOSS Report - I think there's a Javascript library for displaying .dot files (though stuff of this complexity might make it explode...). + vector names; + for (list::const_iterator it=plugins.begin(), endIt=plugins.end(); it != endIt; ++it) { + names.push_back(it->Name()); + } + boss::ofstream outfun("fun.dot"); + boost::write_graphviz(outfun, graph, boost::make_label_writer(&names[0])); + if (!cyclicDependenciesExist) {