]> granicus.if.org Git - graphviz/commitdiff
fix ps library shapes
authorellson <devnull@localhost>
Fri, 29 Sep 2006 17:42:45 +0000 (17:42 +0000)
committerellson <devnull@localhost>
Fri, 29 Sep 2006 17:42:45 +0000 (17:42 +0000)
12 files changed:
lib/gvc/gvplugin_render.h
lib/gvc/gvrender.c
lib/gvc/gvusershape.c
plugin/core/gvrender_core_dot.c
plugin/core/gvrender_core_fig.c
plugin/core/gvrender_core_map.c
plugin/core/gvrender_core_ps.c
plugin/core/gvrender_core_svg.c
plugin/gd/gvrender_gd.c
plugin/gd/gvrender_gd_vrml.c
plugin/ming/gvrender_ming.c
plugin/pango/gvrender_pango.c

index b126995d866a98ae8447d6467b8629568f2d856e..7f100c793740d1d4e0089593f70bf30ebf16d5de 100644 (file)
@@ -56,6 +56,7 @@ extern "C" {
                             int arrow_at_start, int arrow_at_end, int);
        void (*polyline) (GVJ_t * job, pointf * A, int n);
        void (*comment) (GVJ_t * job, char *comment);
+       void (*library_shape) (GVJ_t * job, char *name, pointf * A, int n, int filled);
     };
 
 #ifdef __cplusplus
index 58a973d9309e21b934076932dcfe64afcc7976c3..8585695ee2c92c2bfb2249c294440db7c269e058 100644 (file)
@@ -37,6 +37,7 @@
 #include "gvcproc.h"
 
 extern int emit_once(char *str);
+extern shape_desc *find_user_shape(char *name);
 
 /* storage for temporary hacks until client API is FP */
 static pointf *AF;
@@ -920,8 +921,13 @@ void gvrender_usershape(GVJ_t * job, char *name, pointf * a, int n, bool filled)
     int i;
     pointf *af;
 
-    if (! (us = gvusershape_find(name)))
+    if (! (us = gvusershape_find(name))) {
+       if (find_user_shape(name)) {
+           if (gvre && gvre->library_shape)
+               gvre->library_shape(job, name, a, n, filled);
+       }
         return;
+    }
 
     if (job->flags & GVRENDER_DOES_TRANSFORM)
        af = a;
index f4f8107ec6dfaeaf5d9c608de73a86f626a14e45..3955f8b161b9956628df0dd3114f2f90566c8090 100644 (file)
@@ -337,18 +337,12 @@ point gvusershape_size(graph_t * g, char *name)
         dpi = POINTS_PER_INCH;
 
     /* no shape file, no shape size */
-    if (!name || (*name == '\0')) {
+    if (!name || (*name == '\0') || !(us = gvusershape_open (name))) {
         rv.x = rv.y = -1;
-        return rv;
     }
-
-    if ((us = gvusershape_open (name))) {
+    else {
        rv.x = us->w * dpi / us->dpi;
        rv.y = us->h * dpi / us->dpi;
     }
-    else {
-        rv.x = rv.y = -1;
-    }
-
     return rv;
 }
index 682e7d12ea14250be0ef302707d1c95b72c9dacb..0d924c0ccc309398808bae53dd6541c1db61c6b5 100644 (file)
@@ -312,6 +312,7 @@ gvrender_engine_t xdot_engine = {
     xdot_bezier,
     xdot_polyline,
     0,                         /* xdot_comment */
+    0,                         /* xdot_library_shape */
 };
 
 gvrender_features_t canon_features = {
index 1817b7a9cd569d9bb96283b7611d80605cb49017..165c7d782e761b5a17efbfce75fbf40e5ce47618 100644 (file)
@@ -501,7 +501,8 @@ gvrender_engine_t fig_engine = {
     fig_polygon,
     fig_bezier,
     fig_polyline,
-    fig_comment
+    fig_comment,
+    0,                         /* fig_library_shape */
 };
 
 
index ca7c2fd85419bf1d490e75bebf37791268a78975..5e04743d7d451c95251c8c60d915afff286f5019 100644 (file)
@@ -282,6 +282,7 @@ static gvrender_engine_t map_engine = {
     0,                         /* map_bezier */
     0,                         /* map_polyline */
     0,                         /* map_comment */
+    0,                         /* map_library_shape */
 };
 
 static gvrender_features_t map_features = {
index 68283dfc73f5122df748a48b2ecde894cb83a90f..1da76c244d4aa221267a0afd5a21e0f5f9d583c2 100644 (file)
@@ -88,7 +88,9 @@ static void psgen_begin_graph(GVJ_t * job)
         if (job->common->show_boxes == NULL)
             core_fputs(job, "%%BoundingBox: (atend)\n");
         core_fputs(job, "%%EndComments\nsave\n");
+        /* include shape library */
         cat_preamble(job, job->common->lib);
+       /* include epsf */
         epsf_define(job->output_file);
     }
     isLatin1 = (GD_charset(obj->u.g) == CHAR_LATIN1);
@@ -439,6 +441,29 @@ static void psgen_comment(GVJ_t * job, char *str)
     core_fputs(job, "\n");
 }
 
+static void psgen_library_shape(GVJ_t * job, char *name, pointf * A, int n, int filled)
+{
+    int j;
+
+    if (filled && job->obj->fillcolor.u.HSVA[3] > .5) {
+       ps_set_color(job, &(job->obj->fillcolor));
+       core_fputs(job, "[ ");
+       for (j = 0; j < n; j++)
+           core_printf(job, "%g %g ", A[j].x, A[j].y);
+       core_printf(job, "%g %g ", A[0].x, A[0].y);
+       core_printf(job, "]  %d true %s\n", n, name);
+    }
+    if (job->obj->pencolor.u.HSVA[3] > .5) {
+        ps_set_pen_style(job);
+        ps_set_color(job, &(job->obj->pencolor));
+        core_fputs(job, "[ ");
+        for (j = 0; j < n; j++)
+           core_printf(job, "%g %g ", A[j].x, A[j].y);
+       core_printf(job, "%g %g ", A[0].x, A[0].y);
+        core_printf(job, "]  %d false %s\n", n, name);
+    }
+}
+
 static gvrender_engine_t psgen_engine = {
     psgen_begin_job,
     psgen_end_job,
@@ -467,6 +492,7 @@ static gvrender_engine_t psgen_engine = {
     psgen_bezier,
     psgen_polyline,
     psgen_comment,
+    psgen_library_shape,
 };
 
 static gvrender_features_t psgen_features = {
index 38f4129e6ebc5f688234c2c663879c243deb38ec..41b0585bde5f035cb4c44a36adeee84a51788528 100644 (file)
@@ -436,6 +436,7 @@ gvrender_engine_t svg_engine = {
     svg_bezier,
     svg_polyline,
     svg_comment,
+    0,                         /* svg_library_shape */
 };
 
 gvrender_features_t svg_features = {
index 6346d65ed166dc1d3e4f348e878edf242c0ef832..dcc1477bf65aab147f8ac6af8ba17444b1709767 100644 (file)
@@ -564,6 +564,7 @@ static gvrender_engine_t gdgen_engine = {
     gdgen_bezier,
     gdgen_polyline,
     0,                         /* gdgen_comment */
+    0,                         /* gdgen_library_shape */
 };
 
 static gvrender_features_t gdgen_features_tc = {
index a879af53a5b6c4126d32c53b262c1729af83f0f0..e9a401fb19ab94ca1a07ffd645a31be3f54cbb70 100644 (file)
@@ -828,6 +828,7 @@ static gvrender_engine_t vrml_engine = {
     vrml_bezier,
     vrml_polyline,
     0,                          /* vrml_comment */
+    0,                          /* vrml_library_shape */
 };
 
 static gvrender_features_t vrml_features = {
index 94ed1d4dc250bd9f0dd6bf0c6474f5c80198c51e..72a3c35c461058c382d3e99135ee22448b53a2e5 100644 (file)
@@ -245,6 +245,7 @@ static gvrender_engine_t ming_engine = {
     ming_bezier,
     ming_polyline,
     0,                         /* ming_comment */
+    0,                         /* ming_library_shape */
 };
 
 static gvrender_features_t ming_features = {
index e04227dc39987966f19c93c221e98e6c467f1fb4..c617fb2314d8fabf7683b009b33daf8ca69c0013 100644 (file)
@@ -415,6 +415,7 @@ static gvrender_engine_t cairogen_engine = {
     cairogen_bezier,
     cairogen_polyline,
     0,                         /* cairogen_comment */
+    0,                         /* cairogen_library_shape */
 };
 
 static gvrender_features_t cairogen_features = {