]> granicus.if.org Git - graphviz/commitdiff
improve arrow shapes by passing through FP coords to renderer
authorellson <devnull@localhost>
Thu, 16 Mar 2006 17:43:27 +0000 (17:43 +0000)
committerellson <devnull@localhost>
Thu, 16 Mar 2006 17:43:27 +0000 (17:43 +0000)
lib/common/arrows.c
lib/gvc/gvcproc.h
lib/gvc/gvrender.c

index 897233eeed4dd26226577a4421ed08c93ede0406..b8755a4f3507c8bc352dd173a90adc4981edb491 100644 (file)
@@ -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)
index 2c07f2c92e9e0a458d8160148c9f9a7b16a5adac..b85a4cf0ef94fb5ab3f14ec5b0bdd4eef9e1c41b 100644 (file)
@@ -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);
index 91daac29bcc6862e49778e47bb664553a33b0725..138d304fe9ed7672422eff58fd7b8a70d88c2e71 100644 (file)
@@ -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;