summaryrefslogtreecommitdiff
path: root/src/gtkext/graph/layout.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2013-08-17 21:54:56 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2013-08-17 21:54:56 (GMT)
commite53684bebd74d0a8ade79082c618ebb21bdea361 (patch)
tree1a9e772134f2fea48ec06c78de1d2ceaef6b69ad /src/gtkext/graph/layout.c
parenta7d77562cd63f6cf0856b4cc19e245072af86f69 (diff)
Replaced some parts of the graph computing for better results.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@356 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/gtkext/graph/layout.c')
-rw-r--r--src/gtkext/graph/layout.c58
1 files changed, 56 insertions, 2 deletions
diff --git a/src/gtkext/graph/layout.c b/src/gtkext/graph/layout.c
index 43caf44..9ac3ee3 100644
--- a/src/gtkext/graph/layout.c
+++ b/src/gtkext/graph/layout.c
@@ -587,10 +587,62 @@ GGraphLayout *g_graph_layout_new(GInstrBlock *blocks, GtkBufferView **views, siz
g_graph_node_visit_nodes(result->nodes, (graph_node_visitor_cb)_register_cb, result);
+ bool _print_dbg_cb(GFlowNode *node, GNodeVisitState state, int *depth)
+ {
+ int i;
+
+ if (state == GVS_ENTER || state == GVS_NODE)
+ {
+ for (i = 0; i < *depth; i++)
+ printf(" ");
+
+ printf("- %p\n", node);
+
+ }
+
+ if (state == GVS_ENTER) (*depth)++;
+ else if (state == GVS_EXIT) (*depth)--;
+
+ return true;
+
+ }
+
+ printf("==== graph ====\n");
+ g_graph_node_visit_nodes(result->nodes, (graph_node_visitor_cb)_print_dbg_cb, (int []){ 0 });
+ printf("\n");
+
/* Actualisation... */
g_graph_layout_refresh(result);
+ bool _print_dbg_ext_cb(GGraphNode *node, GNodeVisitState state, int *depth)
+ {
+ int i;
+ GtkAllocation alloc;
+
+ if (state == GVS_ENTER || state == GVS_NODE)
+ {
+ for (i = 0; i < *depth; i++)
+ printf(" ");
+
+ alloc = g_graph_node_get_allocation(node);
+ printf("- %p - (%d ; %d) - (%d ; %d)\n", node,
+ alloc.x, alloc.y,
+ alloc.width, alloc.height);
+
+ }
+
+ if (state == GVS_ENTER) (*depth)++;
+ else if (state == GVS_EXIT) (*depth)--;
+
+ return true;
+
+ }
+
+ printf("==== graph ====\n");
+ g_graph_node_visit_nodes(result->nodes, (graph_node_visitor_cb)_print_dbg_ext_cb, (int []){ 0 });
+ printf("\n");
+
return result;
}
@@ -654,8 +706,10 @@ void g_graph_layout_refresh(GGraphLayout *layout)
/* Traitement des positions horizontales */
- g_graph_node_set_position(layout->nodes, (gint []) { 0 }, NULL);
- g_virtual_node_organize_x_line(G_VIRTUAL_NODE(layout->nodes), layout->nodes);
+ g_graph_node_set_x_position(layout->nodes, GRAPH_HORIZONTAL_MARGIN);
+
+ g_graph_node_prepare_x_line(layout->nodes, layout->nodes);
+ g_graph_node_apply_position(layout->nodes);
for (i = 0; i < layout->edges_count; i++)
g_graph_edge_reserve_horizontal_space(layout->edges[i], layout->ranks);