This is hpplot.c in view mode; [Download] [Up]
/* This file contains drivers for the HP7475A plotter */ #include "plplot.h" #include <stdio.h> #include <string.h> #define PLTX 10299 #define PLTY 7649 static FILE *OutDev=NULL; static int orient=0; static int fileopen=0; void hp7475setup(xdpi, ydpi, xwid, ywid) int xwid, ywid; double xdpi, ydpi; { } void hp7475orient(ori) int ori; { orient = ori; } void hp7475select(file) FILE *file; { OutDev = file; } /* Set up device specific stuff and initialize the device */ /* If orient is 0 set up for landscape, otherwise portrait. */ void hp7475init() { char line[80]; /* setpxl() sets the dots/mm in the x and y directions */ setpxl(40.,40.); /* 40 dots/mm or 1016 dots/inch */ /* setphy() sets the device coordinates. These are integer */ /* values. Set up for landscape orientation (long axis of page in the */ /* x direction). Origin is in the lower left hand corner. */ if(!orient) setphy(0,PLTX,0,PLTY); else setphy(0,PLTY,0,PLTX); /* Set default pen color using scol(color). */ /* Any default pen color can be used but a black pen is probably best. */ scol(1); /* Set default pen width using swid(width) */ swid(1); /* Set device interaction mode using smod(mode). Set mode to 0 for */ /* a noninteractive device, Unless you are writing your */ /* own Amiga screen driver mode should be 0. */ smod(0); /* Well that's all the information plplot needs. Let's prompt for a */ /* graphics file name. */ while(!OutDev) { printf("Enter graphics file name. "); fgets(line,sizeof(line),stdin); line[strlen(line)-1] = '\0'; if (!(OutDev = fopen(line,"w"))) fprintf(stderr,"Can't open %s.\n",line); else fileopen; } fprintf(OutDev,"IN; "); } /* Sets to text mode */ void hp7475text() { /* None of the built in fonts are supported yet. */ } /* Sets to graphics mode */ void hp7475graph() { /* We're always in graphics mode with this device. */ } /* Clears the page */ void hp7475clear() { /* On the HP plotter eject the page. */ fprintf(OutDev,"PG; "); } static int xlast, ylast; void hp7475page() { xlast = -100000; ylast = -100000; } void hp7475eop() { fflush(OutDev); } void hp7475width(width) int width; { } /* Change the pen color */ void hp7475color(color) int color; { if(color<1 || color>8) fprintf(stderr,"Invalid pen selection.\n"); else fprintf(OutDev,"SP %d;",color); } /* Draws a line from (x1,y1) to (x2,y2) */ void hp7475line(x1,y1,x2,y2) int x1,y1,x2,y2; { /* If starting point of this line is the same as the ending point of */ /* the previous line then don't raise the pen. (This really speeds up */ /* plotting and reduces the size of the file. */ if(!orient) { if(x1 == xlast && y1 == ylast) fprintf(OutDev," %d %d",x2,y2); else fprintf(OutDev,"\nPU %d %d PD %d %d",x1,y1,x2,y2); } else { if(x1 == xlast && y1 == ylast) fprintf(OutDev," %d %d",PLTX-y2,x2); else fprintf(OutDev,"\nPU %d %d PD %d %d",PLTX-y1,x1,PLTX-y2,x2); } xlast = x2; ylast = y2; } /* Cleanup and close file. */ void hp7475tidy() { fprintf(OutDev,"\nSP0"); if(fileopen) fclose(OutDev); OutDev=NULL; orient=0; fileopen=0; } void hp7475cwin() { } void hp7475gwin() { }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.