diff options
Diffstat (limited to 'src/gtkext/graph/layout.c')
| -rw-r--r-- | src/gtkext/graph/layout.c | 46 | 
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); | 
