From: ellson Date: Fri, 28 Jan 2005 22:32:07 +0000 (+0000) Subject: get part of tcldot working again X-Git-Tag: LAST_LIBGRAPH~32^2~7976 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ef4d3d0b95f95e76fb604d18a35295b58d61ef95;p=graphviz get part of tcldot working again --- diff --git a/lib/common/const.h b/lib/common/const.h index 70546c883..193c83182 100644 --- a/lib/common/const.h +++ b/lib/common/const.h @@ -151,12 +151,13 @@ #define DIA 24 /* dia drawing tool */ #define SVG 25 /* Structured Vector Graphics */ #define SVGZ 26 /* compressed SVG */ -#define CANONICAL_DOT 27 /* wanted for tcl/tk version */ -#define PDF 28 -#define EXTENDED_DOT 29 /* dot with drawing info */ +#define TK 27 /* TK canvas */ +#define CANONICAL_DOT 28 /* wanted for tcl/tk version */ +#define PDF 29 +#define EXTENDED_DOT 30 /* dot with drawing info */ -#define QPDF 30 /* Quartz paged PDF */ -#define QEPDF 31 /* Quartz embedded PDF */ +#define QPDF 31 /* Quartz paged PDF */ +#define QEPDF 32 /* Quartz embedded PDF */ #define QBM_FIRST 100 /* first Quartz bitmap format, inclusive */ #define QBM_LAST 200 /* last Quartz bitmap format, exclusive */ diff --git a/lib/common/output.c b/lib/common/output.c index 735bdaa48..61e00bb0d 100644 --- a/lib/common/output.c +++ b/lib/common/output.c @@ -148,7 +148,7 @@ void dotneato_write_one(GVC_t * gvc, graph_t * g) case POSTSCRIPT: case PDF: case HPGL: case PCL: case MIF: case PIC_format: case GIF: case PNG: case JPEG: case WBMP: case GD: case memGD: case GD2: case VRML: case METAPOST: - case SVG: case SVGZ: case QPDF: case QEPDF: case ISMAP: + case TK: case SVG: case SVGZ: case QPDF: case QEPDF: case ISMAP: case IMAP: case CMAP: case CMAPX: case FIG: case VTX: case DIA: emit_graph(gvc, g, flags); break; @@ -179,7 +179,10 @@ void dotneato_write_one(GVC_t * gvc, graph_t * g) break; } - fflush(gvc->job->output_file); +#if 0 + if (gvc->job->output_lang != TK) + fflush(gvc->job->output_file); +#endif #if 0 emit_deinit(gvc); #endif diff --git a/tclpkg/tcldot/tcldot.c b/tclpkg/tcldot/tcldot.c index d3f278a48..b18dfb51f 100644 --- a/tclpkg/tcldot/tcldot.c +++ b/tclpkg/tcldot/tcldot.c @@ -1107,22 +1107,18 @@ static int graphcmd(ClientData clientData, Tcl_Interp * interp, tkgendata.interp = interp; gvrender_output_langname_job(gvc, "TK"); + gvc->job->output_lang = TK; + gvc->job->codegen = &TK_CodeGen; + gvc->job->output_file = (FILE *) & tkgendata; + /* make sure that layout is done */ gvc->g = g = g->root; if (!GD_drawing(g) || argc > 3) tcldot_layout(g, (argc > 3) ? argv[3] : (char *) NULL); /* render graph TK canvas commands */ - gvc->job->output_lang = - gvrender_select(gvc, gvc->job->output_langname); - gvc->job->output_file = (FILE *) & tkgendata; -#if ENABLE_CODEGENS - Output_lang = gvc->job->output_lang; - Output_file = gvc->job->output_file; -#endif - gvc->job->codegen = &TK_CodeGen; - /* emit graph in sorted order, all nodes then all edges */ - emit_graph(gvc, g, EMIT_SORTED); + dotneato_write_one(gvc, g); + gvrender_delete_jobs(gvc); return TCL_OK; @@ -1134,38 +1130,21 @@ static int graphcmd(ClientData clientData, Tcl_Interp * interp, return TCL_ERROR; } gvrender_output_langname_job(gvc, "memGD"); - -/* FIXME - nasty hack because memGD is not a language available from command line */ -#if 0 - gvc->job->output_lang = - gvrender_select(gvc, gvc->job->output_langname); - -#else gvc->job->output_lang = memGD; -#endif - - if (! - (gvc->job->output_file = + gvc->job->codegen = &memGD_CodeGen; + if (! (gvc->job->output_file = (FILE *) tclhandleXlate(GDHandleTable, argv[2]))) { Tcl_AppendResult(interp, "GD Image not found.", (char *) NULL); return TCL_ERROR; } -#if ENABLE_CODEGENS - Output_lang = gvc->job->output_lang; - Output_file = gvc->job->output_file; -#endif /* make sure that layout is done */ gvc->g = g = g->root; if (!GD_drawing(g) || argc > 4) tcldot_layout(g, (argc > 4) ? argv[4] : (char *) NULL); + + dotneato_write_one(gvc, g); - /* set default margins for current output format */ - dotneato_set_margins(gvc, g); - /* render graph to open GD structure */ - gvc->job->codegen = &memGD_CodeGen; - /* emit graph in sorted order, all nodes then all edges */ - emit_graph(gvc, g, 1); gvrender_delete_jobs(gvc); Tcl_AppendResult(interp, argv[2], (char *) NULL); return TCL_OK; @@ -1270,51 +1249,58 @@ static int graphcmd(ClientData clientData, Tcl_Interp * interp, } else if ((c == 'w') && (strncmp(argv[1], "write", length) == 0)) { g = g->root; if (argc < 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], - " write fileHandle ?language ?DOT|NEATO|TWOPI|FDP|CIRCO|NOP??\"", - (char *) NULL); + Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], + " write fileHandle ?language ?DOT|NEATO|TWOPI|FDP|CIRCO|NOP??\"", + (char *) NULL); return TCL_ERROR; } + + /* configure codegens */ +// config_codegen_builtins(gvc); +// gvplugin_builtins(gvc); +// gvconfig(gvc, CONFIG); + /* process lang first to create job */ if (argc < 4) { - gvrender_output_langname_job(gvc, "dot"); + i = gvrender_output_langname_job(gvc, "dot"); } else { - gvrender_output_langname_job(gvc, argv[3]); + i = gvrender_output_langname_job(gvc, argv[3]); + } + if (i == NO_SUPPORT) { + const char *s = gvplugin_list(gvc, API_render, argv[3]); + Tcl_AppendResult(interp, "Bad langname: \"", argv[3], + "\". Use one of:", s, (char *)NULL); + return TCL_ERROR; } /* populate new job struct with output language and output file data */ gvc->job->output_lang = gvrender_select(gvc, gvc->job->output_langname); - if (Tcl_GetOpenFile - (interp, argv[2], 1, 1, - (ClientData *) & (gvc->job->output_file)) != TCL_OK) + + if (Tcl_GetOpenFile (interp, argv[2], 1, 1, + (ClientData *) &(gvc->job->output_file)) != TCL_OK) return TCL_ERROR; -#if ENABLE_CODEGENS - /* old codegens use globals */ - Output_lang = gvc->job->output_lang; - Output_file = gvc->job->output_file; -#endif + /* make sure that layout is done - unless canonical output */ if ((!GD_drawing(g) || argc > 4) && gvc->job->output_lang != CANONICAL_DOT) { tcldot_layout(g, (argc > 4) ? argv[4] : (char *) NULL); } - emit_reset(gvc, g); /* reset page numbers in postscript */ dotneato_write_one(gvc, g); + gvrender_delete_jobs(gvc); return TCL_OK; } else { Tcl_AppendResult(interp, "bad option \"", argv[1], - "\": must be one of:", - "\n\taddedge, addnode, addsubgraph, countedges, countnodes,", - "\n\tlayout, listattributes, listedgeattributes, listnodeattributes,", - "\n\tlistedges, listnodes, listsubgraphs, render, rendergd,", - "\n\tqueryattributes, queryedgeattributes, querynodeattributes,", - "\n\tqueryattributevalues, queryedgeattributevalues, querynodeattributevalues,", - "\n\tsetattributes, setedgeattributes, setnodeattributes,", - "\n\tshowname, write.", (char *) NULL); + "\": must be one of:", + "\n\taddedge, addnode, addsubgraph, countedges, countnodes,", + "\n\tlayout, listattributes, listedgeattributes, listnodeattributes,", + "\n\tlistedges, listnodes, listsubgraphs, render, rendergd,", + "\n\tqueryattributes, queryedgeattributes, querynodeattributes,", + "\n\tqueryattributevalues, queryedgeattributevalues, querynodeattributevalues,", + "\n\tsetattributes, setedgeattributes, setnodeattributes,", + "\n\tshowname, write.", (char *) NULL); return TCL_ERROR; } } /* graphcmd */