diff options
author | David Robillard <d@drobilla.net> | 2013-12-18 00:31:20 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2013-12-18 00:31:20 +0000 |
commit | ef91731a480b79c96e10b2b5256a36407bb5ef6e (patch) | |
tree | f0dcb5a1aad0bb1cb7de5f8c5a4c95697dfde57a /src/node.c | |
parent | d273249ccc8d4604e86351defa92f6743eae2b45 (diff) | |
download | ganv-ef91731a480b79c96e10b2b5256a36407bb5ef6e.tar.gz ganv-ef91731a480b79c96e10b2b5256a36407bb5ef6e.tar.bz2 ganv-ef91731a480b79c96e10b2b5256a36407bb5ef6e.zip |
Add experimental (slow) force-directed graph layout to Ganv.
This continuously arranges the graph, and the user can drag around nodes to
influence the layout which is handy.
To try, configure with --no-graphviz --fdgl.
Still rough around the edges, in particular detached nodes will fly off into
space. Also entirely too slow for production use, will need a more
sophisticated data structure for that, so the repel calculation isn't O(n^2).
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5177 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/node.c')
-rw-r--r-- | src/node.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -68,6 +68,13 @@ ganv_node_init(GanvNode* node) impl->highlighted = FALSE; impl->draggable = FALSE; impl->show_label = TRUE; + impl->grabbed = FALSE; +#ifdef GANV_FDGL + impl->force.x = 0.0; + impl->force.y = 0.0; + impl->vel.x = 0.0; + impl->vel.y = 0.0; +#endif } static void @@ -442,6 +449,7 @@ ganv_node_default_event(GanvItem* item, GDK_POINTER_MOTION_MASK|GDK_BUTTON_RELEASE_MASK|GDK_BUTTON_PRESS_MASK, ganv_canvas_get_move_cursor(canvas), event->button.time); + node->impl->grabbed = TRUE; dragging = TRUE; return TRUE; } @@ -452,6 +460,7 @@ ganv_node_default_event(GanvItem* item, gboolean selected; g_object_get(G_OBJECT(node), "selected", &selected, NULL); ganv_item_ungrab(GANV_ITEM(node), event->button.time); + node->impl->grabbed = FALSE; dragging = FALSE; if (event->button.x != drag_start_x || event->button.y != drag_start_y) { if (selected) { |