|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r79850 - in sandbox/icl/libs/xplore/br1/sqlbrowser: . Dag
From: afojgo_at_[hidden]
Date: 2012-08-02 09:56:45
Author: jofaber
Date: 2012-08-02 09:56:43 EDT (Thu, 02 Aug 2012)
New Revision: 79850
URL: http://svn.boost.org/trac/boost/changeset/79850
Log:
Adapting visitor for dag representation.
Text files modified:
sandbox/icl/libs/xplore/br1/sqlbrowser/CreatorVisitor2.h | 53 ++++++++++++++++++++++++++++++++++-----
sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/DbBasedGraph.h | 10 +++---
sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp | 3 -
3 files changed, 52 insertions(+), 14 deletions(-)
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/CreatorVisitor2.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/CreatorVisitor2.h (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/CreatorVisitor2.h 2012-08-02 09:56:43 EDT (Thu, 02 Aug 2012)
@@ -81,10 +81,7 @@
struct OnExamineEdge : public boost::base_visitor<OnExamineEdge>
{
OnExamineEdge(DagItem* curItem, QString* result, Vertex2AttributesMap& attrs)
- : p_curItem(curItem), p_result(result), r_attrs(attrs)
- {
- //CL r_attrs[0].setDagItem(p_curItem); //Root node
- }
+ : p_curItem(curItem), p_result(result), r_attrs(attrs){}
typedef boost::on_examine_edge event_filter;
@@ -92,9 +89,9 @@
void operator()(Edge edge, Graph& dag)
{
vertex_descriptor source_node = source(edge, dag);
- dbg_str = QString("(%1)[%2] %3").arg(source_node).arg(dag[source_node].key()).arg(dag[source_node].name());
+ dbg_src = QString("(%1)[%2] %3").arg(source_node).arg(dag[source_node].key()).arg(dag[source_node].name());
vertex_descriptor target_node = target(edge, dag);
- dbg_str = QString("(%1)[%2] %3").arg(target_node).arg(dag[target_node].key()).arg(dag[target_node].name());
+ dbg_trg = QString("(%1)[%2] %3").arg(target_node).arg(dag[target_node].key()).arg(dag[target_node].name());
int source_depth = r_attrs[source_node].depth();
int target_depth = source_depth + 1;
@@ -134,9 +131,51 @@
DagItem* p_curItem;
QString* p_result;
Vertex2AttributesMap& r_attrs;
- QString dbg_str;
+ QString dbg_src;//CL
+ QString dbg_trg;//CL
};
+
+ struct OnForwardOrCrossEdge : public boost::base_visitor<OnForwardOrCrossEdge>
+ {
+ OnForwardOrCrossEdge(DagItem* curItem, QString* result, Vertex2AttributesMap& attrs)
+ : p_curItem(curItem), p_result(result), r_attrs(attrs){}
+
+ typedef boost::on_forward_or_cross_edge event_filter;
+
+ template<class Edge, class Graph>
+ void operator()(Edge edge, Graph& graph)
+ {
+ //int source_depth = graph[source(edge, graph)].depth();
+ vertex_descriptor sourceVertex = source(edge, graph);
+ vertex_descriptor targetVertex = target(edge, graph);
+ Vertex2AttributesMap::iterator sourceVertex_ = r_attrs.find(sourceVertex);
+
+ int sourceDepth = depth(sourceVertex);
+ int targetDepth = sourceDepth + 1;
+
+ *p_result += indentation(targetDepth)
+ + QString("[%1<%2>%3]\n").arg(graph[sourceVertex].key())
+ .arg(graph[edge].typeName())
+ .arg(graph[targetVertex].key());
+ // When constructing a QTreeModel I have to copy the node associated to
+ // graph[targetVertex] (e.g. graph[targetVertex].QtModel
+ }
+
+ template<class Vertex>
+ int depth(Vertex& node)
+ {
+ Vertex2AttributesMap::iterator node_ = r_attrs.find(node);
+ return node_ == r_attrs.end() ? 0 : (*node_).second.depth();
+ }
+
+ DagItem* p_curItem;
+ QString* p_result;
+ Vertex2AttributesMap& r_attrs;
+ QString dbg_str;//CL
+ };
+
+
struct OnFinishVertex : public boost::base_visitor<OnFinishVertex>
{
OnFinishVertex(DagItem* curItem, QString* result, Vertex2AttributesMap& names)
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/DbBasedGraph.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/DbBasedGraph.h (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/DbBasedGraph.h 2012-08-02 09:56:43 EDT (Thu, 02 Aug 2012)
@@ -203,11 +203,11 @@
boost::depth_first_search(
m_aGraph
, make_dfs_visitor(boost::make_list(
- CreatorVisitor2<DbBasedGraph>::OnDiscoverVertex (modelRoot, &graphAsString, vertex2AttrMap)
- , CreatorVisitor2<DbBasedGraph>::OnExamineEdge (modelRoot, &graphAsString, vertex2AttrMap)
- // , CreatorVisitor2<DbBasedGraph>::OnForwardOrCrossEdge(modelRoot, &graphAsString, vertex2AttrMap)
- , CreatorVisitor2<DbBasedGraph>::OnFinishVertex (modelRoot, &graphAsString, vertex2AttrMap)
- )
+ CreatorVisitor2<DbBasedGraph>::OnDiscoverVertex (modelRoot, &graphAsString, vertex2AttrMap)
+ , CreatorVisitor2<DbBasedGraph>::OnExamineEdge (modelRoot, &graphAsString, vertex2AttrMap)
+ , CreatorVisitor2<DbBasedGraph>::OnForwardOrCrossEdge(modelRoot, &graphAsString, vertex2AttrMap)
+ , CreatorVisitor2<DbBasedGraph>::OnFinishVertex (modelRoot, &graphAsString, vertex2AttrMap)
+ )
)
, pm_color
, start_vertex
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp 2012-08-02 09:56:43 EDT (Thu, 02 Aug 2012)
@@ -254,8 +254,7 @@
DagModel2* dagmo = new DagModel2(); // Dag-Model
QString dbg_dagString = ogra.makeDagModel(dagmo);
util::launchMsgBox(dbg_dagString);
- //dagmo->setDag(ogra); //Make the Model from a boost::graph internally
- //dagmo->makeDagModel();
+ ext_tree->setModel(dagmo);
//--------------------------------------------------------------------------
if(success)
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk