summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-12-18 20:17:03 +0000
committerDavid Robillard <d@drobilla.net>2013-12-18 20:17:03 +0000
commit0b6320b122e546f873cc8d8f3a90f8c5b97a423e (patch)
tree94afc141ee1ac76ea29e458fa90febfc7dbcc3dd
parent1dffad8f3b0d7919357bc3a10ccfd3f66b3c38ba (diff)
downloadganv-0b6320b122e546f873cc8d8f3a90f8c5b97a423e.tar.gz
ganv-0b6320b122e546f873cc8d8f3a90f8c5b97a423e.tar.bz2
ganv-0b6320b122e546f873cc8d8f3a90f8c5b97a423e.zip
FDGL: Add slight directional force to push sinks to the right/down.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5183 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/Canvas.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/Canvas.cpp b/src/Canvas.cpp
index 58f1e9e..56c4f21 100644
--- a/src/Canvas.cpp
+++ b/src/Canvas.cpp
@@ -775,9 +775,17 @@ GanvCanvasImpl::layout_iteration()
continue;
}
- const Vector tail_pos = { edge->impl->coords.x1, edge->impl->coords.y1 };
- const Vector head_pos = { edge->impl->coords.x2, edge->impl->coords.y2 };
- const Vector f = spring_force(head_pos, tail_pos, 1.0);
+ // Add slight directional force to push sinks to the right/down
+ static const double DIR_MAGNITUDE = -400.0;
+ Vector dir = { 0.0, 0.0 };
+ switch (_gcanvas->direction) {
+ case GANV_DIRECTION_RIGHT: dir.x = DIR_MAGNITUDE; break;
+ case GANV_DIRECTION_DOWN: dir.y = DIR_MAGNITUDE; break;
+ }
+
+ const Vector tpos = { edge->impl->coords.x1, edge->impl->coords.y1 };
+ const Vector hpos = { edge->impl->coords.x2, edge->impl->coords.y2 };
+ const Vector f = vec_add(dir, spring_force(hpos, tpos, 1.0));
apply_force(tail, head, f);
}