This is tektronix.c in view mode; [Download] [Up]
#include "plplot.h" #include <stdio.h> /*debug#include <limits.h>*/ /* This file contains the tektronix dependent routines for use with plplot. */ #define TEKX 1023 #define TEKY 779 /* Define graphics control characters. */ #define FF 12 #define CAN 24 #define ESC 27 #define GS 29 #define US 31 static FILE *OutFile=NULL; static int porient=0; static int fileopen=0; void tektsetup(xdpi,ydpi,xwid,ywid) double xdpi, ydpi; int xwid, ywid; { /* ignore */ } void tekfsetup(xdpi,ydpi,xwid,ywid) double xdpi, ydpi; int xwid, ywid; { } void tektinit() { smod(1); /* an interactive device */ OutFile = stdout; teksetup(0); } void tekfinit() { char response[80]; smod(0); /* not an interactive terminal */ while(!OutFile) { printf("Enter graphics command storage file name. "); fgets(response,sizeof(response),stdin); response[strlen(response)-1] = '\0'; if ((OutFile = fopen(response,"w")) == NULL) fprintf(stderr,"Can't open %s.\n",response); else fileopen=1; } teksetup(porient); } teksetup(portrait) int portrait; { /* set default pen color*/ scol(1); if(!portrait) { /* set device resolution in dots/mm */ setpxl(4.771*16,4.653*16); /* set page size */ setphy(0,TEKX*16,0,TEKY*16); } else { /* set device resolution in dots/mm */ setpxl(4.653*16,4.771*16); /* set page size */ setphy(0,TEKY*16,0,TEKX*16); } fprintf(OutFile,"%c",GS); } /* Sets the tektronix to text mode */ void tektext() { fprintf(OutFile,"%c",US); } /* Sets the tektronix to graphics mode */ void tekgraph() { /* Nothing has to be done here */ } /* Clears the tektronix screen */ void tektclear() { fprintf(OutFile,"%c%c",ESC,FF); } void tekfclear() { fprintf(OutFile,"%c%c",ESC,FF); } void tektorient(ori) int ori; { } void tektselect(file) FILE *file; { } void tekforient(ori) int ori; { porient = ori; } void tekfselect(file) FILE *file; { OutFile = file; fileopen=0; } /* Change color */ void tekcolor(colour) int colour; { } static int xold, yold; void tekpage() { xold = -100000; yold = -100000; fprintf(OutFile,"%c%c",ESC,FF); } void tekeop() { fflush(OutFile); } /* Change pen width */ void tekwidth(width) int width; { } /* Draws a line in the current colour from (x1,y1) to (x2,y2) */ void tekline(x1a,y1a,x2a,y2a) int x1a,y1a,x2a,y2a; { int x1,y1,x2,y2,hy,ly,hx,lx; x1a >>= 4; y1a >>= 4; x2a >>= 4; y2a >>= 4; if(!porient) { x1 = x1a; y1 = y1a; x2 = x2a; y2 = y2a; } else { x1 = TEKX - y1a; y1 = x1a; x2 = TEKX - y2a; y2 = x2a; } /* If continuation of previous line just send new point */ if(x1 == xold && y1 == yold) { hy = y2/32 + 32; ly = y2 - (y2/32)*32 + 96; hx = x2/32 + 32; lx = x2 - (x2/32)*32 + 64; fprintf(OutFile,"%c%c%c%c",hy,ly,hx,lx); } else { fprintf(OutFile,"%c",GS); hy = y1/32 + 32; ly = y1 - (y1/32)*32 + 96; hx = x1/32 + 32; lx = x1 - (x1/32)*32 + 64; fprintf(OutFile,"%c%c%c%c",hy,ly,hx,lx); hy = y2/32 + 32; ly = y2 - (y2/32)*32 + 96; hx = x2/32 + 32; lx = x2 - (x2/32)*32 + 64; fprintf(OutFile,"%c%c%c%c",hy,ly,hx,lx); } xold = x2; yold = y2; } /* Close file */ void tekftidy() { if(fileopen) fclose(OutFile); } void tekttidy() { tektclear(); fprintf(OutFile,"%c%c",US,CAN); fflush(OutFile); } void tekfcwin() { } void tekcwin() { fprintf(OutFile,"%c%c",US,CAN); fflush(OutFile); } void tekfgwin() { } void tekgwin() { fprintf(OutFile,"%c",GS); fflush(OutFile); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.