From: ellson Date: Wed, 6 Feb 2008 17:01:48 +0000 (+0000) Subject: edge penwidth makes normal arrowheads wider, not bigger X-Git-Tag: LAST_LIBGRAPH~32^2~4761 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8215efaca018ab7e2b3f8e697a3b9dee35b2a0f8;p=graphviz edge penwidth makes normal arrowheads wider, not bigger --- diff --git a/lib/common/arrows.c b/lib/common/arrows.c index 40751a6cd..161405ffa 100644 --- a/lib/common/arrows.c +++ b/lib/common/arrows.c @@ -99,16 +99,16 @@ static arrowname_t Arrownames[] = { typedef struct arrowtype_t { int type; double lenfact; /* ratio of length of this arrow type to standards arrow */ - void (*gen) (GVJ_t * job, pointf p, pointf u, int flag); /* generator function for type */ + void (*gen) (GVJ_t * job, pointf p, pointf u, double wscale, int flag); /* generator function for type */ } arrowtype_t; /* forward declaration of functions used in Arrowtypes[] */ -static void arrow_type_normal(GVJ_t * job, pointf p, pointf u, int flag); -static void arrow_type_crow(GVJ_t * job, pointf p, pointf u, int flag); -static void arrow_type_tee(GVJ_t * job, pointf p, pointf u, int flag); -static void arrow_type_box(GVJ_t * job, pointf p, pointf u, int flag); -static void arrow_type_diamond(GVJ_t * job, pointf p, pointf u, int flag); -static void arrow_type_dot(GVJ_t * job, pointf p, pointf u, int flag); +static void arrow_type_normal(GVJ_t * job, pointf p, pointf u, double wscale, int flag); +static void arrow_type_crow(GVJ_t * job, pointf p, pointf u, double wscale, int flag); +static void arrow_type_tee(GVJ_t * job, pointf p, pointf u, double wscale, int flag); +static void arrow_type_box(GVJ_t * job, pointf p, pointf u, double wscale, int flag); +static void arrow_type_diamond(GVJ_t * job, pointf p, pointf u, double wscale, int flag); +static void arrow_type_dot(GVJ_t * job, pointf p, pointf u, double wscale, int flag); static arrowtype_t Arrowtypes[] = { {ARR_TYPE_NORM, 1.0, arrow_type_normal}, @@ -289,12 +289,12 @@ int arrowStartClip(edge_t* e, point * ps, int startp, return startp; } -static void arrow_type_normal(GVJ_t * job, pointf p, pointf u, int flag) +static void arrow_type_normal(GVJ_t * job, pointf p, pointf u, double wscale, int flag) { pointf q, v, a[5]; - v.x = -u.y * 0.35; - v.y = u.x * 0.35; + v.x = -u.y * 0.35 * wscale; + v.y = u.x * 0.35 * wscale; q.x = p.x + u.x; q.y = p.y + u.y; if (flag & ARR_MOD_INV) { @@ -320,7 +320,7 @@ static void arrow_type_normal(GVJ_t * job, pointf p, pointf u, int flag) gvrender_polygon(job, &a[1], 3, !(flag & ARR_MOD_OPEN)); } -static void arrow_type_crow(GVJ_t * job, pointf p, pointf u, int flag) +static void arrow_type_crow(GVJ_t * job, pointf p, pointf u, double wscale, int flag) { pointf m, n, q, v, a[7]; @@ -357,7 +357,7 @@ static void arrow_type_crow(GVJ_t * job, pointf p, pointf u, int flag) gvrender_polygon(job, a, 7, 1); } -static void arrow_type_tee(GVJ_t * job, pointf p, pointf u, int flag) +static void arrow_type_tee(GVJ_t * job, pointf p, pointf u, double wscale, int flag) { pointf m, n, q, v, a[4]; @@ -390,7 +390,7 @@ static void arrow_type_tee(GVJ_t * job, pointf p, pointf u, int flag) gvrender_polyline(job, a, 2); } -static void arrow_type_box(GVJ_t * job, pointf p, pointf u, int flag) +static void arrow_type_box(GVJ_t * job, pointf p, pointf u, double wscale, int flag) { pointf m, q, v, a[4]; @@ -421,7 +421,7 @@ static void arrow_type_box(GVJ_t * job, pointf p, pointf u, int flag) gvrender_polyline(job, a, 2); } -static void arrow_type_diamond(GVJ_t * job, pointf p, pointf u, int flag) +static void arrow_type_diamond(GVJ_t * job, pointf p, pointf u, double wscale, int flag) { pointf q, r, v, a[5]; @@ -445,7 +445,7 @@ static void arrow_type_diamond(GVJ_t * job, pointf p, pointf u, int flag) gvrender_polygon(job, a, 4, !(flag & ARR_MOD_OPEN)); } -static void arrow_type_dot(GVJ_t * job, pointf p, pointf u, int flag) +static void arrow_type_dot(GVJ_t * job, pointf p, pointf u, double wscale, int flag) { double r; pointf AF[2]; @@ -458,7 +458,7 @@ static void arrow_type_dot(GVJ_t * job, pointf p, pointf u, int flag) gvrender_ellipse(job, AF, 2, !(flag & ARR_MOD_OPEN)); } -static pointf arrow_gen_type(GVJ_t * job, pointf p, pointf u, int flag) +static pointf arrow_gen_type(GVJ_t * job, pointf p, pointf u, double wscale, int flag) { int f; arrowtype_t *arrowtype; @@ -468,7 +468,7 @@ static pointf arrow_gen_type(GVJ_t * job, pointf p, pointf u, int flag) if (f == arrowtype->type) { u.x *= arrowtype->lenfact; u.y *= arrowtype->lenfact; - (arrowtype->gen) (job, p, u, flag); + (arrowtype->gen) (job, p, u, wscale, flag); p.x = p.x + u.x; p.y = p.y + u.y; break; @@ -515,7 +515,7 @@ boxf arrow_bb(pointf p, pointf u, double scale, int flag) return bb; } -void arrow_newgen(GVJ_t * job, emit_state_t emit_state, pointf p, pointf u, double scale, int flag) +void arrow_newgen(GVJ_t * job, emit_state_t emit_state, pointf p, pointf u, double scale, double wscale, int flag) { obj_state_t *obj = job->obj; double s; @@ -542,12 +542,12 @@ void arrow_newgen(GVJ_t * job, emit_state_t emit_state, pointf p, pointf u, doub /* arrow head closest to node */ f = flag & ((1 << 16) - 1); - p = arrow_gen_type(job, p, u, f); + p = arrow_gen_type(job, p, u, wscale, f); /* arrow head furthest from node */ /* start where first one ended */ f = (flag >> 16) & ((1 << 16) - 1); - arrow_gen_type(job, p, u, f); + arrow_gen_type(job, p, u, wscale, f); gvrender_end_context(job); @@ -555,11 +555,11 @@ void arrow_newgen(GVJ_t * job, emit_state_t emit_state, pointf p, pointf u, doub } /* FIXME emit.c and output.c require wrapper for int point coords */ -void arrow_gen(GVJ_t * job, emit_state_t emit_state, point p, point u, double scale, int flag) +void arrow_gen(GVJ_t * job, emit_state_t emit_state, point p, point u, double scale, double wscale, int flag) { pointf P, U; P2PF(p, P); P2PF(u, U); - arrow_newgen(job, emit_state, P, U, scale, flag); + arrow_newgen(job, emit_state, P, U, scale, wscale, flag); } diff --git a/lib/common/emit.c b/lib/common/emit.c index 47bef19be..e67718dfd 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1264,7 +1264,7 @@ static void emit_edge_graphics(GVJ_t * job, edge_t * e, char** styles) bezierf bzf; splinesf offspl, tmpspl; pointf pf0, pf1, pf2 = { 0, 0 }, pf3, *offlist, *tmplist; - double scale, numc2; + double scale, wscale = 1., numc2; char* p; #define SEP 2.0 @@ -1275,7 +1275,7 @@ static void emit_edge_graphics(GVJ_t * job, edge_t * e, char** styles) color = late_string(e, E_color, ""); if (job->obj->penwidth > 4) - scale *= job->obj->penwidth / 4; + wscale = job->obj->penwidth / 4; /* need to know how many colors separated by ':' */ for (p = color; *p; p++) @@ -1386,7 +1386,7 @@ static void emit_edge_graphics(GVJ_t * job, edge_t * e, char** styles) } } arrow_gen(job, EMIT_TDRAW, bz.sp, bz.list[0], - scale, bz.sflag); + scale, wscale, bz.sflag); } if (bz.eflag) { if (color != headcolor) { @@ -1397,7 +1397,7 @@ static void emit_edge_graphics(GVJ_t * job, edge_t * e, char** styles) } } arrow_gen(job, EMIT_HDRAW, bz.ep, bz.list[bz.size - 1], - scale, bz.eflag); + scale, wscale, bz.eflag); } free(colors); for (i = 0; i < offspl.size; i++) { @@ -1431,11 +1431,11 @@ static void emit_edge_graphics(GVJ_t * job, edge_t * e, char** styles) FALSE, FALSE); if (bz.sflag) { arrow_gen(job, EMIT_TDRAW, bz.sp, bz.list[0], - scale, bz.sflag); + scale, wscale, bz.sflag); } if (bz.eflag) { arrow_gen(job, EMIT_HDRAW, bz.ep, bz.list[bz.size - 1], - scale, bz.eflag); + scale, wscale, bz.eflag); } /* arrow_gen resets the job style * If we have more splines to do, restore the old one. diff --git a/lib/common/render.h b/lib/common/render.h index 9085a7f97..04fd2e7e9 100644 --- a/lib/common/render.h +++ b/lib/common/render.h @@ -67,7 +67,7 @@ extern "C" { extern void arrow_flags(Agedge_t * e, int *sflag, int *eflag); extern boxf arrow_bb(pointf p, pointf u, double scale, int flag); extern void arrow_gen(GVJ_t * job, emit_state_t emit_state, point p, point u, - double scale, int flag); + double scale, double wscale, int flag); extern double arrow_length(edge_t * e, int flag); extern int arrowEndClip(edge_t*, point*, int, int , bezier*, int eflag); extern int arrowStartClip(edge_t*, point* ps, int, int, bezier*, int sflag);