]> granicus.if.org Git - graphviz/commitdiff
Various small shape related fixes:
authorEmden Gansner <erg@research.att.com>
Tue, 7 Aug 2012 18:00:41 +0000 (14:00 -0400)
committerEmden Gansner <erg@research.att.com>
Tue, 7 Aug 2012 18:00:41 +0000 (14:00 -0400)
 - 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

lib/common/emit.c
lib/common/shapes.c
lib/common/splines.c
lib/common/utils.c

index 569c4632df4fd78860004152d44bdb276eeaa77f..d2c168e2cde3d2fcbd06954e1d0bb09b3770caa7 100644 (file)
@@ -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;
 }
index 6f8f878958356a59b2a125e7716a871f0ed9458d..533b878c509adbc34d5475b2b945910ad287de15 100644 (file)
@@ -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));
index 3c6514ec95389483d3e6dab461b3e714b660f821..996375a50310df3185c47fdfac70cdd109bf5cb5 100644 (file)
@@ -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;
index b51d6444b9999a2a9903749d4f635a212a53aed6..58ff9ac029036813a190c33e6f068aab19124831 100644 (file)
@@ -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