=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/plot/ox_plot_xevent.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -p -r1.5 -r1.6 --- OpenXM_contrib2/asir2000/plot/ox_plot_xevent.c 2000/10/14 07:45:34 1.5 +++ OpenXM_contrib2/asir2000/plot/ox_plot_xevent.c 2000/10/15 06:56:52 1.6 @@ -45,7 +45,7 @@ * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. * - * $OpenXM: OpenXM_contrib2/asir2000/plot/ox_plot_xevent.c,v 1.4 2000/10/14 07:43:52 takayama Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/plot/ox_plot_xevent.c,v 1.5 2000/10/14 07:45:34 takayama Exp $ */ #include "ca.h" #include "parse.h" @@ -336,8 +336,6 @@ search_active_canvas() } -#define PRINT_XOFFSET 100 -#define PRINT_YOFFSET 100 static struct canvas *Can; /* void print_canvas(Widget w,struct canvas *can, XtPointer calldata); */ static void output_to_file(Widget , XtPointer, XtPointer ); @@ -347,6 +345,8 @@ static void generate_psfile(struct canvas *can, FILE * static Widget PrintDialog; static Widget PrintDialog_lp; static Widget W; +static char *Fname = NULL; +static char *PrinterName = NULL; static void print_canvas(w,can,calldata) Widget w; @@ -364,7 +364,7 @@ static void print_canvas(w,can,calldata) create_popup(can->shell,"Print/Output PS file","",&fshell,&fdialog); XawDialogAddButton(fdialog,"print",output_to_printer,w); XawDialogAddButton(fdialog,"Output PS file",print_canvas_to_file,w); - XawDialogAddButton(fdialog,"cancel",cancel_output_to_file,w); + XawDialogAddButton(fdialog,"dismiss",cancel_output_to_file,w); XtSetSensitive(w,False); XtPopup(fshell,XtGrabNone); } static void print_canvas_to_file(w,can,calldata) @@ -375,14 +375,16 @@ static void print_canvas_to_file(w,can,calldata) FILE *fp; Arg arg[10]; int n; - char psfile[50]; + static char *psfile = NULL; Widget fshell,fdialog; extern struct canvas *Can; extern Widget PrintDialog; + extern char *Fname; w = W; can = Can; - strcpy(psfile,"ox_plot.eps"); + if (psfile == NULL || Fname == NULL) psfile = "ox_plot.eps"; + else psfile = Fname; /* BUG */ create_popup(can->shell,"Output as PS file",psfile,&fshell,&fdialog); n = 0; XtSetArg(arg[n], XtNlabel, "File : "); n++; @@ -401,14 +403,16 @@ static void output_to_printer(w,can,calldata) FILE *fp; Arg arg[10]; int n; - char psfile[50]; + static char *psfile = NULL; Widget fshell,fdialog; extern struct canvas *Can; extern Widget PrintDialog_lp; + extern char *PrinterName; w = W; can = Can; - strcpy(psfile,"lp"); + if (psfile == NULL || PrinterName == NULL) psfile = "lp"; + else psfile = PrinterName; /* BUG */ create_popup(can->shell,"Output PS file to printer",psfile,&fshell,&fdialog); n = 0; XtSetArg(arg[n], XtNlabel, "PS Printer Name : "); n++; @@ -440,6 +444,7 @@ static void output_to_file(w,fbutton,call) Widget shell = XtParent(XtParent(w)); fname = XawDialogGetValueString(PrintDialog); + Fname = fname; fprintf(stderr,"fname=%s\n",fname); fflush(NULL); fp = fopen(fname,"w"); if (fp == NULL) { @@ -469,6 +474,7 @@ static void output_to_ps_printer(w,fbutton,call) sprintf(fname,"/tmp/ox_plot_%d.eps",(int) getpid(),id++); printerName = XawDialogGetValueString(PrintDialog_lp); + PrinterName = printerName; fprintf(stderr,"printerName=%s\n",printerName); fflush(NULL); fp = fopen(fname,"w"); if (fp == NULL) { @@ -500,34 +506,16 @@ static void generate_psfile(can,fp) { int x,y; XImage *image; - int color; + int color[1]; + int colorSize = 1; fprintf(stderr,"generate_psfile\n"); if ( display ) { fprintf(stderr,"generate_psfile: output to a file.\n"); - fprintf(fp,"%%!\n"); - fprintf(fp,"%%%%BoundingBox: %d %d %d %d \n",PRINT_XOFFSET,PRINT_YOFFSET, - PRINT_XOFFSET+can->width+1,PRINT_YOFFSET+can->height+1); - fprintf(fp,"%%This is generated by ifplot\n"); - fprintf(fp,"/ifplot_putpixel { /oxcolor 2 1 roll def \n"); - fprintf(fp," /yyy 2 1 roll def /xxx 2 1 roll def \n"); - fprintf(fp," gsave newpath xxx yyy .5 0 360 arc \n"); - fprintf(fp," .3 oxcolor .04 mul add setgray fill grestore \n"); - fprintf(fp,"} def \n"); - fprintf(fp,"%% newpath .... stroke \n"); image = XGetImage(display,can->pix, 0,0,can->width,can->height,-1,ZPixmap); - for (x=0; xwidth; x++) { - for (y=0; yheight; y++) { - if ((color = (int) XGetPixel(image,x,y)) == 1) { - /* white background */ - }else { - fprintf(fp,"%d %d %d ifplot_putpixel \n",PRINT_XOFFSET+x, - PRINT_YOFFSET+can->height-y,color); - } - } - } + color[0] = 0; /* balck line */ + generatePS_from_image(fp,image,can->width,can->height,color,colorSize); /* pline(display,can,can->window); */ - fprintf(fp,"showpage \n"); }else{ fprintf(stderr,"Cannot print on this system\n"); }