summaryrefslogtreecommitdiff
path: root/src/gtkext/graph/layout.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-05-04 21:58:09 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-05-04 21:58:09 (GMT)
commit4d0451c1153eb572f5ab0833c0c0911dfdc5f11a (patch)
tree6fb1690ded59d323bb21ac200dabb69dca528f2d /src/gtkext/graph/layout.c
parent08adf78fbff30d213891a533fbf43d91816b166a (diff)
Reordered slot indexes in order to avoid edges crossings.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@525 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/gtkext/graph/layout.c')
-rw-r--r--src/gtkext/graph/layout.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/gtkext/graph/layout.c b/src/gtkext/graph/layout.c
index d2e3b51..1084578 100644
--- a/src/gtkext/graph/layout.c
+++ b/src/gtkext/graph/layout.c
@@ -25,6 +25,7 @@
#include <malloc.h>
+#include <stdlib.h>
#include "node.h"
@@ -318,11 +319,17 @@ void g_graph_layout_add_edge(GGraphLayout *layout, GGraphEdge *edge)
* Remarques : - *
* *
******************************************************************************/
-
+#include "node-int.h"
void g_graph_layout_refresh(GGraphLayout *layout)
{
size_t i; /* Boucle de parcours */
+
+ int counter = 0;
+
+
+ restart:
+
g_graph_ranks_reset_reservations(layout->ranks);
bool _reset_cb(GGraphNode *node, GNodeVisitState state, void *unused)
@@ -347,6 +354,43 @@ void g_graph_layout_refresh(GGraphLayout *layout)
g_graph_node_prepare_x_line(layout->nodes, layout->nodes);
g_graph_node_apply_position(layout->nodes);
+
+
+ bool _reorder_cb(GGraphNode *node, GNodeVisitState state, GGraphNode *nodes)
+ {
+ if (state == GVS_NODE)
+ g_flow_node_reorder_slots(G_FLOW_NODE(node), nodes);
+ return true;
+ }
+
+ //qsort(layout->edges, layout->edges_count, sizeof(GGraphEdge *), (__compar_fn_t)g_graph_edge_compare);
+
+
+
+ if (counter++ == 0)
+ {
+ g_graph_node_visit_nodes(layout->nodes, (graph_node_visitor_cb)_reorder_cb, layout->nodes);
+ goto restart;
+ }
+
+ /*
+ bool _rinint_cb(GGraphNode *node, GNodeVisitState state, GGraphNode *nodes)
+ {
+ node->alloc.x = UNINITIALIZED_NODE_POS;
+ node->alloc.y = UNINITIALIZED_NODE_POS;
+ return true;
+ }
+
+ g_graph_node_visit_nodes(layout->nodes, (graph_node_visitor_cb)_rinint_cb, layout->nodes);
+
+
+ g_graph_node_apply_position(layout->nodes);
+ */
+
+ qsort(layout->edges, layout->edges_count, sizeof(GGraphEdge *), (__compar_fn_t)g_graph_edge_compare);
+
+
+
for (i = 0; i < layout->edges_count; i++)
g_graph_edge_reserve_horizontal_space(layout->edges[i], layout->ranks);