From: ellson Date: Sun, 7 Sep 2008 19:06:28 +0000 (+0000) Subject: ps renderers now use gvio X-Git-Tag: LAST_LIBGRAPH~32^2~3445 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ecc69ce973accb02379336a2a90ff79001ef4602;p=graphviz ps renderers now use gvio --- diff --git a/graphs/undirected/Makefile.am b/graphs/undirected/Makefile.am index 2e9447716..1b411879b 100644 --- a/graphs/undirected/Makefile.am +++ b/graphs/undirected/Makefile.am @@ -15,7 +15,7 @@ test: $(top_builddir)/cmd/dot/dot -Kneato -Tcanon -Tcmap -Tcmapx \ -Tdia -Tgv -Tfig -Tgd -Tgd2 -Tgif -Thpgl \ -Tismap -Timap -Tjpg -Tmif -Tmp -Tpcl -Tpdf -Tpic \ - -Tplain -Tplain-ext -Tpng -Tps -Tps2 -Tps:cairo -Tsvg \ + -Tplain -Tplain-ext -Tpng -Tps -Tps2 -Tps:cairo -Tps:lasi -Tsvg \ -Tsvg:cairo -Tsvgz -Tvrml -Twbmp -Tvtx -Txdot \ -O $(GRAPHS) @@ -139,7 +139,11 @@ ps: ps_cairo: for i in $(GRAPHS); do echo "neato $$i"; \ - $(top_builddir)/cmd/dot/dot -Kneato -Tps:cairo -o$$i.ps $(top_srcdir)/graphs/undirected/$$i; done + $(top_builddir)/cmd/dot/dot -Kneato -Tps:cairo -o$$i.cairo.ps $(top_srcdir)/graphs/undirected/$$i; done + +ps_lasi: + for i in $(GRAPHS); do echo "neato $$i"; \ + $(top_builddir)/cmd/dot/dot -Kneato -Tps:lasi -o$$i.lasi.ps $(top_srcdir)/graphs/undirected/$$i; done ps2: for i in $(GRAPHS); do echo "neato $$i"; \ diff --git a/graphviz.spec.in b/graphviz.spec.in index 5b47860b4..3fac192fa 100644 --- a/graphviz.spec.in +++ b/graphviz.spec.in @@ -185,7 +185,8 @@ BuildRequires: librsvg2-devel %if %fedora >= 7 %define DEVIL 1 %define GDK_PIXBUF 1 -BuildRequires: gd gd-devel perl-devel DevIL-devel +%define LASI 1 +BuildRequires: gd gd-devel perl-devel DevIL-devel lasi-devel %endif %if %fedora >= 8 %define R_LANG 1 @@ -249,7 +250,8 @@ BuildRequires: librsvg2-devel %define GDK_PIXBUF 1 %define SMYRNA 1 %define SFDP 1 -BuildRequires: gd gd-devel perl-devel DevIL-devel +%define LASI 1 +BuildRequires: gd gd-devel perl-devel DevIL-devel lasi-devel BuildRequires: gtkglarea2-devel gtkglext-devel glade3-libgladeui-devel gts-devel %endif %if %att_fedora >= 8 @@ -677,6 +679,7 @@ CFLAGS="$RPM_OPT_FLAGS" \ --enable-tcl%{!?TCL:=no} \ --with%{!?DEVIL:out}-devil \ --with%{!?IPSEPCOLA:out}-ipsepcola \ + --with%{!?LASI:out}-lasi \ --with%{!?MING:out}-ming \ --with%{!?SMYRNA:out}-smyrna \ --with%{!?SFDP:out}-sfdp \ diff --git a/lib/common/mpgen.c b/lib/common/mpgen.c index 4f53eeb8f..54319cd29 100644 --- a/lib/common/mpgen.c +++ b/lib/common/mpgen.c @@ -49,7 +49,7 @@ static void mp_reset(void) onetime = TRUE; } -/* cat_libfile: +/* mp_cat_libfile: * Write library files onto the given file pointer. * arglib is an NULL-terminated array of char* * Each non-trivial entry should be the name of a file to be included. @@ -59,7 +59,7 @@ static void mp_reset(void) * The stdlib is printed first, if used, followed by the user libraries. * We check that for web-safe file usage. */ -static void cat_libfile(FILE * ofp, const char **arglib, const char **stdlib) +static void mp_cat_libfile(FILE * ofp, const char **arglib, const char **stdlib) { FILE *fp; const char **s, *bp, *p; @@ -131,7 +131,7 @@ static void mp_begin_graph(GVC_t * gvc, graph_t * g, box bb, point pb) if (onetime) { fprintf(Output_file, "%% BoundingBox: %d %d %d %d\n", bb.LL.x, bb.LL.y, bb.UR.x + 1, bb.UR.y + 1); - cat_libfile(Output_file,U_lib,mp_lib); + mp_cat_libfile(Output_file,U_lib,mp_lib); onetime = FALSE; } } diff --git a/lib/common/psusershape.c b/lib/common/psusershape.c index 839877b2b..770e99ff1 100644 --- a/lib/common/psusershape.c +++ b/lib/common/psusershape.c @@ -127,6 +127,51 @@ void epsf_free(node_t * n) free(ND_shape_info(n)); } + +/* cat_libfile: + * Write library files onto the given file pointer. + * arglib is an NULL-terminated array of char* + * Each non-trivial entry should be the name of a file to be included. + * stdlib is an NULL-terminated array of char* + * Each of these is a line of a standard library to be included. + * If any item in arglib is the empty string, the stdlib is not used. + * The stdlib is printed first, if used, followed by the user libraries. + * We check that for web-safe file usage. + */ +void cat_libfile(GVJ_t * job, const char **arglib, const char **stdlib) +{ + FILE *fp; + const char **s, *bp, *p; + int i; + boolean use_stdlib = TRUE; + + /* check for empty string to turn off stdlib */ + if (arglib) { + for (i = 0; use_stdlib && ((p = arglib[i])); i++) { + if (*p == '\0') + use_stdlib = FALSE; + } + } + if (use_stdlib) + for (s = stdlib; *s; s++) { + gvputs(job, *s); + gvputs(job, "\n"); + } + if (arglib) { + for (i = 0; (p = arglib[i]) != 0; i++) { + if (*p == '\0') + continue; /* ignore empty string */ + p = safefile(p); /* make sure filename is okay */ + if ((fp = fopen(p, "r"))) { + while ((bp = Fgets(fp))) + gvputs(job, bp); + gvputs(job, "\n"); /* append a newline just in case */ + } else + agerr(AGWARN, "can't open library file %s\n", p); + } + } +} + #define FILTER_EPSF 1 #ifdef FILTER_EPSF /* this removes EPSF DSC comments that, when nested in another diff --git a/lib/common/render.h b/lib/common/render.h index c027d740c..a7534c72b 100644 --- a/lib/common/render.h +++ b/lib/common/render.h @@ -105,6 +105,7 @@ extern "C" { extern void endpath(path *, Agedge_t *, int, pathend_t *, boolean); extern void epsf_init(node_t * n); extern void epsf_free(node_t * n); + extern void cat_libfile(GVJ_t * job, const char **arglib, const char **stdlib); extern shape_desc *find_user_shape(char *); extern void free_line(textpara_t *); extern void free_label(textlabel_t *); diff --git a/lib/gvc/gvcint.h b/lib/gvc/gvcint.h index f6caf959f..d61c21d41 100644 --- a/lib/gvc/gvcint.h +++ b/lib/gvc/gvcint.h @@ -92,7 +92,7 @@ extern "C" { void *keycodes; /* externally provided write() displine */ - size_t (*write_fn) (GVJ_t *job, const char *s, int len); + size_t (*write_fn) (GVJ_t *job, const char *s, size_t len); /* FIXME - everything below should probably move to GVG_t */ diff --git a/plugin/core/gvrender_core_ps.c b/plugin/core/gvrender_core_ps.c index 2be9fef24..621edb3d5 100644 --- a/plugin/core/gvrender_core_ps.c +++ b/plugin/core/gvrender_core_ps.c @@ -23,7 +23,7 @@ #include "gvplugin_render.h" #include "gvplugin_device.h" -#include "graph.h" +#include "gvio.h" #include "agxbuf.h" #include "utils.h" #include "ps.h" @@ -40,56 +40,13 @@ extern void epsf_define(GVJ_t * job); extern char *ps_string(char *ins, int latin); +extern void cat_libfile(GVJ_t * job, const char **arglib, const char **stdlib); typedef enum { FORMAT_PS, FORMAT_PS2, FORMAT_EPS } format_type; static int isLatin1; static char setupLatin1; -/* cat_libfile: - * Write library files onto the given file pointer. - * arglib is an NULL-terminated array of char* - * Each non-trivial entry should be the name of a file to be included. - * stdlib is an NULL-terminated array of char* - * Each of these is a line of a standard library to be included. - * If any item in arglib is the empty string, the stdlib is not used. - * The stdlib is printed first, if used, followed by the user libraries. - * We check that for web-safe file usage. - */ -static void cat_libfile(GVJ_t * job, const char **arglib, const char **stdlib) -{ - FILE *fp; - const char **s, *bp, *p; - int i; - boolean use_stdlib = TRUE; - - /* check for empty string to turn off stdlib */ - if (arglib) { - for (i = 0; use_stdlib && ((p = arglib[i])); i++) { - if (*p == '\0') - use_stdlib = FALSE; - } - } - if (use_stdlib) - for (s = stdlib; *s; s++) { - gvputs(job, *s); - gvputs(job, "\n"); - } - if (arglib) { - for (i = 0; (p = arglib[i]) != 0; i++) { - if (*p == '\0') - continue; /* ignore empty string */ - p = safefile(p); /* make sure filename is okay */ - if ((fp = fopen(p, "r"))) { - while ((bp = Fgets(fp))) - gvputs(job, bp); - gvputs(job, "\n"); /* append a newline just in case */ - } else - agerr(AGWARN, "can't open library file %s\n", p); - } - } -} - static void psgen_begin_job(GVJ_t * job) { gvputs(job, "%!PS-Adobe-3.0 EPSF-3.0\n"); diff --git a/plugin/lasi/gvrender_lasi.cpp b/plugin/lasi/gvrender_lasi.cpp index 08dedfb2c..dcb3b00b2 100644 --- a/plugin/lasi/gvrender_lasi.cpp +++ b/plugin/lasi/gvrender_lasi.cpp @@ -23,19 +23,19 @@ #include #include - #include "gvplugin_render.h" #include "gvplugin_device.h" #include "gvio.h" -#include "ps.h" +#include "gvcint.h" #include "agxbuf.h" #include "utils.h" +#include "ps.h" using namespace LASi; using namespace std; /* for CHAR_LATIN1 */ -#include "const.h" +// #include "const.h" /* * J$: added `pdfmark' URL embedding. PostScript rendered from @@ -45,7 +45,8 @@ using namespace std; #define PDFMAX 14400 /* Maximum size of PDF page */ extern "C" { - extern void epsf_define(FILE * of); + extern void epsf_define(GVJ_t * job); + extern void cat_libfile(GVJ_t * job, const char **arglib, const char **stdlib); } typedef enum { FORMAT_PS, FORMAT_PS2, FORMAT_EPS } format_type; @@ -54,157 +55,109 @@ typedef enum { FORMAT_PS, FORMAT_PS2, FORMAT_EPS } format_type; //static char setupLatin1; PostscriptDocument doc; +size_t (*save_write_fn) (GVJ_t *job, const char *s, size_t len); -/* cat_libfile: - * Write library files onto the given file pointer. - * arglib is an NULL-terminated array of char* - * Each non-trivial entry should be the name of a file to be included. - * stdlib is an NULL-terminated array of char* - * Each of these is a line of a standard library to be included. - * If any item in arglib is the empty string, the stdlib is not used. - * The stdlib is printed first, if used, followed by the user libraries. - * We check that for web-safe file usage. - */ -static void cat_libfile(GVJ_t *job, const char **arglib, const char **stdlib) +static size_t lasi_head_writer(GVJ_t * job, const char *s, size_t len) { - FILE *fp; - const char **s, *bp, *p; - int i; - boolean use_stdlib = TRUE; - - /* check for empty string to turn off stdlib */ - if (arglib) { - for (i = 0; use_stdlib && ((p = arglib[i])); i++) { - if (*p == '\0') - use_stdlib = FALSE; - } - } - if (use_stdlib) - for (s = stdlib; *s; s++) { - doc.osBody() << *s << endl; - } - if (arglib) { - for (i = 0; (p = arglib[i]) != 0; i++) { - if (*p == '\0') - continue; /* ignore empty string */ - p = safefile(p); /* make sure filename is okay */ - if ((fp = fopen(p, "r"))) { - while ((bp = Fgets(fp))) - doc.osBody() << bp; - doc.osBody() << endl; /* append a newline just in case */ - } else - job->common->errorfn("can't open library file %s\n", p); - } - } + doc.osHeader() << s; + return len; } -static void lasi_printpointf(GVJ_t * job, pointf p) +static size_t lasi_body_writer(GVJ_t * job, const char *s, size_t len) { - doc.osBody() << p.x << ' ' << p.y << ' ' ; + doc.osBody() << s; + return len; } -static void lasi_printpointflist(GVJ_t * job, pointf A[], int n) +static size_t lasi_footer_writer(GVJ_t * job, const char *s, size_t len) { - for (int i = 0; i < n; i++) { - lasi_printpointf(job, A[i]); - } + doc.osFooter() << s; + return len; } static void lasi_begin_job(GVJ_t * job) { + save_write_fn = job->gvc->write_fn; + job->gvc->write_fn = lasi_head_writer; + // gvputs(job, "%!PS-Adobe-3.0 EPSF-3.0\n"); -// gvprintf(job, "%%%%Creator: %s version %s (%s)\n", -// job->common->info[0], job->common->info[1], job->common->info[2]); -// gvprintf(job, "%%%%For: %s\n", job->common->user); - doc.osHeader() << "%%Creator: " << job->common->info[0] \ - << " version " << job->common->info[1] \ - << " (" << job->common->info[2] << ")" << endl; - doc.osHeader() << "%%For: " << job->common->user << endl; + gvprintf(job, "%%%%Creator: %s version %s (%s)\n", + job->common->info[0], job->common->info[1], job->common->info[2]); + gvprintf(job, "%%%%For: %s\n", job->common->user); } static void lasi_end_job(GVJ_t * job) { - // create the new stream to "redirect" cout's output to - ostringstream output; - - // smart class that will swap streambufs and replace them - // when object goes out of scope. - class StreamBuf_Swapper - { - public: - StreamBuf_Swapper(ostream & orig, ostream & replacement) - : buf_(orig.rdbuf()), str_(orig) - { - orig.rdbuf(replacement.rdbuf()); - } - ~StreamBuf_Swapper() - { - str_.rdbuf(buf_); - } - private: - std::streambuf * buf_; - std::ostream & str_; - } swapper(cout, output); + job->gvc->write_fn = lasi_footer_writer; // gvputs(job, "%%Trailer\n"); if (job->render.id != FORMAT_EPS) -// gvprintf(job, "%%%%Pages: %d\n", job->common->viewNum); - doc.osFooter() << "%%Pages: " << job->common->viewNum << endl; + gvprintf(job, "%%%%Pages: %d\n", job->common->viewNum); if (job->common->show_boxes == NULL) if (job->render.id != FORMAT_EPS) -// gvprintf(job, "%%%%BoundingBox: %d %d %d %d\n", -// job->boundingBox.LL.x, job->boundingBox.LL.y, -// job->boundingBox.UR.x, job->boundingBox.UR.y); - doc.osFooter() << "%%BoundingBox: " << job->pageBoundingBox.LL.x << ' ' \ - << job->pageBoundingBox.LL.y << ' ' \ - << job->pageBoundingBox.UR.x << ' ' \ - << job->pageBoundingBox.UR.y << endl; -// gvputs(job, "end\nrestore\n"); - doc.osFooter() << "end" << endl; - doc.osFooter() << "restore" << endl; + gvprintf(job, "%%%%BoundingBox: %d %d %d %d\n", + job->boundingBox.LL.x, job->boundingBox.LL.y, + job->boundingBox.UR.x, job->boundingBox.UR.y); + gvputs(job, "end\nrestore\n"); // gvputs(job, "%%EOF\n"); - doc.write(cout); - gvputs(job, output.str().c_str()); + { + // create the new stream to "redirect" cout's output to + ostringstream output; + + // smart class that will swap streambufs and replace them + // when object goes out of scope. + class StreamBuf_Swapper + { + public: + StreamBuf_Swapper(ostream & orig, ostream & replacement) + : buf_(orig.rdbuf()), str_(orig) + { + orig.rdbuf(replacement.rdbuf()); + } + ~StreamBuf_Swapper() + { + str_.rdbuf(buf_); + } + private: + std::streambuf * buf_; + std::ostream & str_; + } swapper(cout, output); + + doc.write(cout); + + job->gvc->write_fn = save_write_fn; + gvputs(job, output.str().c_str()); + } } static void lasi_begin_graph(GVJ_t * job) { obj_state_t *obj = job->obj; + job->gvc->write_fn = lasi_body_writer; + // setupLatin1 = FALSE; if (job->common->viewNum == 0) { -// gvprintf(job, "%%%%Title: %s\n", obj->u.g->name); - doc.osBody() << "%%Title: " << obj->u.g->name << endl; + gvprintf(job, "%%%%Title: %s\n", obj->u.g->name); if (job->render.id != FORMAT_EPS) -// gvputs(job, "%%Pages: (atend)\n"); - doc.osBody() << "%%Pages: (atend)" << endl; + gvputs(job, "%%Pages: (atend)\n"); else -// gvputs(job, "%%Pages: 1\n"); - doc.osBody() << "%%Pages: 1" << endl; + gvputs(job, "%%Pages: 1\n"); if (job->common->show_boxes == NULL) { if (job->render.id != FORMAT_EPS) -// gvputs(job, "%%BoundingBox: (atend)\n"); - doc.osBody() << "%%BoundingBox: (atend)" << endl; + gvputs(job, "%%BoundingBox: (atend)\n"); else -// gvprintf(job, "%%%%BoundingBox: %d %d %d %d\n", -// job->pageBoundingBox.LL.x, job->pageBoundingBox.LL.y, -// job->pageBoundingBox.UR.x, job->pageBoundingBox.UR.y); - doc.osBody() << "%%BoundingBox: " << job->pageBoundingBox.LL.x << ' ' \ - << job->pageBoundingBox.LL.y << ' ' \ - << job->pageBoundingBox.UR.x << ' ' \ - << job->pageBoundingBox.UR.y << endl; + gvprintf(job, "%%%%BoundingBox: %d %d %d %d\n", + job->pageBoundingBox.LL.x, job->pageBoundingBox.LL.y, + job->pageBoundingBox.UR.x, job->pageBoundingBox.UR.y); } -// gvputs(job, "%%EndComments\nsave\n"); - doc.osBody() << "%%EndComments" << endl; - doc.osBody() << "save" << endl; + gvputs(job, "%%EndComments\nsave\n"); /* include shape library */ -// cat_preamble(job, job->common->lib); cat_libfile(job, job->common->lib, ps_txt); /* include epsf */ -// FIXME!! -// epsf_define(job->output_file); + epsf_define(job); if (job->common->show_boxes) { const char* args[2]; args[0] = job->common->show_boxes[0]; @@ -224,60 +177,39 @@ static void lasi_begin_graph(GVJ_t * job) // setupLatin1 = TRUE; // } /* Set base URL for relative links (for Distiller >= 3.0) */ - if (obj->url) { -// gvprintf(job, "[ {Catalog} << /URI << /Base (%s) >> >>\n" -// "/PUT pdfmark\n", obj->url); - doc.osBody() << "[ {Catalog} << /URI << /Base (" << obj->url << ") >> >>" << endl; - doc.osBody() << "/PUT pdfmark" << endl; - } + if (obj->url) + gvprintf(job, "[ {Catalog} << /URI << /Base (%s) >> >>\n" + "/PUT pdfmark\n", obj->url); } static void lasi_begin_layer(GVJ_t * job, char *layername, int layerNum, int numLayers) { -// gvprintf(job, "%d %d setlayer\n", layerNum, numLayers); - doc.osBody() << layerNum << ' ' << numLayers << "setlayer" << endl; + gvprintf(job, "%d %d setlayer\n", layerNum, numLayers); } static void lasi_begin_page(GVJ_t * job) { box pbr = job->pageBoundingBox; -// gvprintf(job, "%%%%Page: %d %d\n", -// job->common->viewNum + 1, job->common->viewNum + 1); - doc.osBody() << "%%Page: " << (job->common->viewNum + 1) << ' ' << (job->common->viewNum + 1) << endl; + gvprintf(job, "%%%%Page: %d %d\n", + job->common->viewNum + 1, job->common->viewNum + 1); if (job->common->show_boxes == NULL) -// gvprintf(job, "%%%%PageBoundingBox: %d %d %d %d\n", -// pbr.LL.x, pbr.LL.y, pbr.UR.x, pbr.UR.y); - doc.osBody() << "%%PageBoundingBox: " << pbr.LL.x << ' ' \ - << pbr.LL.y << ' ' \ - << pbr.UR.x << ' ' \ - << pbr.UR.y << endl; -// gvprintf(job, "%%%%PageOrientation: %s\n", -// (job->rotation ? "Landscape" : "Portrait")); - doc.osBody() << "%%PageOrientation: " << (job->rotation ? "Landscape" : "Portrait") << endl; + gvprintf(job, "%%%%PageBoundingBox: %d %d %d %d\n", + pbr.LL.x, pbr.LL.y, pbr.UR.x, pbr.UR.y); + gvprintf(job, "%%%%PageOrientation: %s\n", + (job->rotation ? "Landscape" : "Portrait")); if (job->render.id == FORMAT_PS2) -// gvprintf(job, "<< /PageSize [%d %d] >> setpagedevice\n", -// pbr.UR.x, pbr.UR.y); - doc.osBody() << "<< /PageSize [" << pbr.UR.x << ' ' \ - << pbr.UR.y << "] >> setpagedevice" << endl; -// gvprintf(job, "%d %d %d beginpage\n", -// job->pagesArrayElem.x, job->pagesArrayElem.y, job->numPages); - doc.osBody() << job->pagesArrayElem.x << ' ' << job->pagesArrayElem.y << ' ' << job->numPages \ - << " beginpage" << endl; + gvprintf(job, "<< /PageSize [%d %d] >> setpagedevice\n", + pbr.UR.x, pbr.UR.y); + gvprintf(job, "%d %d %d beginpage\n", + job->pagesArrayElem.x, job->pagesArrayElem.y, job->numPages); if (job->common->show_boxes == NULL) -// gvprintf(job, "gsave\n%d %d %d %d boxprim clip newpath\n", -// pbr.LL.x, pbr.LL.y, pbr.UR.x-pbr.LL.x, pbr.UR.y-pbr.LL.y); - doc.osBody() << "gsave" << endl; - doc.osBody() << pbr.LL.x << ' ' << pbr.LL.y << ' ' \ - << pbr.UR.x << ' ' << pbr.UR.y << " boxprim clip newpath" << endl; - -// gvprintf(job, "%g %g set_scale %d rotate %g %g translate\n", -// job->scale.x, job->scale.y, -// job->rotation, -// job->translation.x, job->translation.y); - doc.osBody() << job->scale.x << ' ' << job->scale.y << " set_scale " \ - << job->rotation << " rotate " \ - << job->translation.x << ' ' << job->translation.y << " translate" << endl; + gvprintf(job, "gsave\n%d %d %d %d boxprim clip newpath\n", + pbr.LL.x, pbr.LL.y, pbr.UR.x-pbr.LL.x, pbr.UR.y-pbr.LL.y); + gvprintf(job, "%g %g set_scale %d rotate %g %g translate\n", + job->scale.x, job->scale.y, + job->rotation, + job->translation.x, job->translation.y); /* Define the size of the PS canvas */ if (job->render.id == FORMAT_PS2) { @@ -285,73 +217,57 @@ static void lasi_begin_page(GVJ_t * job) job->common->errorfn("canvas size (%d,%d) exceeds PDF limit (%d)\n" "\t(suggest setting a bounding box size, see dot(1))\n", pbr.UR.x, pbr.UR.y, PDFMAX); -// gvprintf(job, "[ /CropBox [%d %d %d %d] /PAGES pdfmark\n", -// pbr.LL.x, pbr.LL.y, pbr.UR.x, pbr.UR.y); - doc.osBody() << "[ /CropBox [" << pbr.LL.x << ' ' \ - << pbr.LL.y << ' ' \ - << pbr.UR.x << ' ' \ - << pbr.UR.y << "] /PAGES pdfmark" << endl; + gvprintf(job, "[ /CropBox [%d %d %d %d] /PAGES pdfmark\n", + pbr.LL.x, pbr.LL.y, pbr.UR.x, pbr.UR.y); } } static void lasi_end_page(GVJ_t * job) { if (job->common->show_boxes) { -// gvputs(job, "0 0 0 edgecolor\n"); - doc.osBody() << "0 0 0 edgecolor" << endl; + gvputs(job, "0 0 0 edgecolor\n"); cat_libfile(job, NULL, job->common->show_boxes + 1); } /* the showpage is really a no-op, but at least one PS processor * out there needs to see this literal token. endpage does the real work. */ -// gvputs(job, "endpage\nshowpage\ngrestore\n"); -// gvputs(job, "%%PageTrailer\n"); -// gvprintf(job, "%%%%EndPage: %d\n", job->common->viewNum); - doc.osBody() << "endpage" << endl; - doc.osBody() << "showpage" << endl; - doc.osBody() << "grestore" << endl; - doc.osBody() << "%%EndPage: " << job->common->viewNum << endl; + gvputs(job, "endpage\nshowpage\ngrestore\n"); + gvputs(job, "%%PageTrailer\n"); + gvprintf(job, "%%%%EndPage: %d\n", job->common->viewNum); } static void lasi_begin_cluster(GVJ_t * job) { obj_state_t *obj = job->obj; -// gvprintf(job, "%% %s\n", obj->u.sg->name); -// gvputs(job, "gsave\n"); - doc.osBody() << "% " << obj->u.sg->name << endl; - doc.osBody() << "gsave" << endl; + gvprintf(job, "%% %s\n", obj->u.sg->name); + gvputs(job, "gsave\n"); } static void lasi_end_cluster(GVJ_t * job) { -// gvputs(job, "grestore\n"); - doc.osBody() << "grestore" << endl; + gvputs(job, "grestore\n"); } static void lasi_begin_node(GVJ_t * job) { -// gvputs(job, "gsave\n"); - doc.osBody() << "gsave" << endl; + gvputs(job, "gsave\n"); } static void lasi_end_node(GVJ_t * job) { -// gvputs(job, "grestore\n"); - doc.osBody() << "grestore" << endl; + gvputs(job, "grestore\n"); } static void lasi_begin_edge(GVJ_t * job) { -// gvputs(job, "gsave\n"); - doc.osBody() << "gsave" << endl; + gvputs(job, "gsave\n"); } static void lasi_end_edge(GVJ_t * job) { -// gvputs(job, "grestore\n"); - doc.osBody() << "grestore" << endl; + gvputs(job, "grestore\n"); } static void lasi_begin_anchor(GVJ_t *job, char *url, char *tooltip, char *target) @@ -359,21 +275,15 @@ static void lasi_begin_anchor(GVJ_t *job, char *url, char *tooltip, char *target obj_state_t *obj = job->obj; if (url && obj->url_map_p) { -// gvputs(job, "[ /Rect [ "); -// gvprintpointflist(job, obj->url_map_p, 2); -// gvputs(job, " ]\n"); -// gvprintf(job, " /Border [ 0 0 0 ]\n" -// " /Action << /Subtype /URI /URI %s >>\n" -// " /Subtype /Link\n" -// "/ANN pdfmark\n", + gvputs(job, "[ /Rect [ "); + gvprintpointflist(job, obj->url_map_p, 2); + gvputs(job, " ]\n"); + gvprintf(job, " /Border [ 0 0 0 ]\n" + " /Action << /Subtype /URI /URI %s >>\n" + " /Subtype /Link\n" + "/ANN pdfmark\n", // ps_string(url, isLatin1)); - doc.osBody() << "[ /Rect [ "; - lasi_printpointflist(job, obj->url_map_p, 2); - doc.osBody() << "]" << endl; - doc.osBody() << " /Border [ 0 0 0 ]" << endl; -// doc.osBody() << " /Action << /Subtype /URI /URI " << ps_string(url, isLatin1) << " >>" << endl; - doc.osBody() << " /Action << /Subtype /URI /URI " << url << " >>" << endl; - doc.osBody() << "/ANN pdfmark" << endl; + url); } } @@ -382,9 +292,8 @@ static void ps_set_pen_style(GVJ_t *job) double penwidth = job->obj->penwidth; char *p, *line, **s = job->obj->rawstyle; -// gvprintnum(job, penwidth); -// gvputs(job," setlinewidth\n"); - doc.osBody() << penwidth << " setlinewidth" << endl; + gvprintdouble(job, penwidth); + gvputs(job," setlinewidth\n"); while (s && (p = line = *s++)) { if (strcmp(line, "setlinewidth") == 0) @@ -393,16 +302,14 @@ static void ps_set_pen_style(GVJ_t *job) p++; p++; while (*p) { -// gvprintf(job,"%s ", p); - doc.osBody() << p << ' '; + gvprintf(job,"%s ", p); while (*p) p++; p++; } if (strcmp(line, "invis") == 0) job->obj->penwidth = 0; -// gvprintf(job, "%s\n", line); - doc.osBody() << line << endl; + gvprintf(job, "%s\n", line); } } @@ -426,9 +333,8 @@ static void ps_set_color(GVJ_t *job, gvcolor_t *color) objtype = "sethsb"; break; } -// gvprintf(job, "%.3f %.3f %.3f %scolor\n", -// color->u.HSVA[0], color->u.HSVA[1], color->u.HSVA[2], objtype); - doc.osBody() << color->u.HSVA[0] << ' ' << color->u.HSVA[1] << ' ' << color->u.HSVA[2] << ' ' << objtype << "color" << endl; + gvprintf(job, "%.3f %.3f %.3f %scolor\n", + color->u.HSVA[0], color->u.HSVA[1], color->u.HSVA[2], objtype); } } @@ -449,13 +355,8 @@ static void lasi_textpara(GVJ_t * job, pointf p, textpara_t * para) font = para->postscript_alias->svg_font_family; } -//fprintf(stderr,"font=\"%s\"\n", para->fontname); -//fprintf(stderr,"ps_font=\"%s\"\n", para->postscript_alias->name); -//fprintf(stderr,"svg_font=\"%s\"\n", para->postscript_alias->svg_font_family); -//fprintf(stderr,"pango_font=\"%s\"\n", pango_font_description_get_family(pango_font)); - ps_set_color(job, &(job->obj->pencolor)); -// gvprintnum(job, para->fontsize); +// gvprintdouble(job, para->fontsize); // gvprintf(job, " /%s set_font\n", para->fontname); doc.osBody() << setFont(font) << setFontSize(para->fontsize) << endl; switch (para->just) { @@ -471,11 +372,9 @@ static void lasi_textpara(GVJ_t * job, pointf p, textpara_t * para) break; } p.y += para->yoffset_centerline; -// gvprintpointf(job, p); -// gvputs(job, " moveto "); - lasi_printpointf(job, p); - doc.osBody() << "moveto" << endl; -// gvprintnum(job, para->width); + gvprintpointf(job, p); + gvputs(job, " moveto "); +// gvprintdouble(job, para->width); // str = ps_string(para->str,isLatin1); // gvprintf(job, " %s alignedtext\n", str); doc.osBody() << show(para->str) << endl; @@ -493,18 +392,14 @@ static void lasi_ellipse(GVJ_t * job, pointf * A, int filled) if (filled && job->obj->fillcolor.u.HSVA[3] > .5) { ps_set_color(job, &(job->obj->fillcolor)); -// gvprintpointflist(job, AA, 2); -// gvputs(job, " ellipse_path fill\n"); - lasi_printpointflist(job, AA, 2); - doc.osBody() << "ellipse_path fill" << endl; + gvprintpointflist(job, AA, 2); + gvputs(job, " ellipse_path fill\n"); } if (job->obj->pencolor.u.HSVA[3] > .5) { ps_set_pen_style(job); ps_set_color(job, &(job->obj->pencolor)); -// gvprintpointflist(job, AA, 2); -// gvputs(job, " ellipse_path stroke\n"); - lasi_printpointflist(job, AA, 2); - doc.osBody() << "ellipse_path stroke" << endl; + gvprintpointflist(job, AA, 2); + gvputs(job, " ellipse_path stroke\n"); } } @@ -516,38 +411,26 @@ lasi_bezier(GVJ_t * job, pointf * A, int n, int arrow_at_start, if (filled && job->obj->fillcolor.u.HSVA[3] > .5) { ps_set_color(job, &(job->obj->fillcolor)); -// gvputs(job, "newpath "); -// gvprintpointf(job, A[0]); -// gvputs(job, " moveto\n"); - doc.osBody() << "newpath "; - lasi_printpointf(job, A[0]); - doc.osBody() << "moveto" << endl; + gvputs(job, "newpath "); + gvprintpointf(job, A[0]); + gvputs(job, " moveto\n"); for (j = 1; j < n; j += 3) { -// gvprintpointflist(job, &A[j], 3); -// gvputs(job, " curveto\n"); - lasi_printpointflist(job, &A[j], 3); - doc.osBody() << "curveto" << endl; + gvprintpointflist(job, &A[j], 3); + gvputs(job, " curveto\n"); } -// gvputs(job, "closepath fill\n"); - doc.osBody() << "closepath fill" << endl; + gvputs(job, "closepath fill\n"); } if (job->obj->pencolor.u.HSVA[3] > .5) { ps_set_pen_style(job); ps_set_color(job, &(job->obj->pencolor)); -// gvputs(job, "newpath "); -// gvprintpointf(job, A[0]); -// gvputs(job, " moveto\n"); - doc.osBody() << "newpath "; - lasi_printpointf(job, A[0]); - doc.osBody() << "moveto" << endl; + gvputs(job, "newpath "); + gvprintpointf(job, A[0]); + gvputs(job, " moveto\n"); for (j = 1; j < n; j += 3) { -// gvprintpointflist(job, &A[j], 3); -// gvputs(job, " curveto\n"); - lasi_printpointflist(job, &A[j], 3); - doc.osBody() << "curveto" << endl; + gvprintpointflist(job, &A[j], 3); + gvputs(job, " curveto\n"); } -// gvputs(job, "stroke\n"); - doc.osBody() << "stroke" << endl; + gvputs(job, "stroke\n"); } } @@ -557,38 +440,26 @@ static void lasi_polygon(GVJ_t * job, pointf * A, int n, int filled) if (filled && job->obj->fillcolor.u.HSVA[3] > .5) { ps_set_color(job, &(job->obj->fillcolor)); -// gvputs(job, "newpath "); -// gvprintpointf(job, A[0]); -// gvputs(job, " moveto\n"); - doc.osBody() << "newpath "; - lasi_printpointf(job, A[0]); - doc.osBody() << "moveto" << endl; + gvputs(job, "newpath "); + gvprintpointf(job, A[0]); + gvputs(job, " moveto\n"); for (j = 1; j < n; j++) { -// gvprintpointf(job, A[j]); -// gvputs(job, " lineto\n"); - lasi_printpointf(job, A[j]); - doc.osBody() << "lineto" << endl; + gvprintpointf(job, A[j]); + gvputs(job, " lineto\n"); } -// gvputs(job, "closepath fill\n"); - doc.osBody() << "closepath fill" << endl; + gvputs(job, "closepath fill\n"); } if (job->obj->pencolor.u.HSVA[3] > .5) { ps_set_pen_style(job); ps_set_color(job, &(job->obj->pencolor)); -// gvputs(job, "newpath "); -// gvprintpointf(job, A[0]); -// gvputs(job, " moveto\n"); - doc.osBody() << "newpath "; - lasi_printpointf(job, A[0]); - doc.osBody() << "moveto" << endl; + gvputs(job, "newpath "); + gvprintpointf(job, A[0]); + gvputs(job, " moveto\n"); for (j = 1; j < n; j++) { -// gvprintpointf(job, A[j]); -// gvputs(job, " lineto\n"); - lasi_printpointf(job, A[j]); - doc.osBody() << "lineto" << endl; + gvprintpointf(job, A[j]); + gvputs(job, " lineto\n"); } -// gvputs(job, "closepath stroke\n"); - doc.osBody() << "closepath stroke" << endl; + gvputs(job, "closepath stroke\n"); } } @@ -599,57 +470,42 @@ static void lasi_polyline(GVJ_t * job, pointf * A, int n) if (job->obj->pencolor.u.HSVA[3] > .5) { ps_set_pen_style(job); ps_set_color(job, &(job->obj->pencolor)); -// gvputs(job, "newpath "); -// gvprintpointf(job, A[0]); -// gvputs(job, " moveto\n"); - doc.osBody() << "newpath "; - lasi_printpointf(job, A[0]); - doc.osBody() << "moveto" << endl; + gvputs(job, "newpath "); + gvprintpointf(job, A[0]); + gvputs(job, " moveto\n"); for (j = 1; j < n; j++) { -// gvprintpointf(job, A[j]); -// gvputs(job, " lineto\n"); - lasi_printpointf(job, A[j]); - doc.osBody() << "lineto" << endl; + gvprintpointf(job, A[j]); + gvputs(job, " lineto\n"); } -// gvputs(job, "stroke\n"); - doc.osBody() << "stroke" << endl; + gvputs(job, "stroke\n"); } } static void lasi_comment(GVJ_t * job, char *str) { -// gvputs(job, "% "); -// gvputs(job, str); -// gvputs(job, "\n"); - doc.osBody() << "% " << str << endl; + gvputs(job, "% "); + gvputs(job, str); + gvputs(job, "\n"); } static void lasi_library_shape(GVJ_t * job, char *name, pointf * A, int n, int filled) { if (filled && job->obj->fillcolor.u.HSVA[3] > .5) { ps_set_color(job, &(job->obj->fillcolor)); -// gvputs(job, "[ "); -// gvprintpointflist(job, A, n); -// gvputs(job, " "); -// gvprintpointf(job, A[0]); -// gvprintf(job, " ] %d true %s\n", n, name); - doc.osBody() << "[ "; - lasi_printpointflist(job, A, n); - lasi_printpointf(job, A[0]); - doc.osBody() << "] " << n << " true " << name << endl; + gvputs(job, "[ "); + gvprintpointflist(job, A, n); + gvputs(job, " "); + gvprintpointf(job, A[0]); + gvprintf(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)); -// gvputs(job, "[ "); -// gvprintpointflist(job, A, n); -// gvputs(job, " "); -// gvprintpointf(job, A[0]); -// gvprintf(job, " ] %d false %s\n", n, name); - doc.osBody() << "[ "; - lasi_printpointflist(job, A, n); - lasi_printpointf(job, A[0]); - doc.osBody() << "] " << n << " false " << name << endl; + gvputs(job, "[ "); + gvprintpointflist(job, A, n); + gvputs(job, " "); + gvprintpointf(job, A[0]); + gvprintf(job, " ] %d false %s\n", n, name); } }