From: erg Date: Mon, 28 Jun 2010 18:29:11 +0000 (+0000) Subject: Finish orthogonal case where edge has head and tail arrows on a single line segment X-Git-Tag: LAST_LIBGRAPH~32^2~1299 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=56712b4f8dadb9d40de1ccae73d02f3ca1cf8ecf;p=graphviz Finish orthogonal case where edge has head and tail arrows on a single line segment --- diff --git a/lib/common/arrows.c b/lib/common/arrows.c index 80984d544..58046bb24 100644 --- a/lib/common/arrows.c +++ b/lib/common/arrows.c @@ -316,18 +316,44 @@ int arrowStartClip(edge_t* e, pointf * ps, int startp, */ void arrowOrthoClip(edge_t* e, pointf* ps, int startp, int endp, bezier* spl, int sflag, int eflag) { - pointf p, q, r; + pointf p, q, r, s, t; double d, tlen, hlen, maxd; if (sflag && eflag && (endp == startp)) { /* handle special case of two arrows on a single segment */ + p = ps[endp]; + q = ps[endp+3]; tlen = arrow_length (e, sflag); hlen = arrow_length (e, eflag); - d = DIST(ps[endp], ps[endp + 3]); - if (hlen + tlen < d) { - spl->eflag = eflag, spl->ep = ps[endp + 3]; + d = DIST(p, q); + if (hlen + tlen >= d) { + hlen = tlen = d/3.0; + } + if (p.y == q.y) { /* horz segment */ + s.y = t.y = p.y; + if (p.x < q.x) { + t.x = q.x - hlen; + s.x = p.x + tlen; + } + else { + t.x = q.x + hlen; + s.x = p.x - tlen; + } } - else { + else { /* vert segment */ + s.x = t.x = p.x; + if (p.y < q.y) { + t.y = q.y - hlen; + s.y = p.y + tlen; + } + else { + t.y = q.y + hlen; + s.y = p.y - tlen; + } } + ps[endp] = ps[endp + 1] = s; + ps[endp + 2] = ps[endp + 3] = t; + spl->eflag = eflag, spl->ep = p; + spl->sflag = sflag, spl->ep = q; return; } if (eflag) {