From: ellson Date: Thu, 16 Mar 2006 17:43:27 +0000 (+0000) Subject: improve arrow shapes by passing through FP coords to renderer X-Git-Tag: LAST_LIBGRAPH~32^2~6747 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d53fbd35161098cfd6f51eee8866f60168a54726;p=graphviz improve arrow shapes by passing through FP coords to renderer --- diff --git a/lib/common/arrows.c b/lib/common/arrows.c index 897233eee..b8755a4f3 100644 --- a/lib/common/arrows.c +++ b/lib/common/arrows.c @@ -289,37 +289,6 @@ int arrowStartClip(edge_t* e, point * ps, int startp, return startp; } -/* FIXME - codegens should accept floats directly */ -static void arrow_codegen_polygon(GVJ_t * job, pointf p[], int np, - int fill) -{ - point P[16]; /* ugly - but this should be enough for arrows */ - int i; - for (i = 0; i < np; i++) - PF2P(p[i], P[i]); - gvrender_polygon(job, P, np, fill); -} - -/* FIXME - codegens should accept floats directly */ -static void arrow_codegen_polyline(GVJ_t * job, pointf p[], int np) -{ - point P[16]; /* ugly - but this should be enough for arrows */ - int i; - for (i = 0; i < np; i++) - PF2P(p[i], P[i]); - gvrender_polyline(job, P, np); -} - -/* FIXME - codegens should accept floats directly */ -static void arrow_codegen_ellipse(GVJ_t * job, pointf p, pointf r, - int fill) -{ - point P, R; - PF2P(p, P); - PF2P(r, R); - gvrender_ellipse(job, P, R.x, R.y, fill); -} - static void arrow_type_normal(GVJ_t * job, pointf p, pointf u, int flag) { pointf q, v, a[5]; @@ -344,11 +313,11 @@ static void arrow_type_normal(GVJ_t * job, pointf p, pointf u, int flag) a[3].y = q.y + v.y; } if (flag & ARR_MOD_LEFT) - arrow_codegen_polygon(job, a, 3, !(flag & ARR_MOD_OPEN)); + gvrender_polygonf(job, a, 3, !(flag & ARR_MOD_OPEN)); else if (flag & ARR_MOD_RIGHT) - arrow_codegen_polygon(job, &a[2], 3, !(flag & ARR_MOD_OPEN)); + gvrender_polygonf(job, &a[2], 3, !(flag & ARR_MOD_OPEN)); else - arrow_codegen_polygon(job, &a[1], 3, !(flag & ARR_MOD_OPEN)); + gvrender_polygonf(job, &a[1], 3, !(flag & ARR_MOD_OPEN)); } static void arrow_type_crow(GVJ_t * job, pointf p, pointf u, int flag) @@ -381,11 +350,11 @@ static void arrow_type_crow(GVJ_t * job, pointf p, pointf u, int flag) a[5].y = p.y + v.y; } if (flag & ARR_MOD_LEFT) - arrow_codegen_polygon(job, a, 5, 1); + gvrender_polygonf(job, a, 5, 1); else if (flag & ARR_MOD_RIGHT) - arrow_codegen_polygon(job, &a[2], 5, 1); + gvrender_polygonf(job, &a[2], 5, 1); else - arrow_codegen_polygon(job, a, 7, 1); + gvrender_polygonf(job, a, 7, 1); } static void arrow_type_tee(GVJ_t * job, pointf p, pointf u, int flag) @@ -415,10 +384,10 @@ static void arrow_type_tee(GVJ_t * job, pointf p, pointf u, int flag) a[1] = m; a[2] = n; } - arrow_codegen_polygon(job, a, 4, 1); + gvrender_polygonf(job, a, 4, 1); a[0] = p; a[1] = q; - arrow_codegen_polyline(job, a, 2); + gvrender_polylinef(job, a, 2); } static void arrow_type_box(GVJ_t * job, pointf p, pointf u, int flag) @@ -446,10 +415,10 @@ static void arrow_type_box(GVJ_t * job, pointf p, pointf u, int flag) a[1] = p; a[2] = m; } - arrow_codegen_polygon(job, a, 4, !(flag & ARR_MOD_OPEN)); + gvrender_polygonf(job, a, 4, !(flag & ARR_MOD_OPEN)); a[0] = m; a[1] = q; - arrow_codegen_polyline(job, a, 2); + gvrender_polylinef(job, a, 2); } static void arrow_type_diamond(GVJ_t * job, pointf p, pointf u, int flag) @@ -469,21 +438,21 @@ static void arrow_type_diamond(GVJ_t * job, pointf p, pointf u, int flag) a[3].x = r.x - v.x; a[3].y = r.y - v.y; if (flag & ARR_MOD_LEFT) - arrow_codegen_polygon(job, &a[2], 3, !(flag & ARR_MOD_OPEN)); + gvrender_polygonf(job, &a[2], 3, !(flag & ARR_MOD_OPEN)); else if (flag & ARR_MOD_RIGHT) - arrow_codegen_polygon(job, a, 3, !(flag & ARR_MOD_OPEN)); + gvrender_polygonf(job, a, 3, !(flag & ARR_MOD_OPEN)); else - arrow_codegen_polygon(job, a, 4, !(flag & ARR_MOD_OPEN)); + gvrender_polygonf(job, a, 4, !(flag & ARR_MOD_OPEN)); } static void arrow_type_dot(GVJ_t * job, pointf p, pointf u, int flag) { - pointf r; + double r; - r.x = r.y = sqrt(u.x * u.x + u.y * u.y) / 2.; + r = sqrt(u.x * u.x + u.y * u.y) / 2.; p.x += u.x / 2.; p.y += u.y / 2.; - arrow_codegen_ellipse(job, p, r, !(flag & ARR_MOD_OPEN)); + gvrender_ellipsef(job, p, r, r, !(flag & ARR_MOD_OPEN)); } static pointf arrow_gen_type(GVJ_t * job, pointf p, pointf u, int flag) diff --git a/lib/gvc/gvcproc.h b/lib/gvc/gvcproc.h index 2c07f2c92..b85a4cf0e 100644 --- a/lib/gvc/gvcproc.h +++ b/lib/gvc/gvcproc.h @@ -114,6 +114,7 @@ extern "C" { extern void gvrender_beziercurve(GVJ_t * job, pointf * AF, int n, int arrow_at_start, int arrow_at_end, int); extern void gvrender_polyline(GVJ_t * job, point * A, int n); + extern void gvrender_polylinef(GVJ_t * job, pointf * AF, int n); extern void gvrender_comment(GVJ_t * job, char *str); extern void gvrender_user_shape(GVJ_t * job, char *name, point * A, int sides, int filled); diff --git a/lib/gvc/gvrender.c b/lib/gvc/gvrender.c index 91daac29b..138d304fe 100644 --- a/lib/gvc/gvrender.c +++ b/lib/gvc/gvrender.c @@ -934,6 +934,38 @@ void gvrender_beziercurve(GVJ_t * job, pointf * af, int n, #endif } +void gvrender_polylinef(GVJ_t * job, pointf * af, int n) +{ + int i; + gvrender_engine_t *gvre = job->render.engine; + + if (gvre && gvre->polyline) { + if (job->style->pen != PEN_NONE) { + if (sizeAF < n) { + sizeAF = n+10; + AF = grealloc(AF, sizeAF * sizeof(pointf)); + } + for (i = 0; i < n; i++) + AF[i] = gvrender_ptf(job, af[i]); + gvre->polyline(job, AF, n); + } + } +#ifndef DISABLE_CODEGENS + else { + codegen_t *cg = job->codegen; + + if (sizeA < n) { + sizeA = n+10; + A = grealloc(A, sizeA * sizeof(point)); + } + for (i = 0; i < n; i++) + PF2P(af[i], A[i]); + if (cg && cg->polyline) + cg->polyline(A, n); + } +#endif +} + void gvrender_polyline(GVJ_t * job, point * a, int n) { gvrender_engine_t *gvre = job->render.engine;