[dia] Istar - actor: finally connection point directions



commit 00e76db640c1c23424c7541e0c8514234af33624
Author: Hans Breuer <hans breuer org>
Date:   Sat Jun 29 18:00:36 2013 +0200

    Istar - actor: finally connection point directions
    
    There was a ToDo from 2005 to have basic auto-routing support
    for this object. This kind of stuff will soon be checked with
    a unit test. Fixed to make that pass.

 objects/Istar/actor.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/objects/Istar/actor.c b/objects/Istar/actor.c
index 31754da..2bba211 100644
--- a/objects/Istar/actor.c
+++ b/objects/Istar/actor.c
@@ -382,9 +382,13 @@ actor_update_data(Actor *actor, AnchorShape horiz, AnchorShape vert)
   dh = elem->height / 2.0;
   for (i = 0; i < NUM_CONNECTIONS-1; i++) {
     real theta = M_PI / 8.0 * i;
-    /* TODO: Set up directions for autorouting */
-    actor->connections[i].pos.x = c.x + dw * cos(theta);
-    actor->connections[i].pos.y = c.y - dh * sin(theta);
+    real costheta = cos(theta);
+    real sintheta = sin(theta);
+    connpoint_update(&actor->connections[i],
+                     c.x + dw * costheta,
+                     c.y - dh * sintheta,
+                     (costheta > .5?DIR_EAST:(costheta < -.5?DIR_WEST:0))|
+                     (sintheta > .5?DIR_NORTH:(sintheta < -.5?DIR_SOUTH:0)));
   }
   actor->connections[16].pos.x = c.x;
   actor->connections[16].pos.y = c.y;
@@ -398,11 +402,11 @@ actor_update_data(Actor *actor, AnchorShape horiz, AnchorShape vert)
 }
 
 /* creation stuff */
-static DiaObject 
-*actor_create(Point *startpoint,
-          void *user_data,
-          Handle **handle1,
-          Handle **handle2)
+static DiaObject *
+actor_create(Point *startpoint,
+            void *user_data,
+            Handle **handle1,
+            Handle **handle2)
 {
   Actor *actor;
   Element *elem;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]