From: Emden Gansner Date: Tue, 7 Aug 2012 18:00:41 +0000 (-0400) Subject: Various small shape related fixes: X-Git-Tag: LAST_LIBGRAPH~32^2~358^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d840fa97832d7f918b7a3462710b4352c60ceb78;p=graphviz Various small shape related fixes: - convert local integers variable to doubles to accurately store node info - allow node penwidth to override default thin line for wedges and stripes if node value is smaller - avoid computing wedge shape if there is only one - turn on *info converter functions by default for cgraph --- diff --git a/lib/common/emit.c b/lib/common/emit.c index 569c4632d..d2c168e2c 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -385,6 +385,9 @@ static double getSegLen (char* s) * where the floats are optional, nonnegative, sum to <= 1. * Store the values in an array of colorseg_t's and return the array in psegs. * If nseg == 0, count the number of colors. + * If the sum of the floats does not equal 1, the remainder is equally distributed + * to all colors without an explicit float. If no such colors exist, the remainder + * is added to the last color. * 0 => okay * 1 => error without message * 2 => error with message @@ -471,6 +474,8 @@ parseSegs (char* clrs, int nseg, colorsegs_t** psegs) return rval; } +#define THIN_LINE 0.5 + /* wedgedEllipse: * Fill an ellipse whose bounding box is given by 2 points in pf * with multiple wedges determined by the color spec in clrs. @@ -487,7 +492,7 @@ wedgedEllipse (GVJ_t* job, pointf * pf, char* clrs) colorsegs_t* segs; colorseg_t* s; int rv; - int save_penwidth = job->obj->penwidth; + double save_penwidth = job->obj->penwidth; pointf ctr, semi; Ppolyline_t* pp; double angle0, angle1; @@ -498,7 +503,8 @@ wedgedEllipse (GVJ_t* job, pointf * pf, char* clrs) ctr.y = (pf[0].y + pf[1].y) / 2.; semi.x = pf[1].x - ctr.x; semi.y = pf[1].y - ctr.y; - gvrender_set_penwidth(job, 0.5); + if (save_penwidth > THIN_LINE) + gvrender_set_penwidth(job, THIN_LINE); angle0 = 0; for (s = segs->segs; s->color; s++) { @@ -515,7 +521,8 @@ wedgedEllipse (GVJ_t* job, pointf * pf, char* clrs) freePath (pp); } - gvrender_set_penwidth(job, save_penwidth); + if (save_penwidth > THIN_LINE) + gvrender_set_penwidth(job, save_penwidth); freeSegs (segs); return rv; } @@ -539,7 +546,7 @@ stripedBox (GVJ_t * job, pointf* AF, char* clrs, int rotate) double xdelta; pointf pts[4]; double lastx; - int save_penwidth = job->obj->penwidth; + double save_penwidth = job->obj->penwidth; rv = parseSegs (clrs, 0, &segs); if ((rv == 1) || (rv == 2)) return rv; @@ -558,7 +565,8 @@ stripedBox (GVJ_t * job, pointf* AF, char* clrs, int rotate) xdelta = (pts[1].x - pts[0].x); pts[1].x = pts[2].x = pts[0].x; - gvrender_set_penwidth(job, 0.5); + if (save_penwidth > THIN_LINE) + gvrender_set_penwidth(job, THIN_LINE); for (s = segs->segs; s->color; s++) { if (s->t == 0) continue; gvrender_set_fillcolor (job, (s->color?s->color:DEFAULT_COLOR)); @@ -570,7 +578,8 @@ stripedBox (GVJ_t * job, pointf* AF, char* clrs, int rotate) gvrender_polygon(job, pts, 4, FILL); pts[0].x = pts[3].x = pts[1].x; } - gvrender_set_penwidth(job, save_penwidth); + if (save_penwidth > THIN_LINE) + gvrender_set_penwidth(job, save_penwidth); freeSegs (segs); return rv; } diff --git a/lib/common/shapes.c b/lib/common/shapes.c index 6f8f87895..533b878c5 100644 --- a/lib/common/shapes.c +++ b/lib/common/shapes.c @@ -1593,6 +1593,8 @@ static port poly_port(node_t * n, char *portname, char *compass) return rv; } +#define multicolor(f) (strchr(f,':')) + /* generic polygon gencode routine */ static void poly_gencode(GVJ_t * job, node_t * n) { @@ -1687,6 +1689,7 @@ static void poly_gencode(GVJ_t * job, node_t * n) } else if (style & (STRIPED|WEDGED)) { fillcolor = findFill (n); + gvrender_set_fillcolor(job, fillcolor); filled = TRUE; } else { @@ -1721,7 +1724,7 @@ static void poly_gencode(GVJ_t * job, node_t * n) /* lay down fill first */ if (filled && pfilled) { if (sides <= 2) { - if ((style & WEDGED) && (j == 0)) { + if ((style & WEDGED) && (j == 0) && multicolor(fillcolor)) { int rv = wedgedEllipse (job, AF, fillcolor); if (rv > 1) agerr (AGPREV, "in node %s\n", agnameof(n)); @@ -1754,7 +1757,7 @@ static void poly_gencode(GVJ_t * job, node_t * n) AF[i].y = P.y * ysize + ND_coord(n).y; } if (sides <= 2) { - if ((style & WEDGED) && (j == 0)) { + if ((style & WEDGED) && (j == 0) && multicolor(fillcolor)) { int rv = wedgedEllipse (job, AF, fillcolor); if (rv > 1) agerr (AGPREV, "in node %s\n", agnameof(n)); diff --git a/lib/common/splines.c b/lib/common/splines.c index 3c6514ec9..996375a50 100644 --- a/lib/common/splines.c +++ b/lib/common/splines.c @@ -160,7 +160,8 @@ static void shape_clip0(inside_t * inside_context, node_t * n, pointf curve[4], boolean left_inside) { - int i, save_real_size; + int i; + double save_real_size; pointf c[4]; save_real_size = ND_rw(n); @@ -193,7 +194,7 @@ shape_clip0(inside_t * inside_context, node_t * n, pointf curve[4], */ void shape_clip(node_t * n, pointf curve[4]) { - int save_real_size; + double save_real_size; boolean left_inside; pointf c; inside_t inside_context; diff --git a/lib/common/utils.c b/lib/common/utils.c index b51d6444b..58ff9ac02 100644 --- a/lib/common/utils.c +++ b/lib/common/utils.c @@ -2169,9 +2169,7 @@ findCluster (Dt_t* map, char* name) #endif #ifdef WITH_CGRAPH -#ifdef DEBUG Agnodeinfo_t* ninfo(Agnode_t* n) {return (Agnodeinfo_t*)AGDATA(n);} Agraphinfo_t* ginfo(Agraph_t* g) {return (Agraphinfo_t*)AGDATA(g);} Agedgeinfo_t* einfo(Agedge_t* e) {return (Agedgeinfo_t*)AGDATA(e);} #endif -#endif