From a2c351e72cc95fbda77793cf127012e3b9d43a51 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 26 Jul 2012 23:16:17 +0000 Subject: Attach arrows to correct location on ports in Graphviz output. git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@4563 a436a847-0d15-0410-975c-d299462d15a1 --- src/Canvas.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Canvas.cpp b/src/Canvas.cpp index 96ae7ae..337cd16 100644 --- a/src/Canvas.cpp +++ b/src/Canvas.cpp @@ -472,7 +472,8 @@ GanvCanvasImpl::layout_dot(const std::string& filename) nodes.gvc = gvc; nodes.G = G; - if (_gcanvas->direction == GANV_DIRECTION_RIGHT) { + const bool flow_right = _gcanvas->direction; + if (flow_right) { agraphattr(G, (char*)"rankdir", (char*)"LR"); } else { agraphattr(G, (char*)"rankdir", (char*)"TD"); @@ -522,12 +523,12 @@ GanvCanvasImpl::layout_dot(const std::string& filename) cell += ">"; const char* label = ganv_node_get_label(GANV_NODE(port)); - if (label && _gcanvas->direction == GANV_DIRECTION_RIGHT) { + if (label && flow_right) { cell += label; } cell += ""; - if (_gcanvas->direction == GANV_DIRECTION_RIGHT) { + if (flow_right) { ports += "" + cell + ""; } else if (port->impl->is_input) { inputs += cell; @@ -552,8 +553,7 @@ GanvCanvasImpl::layout_dot(const std::string& filename) // Label row std::stringstream colspan; - colspan << ((_gcanvas->direction == GANV_DIRECTION_RIGHT) - ? 1 : (n_cols + 1)); + colspan << (flow_right ? 1 : (n_cols + 1)); html += std::string(""; @@ -604,10 +604,10 @@ GanvCanvasImpl::layout_dot(const std::string& filename) if (tail_i != nodes.end() && head_i != nodes.end()) { Agedge_t* e = agedge(G, tail_i->second, head_i->second); ss.str(""); - ss << edge->impl->tail; + ss << edge->impl->tail << (flow_right ? ":e" : ":s"); agsafeset(e, (char*)"tailport", (char*)ss.str().c_str(), NULL); ss.str(""); - ss << edge->impl->head; + ss << edge->impl->head << (flow_right ? ":w" : ":n"); agsafeset(e, (char*)"headport", (char*)ss.str().c_str(), NULL); } else { std::cerr << "Unable to find graphviz node" << std::endl; -- cgit v1.2.1