home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-10-27 | 48.3 KB | 2,320 lines |
- Newsgroups: comp.sources.misc
- From: gershon%gr@cs.utah.edu (Elber Gershon)
- Subject: v24i038: gnuplot3 - interactive function plotting utility, Part16/26
- Message-ID: <1991Oct28.002308.12469@sparky.imd.sterling.com>
- X-Md4-Signature: 676522afedfc30eebb23d254a4fefb3e
- Date: Mon, 28 Oct 1991 00:23:08 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: gershon%gr@cs.utah.edu (Elber Gershon)
- Posting-number: Volume 24, Issue 38
- Archive-name: gnuplot3/part16
- Environment: UNIX, MS-DOS, VMS
- Supersedes: gnuplot2: Volume 11, Issue 65-79
-
- #!/bin/sh
- # this is Part.16 (part 16 of a multipart archive)
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file gnuplot/term/hpljii.trm continued
- #
- if test ! -r _shar_seq_.tmp; then
- echo 'Please unpack part 1 first!'
- exit 1
- fi
- (read Scheck
- if test "$Scheck" != 16; then
- echo Please unpack part "$Scheck" next!
- exit 1
- else
- exit 0
- fi
- ) < _shar_seq_.tmp || exit 1
- if test ! -f _shar_wnt_.tmp; then
- echo 'x - still skipping gnuplot/term/hpljii.trm'
- else
- echo 'x - continuing file gnuplot/term/hpljii.trm'
- sed 's/^X//' << 'SHAR_EOF' >> 'gnuplot/term/hpljii.trm' &&
- /*
- X * Copyright (C) 1990
- X *
- X * Permission to use, copy, and distribute this software and its
- X * documentation for any purpose with or without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and
- X * that both that copyright notice and this permission notice appear
- X * in supporting documentation.
- X *
- X * Permission to modify the software is granted, but not the right to
- X * distribute the modified code. Modifications are to be distributed
- X * as patches to released version.
- X *
- X * This software is provided "as is" without express or implied warranty.
- X *
- X * This file is included by ../term.c.
- X *
- X * This terminal driver supports:
- X * hpljii, hpdj
- X *
- X * AUTHORS
- X * John Engels
- X * Russell Lang
- X * Maurice Castro
- X *
- X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
- X *
- X */
- X
- /* The following HP laserjet series II driver uses generic bit mapped graphics
- X routines from bitmap.c to build up a bit map in memory. The driver
- X interchanges colomns and lines in order to access entire lines
- X easily and returns the lines to get bits in the right order :
- X (x,y) -> (y,XMAX-1-x). */
- /* This interchange is done by calling b_makebitmap() with reversed
- X xmax and ymax, and then setting b_rastermode to TRUE. b_setpixel()
- X will then perform the interchange before each pixel is plotted */
- /* by John Engels JENGELS@BNANDP51.BITNET, inspired by the hpljet driver
- X of Jyrki Yli-Nokari */
- X
- #ifdef HPLJII
- X
- /* We define 4 different print qualities : 300ppi, 150ppi, 100ppi and
- X 75ppi. (Pixel size = 1, 2, 3, 4 dots) */
- X
- #define HPLJII_DPP (hplj_dpp) /* dots per pixel */
- #define HPLJII_PPI (300/HPLJII_DPP) /* pixel per inch */
- /* make XMAX and YMAX a multiple of 8 */
- #define HPLJII_XMAX (8*(unsigned int)(xsize*1920/HPLJII_DPP/8.0+0.9))
- #define HPLJII_YMAX (8*(unsigned int)(ysize*1920/HPLJII_DPP/8.0+0.9))
- X
- #define HPLJII_VCHAR (HPLJII_PPI/6) /* Courier font with 6 lines per inch */
- #define HPLJII_HCHAR (HPLJII_PPI/10) /* Courier font with 10 caracters
- X per inch */
- X
- /* default values for term_tbl */
- #define HPLJII_75PPI_XMAX (1920/4)
- #define HPLJII_75PPI_YMAX (1920/4)
- #define HPLJII_75PPI_HCHAR (1920/4/6)
- #define HPLJII_75PPI_VCHAR (1920/4/10)
- #define HPLJII_75PPI_VTIC 5
- #define HPLJII_75PPI_HTIC 5
- X
- X
- #define HPLJII_PUSH_CURSOR fprintf(outfile,"\033&f0S") /* Save current
- X cursor position */
- #define HPLJII_POP_CURSOR fprintf(outfile,"\033&f1S") /* Restore
- X cursor position */
- #define HPLJII_COURIER fprintf(outfile,"\033(0N\033(s0p10.0h12.0v0s0b3T\033&l6D")
- X /* be sure to use courier font with 6lpi and 10cpi */
- X
- static int hplj_dpp=4;
- /* bm_pattern not appropriate for 300ppi graphics */
- static unsigned int b_300ppi_pattern[] = {0xffff, 0x1111,
- X 0xffff, 0x3333, 0x0f0f, 0x3f3f, 0x0fff, 0x00ff, 0x33ff};
- X
- HPLJIIoptions()
- {
- char opt[4];
- X
- #define HPDJERROR "expecting dots per inch size 75, 100, 150 or 300"
- X if (!END_OF_COMMAND) {
- X if (token[c_token].length>3)
- X int_error(HPDJERROR,c_token);
- X
- X /* almost_equals() won't accept numbers - use strcmp() instead */
- X capture(opt,c_token,c_token);
- X if (!strcmp(opt,"75")) {
- X hplj_dpp = 4;
- X }
- X else if (!strcmp(opt,"100")) {
- X hplj_dpp = 3;
- X }
- X else if (!strcmp(opt,"150")) {
- X hplj_dpp = 2;
- X }
- X else if (!strcmp(opt,"300")) {
- X hplj_dpp = 1;
- X } else {
- X int_error(HPDJERROR,c_token);
- X }
- X c_token++;
- X }
- X
- X term_tbl[term].xmax = HPLJII_XMAX;
- X term_tbl[term].ymax = HPLJII_YMAX;
- X switch(hplj_dpp) {
- X case 1:
- X strcpy(term_options,"300");
- X term_tbl[term].v_tic = 15;
- X term_tbl[term].h_tic = 15;
- X break;
- X case 2:
- X strcpy(term_options,"150");
- X term_tbl[term].v_tic = 8;
- X term_tbl[term].h_tic = 8;
- X break;
- X case 3:
- X strcpy(term_options,"100");
- X term_tbl[term].v_tic = 6;
- X term_tbl[term].h_tic = 6;
- X break;
- X case 4:
- X strcpy(term_options,"75");
- X term_tbl[term].v_tic = 5;
- X term_tbl[term].h_tic = 5;
- X break;
- X }
- }
- X
- X
- HPLJIIinit()
- {
- #ifdef vms
- X reopen_binary();
- #endif /* vms */
- #ifdef PC
- X reopen_binary();
- #endif /* PC */
- }
- X
- X
- HPLJIIgraphics()
- {
- X term_tbl[term].v_char = HPLJII_VCHAR;
- X term_tbl[term].h_char = HPLJII_HCHAR;
- X HPLJII_COURIER;
- X HPLJII_PUSH_CURSOR;
- X /* rotate plot -90 degrees by reversing XMAX and YMAX and by
- X setting b_rastermode to TRUE */
- X b_makebitmap(HPLJII_YMAX,HPLJII_XMAX,1);
- X b_rastermode = TRUE;
- }
- X
- X
- /* HPLJIItext by rjl - no compression */
- HPLJIItext()
- {
- X register int x,j,row;
- X
- X fprintf(outfile,"\033*t%dR", HPLJII_PPI);
- X HPLJII_POP_CURSOR;
- X fprintf(outfile, "\033*r1A");
- X
- X /* dump bitmap in raster mode */
- X for (x = b_xsize-1; x >= 0; x--) {
- X row = (b_ysize/8)-1;
- X fprintf(outfile, "\033*b0m%dW", b_ysize/8);
- X for (j = row; j >= 0; j--) {
- X (void) fputc( (char)(*((*b_p)[j]+x)), outfile );
- X }
- X }
- X fprintf(outfile, "\033*rB");
- X
- X b_freebitmap();
- X
- #ifndef vms /* most vms spoolers add a formfeed character */
- X fprintf(outfile,"\f");
- #endif /* not vms */
- }
- X
- X
- X
- HPLJIIlinetype(linetype)
- int linetype;
- {
- X
- X if (hplj_dpp == 1) {
- X if (linetype>=7)
- X linetype %= 7;
- X /* b_pattern not appropriate for 300ppi graphics */
- X b_linemask = b_300ppi_pattern[linetype+2];
- X b_maskcount=0;
- X }
- X else {
- X b_setlinetype(linetype);
- X }
- }
- X
- #define HPLJIImove b_move
- #define HPLJIIvector b_vector
- #define HPLJIItext_angle b_text_angle
- X
- HPLJIIput_text(x,y,str)
- unsigned int x, y;
- char *str;
- {
- X switch (b_angle) {
- X case 0:
- X y -= HPLJII_VCHAR/5;
- X HPLJII_POP_CURSOR;
- X HPLJII_PUSH_CURSOR;
- X /* (0,0) is the upper left point of the paper */
- X fprintf(outfile, "\033*p%+dx%+dY", x*HPLJII_DPP
- X , (HPLJII_YMAX-y-1)*HPLJII_DPP );
- X fputs(str, outfile);
- /* for (; *str; ++str, x += HPLJII_HCHAR)
- X HPLJIIputc (x, y, *str, b_angle);*/
- X break;
- X case 1:
- X y += (HPLJII_HCHAR-2*HPLJII_VCHAR)/2;
- X y += (HPLJII_VCHAR+HPLJII_HCHAR)*strlen(str)/2;
- X for (; *str; ++str, y -= HPLJII_VCHAR)
- X HPLJIIputc (x, y, *str, b_angle);
- X break;
- X }
- }
- X
- HPLJIIputc(x,y,c,angle)
- unsigned int x,y;
- int angle;
- char c;
- {
- X HPLJII_POP_CURSOR;
- X HPLJII_PUSH_CURSOR;
- X /* (0,0) is the upper left point of the paper */
- X fprintf(outfile, "\033*p%+dx%+dY", x*HPLJII_DPP
- X , (HPLJII_YMAX-y-1)*HPLJII_DPP );
- X fputc(c, outfile);
- }
- X
- X
- HPLJIIreset()
- {
- #ifdef vms
- X fflush_binary();
- #endif /* vms */
- }
- X
- X
- /* HP DeskJet routines */
- HPDJgraphics()
- {
- X switch(hplj_dpp) {
- X case 1:
- X b_charsize(FNT13X25);
- X term_tbl[term].v_char = FNT13X25_VCHAR;
- X term_tbl[term].h_char = FNT13X25_HCHAR;
- X break;
- X case 2:
- X b_charsize(FNT13X25);
- X term_tbl[term].v_char = FNT13X25_VCHAR;
- X term_tbl[term].h_char = FNT13X25_HCHAR;
- X break;
- X case 3:
- X b_charsize(FNT9X17);
- X term_tbl[term].v_char = FNT9X17_VCHAR;
- X term_tbl[term].h_char = FNT9X17_HCHAR;
- X break;
- X case 4:
- X b_charsize(FNT5X9);
- X term_tbl[term].v_char = FNT5X9_VCHAR;
- X term_tbl[term].h_char = FNT5X9_HCHAR;
- X break;
- X }
- X /* rotate plot -90 degrees by reversing XMAX and YMAX and by
- X setting b_rastermode to TRUE */
- X b_makebitmap(HPLJII_YMAX,HPLJII_XMAX,1);
- X b_rastermode = TRUE;
- }
- X
- X
- /* 0 compression raster bitmap dump. Compatible with HP DeskJet 500
- X hopefully compatible with other HP Deskjet printers */
- HPDJtext()
- {
- X register int x,j,row;
- X
- X fprintf(outfile,"\033*b0M");
- X fprintf(outfile,"\033*t%dR", HPLJII_PPI);
- X fprintf(outfile, "\033*r0A");
- X
- X /* dump bitmap in raster mode */
- X for (x = b_xsize-1; x >= 0; x--) {
- X row = (b_ysize/8)-1;
- X fprintf(outfile, "\033*b%dW", b_ysize/8);
- X for (j = row; j >= 0; j--) {
- X (void) fputc( (char)(*((*b_p)[j]+x)), outfile );
- X }
- X }
- X fprintf(outfile, "\033*rbC");
- X
- X b_freebitmap();
- X
- #ifndef vms /* most vms spoolers add a formfeed character */
- X fprintf(outfile,"\f");
- #endif /* not vms */
- }
- X
- #define HPDJtext_angle b_text_angle
- #define HPDJput_text b_put_text
- X
- #endif /* HPLJII */
- X
- SHAR_EOF
- echo 'File gnuplot/term/hpljii.trm is complete' &&
- chmod 0644 gnuplot/term/hpljii.trm ||
- echo 'restore of gnuplot/term/hpljii.trm failed'
- Wc_c="`wc -c < 'gnuplot/term/hpljii.trm'`"
- test 8101 -eq "$Wc_c" ||
- echo 'gnuplot/term/hpljii.trm: original size 8101, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= gnuplot/term/pc.trm ==============
- if test -f 'gnuplot/term/pc.trm' -a X"$1" != X"-c"; then
- echo 'x - skipping gnuplot/term/pc.trm (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting gnuplot/term/pc.trm (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/pc.trm' &&
- /* GNUPLOT - pc.trm */
- /*
- X * Copyright (C) 1990
- X *
- X * Permission to use, copy, and distribute this software and its
- X * documentation for any purpose with or without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and
- X * that both that copyright notice and this permission notice appear
- X * in supporting documentation.
- X *
- X * Permission to modify the software is granted, but not the right to
- X * distribute the modified code. Modifications are to be distributed
- X * as patches to released version.
- X *
- X * This software is provided "as is" without express or implied warranty.
- X *
- X * This file is included by ../term.c.
- X *
- X * This terminal driver supports:
- X * Under Microsoft C
- X * cga, egabios, egalib, vgabios, hercules, corona325, att
- X * Under Turboc C
- X * egalib, vgalib, vgamono, svga, mcga, cga, hercules, att
- X *
- X * AUTHORS
- X * Colin Kelley, Thomas Williams, William Wilson, Russell Lang
- X *
- X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
- X *
- X */
- X
- #ifdef __TURBOC__
- #include <graphics.h>
- #include <conio.h>
- #include <dos.h>
- X int g_driver, g_mode, g_error;
- X char far *path;
- X char *pathp, path_s[128];
- X
- /* instead of string.h */
- extern char *strrchr();
- X
- get_path()
- {
- X path=(char far *) getenv("BGI");
- X if (path==NULL) {
- X (void) strcpy(path_s,_argv[0]);
- X pathp=strrchr(path_s,'\\');
- X *pathp=0x00;
- X path=path_s;
- X }
- }
- X
- static struct text_info tinfo; /* So we can restore starting text mode. */
- #endif
- X
- X
- static char near buf[80]; /* kludge since EGA.LIB is compiled SMALL */
- X
- static int pattern[] = {0xffff, 0x0f0f, 0xffff, 0xaaaa, 0x3333, 0x3f3f, 0x0f0f};
- X
- static int graphics_on = FALSE;
- int startx, starty;
- X
- int pc_angle;
- #define PC_VCHAR FNT5X9_VCHAR
- #define PC_HCHAR FNT5X9_HCHAR
- X
- pause() /* press any key to continue... */
- {
- X (void) getch();
- }
- X
- X
- PC_text()
- {
- X if (graphics_on) {
- X graphics_on = FALSE;
- X pause();
- X }
- #ifdef __TURBOC__
- X restorecrtmode();
- X textmode(tinfo.currmode);
- X clrscr();
- #else
- X Vmode(3);
- #endif
- }
- X
- PC_reset()
- {
- #ifdef __TURBOC__
- X closegraph();
- X textmode(tinfo.currmode);
- X clrscr();
- #endif
- }
- X
- X
- #ifndef __TURBOC__
- X
- PC_putc(x,y,c,angle,line_func)
- unsigned int x,y;
- char c;
- int angle;
- FUNC_PTR line_func;
- {
- int i,j,k;
- unsigned int pixelon;
- X i = (int)(c) - 32;
- X for (j=0; j<FNT5X9_VBITS; j++) {
- X for (k=0; k<FNT5X9_HBITS; k++) {
- X pixelon = (((unsigned int)(fnt5x9[i][j])) >> k & 1);
- X if (pixelon) {
- X switch(angle) {
- X case 0 : (*line_func)(x+k+1,y-j,x+k+1,y-j);
- X break;
- X case 1 : (*line_func)(x-j,y-k-1,x-j,y-k-1);
- X break;
- X }
- X }
- X }
- X }
- }
- X
- X
- int PC_text_angle(ang)
- int ang;
- {
- X pc_angle=ang;
- X return TRUE;
- }
- X
- X
- #define CGA_XMAX 640
- #define CGA_YMAX 200
- X
- #define CGA_XLAST (CGA_XMAX - 1)
- #define CGA_YLAST (CGA_YMAX - 1)
- X
- #define CGA_VCHAR PC_VCHAR
- #define CGA_HCHAR PC_HCHAR
- #define CGA_VTIC 4
- #define CGA_HTIC 6
- X
- int line_cga;
- X
- CGA_init()
- {
- X PC_color(1); /* monochrome */
- }
- X
- CGA_graphics()
- {
- X graphics_on = TRUE;
- X Vmode(6);
- }
- X
- #define CGA_text PC_text
- X
- CGA_linetype(linetype)
- {
- X if (linetype >= 5)
- X linetype %= 5;
- X line_cga=linetype;
- X PC_mask(pattern[linetype+2]);
- }
- X
- CGA_move(x,y)
- {
- X startx = x;
- X starty = y;
- }
- X
- X
- CGA_vector(x,y)
- {
- X PC_line(startx,CGA_YLAST-starty,x,CGA_YLAST-y);
- X startx = x;
- X starty = y;
- }
- X
- X
- CGA_put_text(x,y,str)
- unsigned int x, y;
- char *str;
- {
- int i;
- int line;
- X line= line_cga; /* disable the dotted lines temporarily */
- X PC_mask(pattern[0]);
- X switch(pc_angle) {
- X case 0 : y -= CGA_VCHAR/2;
- X break;
- X case 1 : x += CGA_VCHAR/2;
- X break;
- X }
- X for (i=0;str[i];i++) {
- X PC_putc(x,CGA_YLAST-y,str[i],pc_angle,PC_line);
- X switch(pc_angle) {
- X case 0 : x+=CGA_HCHAR ;
- X break;
- X case 1 : y+=CGA_HCHAR ;
- X break;
- X }
- X }
- X PC_mask(pattern[line]); /* enable dotted lines */
- }
- X
- X
- #define CGA_text_angle PC_text_angle
- X
- #define CGA_reset PC_reset
- X
- X
- #define EGA_XMAX 640
- #define EGA_YMAX 350
- X
- #define EGA_XLAST (EGA_XMAX - 1)
- #define EGA_YLAST (EGA_YMAX - 1)
- X
- #define EGA_VCHAR PC_VCHAR
- #define EGA_HCHAR PC_HCHAR
- #define EGA_VTIC 4
- #define EGA_HTIC 5
- X
- static int ega64color[] = {1,1,5,4,3,5,4,3, 5, 4, 3, 5, 4, 3,5};
- static int ega256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
- X
- static int *egacolor;
- X
- X
- EGA_init()
- {
- X PC_mask(0xffff);
- X egacolor = ega256color; /* should be smarter */
- }
- X
- EGA_graphics()
- {
- X graphics_on = TRUE;
- X Vmode(16);
- }
- X
- #define EGA_text PC_text
- X
- EGA_linetype(linetype)
- {
- X if (linetype >= 13)
- X linetype %= 13;
- X PC_color(egacolor[linetype+2]);
- }
- X
- EGA_move(x,y)
- {
- X startx = x;
- X starty = y;
- }
- X
- EGA_vector(x,y)
- {
- X PC_line(startx,EGA_YLAST-starty,x,EGA_YLAST-y);
- X startx = x;
- X starty = y;
- }
- X
- X
- EGA_put_text(x,y,str)
- unsigned int x, y;
- char *str;
- {
- int i;
- X switch(pc_angle) {
- X case 0 : y -= EGA_VCHAR/2;
- X break;
- X case 1 : x += EGA_VCHAR/2;
- X break;
- X }
- X for (i=0;str[i];i++) {
- X PC_putc(x,EGA_YLAST-y,str[i],pc_angle,PC_line);
- X switch(pc_angle) {
- X case 0 : x+=EGA_HCHAR ;
- X break;
- X case 1 : y+=EGA_HCHAR ;
- X break;
- X }
- X }
- }
- X
- X
- #define EGA_text_angle PC_text_angle
- X
- #define EGA_reset PC_reset
- X
- X
- X
- /* The following VGA routines are hacked from the above EGA routines
- X They worked on two VGA cards.
- X Russell Lang, eln272v@monu1.cc.monash.oz */
- #define VGA_XMAX 640
- #define VGA_YMAX 480
- X
- #define VGA_XLAST (VGA_XMAX - 1)
- #define VGA_YLAST (VGA_YMAX - 1)
- X
- #define VGA_VCHAR PC_VCHAR
- #define VGA_HCHAR PC_HCHAR
- #define VGA_VTIC 5
- #define VGA_HTIC 5
- X
- static int vga256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
- X
- static int *vgacolor;
- X
- X
- VGA_init()
- {
- X PC_mask(0xffff);
- X vgacolor = vga256color; /* should be smarter */
- }
- X
- VGA_graphics()
- {
- X graphics_on = TRUE;
- X Vmode(18);
- }
- X
- #define VGA_text PC_text
- X
- VGA_linetype(linetype)
- {
- X if (linetype >= 13)
- X linetype %= 13;
- X PC_color(vgacolor[linetype+2]);
- }
- X
- VGA_move(x,y)
- {
- X startx = x;
- X starty = y;
- }
- X
- VGA_vector(x,y)
- {
- X PC_line(startx,VGA_YLAST-starty,x,VGA_YLAST-y);
- X startx = x;
- X starty = y;
- }
- X
- X
- VGA_put_text(x,y,str)
- unsigned int x, y;
- char *str;
- {
- int i;
- X switch(pc_angle) {
- X case 0 : y -= VGA_VCHAR/2;
- X break;
- X case 1 : x += VGA_VCHAR/2;
- X break;
- X }
- X for (i=0;str[i];i++) {
- X PC_putc(x,VGA_YLAST-y,str[i],pc_angle,PC_line);
- X switch(pc_angle) {
- X case 0 : x+=VGA_HCHAR ;
- X break;
- X case 1 : y+=VGA_HCHAR ;
- X break;
- X }
- X }
- }
- X
- X
- #define VGA_text_angle PC_text_angle
- X
- #define VGA_reset PC_reset
- X
- X
- X
- #ifdef EGALIB
- X
- #define EGALIB_XMAX 640
- #define EGALIB_YMAX 350
- X
- #define EGALIB_XLAST (EGA_XMAX - 1)
- #define EGALIB_YLAST (EGA_YMAX - 1)
- X
- #define EGALIB_VCHAR 14
- #define EGALIB_HCHAR 8
- #define EGALIB_VTIC 4
- #define EGALIB_HTIC 5
- X
- #include "mcega.h"
- X
- EGALIB_init()
- {
- X GPPARMS();
- X if (GDTYPE != 5) {
- X term = 0;
- X int_error("color EGA board not found",NO_CARET);
- X }
- X egacolor = (GDMEMORY < 256) ? ega64color : ega256color;
- }
- X
- EGALIB_graphics()
- {
- X graphics_on = TRUE;
- X GPINIT();
- }
- X
- EGALIB_text()
- {
- X if (graphics_on) {
- X graphics_on = FALSE;
- X pause();
- X }
- X GPTERM();
- }
- X
- EGALIB_linetype(linetype)
- {
- X if (linetype >= 13)
- X linetype %= 13;
- X GPCOLOR(egacolor[linetype+2]);
- }
- X
- EGALIB_move(x,y)
- {
- X GPMOVE(x,GDMAXROW-y);
- }
- X
- X
- EGALIB_vector(x,y)
- {
- X GPLINE(x,GDMAXROW-y);
- }
- X
- X
- EGALIB_put_text(x,y,str)
- int x, y;
- char *str;
- {
- X strcpy((char far *)buf,str);
- X GotoXY((int)(x/EGALIB_HCHAR),
- X (int)((EGALIB_YMAX-y-(EGALIB_VCHAR/2))/EGALIB_VCHAR));
- X gprintf(buf);
- }
- X
- X
- #define EGALIB_reset PC_reset
- X
- #endif /* EGALIB */
- X
- X
- #ifdef HERCULES
- X
- #define HERC_XMAX 720
- #define HERC_YMAX 348
- X
- #define HERC_XLAST (HERC_XMAX - 1)
- #define HERC_YLAST (HERC_YMAX - 1)
- X
- #define HERC_VCHAR PC_VCHAR
- #define HERC_HCHAR PC_HCHAR
- #define HERC_VTIC 4
- #define HERC_HTIC 5
- X
- int line_herc;
- X
- HERC_init()
- {
- X H_init();
- }
- X
- HERC_graphics()
- {
- X HVmode(1);
- X graphics_on = TRUE;
- }
- X
- HERC_text()
- {
- X if (graphics_on) {
- X graphics_on = FALSE;
- X pause();
- X }
- X HVmode(0);
- }
- X
- HERC_linetype(linetype)
- {
- X if (linetype >= 5)
- X linetype %= 5;
- X H_mask(pattern[linetype+2]);
- X line_herc = linetype;
- }
- X
- HERC_move(x,y)
- {
- X if (x < 0)
- X startx = 0;
- X else if (x > HERC_XLAST)
- X startx = HERC_XLAST;
- X else
- X startx = x;
- X
- X if (y < 0)
- X starty = 0;
- X else if (y > HERC_YLAST)
- X starty = HERC_YLAST;
- X else
- X starty = y;
- }
- X
- HERC_vector(x,y)
- {
- X if (x < 0)
- X x = 0;
- X else if (x > HERC_XLAST)
- X x = HERC_XLAST;
- X if (y < 0)
- X y = 0;
- X else if (y > HERC_YLAST)
- X y = HERC_YLAST;
- X
- X H_line(startx,HERC_YLAST-starty,x,HERC_YLAST-y);
- X startx = x;
- X starty = y;
- }
- X
- X
- HERC_put_text(x,y,str)
- unsigned int x, y;
- char *str;
- {
- int i;
- int line;
- X line= line_herc; /* disable the dotted lines temporarily */
- X H_mask(pattern[0]);
- X switch(pc_angle) {
- X case 0 : y -= HERC_VCHAR/2;
- X break;
- X case 1 : x += HERC_VCHAR/2;
- X break;
- X }
- X for (i=0;str[i];i++) {
- X PC_putc(x,HERC_YLAST-y,str[i],pc_angle,H_line);
- X switch(pc_angle) {
- X case 0 : x+=HERC_HCHAR ;
- X break;
- X case 1 : y+=HERC_HCHAR ;
- X break;
- X }
- X }
- X H_mask(pattern[line]); /* enable dotted lines */
- }
- X
- X
- #define HERC_text_angle PC_text_angle
- X
- #define HERC_reset PC_reset
- X
- X
- #endif /* HERCULES */
- X
- X
- /* thanks to sask!macphed (Geoff Coleman and Ian Macphedran) for the
- X ATT 6300 driver */
- X
- X
- #ifdef ATT6300
- X
- #define ATT_XMAX 640
- #define ATT_YMAX 400
- X
- #define ATT_XLAST (ATT_XMAX - 1)
- #define ATT_YLAST (ATT_YMAX - 1)
- X
- #define ATT_VCHAR PC_VCHAR
- #define ATT_HCHAR PC_HCHAR
- #define ATT_VTIC 4
- #define ATT_HTIC 5
- X
- #define ATT_init CGA_init
- X
- ATT_graphics()
- {
- X graphics_on = TRUE;
- X Vmode(0x40); /* 40H is the magic number for the AT&T driver */
- }
- X
- #define ATT_text CGA_text
- X
- #define ATT_linetype CGA_linetype
- X
- #define ATT_move CGA_move
- X
- ATT_vector(x,y)
- {
- X PC_line(startx,ATT_YLAST-starty,x,ATT_YLAST-y);
- X startx = x;
- X starty = y;
- }
- X
- X
- ATT_put_text(x,y,str)
- unsigned int x, y;
- char *str;
- {
- int i;
- int line;
- X line= line_cga; /* disable the dotted lines temporarily */
- X PC_mask(pattern[0]);
- X switch(pc_angle) {
- X case 0 : y -= ATT_VCHAR/2;
- X break;
- X case 1 : x += ATT_VCHAR/2;
- X break;
- X }
- X for (i=0;str[i];i++) {
- X PC_putc(x,ATT_YLAST-y,str[i],pc_angle,PC_line);
- X switch(pc_angle) {
- X case 0 : x+=ATT_HCHAR ;
- X break;
- X case 1 : y+=ATT_HCHAR ;
- X break;
- X }
- X }
- X PC_mask(pattern[line]); /* enable dotted lines */
- }
- X
- X
- #define ATT_text_angle PC_text_angle
- X
- #define ATT_reset CGA_reset
- X
- #endif /* ATT6300 */
- X
- X
- #ifdef CORONA
- X
- #define COR_XMAX 640
- #define COR_YMAX 325
- X
- #define COR_XLAST (COR_XMAX - 1)
- #define COR_YLAST (COR_YMAX - 1)
- X
- #define COR_VCHAR PC_VCHAR
- #define COR_HCHAR PC_HCHAR
- #define COR_VTIC 4
- #define COR_HTIC 5
- X
- int line_cor;
- X
- static int corscreen; /* screen number, 0 - 7 */
- X
- COR_init()
- {
- register char *p;
- X if (!(p = getenv("CORSCREEN")))
- X int_error("must run CORPLOT for Corona graphics",NO_CARET);
- X corscreen = *p - '0';
- }
- X
- COR_graphics()
- {
- X graphics_on = TRUE;
- X Vmode(3); /* clear text screen */
- X grinit(corscreen);
- X grandtx();
- }
- X
- COR_text()
- {
- X if (graphics_on) {
- X graphics_on = FALSE;
- X pause();
- X }
- X grreset();
- X txonly();
- X Vmode(3);
- }
- X
- COR_linetype(linetype)
- {
- X if (linetype >= 5)
- X linetype %= 5;
- X line_cor = linetype;
- X Cor_mask(pattern[linetype+2]);
- }
- X
- COR_move(x,y)
- {
- X if (x < 0)
- X startx = 0;
- X else if (x > COR_XLAST)
- X startx = COR_XLAST;
- X else
- X startx = x;
- X
- X if (y < 0)
- X starty = 0;
- X else if (y > COR_YLAST)
- X starty = COR_YLAST;
- X else
- X starty = y;
- }
- X
- COR_vector(x,y)
- {
- X if (x < 0)
- X x = 0;
- X else if (x > COR_XLAST)
- X x = COR_XLAST;
- X if (y < 0)
- X y = 0;
- X else if (y > COR_YLAST)
- X y = COR_YLAST;
- X
- X Cor_line(startx,COR_YLAST-starty,x,COR_YLAST-y);
- X startx = x;
- X starty = y;
- }
- X
- X
- COR_put_text(x,y,str)
- unsigned int x, y;
- char *str;
- {
- int i;
- int line;
- X line= line_cor; /* disable the dotted lines temporarily */
- X Cor_mask(pattern[0]);
- X switch(pc_angle) {
- X case 0 : y -= COR_VCHAR/2;
- X break;
- X case 1 : x += COR_VCHAR/2;
- X break;
- X }
- X for (i=0;str[i];i++) {
- X PC_putc(x,COR_YLAST-y,str[i],pc_angle,Cor_line);
- X switch(pc_angle) {
- X case 0 : x+=COR_HCHAR ;
- X break;
- X case 1 : y+=COR_HCHAR ;
- X break;
- X }
- X }
- X COR_mask(pattern[line]); /* enable dotted lines */
- }
- X
- X
- #define COR_text_angle PC_text_angle
- X
- #define COR_reset PC_reset
- X
- #endif /* CORONA */
- X
- X
- #else /* ifndef __TURBOC__ */
- /* all of the Turbo C routines for the different graphics devices go here */
- X
- #define VGA_XMAX 640
- #define VGA_YMAX 480
- X
- #define VGA_XLAST (VGA_XMAX - 1)
- #define VGA_YLAST (VGA_YMAX - 1)
- X
- #define VGA_VCHAR 10
- #define VGA_HCHAR 8
- #define VGA_VTIC 4
- #define VGA_HTIC 5
- X
- #define SVGA_XMAX 640
- #define SVGA_YMAX 480
- X
- #define SVGA_VCHAR 10
- #define SVGA_HCHAR 8
- #define SVGA_VTIC 4
- #define SVGA_HTIC 5
- X
- static int vga256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
- static int *vgacolor;
- X
- static int svga_xmax = SVGA_XMAX,
- X svga_ymax = SVGA_YMAX,
- X svga_xlast = 639,
- X svga_ylast = 479;
- X
- #define VGA_reset EGALIB_reset
- #define VGA_text EGALIB_text
- #define VGA_move EGALIB_move
- #define VGA_vector EGALIB_vector
- #define VGA_text_angle PC_text_angle
- #define VGA_justify_text PC_justify_text
- X
- #define SVGA_reset EGALIB_reset
- #define SVGA_text EGALIB_text
- #define SVGA_move EGALIB_move
- #define SVGA_vector EGALIB_vector
- #define SVGA_text_angle PC_text_angle
- #define SVGA_justify_text PC_justify_text
- #define SVGA_linetype VGA_linetype
- X
- int PC_text_angle(ang)
- int ang;
- {
- X int size = svga_ymax > 600 ? 2 : 1;
- X
- X pc_angle = ang;
- X
- X switch (ang) {
- X case 0 : settextstyle(DEFAULT_FONT,HORIZ_DIR,size);
- X break;
- X case 1 : settextstyle(DEFAULT_FONT,VERT_DIR,size);
- X break;
- X }
- X return TRUE;
- }
- X
- int PC_justify_text(mode)
- enum JUSTIFY mode;
- {
- X switch(mode) {
- X case LEFT :
- X settextjustify(LEFT_TEXT,CENTER_TEXT);
- X break;
- X case CENTRE :
- X settextjustify(CENTER_TEXT,CENTER_TEXT);
- X break;
- X case RIGHT:
- X settextjustify(RIGHT_TEXT,CENTER_TEXT);
- X break;
- X }
- X return TRUE;
- }
- X
- VGA_init()
- {
- X g_driver=VGA;
- X g_mode=2;
- X gettextinfo(&tinfo);
- X initgraph(&g_driver,&g_mode,path);
- X if(g_driver!=9){
- X term=0;
- X switch (g_driver){
- X case -2: fprintf(stderr,"Graphics card not detected.\n");
- X break;
- X case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
- X break;
- X case -4: fprintf(stderr,"Invalid BGI driver file.\n");
- X break;
- X case -5: fprintf(stderr,"Insufficient memory to load ",
- X "graphics driver.");
- X break;
- X }
- X
- /* int_error("color VGA board not found",NO_CARET);*/
- X }
- X if(g_driver==VGA) vgacolor=vga256color;
- }
- X
- VGA_graphics()
- { g_driver=VGA;
- X g_mode=2;
- X graphics_on = TRUE;
- X gettextinfo(&tinfo);
- X setgraphmode(getgraphmode());
- X VGA_justify_text(LEFT);
- }
- X
- VGA_linetype(linetype)
- {
- X if (linetype >= 13)
- X linetype %= 13;
- X setcolor(vgacolor[linetype+2]);
- }
- X
- VGA_put_text(x,y,str)
- unsigned int x, y;
- char *str;
- {
- X strcpy((char far *)buf,str);
- X outtextxy(x,VGA_YLAST-y,buf);
- }
- X
- X
- VGAMONO_linetype(linetype)
- {
- X if (linetype >= 5)
- X linetype %= 5;
- X setlinestyle(4,pattern[linetype+2],1);
- }
- X
- static int huge detect_svga(void)
- {
- X return g_mode;
- }
- X
- SVGA_init()
- {
- X char *p, name[128], *SVGA = getenv( "SVGA" );
- X
- X if (SVGA == NULL)
- X int_error("'SVGA' driver environment variable is not set",
- X NO_CARET);
- X
- X strcpy(name, SVGA);
- X if ((p = strrchr(name, '.')) == NULL ||
- X sscanf(&p[1], "%d", &g_mode) != 1)
- X int_error("'SVGA' envvar should be of the form 'name.mode'",
- X NO_CARET);
- X
- X *p = 0;
- X
- X installuserdriver(name, detect_svga);
- X gettextinfo(&tinfo);
- X g_driver = 0;
- X initgraph(&g_driver,&g_mode,path);
- X if(g_driver<0){
- X term=0;
- X switch (g_driver){
- X case -2: fprintf(stderr,"Graphics card not detected.\n");
- X break;
- X case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
- X break;
- X case -4: fprintf(stderr,"Invalid BGI driver file.\n");
- X break;
- X case -5: fprintf(stderr,"Insufficient memory to load ",
- X "graphics driver.");
- X break;
- X }
- X
- X }
- X else
- X vgacolor=vga256color;
- X
- X /* Get the screen size: */
- X svga_xmax = term_tbl[term].xmax = getmaxx() + 1;
- X svga_ymax = term_tbl[term].ymax = getmaxy() + 1;
- X svga_xlast = svga_xmax-1;
- X svga_ylast = svga_ymax-1;
- X
- X if (svga_ymax > 600) { /* Double the tic/font sizes. */
- X term_tbl[term].h_char = SVGA_HCHAR * 2;
- X term_tbl[term].v_char = SVGA_VCHAR * 2;
- X term_tbl[term].h_tic = SVGA_HTIC * 2;
- X term_tbl[term].v_tic = SVGA_VTIC * 2;
- X settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
- X }
- X else
- X settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
- }
- X
- SVGA_graphics()
- {
- X graphics_on = TRUE;
- X gettextinfo(&tinfo);
- X setgraphmode(getgraphmode());
- X VGA_justify_text(LEFT);
- X
- X svga_ymax = getmaxy() + 1;
- X if (svga_ymax > 600) /* Double the tic/font sizes. */
- X settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
- X else
- X settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
- }
- X
- SVGA_put_text(x,y,str)
- unsigned int x, y;
- char *str;
- {
- X strcpy((char far *)buf,str);
- X outtextxy(x,svga_ylast-y,buf);
- }
- X
- #define MCGA_XMAX 640
- #define MCGA_YMAX 480
- X
- #define MCGA_XLAST (MCGA_XMAX - 1)
- #define MCGA_YLAST (MCGA_YMAX - 1)
- X
- #define MCGA_VCHAR 10
- #define MCGA_HCHAR 8
- #define MCGA_VTIC 4
- #define MCGA_HTIC 5
- X
- static int *MCGAcolor;
- X
- #define MCGA_reset EGALIB_reset
- #define MCGA_text EGALIB_text
- #define MCGA_move EGALIB_move
- #define MCGA_vector EGALIB_vector
- #define MCGA_text_angle PC_text_angle
- #define MCGA_justify_text PC_justify_text
- X
- MCGA_init()
- {
- X g_driver=MCGA;
- X g_mode=5;
- X gettextinfo(&tinfo);
- X initgraph(&g_driver,&g_mode,path);
- X if(g_driver!=2){
- X term=0;
- X switch (g_driver){
- X case -2: fprintf(stderr,"Graphics card not detected.\n");
- X break;
- X case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
- X break;
- X case -4: fprintf(stderr,"Invalid BGI driver file.\n");
- X break;
- X case -5: fprintf(stderr,"Insufficient memory to load ",
- X "graphics driver.");
- X break;
- X }
- X }
- }
- X
- MCGA_graphics()
- {
- X graphics_on = TRUE;
- X gettextinfo(&tinfo);
- X setgraphmode(getgraphmode());
- X MCGA_justify_text(LEFT);
- }
- X
- X
- MCGA_put_text(x,y,str)
- unsigned int x, y;
- char *str;
- {
- X strcpy((char far *)buf,str);
- X outtextxy(x,MCGA_YLAST-y,buf);
- }
- X
- X
- MCGA_linetype(linetype)
- {
- X if (linetype >= 5)
- X linetype %= 5;
- X setlinestyle(4,pattern[linetype+2],1);
- }
- X
- X
- #define EGALIB_XMAX 640
- #define EGALIB_YMAX 350
- X
- #define EGALIB_XLAST (EGALIB_XMAX - 1)
- #define EGALIB_YLAST (EGALIB_YMAX - 1)
- X
- #define EGALIB_VCHAR 10
- #define EGALIB_HCHAR 8
- #define EGALIB_VTIC 4
- #define EGALIB_HTIC 5
- X
- static int ega64color[] = {1,1,5,4,3,5,4,3, 5, 4, 3, 5, 4, 3,5};
- static int ega256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
- X
- static int *egacolor;
- X
- #define EGALIB_text_angle PC_text_angle
- #define EGALIB_justify_text PC_justify_text
- X
- EGALIB_init()
- {
- X g_driver=EGA;
- X g_mode=1;
- X gettextinfo(&tinfo);
- X initgraph(&g_driver,&g_mode,path);
- X if(g_driver<3 || g_driver>4){
- X term=0;
- X switch (g_driver){
- X case -2: fprintf(stderr,"Graphics card not detected.\n");
- X break;
- X case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
- X break;
- X case -4: fprintf(stderr,"Invalid BGI driver file.\n");
- X break;
- X case -5: fprintf(stderr,"Insufficient memory to load ",
- X "graphics driver.");
- X break;
- X }
- X
- /* int_error("color EGA board not found",NO_CARET);*/
- X }
- X if(g_driver==EGA) egacolor=ega256color;
- X if(g_driver==EGA64) egacolor=ega64color;
- }
- X
- EGALIB_graphics()
- {
- X graphics_on = TRUE;
- X gettextinfo(&tinfo);
- X setgraphmode(getgraphmode());
- X EGALIB_justify_text(LEFT);
- }
- X
- EGALIB_text()
- {
- X if (graphics_on) {
- X graphics_on = FALSE;
- X pause();
- X }
- X restorecrtmode();
- X textmode(tinfo.currmode);
- X clrscr();
- X svga_ymax = SVGA_YMAX; /* Since it may double font size if too high. */
- }
- X
- EGALIB_linetype(linetype)
- {
- X if (linetype >= 13)
- X linetype %= 13;
- X setcolor(egacolor[linetype+2]);
- }
- X
- EGALIB_move(x,y)
- {
- X moveto(x,getmaxy()-y);
- }
- X
- X
- EGALIB_vector(x,y)
- {
- X lineto(x,getmaxy()-y);
- }
- X
- X
- EGALIB_put_text(x,y,str)
- unsigned int x, y;
- char *str;
- {
- X strcpy((char far *)buf,str);
- X outtextxy(x,EGALIB_YLAST-y,buf);
- }
- X
- X
- EGALIB_reset()
- {
- X closegraph();
- X textmode(tinfo.currmode);
- X clrscr();
- X svga_ymax = SVGA_YMAX; /* Since it may double font size if too high. */
- }
- X
- X
- #define CGA_XMAX 640
- #define CGA_YMAX 200
- X
- #define CGA_XLAST (CGA_XMAX - 1)
- #define CGA_YLAST (CGA_YMAX - 1)
- X
- #define CGA_VCHAR 10
- #define CGA_HCHAR 8
- #define CGA_VTIC 4
- #define CGA_HTIC 6
- X
- #define CGA_text_angle PC_text_angle
- #define CGA_justify_text PC_justify_text
- #define CGA_reset PC_reset
- X
- CGA_init()
- {
- X g_driver=CGA;
- X g_mode=4;
- X gettextinfo(&tinfo);
- X initgraph(&g_driver,&g_mode,path);
- X switch (g_driver){
- X case -2: fprintf(stderr,"Graphics card not detected.\n");
- X break;
- X case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
- X break;
- X case -4: fprintf(stderr,"Invalid BGI driver file.\n");
- X break;
- X case -5: fprintf(stderr,"Insufficient memory to load ",
- X "graphics driver.");
- X break;
- X }
- /* PC_color(1); monochrome */
- X
- }
- X
- CGA_graphics()
- {
- X graphics_on = TRUE;
- X gettextinfo(&tinfo);
- X setgraphmode(getgraphmode());
- X CGA_justify_text(LEFT);
- X /* Vmode(6);*/
- }
- X
- #define CGA_text PC_text
- X
- CGA_linetype(linetype)
- {
- X if (linetype >= 5)
- X linetype %= 5;
- X setlinestyle(4,pattern[linetype+2],1);
- }
- X
- CGA_move(x,y)
- {
- X moveto(x,getmaxy()-y);
- }
- X
- X
- CGA_vector(x,y)
- {
- X lineto(x,getmaxy()-y);
- }
- X
- CGA_put_text(x,y,str)
- unsigned int x, y;
- char *str;
- {
- X strcpy((char far *)buf,str);
- X outtextxy(x,CGA_YLAST-y,buf);
- }
- X
- X
- X
- #define HERC_XMAX 720
- #define HERC_YMAX 348
- X
- #define HERC_XLAST (HERC_XMAX - 1)
- #define HERC_YLAST (HERC_YMAX - 1)
- X
- #define HERC_VCHAR 10
- #define HERC_HCHAR 8
- #define HERC_VTIC 4
- #define HERC_HTIC 5
- X
- #define HERC_text_angle PC_text_angle
- #define HERC_justify_text PC_justify_text
- #define HERC_reset PC_reset
- X
- HERC_init()
- {
- X g_driver=HERCMONO;
- X g_mode=0;
- X gettextinfo(&tinfo);
- X initgraph(&g_driver,&g_mode,path);
- X switch (g_driver){
- X case -2: fprintf(stderr,"Graphics card not detected.\n");
- X break;
- X case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
- X break;
- X case -4: fprintf(stderr,"Invalid BGI driver file.\n");
- X break;
- X case -5: fprintf(stderr,"Insufficient memory to load ",
- X "graphics driver.");
- X break;
- X }
- }
- X
- HERC_graphics()
- {
- X gettextinfo(&tinfo);
- X setgraphmode(getgraphmode());
- X HERC_justify_text(LEFT);
- X graphics_on = TRUE;
- }
- X
- HERC_text()
- {
- X if (graphics_on) {
- X graphics_on = FALSE;
- X pause();
- X }
- X restorecrtmode();
- X textmode(tinfo.currmode);
- X clrscr();
- }
- X
- HERC_linetype(linetype)
- {
- X if (linetype >= 5)
- X linetype %= 5;
- X setlinestyle(4,pattern[linetype+2],1);
- }
- X
- HERC_move(x,y)
- {
- X if (x < 0)
- X x = 0;
- X else if (x > HERC_XLAST)
- X x = HERC_XLAST;
- X
- X if (y < 0)
- X y = 0;
- X else if (y > HERC_YLAST)
- X y = HERC_YLAST;
- X moveto(x,getmaxy()-y);
- }
- X
- HERC_vector(x,y)
- {
- X if (x < 0)
- X x = 0;
- X else if (x > HERC_XLAST)
- X x = HERC_XLAST;
- X if (y < 0)
- X y = 0;
- X else if (y > HERC_YLAST)
- X y = HERC_YLAST;
- X
- X lineto(x,getmaxy()-y);
- }
- X
- X
- HERC_put_text(x,y,str)
- unsigned int x, y;
- char *str;
- {
- X strcpy((char far *)buf,str);
- X outtextxy(x,HERC_YLAST-y,buf);
- }
- X
- X
- #ifdef ATT6300
- /* this driver added by rjl@monu1.cc.monash.edu.au */
- X
- #define ATT_XMAX 640
- #define ATT_YMAX 400
- X
- #define ATT_XLAST (ATT_XMAX - 1)
- #define ATT_YLAST (ATT_YMAX - 1)
- X
- #define ATT_VCHAR PC_VCHAR
- #define ATT_HCHAR PC_HCHAR
- #define ATT_VTIC 4
- #define ATT_HTIC 5
- X
- #define ATT_text_angle PC_text_angle
- #define ATT_justify_text PC_justify_text
- #define ATT_reset PC_reset
- X
- ATT_init()
- {
- X g_driver=ATT400;
- X g_mode=5;
- X gettextinfo(&tinfo);
- X initgraph(&g_driver,&g_mode,path);
- X switch (g_driver){
- X case -2: fprintf(stderr,"Graphics card not detected.\n");
- X break;
- X case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
- X break;
- X case -4: fprintf(stderr,"Invalid BGI driver file.\n");
- X break;
- X case -5: fprintf(stderr,"Insufficient memory to load ",
- X "graphics driver.");
- X break;
- X }
- }
- X
- ATT_graphics()
- {
- X gettextinfo(&tinfo);
- X setgraphmode(getgraphmode());
- X ATT_justify_text(LEFT);
- X graphics_on = TRUE;
- }
- X
- ATT_text()
- {
- X if (graphics_on) {
- X graphics_on = FALSE;
- X pause();
- X }
- X restorecrtmode();
- X textmode(tinfo.currmode);
- X clrscr();
- }
- X
- ATT_linetype(linetype)
- {
- X if (linetype >= 5)
- X linetype %= 5;
- X setlinestyle(4,pattern[linetype+2],1);
- }
- X
- ATT_move(x,y)
- {
- X if (x < 0)
- X x = 0;
- X else if (x > ATT_XLAST)
- X x = ATT_XLAST;
- X
- X if (y < 0)
- X y = 0;
- X else if (y > ATT_YLAST)
- X y = ATT_YLAST;
- X moveto(x,getmaxy()-y);
- }
- X
- ATT_vector(x,y)
- {
- X if (x < 0)
- X x = 0;
- X else if (x > ATT_XLAST)
- X x = ATT_XLAST;
- X if (y < 0)
- X y = 0;
- X else if (y > ATT_YLAST)
- X y = ATT_YLAST;
- X
- X lineto(x,getmaxy()-y);
- }
- X
- X
- ATT_put_text(x,y,str)
- unsigned int x, y;
- char *str;
- {
- X strcpy((char far *)buf,str);
- X outtextxy(x,ATT_YLAST-y,buf);
- }
- #endif /* ifdef ATT6300 */
- X
- #endif /* ifndef __TURBOC__ */
- X
- SHAR_EOF
- chmod 0644 gnuplot/term/pc.trm ||
- echo 'restore of gnuplot/term/pc.trm failed'
- Wc_c="`wc -c < 'gnuplot/term/pc.trm'`"
- test 25264 -eq "$Wc_c" ||
- echo 'gnuplot/term/pc.trm: original size 25264, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= gnuplot/term/imagen.trm ==============
- if test -f 'gnuplot/term/imagen.trm' -a X"$1" != X"-c"; then
- echo 'x - skipping gnuplot/term/imagen.trm (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting gnuplot/term/imagen.trm (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/imagen.trm' &&
- /* GNUPLOT - imagen.trm */
- /*
- X * Copyright (C) 1990
- X *
- X * Permission to use, copy, and distribute this software and its
- X * documentation for any purpose with or without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and
- X * that both that copyright notice and this permission notice appear
- X * in supporting documentation.
- X *
- X * Permission to modify the software is granted, but not the right to
- X * distribute the modified code. Modifications are to be distributed
- X * as patches to released version.
- X *
- X * This software is provided "as is" without express or implied warranty.
- X *
- X * This file is included by ../term.c.
- X *
- X * This terminal driver supports:
- X * Imagen laser printers
- X *
- X * AUTHORS
- X * Paul E. McKenney, David Kotz
- X *
- X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
- X *
- X */
- X
- /*
- X * Original for direct Imagen output (but retaining many of the
- X * LaTeX extensions) by Paul E. McKenney, 1989.
- X * Further modified by David Kotz to fit into gnuplot 2.0.
- X * Information Science and Technology Division, SRI International,
- X * 333 Ravenswood Ave, Menlo Park, CA 94025.
- X * Mail to mckenney@sri.com.
- X */
- X
- #include "impcodes.h"
- X
- #define IMAGEN_PTS_PER_INCH (300)
- X
- #define IMAGEN_XMAX (IMAGEN_PTS_PER_INCH * 10) /* 10.0 inches */
- #define IMAGEN_YMAX (IMAGEN_PTS_PER_INCH * 75 / 10) /* 7.5 inches */
- X
- #define IMAGEN_FONTSIZE 12
- X
- #define IMAGEN_HTIC (20)
- #define IMAGEN_VTIC (20)
- #define IMAGEN_VCHAR (IMAGEN_FONTSIZE*5)
- #define IMAGEN_HCHAR (IMAGEN_VCHAR/2)
- X
- static int IMAGEN_orgx; /* absolute-pixel-ORIgin of graph. */
- static int IMAGEN_orgy;
- static int IMAGEN_posx; /* current drawing position (lines). */
- static int IMAGEN_posy;
- static int IMAGEN_inplot;
- static int IMAGEN_xmax; /* width of graph in pixels. */
- static int IMAGEN_ymax; /* height of graph in pixels. */
- static int IMAGEN_hchar; /* Height of CHAR in current font. */
- static int IMAGEN_wchar; /* Width of CHAR in current font. */
- static int IMAGEN_blofs; /* BaseLine OFfSet from bounding box. */
- static int IMAGEN_angle = -1; /* 0 for horizontal text, 1 for vertical */
- static enum JUSTIFY IMAGEN_justify = LEFT; /* left/center/right */
- X
- static IMAGEN_seq_pos; /* position in sequence */
- X
- static void IMAGEN_putwd();
- static void IMAGEN_createfamily();
- static void IMAGEN_setfont();
- static void IMAGEN_setpos();
- static char *IMAGEN_cvts();
- X
- IMAGEN_init()
- {
- X char font[10]; /* font name */
- X
- X IMAGEN_posx = IMAGEN_posy = 0;
- X
- X IMAGEN_orgx = (11.0 * IMAGEN_PTS_PER_INCH - IMAGEN_XMAX) / 2;
- X IMAGEN_orgy = (8.5 * IMAGEN_PTS_PER_INCH - IMAGEN_YMAX)/ 2;
- X
- X fputs("@document(language impress)", outfile);
- X
- X putc(imP_SET_HV_SYSTEM, outfile);
- X putc((3<<3)|5, outfile);
- X
- X sprintf(font, "cour%02d", IMAGEN_FONTSIZE);
- X IMAGEN_createfamily(font, IMAGEN_FONTSIZE);
- X IMAGEN_setfont(IMAGEN_FONTSIZE);
- X
- X IMAGEN_text_angle(0);
- X
- X putc(imP_SET_ABS_H, outfile);
- X IMAGEN_putwd(0);
- X putc(imP_SET_ABS_V, outfile);
- X IMAGEN_putwd(0);
- X
- X IMAGEN_linetype(-1);
- }
- X
- IMAGEN_graphics()
- {
- X static BOOLEAN first = TRUE;
- X
- X if (!first)
- X putc(imP_ENDPAGE, outfile);
- X first = FALSE;
- X
- X IMAGEN_move(0, 0);
- }
- X
- IMAGEN_text()
- {
- }
- X
- X
- IMAGEN_linetype(linetype)
- int linetype;
- {
- X static int lastlinetype = -10;
- X
- X if (linetype < 0)
- X linetype = -linetype;
- X else
- X linetype *= 2;
- X
- X if (lastlinetype == linetype)
- X return;
- X
- X lastlinetype = linetype; /* now >= 0 */
- X
- X putc(imP_SET_PEN, outfile);
- X putc(linetype, outfile);
- }
- X
- X
- IMAGEN_move(x,y)
- X unsigned int x,y;
- {
- X IMAGEN_posx = x;
- X IMAGEN_posy = y;
- }
- X
- IMAGEN_vector(ux,uy)
- X unsigned int ux,uy;
- {
- X /* Create path. */
- X
- X putc(imP_CREATE_PATH, outfile);
- X IMAGEN_putwd(2);
- X IMAGEN_putwd(IMAGEN_posx + IMAGEN_orgx);
- X IMAGEN_putwd(IMAGEN_posy + IMAGEN_orgy);
- X IMAGEN_putwd(ux + IMAGEN_orgx);
- X IMAGEN_putwd(uy + IMAGEN_orgy);
- X
- X /* Draw path with black pen. */
- X
- X putc(imP_DRAW_PATH, outfile);
- X putc(15, outfile);
- X
- X /* Set current position to end of line. */
- X
- X IMAGEN_move(ux, uy);
- }
- X
- static void
- IMAGEN_setpos(ux, uy)
- X int ux,uy;
- {
- X /* Set x and y position (for text), also set beginning-of-line. */
- X
- X putc(imP_SET_ABS_H, outfile);
- X IMAGEN_putwd(ux + IMAGEN_orgx);
- X putc(imP_SET_ABS_V, outfile);
- X IMAGEN_putwd(uy + IMAGEN_orgy);
- X putc(imP_SET_BOL, outfile);
- X if (IMAGEN_angle == 1)
- X IMAGEN_putwd(uy + IMAGEN_orgx); /* vertical */
- X else
- X IMAGEN_putwd(ux + IMAGEN_orgx); /* horizontal */
- }
- X
- IMAGEN_text_angle(angle)
- X int angle;
- {
- X if (IMAGEN_angle != angle) {
- X IMAGEN_angle = angle; /* record for later use */
- X putc(imP_SET_ADV_DIRS, outfile);
- X putc(angle == 0 ? 0 : 7, outfile); /* 0=>horiz : 7=>vert */
- X }
- X
- X return(TRUE);
- }
- X
- IMAGEN_justify_text(mode)
- X enum JUSTIFY mode;
- {
- X IMAGEN_justify = mode;
- X return(TRUE);
- }
- X
- static char *
- IMAGEN_cvts(str, width, height)
- X char *str;
- X int *width;
- X int *height;
- {
- X char *cp1;
- X char *cp2;
- X static char *buf = NULL;
- X int h;
- X int maxw;
- X int w;
- X
- X /* Free up old buffer, if there is one, get a new one. Since */
- X /* all transformations shorten the string, get a buffer that is */
- X /* the same size as the input string. */
- X
- X if (buf != NULL)
- X (void) free(buf);
- X buf = (char *) alloc(strlen(str), "converted label string");
- X
- X /* Do the transformations. */
- X
- X cp1 = str;
- X cp2 = buf;
- X h = 1;
- X maxw = 0;
- X w = 0;
- X while (strlen(cp1) > 0) {
- X switch (*cp1) {
- X case ' ' : /* Space character. */
- X *cp2++ = imP_SP;
- X w++;
- X break;
- X
- X case '\\' : /* Escape sequence. */
- X if (*++cp1 == '\\') {
- X /* Begin new line. */
- X h++;
- X if (w > maxw)
- X maxw = w;
- X w = 0;
- X *cp2++ = imP_CRLF;
- X break;
- X }
- X
- X /* Fall through to just copy next char out. */
- X
- X default :
- X *cp2++ = *cp1;
- X w++;
- X break;
- X }
- X cp1++;
- X }
- X
- X *cp2 = '\0';
- X if (w > maxw)
- X maxw = w;
- X
- X if (height != NULL)
- X *height = IMAGEN_angle ?
- X IMAGEN_wchar * maxw :
- X IMAGEN_hchar * h;
- X if (width != NULL)
- X *width = IMAGEN_angle ?
- X IMAGEN_hchar * h :
- X IMAGEN_wchar * maxw;
- X return (buf);
- }
- X
- IMAGEN_put_text(x, y, str)
- X int x,y; /* reference point of string */
- X char str[]; /* the text */
- {
- X char *cvstr;
- X int height;
- X int width;
- X
- X cvstr = IMAGEN_cvts(str, &width, &height);
- X
- X switch (IMAGEN_justify) {
- X case LEFT: break;
- X case CENTRE: x -= width/2; break;
- X case RIGHT: x -= width; break;
- X }
- X
- X if (IMAGEN_angle) { /* vertical */
- X x += IMAGEN_hchar;
- X y -= height/2;
- X } else /* horizontal */
- X y += height/2 - IMAGEN_hchar;
- X
- X IMAGEN_setpos(x, y + IMAGEN_blofs);
- X fputs(cvstr, outfile);
- }
- X
- X
- IMAGEN_reset()
- {
- X putc(imP_EOF, outfile);
- }
- X
- static void
- IMAGEN_putwd(w)
- {
- X putc(w>>8, outfile);
- X putc(w, outfile);
- }
- X
- static void
- IMAGEN_createfamily(c, sz)
- X char *c;
- X int sz;
- {
- X putc(imP_CREATE_FAMILY_TABLE, outfile);
- X putc(sz, outfile);
- X putc(1, outfile);
- X putc(0, outfile);
- X fputs(c, outfile);
- X putc(0, outfile);
- }
- X
- static void
- IMAGEN_setfont(sz)
- X int sz;
- {
- X IMAGEN_hchar = sz * 5;
- X IMAGEN_wchar = IMAGEN_hchar / 2;
- X IMAGEN_blofs = IMAGEN_hchar / 3;
- X putc(imP_SET_FAMILY, outfile);
- X putc(sz, outfile);
- X putc(imP_SET_SP, outfile);
- X IMAGEN_putwd(IMAGEN_wchar);
- X putc(imP_SET_IL, outfile);
- X IMAGEN_putwd(IMAGEN_hchar);
- }
- SHAR_EOF
- chmod 0666 gnuplot/term/imagen.trm ||
- echo 'restore of gnuplot/term/imagen.trm failed'
- Wc_c="`wc -c < 'gnuplot/term/imagen.trm'`"
- test 7396 -eq "$Wc_c" ||
- echo 'gnuplot/term/imagen.trm: original size 7396, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= gnuplot/term/iris4d.trm ==============
- if test -f 'gnuplot/term/iris4d.trm' -a X"$1" != X"-c"; then
- echo 'x - skipping gnuplot/term/iris4d.trm (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting gnuplot/term/iris4d.trm (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/iris4d.trm' &&
- /* GNUPLOT - iris4d.trm */
- /*
- X * Copyright (C) 1990
- X *
- X * Permission to use, copy, and distribute this software and its
- X * documentation for any purpose with or without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and
- X * that both that copyright notice and this permission notice appear
- X * in supporting documentation.
- X *
- X * Permission to modify the software is granted, but not the right to
- X * distribute the modified code. Modifications are to be distributed
- X * as patches to released version.
- X *
- X * This software is provided "as is" without express or implied warranty.
- X *
- X * This file is included by ../term.c.
- X *
- X * This terminal driver supports:
- X * IRIS terminals
- X *
- X * AUTHORS
- X * John H. Merritt
- X * (Applied Research Corporation) 7/1/89
- X * INTERNET: merritt@iris613.gsfc.nasa.gov
- X *
- X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
- X *
- X */
- X
- #include <gl.h>
- X
- #define IRIS4DRC ".gnuplot_iris4d"
- X
- #define IRIS4D_XMAX 1024
- #define IRIS4D_YMAX 1024
- X
- #define IRIS4D_XLAST (IRIS4D_XMAX - 1)
- #define IRIS4D_YLAST (IRIS4D_YMAX - 1)
- X
- #define IRIS4D_VCHAR (IRIS4D_YMAX/30)
- #define IRIS4D_HCHAR (IRIS4D_XMAX/72)
- #define IRIS4D_VTIC (IRIS4D_YMAX/80)
- #define IRIS4D_HTIC (IRIS4D_XMAX/80)
- X
- static short colors24bits[][3] =
- {
- X { 85, 85, 85 }, /* 0. BACK GROUND ( DARKGRAY ) */
- X { 0, 0, 0 }, /* 1. BLACK */
- X { 170, 0, 170 }, /* 2. MAGENTA */
- X { 85, 255, 255 }, /* 3. LIGHTCYAN */
- X { 170, 0, 0 }, /* 4. RED */
- X { 0, 170, 0 }, /* 5. GREEN */
- X { 255, 85, 255 }, /* 6. LIGHTMAGENTA */
- X { 255, 255, 85 }, /* 7. YELLOW */
- X { 255, 85, 85 }, /* 8. LIGHTRED */
- X { 85, 255, 85 }, /* 9. LIGHTGREEN */
- X { 0, 170, 170 }, /* 10. CYAN */
- X { 170, 170, 0 }, /* 11. BROWN */
- };
- #define COLOR24_SIZE (sizeof(colors24bits) / (sizeof(short) * 3))
- X
- static iris24bits = FALSE;
- X
- #define IRIS4D_BACKGROUND 0
- #define IRIS4D_BLACK 1
- #define IRIS4D_MAGENTA 2
- #define IRIS4D_LIGHTCYAN 3
- #define IRIS4D_RED 4
- #define IRIS4D_GREEN 5
- #define IRIS4D_LIGHTMAGENTA 6
- #define IRIS4D_YELLOW 7
- #define IRIS4D_LIGHTRED 8
- #define IRIS4D_LIGHTGREEN 9
- #define IRIS4D_CYAN 10
- #define IRIS4D_BROWN 11
- X
- IRIS4D_options()
- {
- X int i = 0;
- X struct value a;
- X extern struct value *const_express();
- X extern double real();
- X
- X if (!END_OF_COMMAND) {
- X i = (int) real(const_express(&a));
- X }
- X
- X iris24bits = (i == 24);
- X
- X sprintf(term_options, "%s",iris24bits ? "24" : "8");
- }
- X
- IRIS4D_init()
- {
- X int i;
- X char homedirfile[80], line[80];
- X FILE *f;
- X
- X foreground();
- X winopen("Gnuplot");
- X if (iris24bits)
- X {
- X RGBmode();
- X gconfig();
- X }
- X
- X strcat(strcat(strcpy(homedirfile,getenv("HOME")),"/"),IRIS4DRC);
- X if ((f = fopen(IRIS4DRC, "r")) != NULL ||
- X (f = fopen(homedirfile, "r")) != NULL) {
- X int c1, c2, c3;
- X for (i = 0; i < COLOR24_SIZE; i++) {
- X if (fgets(line, 79, f) == NULL ||
- X sscanf(line, "%d %d %d", &c1, &c2, &c3) != 3)
- X int_error("Iris4d color file terminated prematurely or wrong format.\n", NO_CARET);
- X colors24bits[i][0] = c1;
- X colors24bits[i][1] = c2;
- X colors24bits[i][2] = c3;
- X }
- X
- X fclose(f);
- X }
- X deflinestyle(1, 0x3FFF); /* long dash */
- X deflinestyle(2, 0x5555); /* dotted */
- X deflinestyle(3, 0x3333); /* short dash */
- X deflinestyle(4, 0xB5AD); /* dotdashed */
- X deflinestyle(5, 0x0F0F); /* dashed */
- X deflinestyle(6, 0xBBBB); /* dotdashed */
- X deflinestyle(7, 0x3F3F); /* mid-long dash */
- X deflinestyle(8, 0x7777); /* mid-long dash */
- X
- X return;
- }
- X
- IRIS4D_graphics()
- {
- X reshapeviewport();
- X ortho2((Coord)0, (Coord)IRIS4D_XMAX, (Coord)0, (Coord)IRIS4D_YMAX);
- X if (iris24bits)
- X RGBcolor(colors24bits[IRIS4D_BACKGROUND][0],
- X colors24bits[IRIS4D_BACKGROUND][1],
- X colors24bits[IRIS4D_BACKGROUND][2]);
- X else
- X color(WHITE);
- X
- X clear();
- SHAR_EOF
- true || echo 'restore of gnuplot/term/iris4d.trm failed'
- fi
- echo 'End of part 16'
- echo 'File gnuplot/term/iris4d.trm is continued in part 17'
- echo 17 > _shar_seq_.tmp
- exit 0
-
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-