From: ellson Date: Tue, 18 Oct 2005 21:10:58 +0000 (+0000) Subject: Fix bug 791 X-Git-Tag: LAST_LIBGRAPH~32^2~7060 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e1a93ee86e82ce6c16d547d08eeca401f51b3765;p=graphviz Fix bug 791 --- diff --git a/lib/common/splines.c b/lib/common/splines.c index 2545ba6b1..315f4809b 100644 --- a/lib/common/splines.c +++ b/lib/common/splines.c @@ -380,7 +380,12 @@ void add_box(path * P, box b) * boxes assuming an inverted node. Note that compassPort already does * some flipping. Even better would be to allow the *_path function * to provide a polygon. + * + * The extra space provided by FUDGE-2 prevents the edge from getting + * too close the side of the node. */ +#define FUDGE 2 + void beginpath(path * P, edge_t * e, int et, pathend_t * endp, bool merge) { @@ -421,7 +426,7 @@ beginpath(path * P, edge_t * e, int et, pathend_t * endp, bool merge) b0.LL.y = P->start.p.y; b0.UR.x = b.UR.x; b0.UR.y = ND_coord_i(n).y + ND_ht_i(n)/2 + GD_ranksep(n->graph)/2; - b.UR.x = ND_coord_i(n).x - ND_lw_i(n) - 2; + b.UR.x = ND_coord_i(n).x - ND_lw_i(n) - (FUDGE-2); b.UR.y = b0.LL.y; b.LL.y = ND_coord_i(n).y - ND_ht_i(n)/2; b.LL.x -= 1; @@ -434,7 +439,7 @@ beginpath(path * P, edge_t * e, int et, pathend_t * endp, bool merge) /* b0.LL.y = ND_coord_i(n).y + ND_ht_i(n)/2; */ b0.UR.x = b.UR.x+1; b0.UR.y = ND_coord_i(n).y + ND_ht_i(n)/2 + GD_ranksep(n->graph)/2; - b.LL.x = ND_coord_i(n).x + ND_rw_i(n) + 2; + b.LL.x = ND_coord_i(n).x + ND_rw_i(n) + (FUDGE-2); b.UR.y = b0.LL.y; b.LL.y = ND_coord_i(n).y - ND_ht_i(n)/2; b.UR.x += 1; @@ -490,7 +495,7 @@ beginpath(path * P, edge_t * e, int et, pathend_t * endp, bool merge) b0.UR.x = b.UR.x+1; b0.LL.x = P->start.p.x; b0.LL.y = b0.UR.y - GD_ranksep(n->graph)/2; - b.LL.x = ND_coord_i(n).x + ND_rw_i(n) + 2; + b.LL.x = ND_coord_i(n).x + ND_rw_i(n) + (FUDGE-2); b.LL.y = b0.UR.y; b.UR.y = ND_coord_i(n).y + ND_ht_i(n)/2; b.UR.x += 1; @@ -616,7 +621,7 @@ void endpath(path * P, edge_t * e, int et, pathend_t * endp, bool merge) b0.UR.y = P->end.p.y; b0.UR.x = b.UR.x; b0.LL.y = ND_coord_i(n).y - ND_ht_i(n)/2 - GD_ranksep(n->graph)/2; - b.UR.x = ND_coord_i(n).x - ND_lw_i(n) - 2; + b.UR.x = ND_coord_i(n).x - ND_lw_i(n) - (FUDGE-2); b.LL.y = b0.UR.y; b.UR.y = ND_coord_i(n).y + ND_ht_i(n)/2; b.LL.x -= 1; @@ -629,7 +634,7 @@ void endpath(path * P, edge_t * e, int et, pathend_t * endp, bool merge) /* b0.UR.y = ND_coord_i(n).y - ND_ht_i(n)/2; */ b0.UR.x = b.UR.x+1; b0.LL.y = ND_coord_i(n).y - ND_ht_i(n)/2 - GD_ranksep(n->graph)/2; - b.LL.x = ND_coord_i(n).x + ND_rw_i(n) + 2; + b.LL.x = ND_coord_i(n).x + ND_rw_i(n) + (FUDGE-2); b.LL.y = b0.UR.y; b.UR.y = ND_coord_i(n).y + ND_ht_i(n)/2; b.UR.x += 1; diff --git a/lib/dotgen/dotsplines.c b/lib/dotgen/dotsplines.c index 34bbc19a0..339e705a1 100644 --- a/lib/dotgen/dotsplines.c +++ b/lib/dotgen/dotsplines.c @@ -2036,7 +2036,12 @@ node_t *n, *adj; * Return an initial bounding box to be used for building the * beginning or ending of the path of boxes. * Height reflects height of tallest node on rank. + * The extra space provided by FUDGE allows begin/endpath to create a box + * FUDGE-2 away from the node, so the routing can avoid the node and the + * box is at least 2 wide. */ +#define FUDGE 4 + static box maximal_bbox(spline_info_t* sp, node_t* vn, edge_t* ie, edge_t* oe) { int nb, b; @@ -2047,7 +2052,7 @@ static box maximal_bbox(spline_info_t* sp, node_t* vn, edge_t* ie, edge_t* oe) left_cl = right_cl = NULL; /* give this node all the available space up to its neighbors */ - b = ND_coord_i(vn).x - ND_lw_i(vn); + b = ND_coord_i(vn).x - ND_lw_i(vn) - FUDGE; if ((left = neighbor(vn, ie, oe, -1))) { if ((left_cl = cl_bound(vn, left))) nb = GD_bb(left_cl).UR.x + sp->Splinesep; @@ -2065,10 +2070,10 @@ static box maximal_bbox(spline_info_t* sp, node_t* vn, edge_t* ie, edge_t* oe) rv.LL.x = MIN(b, sp->LeftBound); /* we have to leave room for our own label! */ - if (ND_label(vn)) + if ((ND_node_type(vn) == VIRTUAL) && (ND_label(vn))) b = ND_coord_i(vn).x + 10; else - b = ND_coord_i(vn).x + ND_rw_i(vn); + b = ND_coord_i(vn).x + ND_rw_i(vn) + FUDGE; if ((right = neighbor(vn, ie, oe, 1))) { if ((right_cl = cl_bound(vn, right))) nb = GD_bb(right_cl).LL.x - sp->Splinesep;