]> granicus.if.org Git - graphviz/commitdiff
migrating usershape code to gvc/gvusershape.c
authorellson <devnull@localhost>
Mon, 11 Jul 2005 22:57:33 +0000 (22:57 +0000)
committerellson <devnull@localhost>
Mon, 11 Jul 2005 22:57:33 +0000 (22:57 +0000)
lib/common/gdusershape.c
lib/common/psusershape.c
lib/common/renderprocs.h
lib/common/shapes.c
lib/common/svgusershape.c
lib/common/utils.c
lib/gvc/gvc.h
lib/gvc/gvusershape.c

index ac02fb6d69941d6e98d166722a29ac2571102c65..ff34d3858cd5fd3a5c6fbb68c0207ae05fd55d10 100644 (file)
@@ -138,8 +138,3 @@ point gd_image_size(graph_t * g, char *shapeimagefile)
        rv.x = rv.y = -1;
     return rv;
 }
-
-point gd_user_shape_size(node_t * n, char *shapeimagefile)
-{
-    return (gd_image_size(n->graph, shapeimagefile));
-}
index 89a6ccb3c932807ea589fb8a521068009caf196f..610b1a0eb99d7480ff35b52fb5acd9a192ff5c2a 100644 (file)
@@ -214,11 +214,6 @@ point ps_image_size(graph_t * g, char *shapeimagefile)
     return rv;
 }
 
-point ps_user_shape_size(node_t * n, char *shapeimagefile)
-{
-    return (ps_image_size(n->graph, shapeimagefile));
-}
-
 void ps_freeusershapes(void)
 {
     if (EPSF_contents) {
index 4b5f704a6331a6be081aa5d57fcd56fed0792802..290858c1bc7811cc4138534e53f3f3e1e0481690 100644 (file)
@@ -105,14 +105,6 @@ extern "C" {
     extern char *gd_alternate_fontlist(char *font);
     extern char *gd_textsize(textline_t * textline, char *fontname,
                             double fontsz, char **fontpath);
-    extern point gd_user_shape_size(node_t * n, char *shapeimagefile);
-    extern point ps_user_shape_size(node_t * n, char *shapeimagefile);
-    extern point svg_user_shape_size(node_t * n, char *shapeimagefile);
-    extern point quartz_user_shape_size(node_t * n, char *shapeimagefile);
-    extern point gd_image_size(graph_t * n, char *shapeimagefile);
-    extern point ps_image_size(graph_t * n, char *shapeimagefile);
-    extern point svg_image_size(graph_t * n, char *shapeimagefile);
-    extern point quartz_image_size(graph_t * n, char *shapeimagefile);
     extern void getdouble(graph_t * g, char *name, double *result);
     extern splines *getsplinepoints(edge_t * e);
     extern void global_def(char *,
@@ -184,7 +176,6 @@ extern "C" {
     extern void updateBB(graph_t * g, textlabel_t * lp);
     extern void use_library(char *);
     extern char *username(void);
-    extern point user_shape_size(node_t * n, char *shapefile);
     extern char* utf8ToLatin1 (char* ins);
     extern void write_attributed_dot(graph_t *g, FILE *f);
     extern void write_canonical_dot(graph_t *g, FILE *f);
index 05e2317f554e7228767af0bb54e4e8bf751770a4..76676679ef7b2c4b3855d469c9a21f92341adf0c 100644 (file)
@@ -575,7 +575,7 @@ static void poly_init(node_t * n)
            point imagesize;
            char *sfile = agget(n, "shapefile");
 
-           imagesize = user_shape_size(n, sfile);
+           imagesize = image_size(n->graph, sfile);
            if ((imagesize.x == -1) && (imagesize.y == -1)) {
                agerr(AGERR,
                      "No or improper shapefile=\"%s\" for node \"%s\"\n",
index a8f9b414a889a0b419aaa9728ca7c5244931ad95..fb4579a76c83c9fecd43e6869320abe6eaebeffa 100644 (file)
@@ -23,11 +23,3 @@ point svg_image_size(graph_t * g, char *shapeimagefile)
     rv.x = rv.y = 0;
     return rv;
 }
-
-point svg_user_shape_size(node_t * n, char *shapeimagefile)
-{
-    point rv;
-
-    rv.x = rv.y = 0;
-    return rv;
-}
index 04f65a45223e47b63409647731a9a19f66cd9526..58457e5f1ef88ed3cf76337aa7abe72881ed499c 100644 (file)
@@ -1143,135 +1143,6 @@ box flip_rec_box(box b, point p)
     return rv;
 }
 
-/*
- * This routine extracts the usershape size from known filetypes, 
- * it does not check that the output renderer knows how to render
- * this file type
- * Returns the size required for the shape in points;
- * returns (-1,-1) on error;
- * returns (0,0) to indicate "don't care". For example, in
- * postscript, a node can have a user-defined shape but no shapefile.
- */
-point user_shape_size(node_t * n, char *shapefile)
-{
-    char *suffix;
-    point rv;
-
-    /* no shape file, no shape size */
-    if (!shapefile) {
-       rv.x = rv.y = -1;
-       return rv;
-    }
-    if (*shapefile == '\0') {
-       rv.x = rv.y = 0;
-       return rv;              /* no shapefile; probably postscript custom */
-    }
-    if (!strncasecmp(shapefile, "http://", 7)) {
-       rv.x = rv.y = 0;
-       return rv;              /* punt on obvious web addresses */
-    }
-
-    suffix = strrchr(shapefile, '.');
-    if (!suffix)
-       suffix = shapefile;
-    else
-       suffix++;
-    if (!strcasecmp(suffix, "wbmp")
-#ifdef HAVE_GD_GIF
-       || !strcasecmp(suffix, "gif")
-#endif
-#ifdef HAVE_GD_JPEG
-       || !strcasecmp(suffix, "jpeg") || !strcasecmp(suffix, "jpg")
-#endif
-#ifdef HAVE_GD_PNG
-       || !strcasecmp(suffix, "png")
-#endif
-#ifdef HAVE_GD_XPM
-       || !strcasecmp(suffix, "xbm")
-/* FIXME - is "xpm" also supported by gd for input ? */
-#endif
-       ) {
-       rv = gd_user_shape_size(n, shapefile);
-    } else
-#ifdef QUARTZ_RENDER
-    if (Output_lang == QPDF || Output_lang == QEPDF ||
-           (Output_lang >= QBM_FIRST && Output_lang <= QBM_LAST))
-       return quartz_user_shape_size(n, shapefile);
-    else
-#endif
-    if (!strcasecmp(suffix, "ps") || !strncasecmp(suffix, "eps", 3) ||
-       !strcasecmp(suffix, "epi")) {
-       rv = ps_user_shape_size(n, shapefile);
-    } else if (!strcasecmp(suffix, "svg")) {
-       rv = svg_user_shape_size(n, shapefile);
-    } else {
-       agerr(AGERR, "shapefile \"%s\" suffix not recognized\n",
-             shapefile);
-       rv.x = rv.y = 0;
-    }
-    return rv;
-}
-
-point image_size(graph_t * g, char *shapefile)
-{
-    char *suffix;
-    point rv;
-
-    /* no shape file, no shape size */
-    if (!shapefile) {
-       rv.x = rv.y = -1;
-       return rv;
-    }
-    if (*shapefile == '\0') {
-       rv.x = rv.y = 0;
-       return rv;              /* no shapefile; probably postscript custom */
-    }
-    if (!strncasecmp(shapefile, "http://", 7)) {
-       rv.x = rv.y = 0;
-       return rv;              /* punt on obvious web addresses */
-    }
-
-    suffix = strrchr(shapefile, '.');
-    if (!suffix)
-       suffix = shapefile;
-    else
-       suffix++;
-    if (!strcasecmp(suffix, "wbmp")
-#ifdef HAVE_GD_GIF
-       || !strcasecmp(suffix, "gif")
-#endif
-#ifdef HAVE_GD_JPEG
-       || !strcasecmp(suffix, "jpeg") || !strcasecmp(suffix, "jpg")
-#endif
-#ifdef HAVE_GD_PNG
-       || !strcasecmp(suffix, "png")
-#endif
-#ifdef HAVE_GD_XPM
-       || !strcasecmp(suffix, "xbm")
-/* FIXME - is "xpm" also supported by gd for input ? */
-#endif
-       ) {
-       rv = gd_image_size(g, shapefile);
-    } else
-#ifdef QUARTZ_RENDER
-    if (Output_lang == QPDF || Output_lang == QEPDF ||
-           (Output_lang >= QBM_FIRST && Output_lang <= QBM_LAST))
-       return quartz_image_size(g, shapefile);
-    else
-#endif
-
-    if (!strcasecmp(suffix, "ps")) {
-       rv = ps_image_size(g, shapefile);
-    } else if (!strcasecmp(suffix, "svg")) {
-       rv = svg_image_size(g, shapefile);
-    } else {
-       agerr(AGERR, "shapefile \"%s\" suffix not recognized\n",
-             shapefile);
-       rv.x = rv.y = -1;
-    }
-    return rv;
-}
-
 /* addLabelBB:
  */
 static box addLabelBB(box bb, textlabel_t * lp)
index fe04f051ea188718eba606acd0c7ea9553eea9c3..9a703bfbae185d64fbf85fe0f6c4fddfa7105c29 100644 (file)
@@ -68,8 +68,8 @@ extern "C" {
 
     extern int gvusershape_select(GVC_t * gvc, char *name);
     extern void * gvusershape_getshape(GVC_t * gvc, char *usershape);
-    extern void gvusershape_freeeshapes(GVC_t * gvc);
-    extern point gvusershape_imagesize(GVC_t * gvc, char *usershape);
+    extern void gvusershape_freeshapes(GVC_t * gvc);
+    extern point gvusershape_size(GVC_t * gvc, char *usershape);
 
 /* device */
 
index 0646581631db8abe63e5276f2a6b14730ded4e84..33a4d675b8713b414f081cf1fd7bfc548413bb58 100644 (file)
 #include "config.h"
 #endif
 
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifndef HAVE_STRCASECMP
+    extern int strcasecmp(const char *s1, const char *s2);
+#endif
+#ifndef HAVE_STRNCASECMP
+    extern int strncasecmp(const char *s1, const char *s2, unsigned int n);
+#endif
+
 #include <stdio.h>
 
 #include "const.h"
 #include "types.h"
 #include "macros.h"
+#include "cdt.h"
+#include "graph.h"
 
 #include "gvplugin_usershape.h"
 #include "gvc.h"
 
+extern point gd_image_size(graph_t * g, char *shapeimagefile);
+extern point ps_image_size(graph_t * g, char *shapeimagefile);
+extern point svg_image_size(graph_t * g, char *shapeimagefile);
+extern point quartz_image_size(graph_t * g, char *shapeimagefile);
+
 int gvusershape_select(GVC_t * gvc, char *usershape)
 {
     gvplugin_available_t *plugin;
@@ -44,3 +64,73 @@ int gvusershape_select(GVC_t * gvc, char *usershape)
     }
     return NO_SUPPORT;
 }
+
+/*
+ * This routine extracts the usershape size from known filetypes,
+ * it does not check that the output renderer knows how to render
+ * this file type
+ * Returns the size required for the shape in points;
+ * returns (-1,-1) on error;
+ * returns (0,0) to indicate "don't care". For example, in
+ * postscript, a node can have a user-defined shape but no shapefile.
+ */
+point image_size(graph_t * g, char *shapefile)
+{
+    char *suffix;
+    point rv;
+
+    /* no shape file, no shape size */
+    if (!shapefile) {
+        rv.x = rv.y = -1;
+        return rv;
+    }
+    if (*shapefile == '\0') {
+        rv.x = rv.y = 0;
+        return rv;              /* no shapefile; probably postscript custom */
+    }
+    if (!strncasecmp(shapefile, "http://", 7)) {
+        rv.x = rv.y = 0;
+        return rv;              /* punt on obvious web addresses */
+    }
+
+    suffix = strrchr(shapefile, '.');
+    if (!suffix)
+        suffix = shapefile;
+    else
+        suffix++;
+    if (!strcasecmp(suffix, "wbmp")
+#ifdef HAVE_GD_GIF
+        || !strcasecmp(suffix, "gif")
+#endif
+#ifdef HAVE_GD_JPEG
+        || !strcasecmp(suffix, "jpeg") || !strcasecmp(suffix, "jpg")
+#endif
+#ifdef HAVE_GD_PNG
+        || !strcasecmp(suffix, "png")
+#endif
+#ifdef HAVE_GD_XPM
+        || !strcasecmp(suffix, "xbm")
+/* FIXME - is "xpm" also supported by gd for input ? */
+#endif
+        ) {
+        rv = gd_image_size(g, shapefile);
+    } else
+#ifdef QUARTZ_RENDER
+    if (Output_lang == QPDF || Output_lang == QEPDF ||
+            (Output_lang >= QBM_FIRST && Output_lang <= QBM_LAST))
+        return quartz_image_size(g, shapefile);
+    else
+#endif
+
+    if (!strcasecmp(suffix, "ps")) {
+        rv = ps_image_size(g, shapefile);
+    } else if (!strcasecmp(suffix, "svg")) {
+        rv = svg_image_size(g, shapefile);
+    } else {
+        agerr(AGERR, "shapefile \"%s\" suffix not recognized\n",
+              shapefile);
+        rv.x = rv.y = -1;
+    }
+    return rv;
+}
+