From: erg Date: Thu, 14 Jul 2005 22:17:21 +0000 (+0000) Subject: Fix the fact that labels for loops and some flat edges in dot are not X-Git-Tag: LAST_LIBGRAPH~32^2~7442 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=24a0ada8118bedb9b88db1a424378fdefecdd1b7;p=graphviz Fix the fact that labels for loops and some flat edges in dot are not contributing to the bounding box. --- diff --git a/lib/common/utils.c b/lib/common/utils.c index 58457e5f1..e906456bf 100644 --- a/lib/common/utils.c +++ b/lib/common/utils.c @@ -1145,13 +1145,20 @@ box flip_rec_box(box b, point p) /* addLabelBB: */ -static box addLabelBB(box bb, textlabel_t * lp) +static box addLabelBB(box bb, textlabel_t * lp, boolean flipxy) { - int width = ROUND(lp->dimen.x); - int height = ROUND(lp->dimen.y); + int width, height; point p = lp->p; int min, max; + if (flipxy) { + height = ROUND(lp->dimen.x); + width = ROUND(lp->dimen.y); + } + else { + width = ROUND(lp->dimen.x); + height = ROUND(lp->dimen.y); + } min = p.x - width / 2; max = p.x + width / 2; if (min < bb.LL.x) @@ -1175,7 +1182,7 @@ static box addLabelBB(box bb, textlabel_t * lp) */ void updateBB(graph_t * g, textlabel_t * lp) { - GD_bb(g) = addLabelBB(GD_bb(g), lp); + GD_bb(g) = addLabelBB(GD_bb(g), lp, GD_flip(g)); } /* compute_bb: @@ -1221,7 +1228,7 @@ void compute_bb(graph_t * g) } } if (ED_label(e) && ED_label(e)->set) - bb = addLabelBB(bb, ED_label(e)); + bb = addLabelBB(bb, ED_label(e), GD_flip(g)); } } diff --git a/lib/dotgen/dotsplines.c b/lib/dotgen/dotsplines.c index ee8d6c8d5..d592051ac 100644 --- a/lib/dotgen/dotsplines.c +++ b/lib/dotgen/dotsplines.c @@ -341,7 +341,10 @@ void dot_splines(graph_t * g) n = e0->tail; r = ND_rank(n); if (r == GD_maxrank(g)) { - sizey = ND_coord_i(GD_rank(g)[r-1].v[0]).y - ND_coord_i(n).y; + if (r > 0) + sizey = ND_coord_i(GD_rank(g)[r-1].v[0]).y - ND_coord_i(n).y; + else + sizey = ND_ht_i(n); } else if (r == GD_minrank(g)) { sizey = ND_coord_i(n).y - ND_coord_i(GD_rank(g)[r+1].v[0]).y; @@ -352,6 +355,11 @@ void dot_splines(graph_t * g) sizey = MIN(upy, dwny); } makeSelfEdge(P, edges, ind, cnt, sd.Multisep, sizey, &sinfo); + for (i = 0; i < cnt; i++) { + e = edges[ind+i]; + if (ED_label(e)) + updateBB(g, ED_label(e)); + } } else if (ND_rank(e0->tail) == ND_rank(e0->head)) { make_flat_edge(&sd, P, edges, ind, cnt); @@ -856,8 +864,10 @@ make_flat_adj_edges(path* P, edge_t** edges, int ind, int cnt, edge_t* e0) for (j = 0; j < auxbz->size; j++) { bz->list[j] = transform(auxbz->list[j], del, GD_flip(g)); } - if (ED_label(e)) + if (ED_label(e)) { ED_label(e)->p = transform(ED_label(auxe)->p, del, GD_flip(g)); + updateBB(g, ED_label(e)); + } } cleanupCloneGraph (auxg);