Code

We now use connector spacing to determine the minimum space required
authortgdwyer <tgdwyer@users.sourceforge.net>
Tue, 18 Jul 2006 01:58:44 +0000 (01:58 +0000)
committertgdwyer <tgdwyer@users.sourceforge.net>
Tue, 18 Jul 2006 01:58:44 +0000 (01:58 +0000)
between shape bounding boxes when graph layout with avoid overlap
constraints is applied.  This means that there should always be enough
room for connectors to route between shapes.  Also changed the default
connector spacing to a less extreme 3.

ChangeLog
src/conn-avoid-ref.h
src/graphlayout/graphlayout.cpp

index d1685477ecc07da7f566b02d78fc5646f79dcc04..280d0ceedabc2674fae36380499512fd28face81 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,14 @@
-2006-07-13  Tim Dwyer  <Tim.Dwyer@infotech.monash.edu.au>
+2006-07-18  Tim Dwyer  <Tim.Dwyer@infotech.monash.edu.au>
+
+       * src/graphlayout/graphlayout.cpp,
+         src/conn-avoid-ref.h:
+         We now use connector spacing to determine the minimum space required
+         between shape bounding boxes when graph layout with avoid overlap
+         constraints is applied.  This means that there should always be enough
+         room for connectors to route between shapes.  Also changed the default
+         connector spacing to a less extreme 3.
+
+2006-07-17  Tim Dwyer  <Tim.Dwyer@infotech.monash.edu.au>
 
        * src/libcola/cola.h,
          src/libcola/connected_components.cpp,
index c60cf7afd1c5a28ed742b37e68b4598bc79dd4eb..0ee6addc377726d49db952645aec5efcbabd2ea5 100644 (file)
@@ -55,7 +55,7 @@ extern GSList *get_avoided_items(GSList *list, SPObject *from,
 extern void avoid_item_move(NR::Matrix const *mp, SPItem *moved_item);
 extern void init_avoided_shape_geometry(SPDesktop *desktop);
 
-static const double defaultConnSpacing = 10.0;
+static const double defaultConnSpacing = 3.0;
 
 #endif /* !SEEN_CONN_AVOID_REF */
 
index dc9dc3ea96d9c28388ffa8e8cd074fd9ac7c8ac7..132db2db626f78edd03d77cdc3a71a1876fde43e 100644 (file)
@@ -3,7 +3,7 @@
  */
 /*
 * Authors:
-*   Tim Dwyer <tgdwyer@gmail.com>
+*   Tim Dwyer <Tim.Dwyer@infotech.monash.edu.au>
 *
 * Copyright (C) 2005 Authors
 *
@@ -16,6 +16,9 @@
 #include <algorithm>
 #include <float.h>
 
+#include "desktop.h"
+#include "inkscape.h"
+#include "sp-namedview.h"
 #include "util/glib-list-iterators.h"
 #include "graphlayout/graphlayout.h"
 #include "sp-path.h"
@@ -76,6 +79,12 @@ void graphlayout(GSList const *const items) {
        //Check 2 or more selected objects
        if (n < 2) return;
 
+    // add the connector spacing to the size of node bounding boxes
+    // so that connectors can always be routed between shapes
+    SPDesktop* desktop = inkscape_active_desktop();
+    double spacing = 0;
+    if(desktop) spacing = desktop->namedview->connector_spacing+0.1;
+
        map<string,unsigned> nodelookup;
        vector<Rectangle*> rs;
        vector<Edge> es;
@@ -88,7 +97,8 @@ void graphlayout(GSList const *const items) {
                NR::Point ll(item_box.min());
                NR::Point ur(item_box.max());
                nodelookup[u->id]=rs.size();
-               rs.push_back(new Rectangle(ll[0],ur[0],ll[1],ur[1]));
+               rs.push_back(new Rectangle(ll[0]-spacing,ur[0]+spacing,
+                    ll[1]-spacing,ur[1]+spacing));
        }
 
        SimpleConstraints scx,scy;