version 1.4, 2000/10/14 07:43:52 |
version 1.6, 2000/10/15 06:56:52 |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM: OpenXM_contrib2/asir2000/plot/ox_plot_xevent.c,v 1.3 2000/08/22 05:04:31 noro 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 "ca.h" |
#include "parse.h" |
#include "parse.h" |
Line 336 search_active_canvas() |
|
Line 336 search_active_canvas() |
|
} |
} |
|
|
|
|
#define PRINT_XOFFSET 100 |
|
#define PRINT_YOFFSET 100 |
|
static struct canvas *Can; |
static struct canvas *Can; |
/* void print_canvas(Widget w,struct canvas *can, XtPointer calldata); */ |
/* void print_canvas(Widget w,struct canvas *can, XtPointer calldata); */ |
static void output_to_file(Widget , XtPointer, XtPointer ); |
static void output_to_file(Widget , XtPointer, XtPointer ); |
Line 347 static void generate_psfile(struct canvas *can, FILE * |
|
Line 345 static void generate_psfile(struct canvas *can, FILE * |
|
static Widget PrintDialog; |
static Widget PrintDialog; |
static Widget PrintDialog_lp; |
static Widget PrintDialog_lp; |
static Widget W; |
static Widget W; |
|
static char *Fname = NULL; |
|
static char *PrinterName = NULL; |
|
|
static void print_canvas(w,can,calldata) |
static void print_canvas(w,can,calldata) |
Widget w; |
Widget w; |
Line 364 static void print_canvas(w,can,calldata) |
|
Line 364 static void print_canvas(w,can,calldata) |
|
create_popup(can->shell,"Print/Output PS file","",&fshell,&fdialog); |
create_popup(can->shell,"Print/Output PS file","",&fshell,&fdialog); |
XawDialogAddButton(fdialog,"print",output_to_printer,w); |
XawDialogAddButton(fdialog,"print",output_to_printer,w); |
XawDialogAddButton(fdialog,"Output PS file",print_canvas_to_file,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); |
XtSetSensitive(w,False); XtPopup(fshell,XtGrabNone); |
} |
} |
static void print_canvas_to_file(w,can,calldata) |
static void print_canvas_to_file(w,can,calldata) |
Line 375 static void print_canvas_to_file(w,can,calldata) |
|
Line 375 static void print_canvas_to_file(w,can,calldata) |
|
FILE *fp; |
FILE *fp; |
Arg arg[10]; |
Arg arg[10]; |
int n; |
int n; |
char psfile[50]; |
static char *psfile = NULL; |
Widget fshell,fdialog; |
Widget fshell,fdialog; |
extern struct canvas *Can; |
extern struct canvas *Can; |
extern Widget PrintDialog; |
extern Widget PrintDialog; |
|
extern char *Fname; |
|
|
w = W; |
w = W; |
can = Can; |
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); |
create_popup(can->shell,"Output as PS file",psfile,&fshell,&fdialog); |
n = 0; |
n = 0; |
XtSetArg(arg[n], XtNlabel, "File : "); n++; |
XtSetArg(arg[n], XtNlabel, "File : "); n++; |
Line 401 static void output_to_printer(w,can,calldata) |
|
Line 403 static void output_to_printer(w,can,calldata) |
|
FILE *fp; |
FILE *fp; |
Arg arg[10]; |
Arg arg[10]; |
int n; |
int n; |
char psfile[50]; |
static char *psfile = NULL; |
Widget fshell,fdialog; |
Widget fshell,fdialog; |
extern struct canvas *Can; |
extern struct canvas *Can; |
extern Widget PrintDialog_lp; |
extern Widget PrintDialog_lp; |
|
extern char *PrinterName; |
|
|
w = W; |
w = W; |
can = Can; |
can = Can; |
strcpy(psfile,"xerox"); |
if (psfile == NULL || PrinterName == NULL) psfile = "lp"; |
|
else psfile = PrinterName; /* BUG */ |
create_popup(can->shell,"Output PS file to printer",psfile,&fshell,&fdialog); |
create_popup(can->shell,"Output PS file to printer",psfile,&fshell,&fdialog); |
n = 0; |
n = 0; |
XtSetArg(arg[n], XtNlabel, "PS Printer Name : "); n++; |
XtSetArg(arg[n], XtNlabel, "PS Printer Name : "); n++; |
Line 440 static void output_to_file(w,fbutton,call) |
|
Line 444 static void output_to_file(w,fbutton,call) |
|
Widget shell = XtParent(XtParent(w)); |
Widget shell = XtParent(XtParent(w)); |
|
|
fname = XawDialogGetValueString(PrintDialog); |
fname = XawDialogGetValueString(PrintDialog); |
|
Fname = fname; |
fprintf(stderr,"fname=%s\n",fname); fflush(NULL); |
fprintf(stderr,"fname=%s\n",fname); fflush(NULL); |
fp = fopen(fname,"w"); |
fp = fopen(fname,"w"); |
if (fp == NULL) { |
if (fp == NULL) { |
Line 469 static void output_to_ps_printer(w,fbutton,call) |
|
Line 474 static void output_to_ps_printer(w,fbutton,call) |
|
sprintf(fname,"/tmp/ox_plot_%d.eps",(int) getpid(),id++); |
sprintf(fname,"/tmp/ox_plot_%d.eps",(int) getpid(),id++); |
|
|
printerName = XawDialogGetValueString(PrintDialog_lp); |
printerName = XawDialogGetValueString(PrintDialog_lp); |
|
PrinterName = printerName; |
fprintf(stderr,"printerName=%s\n",printerName); fflush(NULL); |
fprintf(stderr,"printerName=%s\n",printerName); fflush(NULL); |
fp = fopen(fname,"w"); |
fp = fopen(fname,"w"); |
if (fp == NULL) { |
if (fp == NULL) { |
Line 500 static void generate_psfile(can,fp) |
|
Line 506 static void generate_psfile(can,fp) |
|
{ |
{ |
int x,y; |
int x,y; |
XImage *image; |
XImage *image; |
int color; |
int color[1]; |
|
int colorSize = 1; |
fprintf(stderr,"generate_psfile\n"); |
fprintf(stderr,"generate_psfile\n"); |
if ( display ) { |
if ( display ) { |
fprintf(stderr,"generate_psfile: output to a file.\n"); |
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, |
image = XGetImage(display,can->pix, |
0,0,can->width,can->height,-1,ZPixmap); |
0,0,can->width,can->height,-1,ZPixmap); |
for (x=0; x<can->width; x++) { |
color[0] = 0; /* balck line */ |
for (y=0; y<can->height; y++) { |
generatePS_from_image(fp,image,can->width,can->height,color,colorSize); |
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); |
|
} |
|
} |
|
} |
|
/* pline(display,can,can->window); */ |
/* pline(display,can,can->window); */ |
fprintf(fp,"showpage \n"); |
|
}else{ |
}else{ |
fprintf(stderr,"Cannot print on this system\n"); |
fprintf(stderr,"Cannot print on this system\n"); |
} |
} |