/* Tue Jul 7 15:47:29 EDT 1992 /leverrier/h1/ksg/src/test llout_.c */ /* llout_ps.c this file includes routines to make a postscript file out of the plots and to send them for printing. */ /* modified Oct 17, 1995 by gsg jr. to allow -h option for lpr command */ #include static float xmin=0.,xmax=12.0,ymin=0.,ymax=8.55,mx0=100,my0=100; static float ax=2450.,ay=3300.; static float ax0=2450.,ay0=3300.; static float a00=1.0; static int ic = -1,jf=0; static int lport=0; /* 0 => landscape, 1 => portrait */ static char name[80],*tempfilename=".temp.plot.file.0987654321..." ; static FILE *filename; static int ipage; static int new_org=0; static int anycolor=0; lloutc_( x0,x2,y0,y2) float *x0,*x2,*y0,*y2; { xmin = *x0; xmax = *x2; ymin = *y0; ymax = *y2; } llout_( itype, x, y, npen) int *itype,*npen; float *x, *y; { int mx,my,ipen; /* fprintf(stderr," inside llout itype = %d npen = %d\n",*itype,*npen); */ if ( *npen == 999) { /* finish the plot and send for printing */ exx(); } if ( *itype == 2 ) { /* change a pen */ if ( anycolor == 0 ) fprintf(filename," %d setpen\n",*npen); else fprintf(filename," %d setpen\n", 0); } if ( *itype == 3 ) { /* set landscape etc. */ lport = *npen; return(0); } if ( *itype == 4) { ipage++; fprintf(filename,"\n stroke \n"); fprintf(filename,"\n showpage \n"); fprintf(filename,"\n%%%%Page:%d %d \n restore \n save \n", ipage,ipage); if ( *npen == 0) { /* erase old data */ fclose(filename); } else if ( *npen == 1) /* print file on laser */ exx(); else if ( *npen == 2) { /* just write file */ fclose(filename); } return(0); } if ( *itype == 5) { ipage++; new_org = 0; fprintf(filename,"\n stroke \n"); fprintf(filename,"\n%% NEW_ORG \n"); fprintf(filename,"\n showpage \n"); fprintf(filename,"\n%%%%Page:%d %d \n restore \n save \n", ipage,ipage); return(0); } if ( *itype == 6) { new_org = 0; fprintf(filename,"\n%% NEW_ORG \n"); fprintf(filename,"\n%% NEW_ORG \n"); return(0); } if ( ic == -1) { ic = 0; ax = ax0 - 2*mx0; ay = ay0 - 2*my0; } if (*itype == 2 ) return(0); if (( *x < xmin) || ( *x > xmax)) return(1); if (( *y < ymin) || ( *y > ymax)) return(1); if ( lport == 1) { mx = ax*( *x - xmin)/(xmax - xmin) + mx0; my = ay*( *y - ymin)/(ymax - ymin) + my0; } else { my = ay*( *x - xmin)/(xmax - xmin) + my0; mx = ax*(a00 - ( *y - ymin)/(ymax - ymin)) + mx0; } ipen = ( *npen > 0) ? *npen : -*npen; ipen %= 10; if ( new_org == 0 ) { new_org++; fprintf(filename,"\n%% new_org \n"); fprintf(filename,"\n%% new_org \n"); /* */ fprintf(filename," stroke %d %d moveto \n",mx,my); } if ( ipen == 3 ) { fprintf(filename," stroke %d %d moveto \n",mx,my); } else { fprintf(filename," %d %d lineto \n",mx,my); } } llchpn_( ipen) int *ipen; { if ( *ipen == -100 ) anycolor ^= 1; } static char st_parm[]=" -h "; static char *pt_st_parm[2]={ " -h ", " "}; static int i_st_parm=1; void set_exx_( ii) int *ii; { i_st_parm = *ii; } static exx() { int ii; char cmd[80]; fprintf(filename,"\n stroke\n"); fclose(filename); sprintf(cmd,"/usr/ucb/lpr %s %s\n", pt_st_parm[ i_st_parm], tempfilename); /* sprintf(cmd,"/plas5/h1/vgr/plt_prt/print %s\n",tempfilename); */ if ((ii = system( cmd )) != 0 ) fprintf( stderr, " system returned error %d \n", ii); ic = -1; } void getplotname_() { /* get the plot name */ fprintf(stderr, "\nWhat name do you wish the plot be called ( - don't save)?"); (void) gets(name); /* now rename the file to the requested name */ if ( *name && rename(tempfilename,name)) { fprintf(stderr,"\n problems in saving the plot file.quitting\n"); exit(1); } } void opentempplotfile_() { /* open a temporary file for the plots */ if ((filename = fopen(tempfilename,"w")) == NULL) { fprintf(stderr,"\n problems in opening temporary file.quitting.\n"); exit(1); } fprintf( filename,"%%!\n\ %%%%Page: 1 1\n\ /setpen {\n\ 0.6 mul setlinewidth\n\ } def\n\ 0.25 0.25 scale\n"); if ( lport == 0 ) fprintf( filename,"0 -50 translate\n"); fprintf( filename," save \n"); ipage = 1; new_org = 0; } void closetempplotfile() { /* close the temporary file for the plots */ fclose(filename); }