home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume24 / gnuplot3 / part16 < prev    next >
Text File  |  1991-10-27  |  49KB  |  2,320 lines

  1. Newsgroups: comp.sources.misc
  2. From: gershon%gr@cs.utah.edu (Elber Gershon)
  3. Subject:  v24i038:  gnuplot3 - interactive function plotting utility, Part16/26
  4. Message-ID: <1991Oct28.002308.12469@sparky.imd.sterling.com>
  5. X-Md4-Signature: 676522afedfc30eebb23d254a4fefb3e
  6. Date: Mon, 28 Oct 1991 00:23:08 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: gershon%gr@cs.utah.edu (Elber Gershon)
  10. Posting-number: Volume 24, Issue 38
  11. Archive-name: gnuplot3/part16
  12. Environment: UNIX, MS-DOS, VMS
  13. Supersedes: gnuplot2: Volume 11, Issue 65-79
  14.  
  15. #!/bin/sh
  16. # this is Part.16 (part 16 of a multipart archive)
  17. # do not concatenate these parts, unpack them in order with /bin/sh
  18. # file gnuplot/term/hpljii.trm continued
  19. #
  20. if test ! -r _shar_seq_.tmp; then
  21.     echo 'Please unpack part 1 first!'
  22.     exit 1
  23. fi
  24. (read Scheck
  25.  if test "$Scheck" != 16; then
  26.     echo Please unpack part "$Scheck" next!
  27.     exit 1
  28.  else
  29.     exit 0
  30.  fi
  31. ) < _shar_seq_.tmp || exit 1
  32. if test ! -f _shar_wnt_.tmp; then
  33.     echo 'x - still skipping gnuplot/term/hpljii.trm'
  34. else
  35. echo 'x - continuing file gnuplot/term/hpljii.trm'
  36. sed 's/^X//' << 'SHAR_EOF' >> 'gnuplot/term/hpljii.trm' &&
  37. /*
  38. X * Copyright (C) 1990   
  39. X *
  40. X * Permission to use, copy, and distribute this software and its
  41. X * documentation for any purpose with or without fee is hereby granted, 
  42. X * provided that the above copyright notice appear in all copies and 
  43. X * that both that copyright notice and this permission notice appear 
  44. X * in supporting documentation.
  45. X *
  46. X * Permission to modify the software is granted, but not the right to
  47. X * distribute the modified code.  Modifications are to be distributed 
  48. X * as patches to released version.
  49. X *  
  50. X * This software  is provided "as is" without express or implied warranty.
  51. X * 
  52. X * This file is included by ../term.c.
  53. X *
  54. X * This terminal driver supports:
  55. X *  hpljii, hpdj
  56. X *
  57. X * AUTHORS
  58. X *  John Engels
  59. X *  Russell Lang
  60. X *  Maurice Castro
  61. X *
  62. X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  63. X * 
  64. X */
  65. X
  66. /* The following HP laserjet series II driver uses generic bit mapped graphics
  67. X   routines from bitmap.c to build up a bit map in memory.  The driver
  68. X   interchanges colomns and lines in order to access entire lines
  69. X   easily and returns the lines to get bits in the right order :
  70. X   (x,y) -> (y,XMAX-1-x). */
  71. /* This interchange is done by calling b_makebitmap() with reversed 
  72. X   xmax and ymax, and then setting b_rastermode to TRUE.  b_setpixel()
  73. X   will then perform the interchange before each pixel is plotted */
  74. /* by John Engels JENGELS@BNANDP51.BITNET, inspired by the hpljet driver
  75. X   of Jyrki Yli-Nokari */
  76. X
  77. #ifdef HPLJII
  78. X
  79. /* We define 4 different print qualities : 300ppi, 150ppi, 100ppi and
  80. X   75ppi.  (Pixel size = 1, 2, 3, 4 dots) */
  81. X
  82. #define HPLJII_DPP (hplj_dpp)   /* dots per pixel */
  83. #define HPLJII_PPI (300/HPLJII_DPP) /* pixel per inch */
  84. /* make XMAX and YMAX a multiple of 8 */
  85. #define HPLJII_XMAX (8*(unsigned int)(xsize*1920/HPLJII_DPP/8.0+0.9))
  86. #define HPLJII_YMAX (8*(unsigned int)(ysize*1920/HPLJII_DPP/8.0+0.9))
  87. X
  88. #define HPLJII_VCHAR (HPLJII_PPI/6) /* Courier font with 6 lines per inch */
  89. #define HPLJII_HCHAR (HPLJII_PPI/10) /* Courier font with 10 caracters
  90. X                                        per inch */
  91. X
  92. /* default values for term_tbl */
  93. #define HPLJII_75PPI_XMAX (1920/4)
  94. #define HPLJII_75PPI_YMAX (1920/4)
  95. #define HPLJII_75PPI_HCHAR (1920/4/6)
  96. #define HPLJII_75PPI_VCHAR (1920/4/10)
  97. #define HPLJII_75PPI_VTIC 5
  98. #define HPLJII_75PPI_HTIC 5
  99. X
  100. X
  101. #define HPLJII_PUSH_CURSOR fprintf(outfile,"\033&f0S") /* Save current
  102. X                  cursor position */
  103. #define HPLJII_POP_CURSOR fprintf(outfile,"\033&f1S") /* Restore
  104. X                  cursor position */
  105. #define HPLJII_COURIER fprintf(outfile,"\033(0N\033(s0p10.0h12.0v0s0b3T\033&l6D")
  106. X         /* be sure to use courier font with 6lpi and 10cpi */
  107. X
  108. static int hplj_dpp=4;
  109. /* bm_pattern not appropriate for 300ppi graphics */
  110. static unsigned int b_300ppi_pattern[] = {0xffff, 0x1111,
  111. X        0xffff, 0x3333, 0x0f0f, 0x3f3f, 0x0fff, 0x00ff, 0x33ff};
  112. X
  113. HPLJIIoptions()
  114. {
  115. char opt[4];
  116. X
  117. #define HPDJERROR "expecting dots per inch size 75, 100, 150 or 300"
  118. X    if (!END_OF_COMMAND) {
  119. X        if (token[c_token].length>3)
  120. X            int_error(HPDJERROR,c_token);
  121. X
  122. X        /* almost_equals() won't accept numbers - use strcmp() instead */
  123. X        capture(opt,c_token,c_token);
  124. X        if (!strcmp(opt,"75")) {
  125. X               hplj_dpp = 4;
  126. X        }
  127. X        else if (!strcmp(opt,"100")) {
  128. X               hplj_dpp = 3;
  129. X        }
  130. X        else if (!strcmp(opt,"150")) {
  131. X               hplj_dpp = 2;
  132. X        }
  133. X        else if (!strcmp(opt,"300")) {
  134. X               hplj_dpp = 1;
  135. X        } else {
  136. X            int_error(HPDJERROR,c_token);
  137. X        }
  138. X        c_token++;
  139. X    }
  140. X
  141. X    term_tbl[term].xmax = HPLJII_XMAX;
  142. X    term_tbl[term].ymax = HPLJII_YMAX;
  143. X    switch(hplj_dpp) {
  144. X        case 1:
  145. X            strcpy(term_options,"300");
  146. X            term_tbl[term].v_tic = 15;
  147. X            term_tbl[term].h_tic = 15;
  148. X            break;
  149. X        case 2:
  150. X            strcpy(term_options,"150");
  151. X            term_tbl[term].v_tic = 8;
  152. X            term_tbl[term].h_tic = 8;
  153. X            break;
  154. X        case 3:
  155. X            strcpy(term_options,"100");
  156. X            term_tbl[term].v_tic = 6;
  157. X            term_tbl[term].h_tic = 6;
  158. X            break;
  159. X        case 4:
  160. X            strcpy(term_options,"75");
  161. X            term_tbl[term].v_tic = 5;
  162. X            term_tbl[term].h_tic = 5;
  163. X            break;
  164. X    }
  165. }
  166. X
  167. X
  168. HPLJIIinit()
  169. {
  170. #ifdef vms
  171. X   reopen_binary();
  172. #endif /* vms */
  173. #ifdef PC
  174. X   reopen_binary();
  175. #endif /* PC */
  176. }
  177. X
  178. X
  179. HPLJIIgraphics()
  180. {
  181. X   term_tbl[term].v_char = HPLJII_VCHAR;
  182. X   term_tbl[term].h_char = HPLJII_HCHAR;
  183. X   HPLJII_COURIER;
  184. X   HPLJII_PUSH_CURSOR;
  185. X   /* rotate plot -90 degrees by reversing XMAX and YMAX and by 
  186. X      setting b_rastermode to TRUE */
  187. X   b_makebitmap(HPLJII_YMAX,HPLJII_XMAX,1);
  188. X   b_rastermode = TRUE;
  189. }
  190. X
  191. X
  192. /* HPLJIItext by rjl - no compression */
  193. HPLJIItext()
  194. {
  195. X  register int x,j,row;
  196. X
  197. X   fprintf(outfile,"\033*t%dR", HPLJII_PPI);
  198. X   HPLJII_POP_CURSOR;
  199. X   fprintf(outfile, "\033*r1A");
  200. X
  201. X   /* dump bitmap in raster mode */
  202. X   for (x = b_xsize-1; x >= 0; x--) {
  203. X      row = (b_ysize/8)-1;
  204. X      fprintf(outfile, "\033*b0m%dW", b_ysize/8);
  205. X      for (j = row; j >= 0; j--) {
  206. X         (void) fputc( (char)(*((*b_p)[j]+x)), outfile );
  207. X      }
  208. X   }
  209. X   fprintf(outfile, "\033*rB");
  210. X
  211. X   b_freebitmap();
  212. X
  213. #ifndef vms  /* most vms spoolers add a formfeed character */
  214. X   fprintf(outfile,"\f");
  215. #endif /* not vms */
  216. }
  217. X
  218. X
  219. X
  220. HPLJIIlinetype(linetype)
  221. int linetype;
  222. {
  223. X
  224. X   if (hplj_dpp == 1) {
  225. X      if (linetype>=7)
  226. X          linetype %= 7;
  227. X      /* b_pattern not appropriate for 300ppi graphics */
  228. X      b_linemask = b_300ppi_pattern[linetype+2];
  229. X      b_maskcount=0;
  230. X   }
  231. X   else {
  232. X      b_setlinetype(linetype);
  233. X   }
  234. }
  235. X
  236. #define HPLJIImove b_move
  237. #define HPLJIIvector b_vector
  238. #define HPLJIItext_angle b_text_angle
  239. X
  240. HPLJIIput_text(x,y,str)
  241. unsigned int x, y;
  242. char *str;
  243. {
  244. X   switch (b_angle) {
  245. X      case 0:
  246. X         y -= HPLJII_VCHAR/5;
  247. X         HPLJII_POP_CURSOR;
  248. X         HPLJII_PUSH_CURSOR;
  249. X         /* (0,0) is the upper left point of the paper */
  250. X         fprintf(outfile, "\033*p%+dx%+dY", x*HPLJII_DPP
  251. X                                         ,  (HPLJII_YMAX-y-1)*HPLJII_DPP );
  252. X         fputs(str, outfile);
  253. /*       for (; *str; ++str, x += HPLJII_HCHAR)
  254. X            HPLJIIputc (x, y, *str, b_angle);*/
  255. X         break;
  256. X      case 1:
  257. X         y += (HPLJII_HCHAR-2*HPLJII_VCHAR)/2;
  258. X         y += (HPLJII_VCHAR+HPLJII_HCHAR)*strlen(str)/2;
  259. X         for (; *str; ++str, y -= HPLJII_VCHAR)
  260. X            HPLJIIputc (x, y, *str, b_angle);
  261. X         break;
  262. X   }
  263. }
  264. X
  265. HPLJIIputc(x,y,c,angle)
  266. unsigned int x,y;
  267. int angle;
  268. char c;
  269. {
  270. X   HPLJII_POP_CURSOR;
  271. X   HPLJII_PUSH_CURSOR;
  272. X   /* (0,0) is the upper left point of the paper */
  273. X   fprintf(outfile, "\033*p%+dx%+dY", x*HPLJII_DPP
  274. X                                   ,  (HPLJII_YMAX-y-1)*HPLJII_DPP );
  275. X   fputc(c, outfile);
  276. }
  277. X
  278. X
  279. HPLJIIreset()
  280. {
  281. #ifdef vms
  282. X   fflush_binary();
  283. #endif /* vms */
  284. }
  285. X
  286. X
  287. /* HP DeskJet routines */
  288. HPDJgraphics()
  289. {
  290. X    switch(hplj_dpp) {
  291. X        case 1:
  292. X            b_charsize(FNT13X25);
  293. X            term_tbl[term].v_char = FNT13X25_VCHAR;
  294. X            term_tbl[term].h_char = FNT13X25_HCHAR;
  295. X            break;
  296. X        case 2:
  297. X            b_charsize(FNT13X25);
  298. X            term_tbl[term].v_char = FNT13X25_VCHAR;
  299. X            term_tbl[term].h_char = FNT13X25_HCHAR;
  300. X            break;
  301. X        case 3:
  302. X            b_charsize(FNT9X17);
  303. X            term_tbl[term].v_char = FNT9X17_VCHAR;
  304. X            term_tbl[term].h_char = FNT9X17_HCHAR;
  305. X            break;
  306. X        case 4:
  307. X            b_charsize(FNT5X9);
  308. X            term_tbl[term].v_char = FNT5X9_VCHAR;
  309. X            term_tbl[term].h_char = FNT5X9_HCHAR;
  310. X            break;
  311. X    }
  312. X    /* rotate plot -90 degrees by reversing XMAX and YMAX and by 
  313. X    setting b_rastermode to TRUE */
  314. X    b_makebitmap(HPLJII_YMAX,HPLJII_XMAX,1);
  315. X    b_rastermode = TRUE;
  316. }
  317. X
  318. X
  319. /* 0 compression raster bitmap dump. Compatible with HP DeskJet 500
  320. X   hopefully compatible with other HP Deskjet printers */
  321. HPDJtext()
  322. {
  323. X  register int x,j,row;
  324. X
  325. X   fprintf(outfile,"\033*b0M");
  326. X   fprintf(outfile,"\033*t%dR", HPLJII_PPI);
  327. X   fprintf(outfile, "\033*r0A");
  328. X
  329. X   /* dump bitmap in raster mode */
  330. X   for (x = b_xsize-1; x >= 0; x--) {
  331. X      row = (b_ysize/8)-1;
  332. X      fprintf(outfile, "\033*b%dW", b_ysize/8);
  333. X      for (j = row; j >= 0; j--) {
  334. X         (void) fputc( (char)(*((*b_p)[j]+x)), outfile );
  335. X      }
  336. X   }
  337. X   fprintf(outfile, "\033*rbC");
  338. X
  339. X   b_freebitmap();
  340. X
  341. #ifndef vms  /* most vms spoolers add a formfeed character */
  342. X   fprintf(outfile,"\f");
  343. #endif /* not vms */
  344. }
  345. X
  346. #define HPDJtext_angle b_text_angle
  347. #define HPDJput_text b_put_text
  348. X
  349. #endif /* HPLJII */
  350. X
  351. SHAR_EOF
  352. echo 'File gnuplot/term/hpljii.trm is complete' &&
  353. chmod 0644 gnuplot/term/hpljii.trm ||
  354. echo 'restore of gnuplot/term/hpljii.trm failed'
  355. Wc_c="`wc -c < 'gnuplot/term/hpljii.trm'`"
  356. test 8101 -eq "$Wc_c" ||
  357.     echo 'gnuplot/term/hpljii.trm: original size 8101, current size' "$Wc_c"
  358. rm -f _shar_wnt_.tmp
  359. fi
  360. # ============= gnuplot/term/pc.trm ==============
  361. if test -f 'gnuplot/term/pc.trm' -a X"$1" != X"-c"; then
  362.     echo 'x - skipping gnuplot/term/pc.trm (File already exists)'
  363.     rm -f _shar_wnt_.tmp
  364. else
  365. > _shar_wnt_.tmp
  366. echo 'x - extracting gnuplot/term/pc.trm (Text)'
  367. sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/pc.trm' &&
  368. /* GNUPLOT - pc.trm */
  369. /*
  370. X * Copyright (C) 1990
  371. X *
  372. X * Permission to use, copy, and distribute this software and its
  373. X * documentation for any purpose with or without fee is hereby granted, 
  374. X * provided that the above copyright notice appear in all copies and 
  375. X * that both that copyright notice and this permission notice appear 
  376. X * in supporting documentation.
  377. X *
  378. X * Permission to modify the software is granted, but not the right to
  379. X * distribute the modified code.  Modifications are to be distributed 
  380. X * as patches to released version.
  381. X *
  382. X * This software  is provided "as is" without express or implied warranty.
  383. X *
  384. X * This file is included by ../term.c.
  385. X *
  386. X * This terminal driver supports:
  387. X *  Under Microsoft C
  388. X *      cga, egabios, egalib, vgabios, hercules, corona325, att
  389. X *  Under Turboc C
  390. X *      egalib, vgalib, vgamono, svga, mcga, cga, hercules, att
  391. X *
  392. X * AUTHORS
  393. X *  Colin Kelley, Thomas Williams, William Wilson, Russell Lang
  394. X *
  395. X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  396. X *
  397. X */
  398. X
  399. #ifdef __TURBOC__
  400. #include <graphics.h>
  401. #include <conio.h>
  402. #include <dos.h>
  403. X  int g_driver, g_mode, g_error;
  404. X  char far *path;
  405. X  char *pathp, path_s[128];
  406. X
  407. /* instead of string.h */
  408. extern char *strrchr();
  409. X
  410. get_path()
  411. {
  412. X   path=(char far *) getenv("BGI");
  413. X   if (path==NULL) {
  414. X      (void) strcpy(path_s,_argv[0]);
  415. X      pathp=strrchr(path_s,'\\');
  416. X      *pathp=0x00;
  417. X      path=path_s;
  418. X   }
  419. }
  420. X
  421. static struct text_info tinfo;       /* So we can restore starting text mode. */
  422. #endif
  423. X
  424. X
  425. static char near buf[80];    /* kludge since EGA.LIB is compiled SMALL */
  426. X
  427. static int pattern[] = {0xffff, 0x0f0f, 0xffff, 0xaaaa, 0x3333, 0x3f3f, 0x0f0f};
  428. X
  429. static int graphics_on = FALSE;
  430. int startx, starty;
  431. X
  432. int pc_angle;
  433. #define PC_VCHAR FNT5X9_VCHAR
  434. #define PC_HCHAR FNT5X9_HCHAR
  435. X
  436. pause()        /* press any key to continue... */
  437. {
  438. X    (void) getch();
  439. }
  440. X
  441. X
  442. PC_text()
  443. {
  444. X    if (graphics_on) {
  445. X        graphics_on = FALSE;
  446. X        pause();
  447. X    }
  448. #ifdef __TURBOC__
  449. X    restorecrtmode();
  450. X        textmode(tinfo.currmode);
  451. X    clrscr();
  452. #else
  453. X    Vmode(3);
  454. #endif
  455. }
  456. X
  457. PC_reset()
  458. {
  459. #ifdef __TURBOC__
  460. X    closegraph();
  461. X        textmode(tinfo.currmode);
  462. X    clrscr();
  463. #endif
  464. }
  465. X
  466. X
  467. #ifndef __TURBOC__
  468. X
  469. PC_putc(x,y,c,angle,line_func)
  470. unsigned int x,y;
  471. char c;
  472. int angle;
  473. FUNC_PTR line_func;
  474. {
  475. int i,j,k;
  476. unsigned int pixelon;
  477. X    i = (int)(c) - 32;
  478. X    for (j=0; j<FNT5X9_VBITS; j++) {
  479. X        for (k=0; k<FNT5X9_HBITS; k++) {
  480. X            pixelon = (((unsigned int)(fnt5x9[i][j])) >> k & 1);
  481. X            if (pixelon) {
  482. X                switch(angle) {
  483. X                    case 0 : (*line_func)(x+k+1,y-j,x+k+1,y-j);
  484. X                            break;
  485. X                    case 1 : (*line_func)(x-j,y-k-1,x-j,y-k-1);
  486. X                            break;
  487. X                }
  488. X            }
  489. X        }
  490. X    }
  491. }
  492. X
  493. X
  494. int PC_text_angle(ang)
  495. int ang;
  496. {
  497. X    pc_angle=ang;
  498. X    return TRUE;
  499. }
  500. X
  501. X
  502. #define CGA_XMAX 640
  503. #define CGA_YMAX 200
  504. X
  505. #define CGA_XLAST (CGA_XMAX - 1)
  506. #define CGA_YLAST (CGA_YMAX - 1)
  507. X
  508. #define CGA_VCHAR PC_VCHAR
  509. #define CGA_HCHAR PC_HCHAR
  510. #define CGA_VTIC 4
  511. #define CGA_HTIC 6
  512. X
  513. int line_cga;
  514. X
  515. CGA_init()
  516. {
  517. X    PC_color(1);        /* monochrome */
  518. }
  519. X
  520. CGA_graphics()
  521. {
  522. X    graphics_on = TRUE;
  523. X    Vmode(6);
  524. }
  525. X
  526. #define CGA_text PC_text
  527. X
  528. CGA_linetype(linetype)
  529. {
  530. X    if (linetype >= 5)
  531. X        linetype %= 5;
  532. X    line_cga=linetype;
  533. X    PC_mask(pattern[linetype+2]);
  534. }
  535. X
  536. CGA_move(x,y)
  537. {
  538. X    startx = x;
  539. X    starty = y;
  540. }
  541. X
  542. X
  543. CGA_vector(x,y)
  544. {
  545. X    PC_line(startx,CGA_YLAST-starty,x,CGA_YLAST-y);
  546. X    startx = x;
  547. X    starty = y;
  548. }
  549. X
  550. X
  551. CGA_put_text(x,y,str)
  552. unsigned int x, y;
  553. char *str;
  554. {
  555. int i;
  556. int line;
  557. X    line= line_cga;     /* disable the dotted lines temporarily */
  558. X    PC_mask(pattern[0]);
  559. X    switch(pc_angle) {
  560. X        case 0 : y -= CGA_VCHAR/2;
  561. X                break;
  562. X        case 1 : x += CGA_VCHAR/2;
  563. X                break;
  564. X    }
  565. X    for (i=0;str[i];i++) {
  566. X        PC_putc(x,CGA_YLAST-y,str[i],pc_angle,PC_line);
  567. X        switch(pc_angle) {
  568. X            case 0 : x+=CGA_HCHAR ;
  569. X                    break;
  570. X            case 1 : y+=CGA_HCHAR ;
  571. X                    break;
  572. X        }
  573. X    }
  574. X    PC_mask(pattern[line]);  /* enable dotted lines */
  575. }
  576. X
  577. X
  578. #define CGA_text_angle PC_text_angle
  579. X
  580. #define CGA_reset PC_reset
  581. X
  582. X
  583. #define EGA_XMAX 640
  584. #define EGA_YMAX 350
  585. X
  586. #define EGA_XLAST (EGA_XMAX - 1)
  587. #define EGA_YLAST (EGA_YMAX - 1)
  588. X
  589. #define EGA_VCHAR PC_VCHAR
  590. #define EGA_HCHAR PC_HCHAR
  591. #define EGA_VTIC 4
  592. #define EGA_HTIC 5
  593. X
  594. static int ega64color[] =  {1,1,5,4,3,5,4,3, 5, 4, 3, 5, 4, 3,5};
  595. static int ega256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  596. X
  597. static int *egacolor;
  598. X
  599. X
  600. EGA_init()
  601. {
  602. X    PC_mask(0xffff);
  603. X    egacolor = ega256color;        /* should be smarter */
  604. }
  605. X
  606. EGA_graphics()
  607. {
  608. X    graphics_on = TRUE;
  609. X    Vmode(16);
  610. }
  611. X
  612. #define EGA_text PC_text
  613. X
  614. EGA_linetype(linetype)
  615. {
  616. X    if (linetype >= 13)
  617. X        linetype %= 13;
  618. X    PC_color(egacolor[linetype+2]);
  619. }
  620. X
  621. EGA_move(x,y)
  622. {
  623. X    startx = x;
  624. X    starty = y;
  625. }
  626. X
  627. EGA_vector(x,y)
  628. {
  629. X    PC_line(startx,EGA_YLAST-starty,x,EGA_YLAST-y);
  630. X    startx = x;
  631. X    starty = y;
  632. }
  633. X
  634. X
  635. EGA_put_text(x,y,str)
  636. unsigned int x, y;
  637. char *str;
  638. {
  639. int i;
  640. X    switch(pc_angle) {
  641. X        case 0 : y -= EGA_VCHAR/2;
  642. X                break;
  643. X        case 1 : x += EGA_VCHAR/2;
  644. X                break;
  645. X    }
  646. X    for (i=0;str[i];i++) {
  647. X        PC_putc(x,EGA_YLAST-y,str[i],pc_angle,PC_line);
  648. X        switch(pc_angle) {
  649. X            case 0 : x+=EGA_HCHAR ;
  650. X                    break;
  651. X            case 1 : y+=EGA_HCHAR ;
  652. X                    break;
  653. X        }
  654. X    }
  655. }
  656. X
  657. X
  658. #define EGA_text_angle PC_text_angle
  659. X
  660. #define EGA_reset PC_reset
  661. X
  662. X
  663. X
  664. /* The following VGA routines are hacked from the above EGA routines
  665. X   They worked on two VGA cards.
  666. X   Russell Lang, eln272v@monu1.cc.monash.oz */
  667. #define VGA_XMAX 640
  668. #define VGA_YMAX 480
  669. X
  670. #define VGA_XLAST (VGA_XMAX - 1)
  671. #define VGA_YLAST (VGA_YMAX - 1)
  672. X
  673. #define VGA_VCHAR PC_VCHAR
  674. #define VGA_HCHAR PC_HCHAR
  675. #define VGA_VTIC 5
  676. #define VGA_HTIC 5
  677. X
  678. static int vga256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  679. X
  680. static int *vgacolor;
  681. X
  682. X
  683. VGA_init()
  684. {
  685. X    PC_mask(0xffff);
  686. X    vgacolor = vga256color;        /* should be smarter */
  687. }
  688. X
  689. VGA_graphics()
  690. {
  691. X    graphics_on = TRUE;
  692. X    Vmode(18);
  693. }
  694. X
  695. #define VGA_text PC_text
  696. X
  697. VGA_linetype(linetype)
  698. {
  699. X    if (linetype >= 13)
  700. X        linetype %= 13;
  701. X    PC_color(vgacolor[linetype+2]);
  702. }
  703. X
  704. VGA_move(x,y)
  705. {
  706. X    startx = x;
  707. X    starty = y;
  708. }
  709. X
  710. VGA_vector(x,y)
  711. {
  712. X    PC_line(startx,VGA_YLAST-starty,x,VGA_YLAST-y);
  713. X    startx = x;
  714. X    starty = y;
  715. }
  716. X
  717. X
  718. VGA_put_text(x,y,str)
  719. unsigned int x, y;
  720. char *str;
  721. {
  722. int i;
  723. X    switch(pc_angle) {
  724. X        case 0 : y -= VGA_VCHAR/2;
  725. X                break;
  726. X        case 1 : x += VGA_VCHAR/2;
  727. X                break;
  728. X    }
  729. X    for (i=0;str[i];i++) {
  730. X        PC_putc(x,VGA_YLAST-y,str[i],pc_angle,PC_line);
  731. X        switch(pc_angle) {
  732. X            case 0 : x+=VGA_HCHAR ;
  733. X                    break;
  734. X            case 1 : y+=VGA_HCHAR ;
  735. X                    break;
  736. X        }
  737. X    }
  738. }
  739. X
  740. X
  741. #define VGA_text_angle PC_text_angle
  742. X
  743. #define VGA_reset PC_reset
  744. X
  745. X
  746. X
  747. #ifdef EGALIB
  748. X
  749. #define EGALIB_XMAX 640
  750. #define EGALIB_YMAX 350
  751. X
  752. #define EGALIB_XLAST (EGA_XMAX - 1)
  753. #define EGALIB_YLAST (EGA_YMAX - 1)
  754. X
  755. #define EGALIB_VCHAR 14
  756. #define EGALIB_HCHAR 8
  757. #define EGALIB_VTIC 4
  758. #define EGALIB_HTIC 5
  759. X
  760. #include "mcega.h"
  761. X
  762. EGALIB_init()
  763. {
  764. X    GPPARMS();
  765. X    if (GDTYPE != 5) {
  766. X        term = 0;
  767. X        int_error("color EGA board not found",NO_CARET);
  768. X    }
  769. X    egacolor = (GDMEMORY < 256) ? ega64color : ega256color;
  770. }
  771. X
  772. EGALIB_graphics()
  773. {
  774. X    graphics_on = TRUE;
  775. X    GPINIT();
  776. }
  777. X
  778. EGALIB_text()
  779. {
  780. X    if (graphics_on) {
  781. X        graphics_on = FALSE;
  782. X        pause();
  783. X    }
  784. X    GPTERM();
  785. }
  786. X
  787. EGALIB_linetype(linetype)
  788. {
  789. X    if (linetype >= 13)
  790. X        linetype %= 13;
  791. X    GPCOLOR(egacolor[linetype+2]);
  792. }
  793. X
  794. EGALIB_move(x,y)
  795. {
  796. X    GPMOVE(x,GDMAXROW-y);
  797. }
  798. X
  799. X
  800. EGALIB_vector(x,y)
  801. {
  802. X    GPLINE(x,GDMAXROW-y);
  803. }
  804. X
  805. X
  806. EGALIB_put_text(x,y,str)
  807. int x, y;
  808. char *str;
  809. {
  810. X    strcpy((char far *)buf,str);
  811. X    GotoXY((int)(x/EGALIB_HCHAR),
  812. X           (int)((EGALIB_YMAX-y-(EGALIB_VCHAR/2))/EGALIB_VCHAR));
  813. X    gprintf(buf);
  814. }
  815. X
  816. X
  817. #define EGALIB_reset PC_reset
  818. X
  819. #endif /* EGALIB */
  820. X
  821. X
  822. #ifdef HERCULES
  823. X
  824. #define HERC_XMAX 720
  825. #define HERC_YMAX 348
  826. X
  827. #define HERC_XLAST (HERC_XMAX - 1)
  828. #define HERC_YLAST (HERC_YMAX - 1)
  829. X
  830. #define HERC_VCHAR PC_VCHAR
  831. #define HERC_HCHAR PC_HCHAR
  832. #define HERC_VTIC 4
  833. #define HERC_HTIC 5
  834. X
  835. int line_herc;
  836. X
  837. HERC_init()
  838. {
  839. X    H_init();
  840. }
  841. X
  842. HERC_graphics()
  843. {
  844. X    HVmode(1);
  845. X    graphics_on = TRUE;
  846. }
  847. X
  848. HERC_text()
  849. {
  850. X    if (graphics_on) {
  851. X        graphics_on = FALSE;
  852. X        pause();
  853. X    }
  854. X    HVmode(0);
  855. }
  856. X
  857. HERC_linetype(linetype)
  858. {
  859. X    if (linetype >= 5)
  860. X        linetype %= 5;
  861. X    H_mask(pattern[linetype+2]);
  862. X    line_herc = linetype;
  863. }
  864. X
  865. HERC_move(x,y)
  866. {
  867. X    if (x < 0)
  868. X        startx = 0;
  869. X    else if (x > HERC_XLAST)
  870. X        startx = HERC_XLAST;
  871. X    else
  872. X        startx = x;
  873. X
  874. X    if (y < 0)
  875. X        starty = 0;
  876. X    else if (y > HERC_YLAST)
  877. X        starty = HERC_YLAST;
  878. X    else
  879. X        starty = y;
  880. }
  881. X
  882. HERC_vector(x,y)
  883. {
  884. X    if (x < 0)
  885. X        x = 0;
  886. X    else if (x > HERC_XLAST)
  887. X        x = HERC_XLAST;
  888. X    if (y < 0)
  889. X        y = 0;
  890. X    else if (y > HERC_YLAST)
  891. X        y = HERC_YLAST;
  892. X
  893. X    H_line(startx,HERC_YLAST-starty,x,HERC_YLAST-y);
  894. X    startx = x;
  895. X    starty = y;
  896. }
  897. X
  898. X
  899. HERC_put_text(x,y,str)
  900. unsigned int x, y;
  901. char *str;
  902. {
  903. int i;
  904. int line;
  905. X    line= line_herc;     /* disable the dotted lines temporarily */
  906. X    H_mask(pattern[0]);
  907. X    switch(pc_angle) {
  908. X        case 0 : y -= HERC_VCHAR/2;
  909. X                break;
  910. X        case 1 : x += HERC_VCHAR/2;
  911. X                break;
  912. X    }
  913. X    for (i=0;str[i];i++) {
  914. X        PC_putc(x,HERC_YLAST-y,str[i],pc_angle,H_line);
  915. X        switch(pc_angle) {
  916. X            case 0 : x+=HERC_HCHAR ;
  917. X                    break;
  918. X            case 1 : y+=HERC_HCHAR ;
  919. X                    break;
  920. X        }
  921. X    }
  922. X    H_mask(pattern[line]);  /* enable dotted lines */
  923. }
  924. X
  925. X
  926. #define HERC_text_angle PC_text_angle
  927. X
  928. #define HERC_reset PC_reset
  929. X
  930. X
  931. #endif /* HERCULES */
  932. X
  933. X
  934. /* thanks to sask!macphed (Geoff Coleman and Ian Macphedran) for the
  935. X   ATT 6300 driver */ 
  936. X
  937. X
  938. #ifdef ATT6300
  939. X
  940. #define ATT_XMAX 640
  941. #define ATT_YMAX 400
  942. X
  943. #define ATT_XLAST (ATT_XMAX - 1)
  944. #define ATT_YLAST (ATT_YMAX - 1)
  945. X
  946. #define ATT_VCHAR PC_VCHAR
  947. #define ATT_HCHAR PC_HCHAR
  948. #define ATT_VTIC 4
  949. #define ATT_HTIC 5
  950. X
  951. #define ATT_init CGA_init
  952. X
  953. ATT_graphics()
  954. {
  955. X    graphics_on = TRUE;
  956. X    Vmode(0x40);        /* 40H is the magic number for the AT&T driver */
  957. }
  958. X
  959. #define ATT_text CGA_text
  960. X
  961. #define ATT_linetype CGA_linetype
  962. X
  963. #define ATT_move CGA_move
  964. X
  965. ATT_vector(x,y)
  966. {
  967. X    PC_line(startx,ATT_YLAST-starty,x,ATT_YLAST-y);
  968. X    startx = x;
  969. X    starty = y;
  970. }
  971. X
  972. X
  973. ATT_put_text(x,y,str)
  974. unsigned int x, y;
  975. char *str;
  976. {
  977. int i;
  978. int line;
  979. X    line= line_cga;     /* disable the dotted lines temporarily */
  980. X    PC_mask(pattern[0]);
  981. X    switch(pc_angle) {
  982. X        case 0 : y -= ATT_VCHAR/2;
  983. X                break;
  984. X        case 1 : x += ATT_VCHAR/2;
  985. X                break;
  986. X    }
  987. X    for (i=0;str[i];i++) {
  988. X        PC_putc(x,ATT_YLAST-y,str[i],pc_angle,PC_line);
  989. X        switch(pc_angle) {
  990. X            case 0 : x+=ATT_HCHAR ;
  991. X                    break;
  992. X            case 1 : y+=ATT_HCHAR ;
  993. X                    break;
  994. X        }
  995. X    }
  996. X    PC_mask(pattern[line]);  /* enable dotted lines */
  997. }
  998. X
  999. X
  1000. #define ATT_text_angle PC_text_angle
  1001. X
  1002. #define ATT_reset CGA_reset
  1003. X
  1004. #endif  /* ATT6300 */
  1005. X
  1006. X
  1007. #ifdef CORONA
  1008. X
  1009. #define COR_XMAX 640
  1010. #define COR_YMAX 325
  1011. X
  1012. #define COR_XLAST (COR_XMAX - 1)
  1013. #define COR_YLAST (COR_YMAX - 1)
  1014. X
  1015. #define COR_VCHAR PC_VCHAR
  1016. #define COR_HCHAR PC_HCHAR
  1017. #define COR_VTIC 4
  1018. #define COR_HTIC 5
  1019. X
  1020. int line_cor;
  1021. X
  1022. static int corscreen;        /* screen number, 0 - 7 */
  1023. X
  1024. COR_init()
  1025. {
  1026. register char *p;
  1027. X    if (!(p = getenv("CORSCREEN")))
  1028. X        int_error("must run CORPLOT for Corona graphics",NO_CARET);
  1029. X    corscreen = *p - '0';
  1030. }
  1031. X
  1032. COR_graphics()
  1033. {
  1034. X    graphics_on = TRUE;
  1035. X    Vmode(3);                /* clear text screen */
  1036. X    grinit(corscreen);
  1037. X    grandtx();
  1038. }
  1039. X
  1040. COR_text()
  1041. {
  1042. X    if (graphics_on) {
  1043. X        graphics_on = FALSE;
  1044. X        pause();
  1045. X    }
  1046. X    grreset();
  1047. X    txonly();
  1048. X    Vmode(3);
  1049. }
  1050. X
  1051. COR_linetype(linetype)
  1052. {
  1053. X    if (linetype >= 5)
  1054. X        linetype %= 5;
  1055. X    line_cor = linetype;
  1056. X    Cor_mask(pattern[linetype+2]);
  1057. }
  1058. X
  1059. COR_move(x,y)
  1060. {
  1061. X    if (x < 0)
  1062. X        startx = 0;
  1063. X    else if (x > COR_XLAST)
  1064. X        startx = COR_XLAST;
  1065. X    else
  1066. X        startx = x;
  1067. X
  1068. X    if (y < 0)
  1069. X        starty = 0;
  1070. X    else if (y > COR_YLAST)
  1071. X        starty = COR_YLAST;
  1072. X    else
  1073. X        starty = y;
  1074. }
  1075. X
  1076. COR_vector(x,y)
  1077. {
  1078. X    if (x < 0)
  1079. X        x = 0;
  1080. X    else if (x > COR_XLAST)
  1081. X        x = COR_XLAST;
  1082. X    if (y < 0)
  1083. X        y = 0;
  1084. X    else if (y > COR_YLAST)
  1085. X        y = COR_YLAST;
  1086. X
  1087. X    Cor_line(startx,COR_YLAST-starty,x,COR_YLAST-y);
  1088. X    startx = x;
  1089. X    starty = y;
  1090. }
  1091. X
  1092. X
  1093. COR_put_text(x,y,str)
  1094. unsigned int x, y;
  1095. char *str;
  1096. {
  1097. int i;
  1098. int line;
  1099. X    line= line_cor;     /* disable the dotted lines temporarily */
  1100. X    Cor_mask(pattern[0]);
  1101. X    switch(pc_angle) {
  1102. X        case 0 : y -= COR_VCHAR/2;
  1103. X                break;
  1104. X        case 1 : x += COR_VCHAR/2;
  1105. X                break;
  1106. X    }
  1107. X    for (i=0;str[i];i++) {
  1108. X        PC_putc(x,COR_YLAST-y,str[i],pc_angle,Cor_line);
  1109. X        switch(pc_angle) {
  1110. X            case 0 : x+=COR_HCHAR ;
  1111. X                    break;
  1112. X            case 1 : y+=COR_HCHAR ;
  1113. X                    break;
  1114. X        }
  1115. X    }
  1116. X    COR_mask(pattern[line]);  /* enable dotted lines */
  1117. }
  1118. X
  1119. X
  1120. #define COR_text_angle PC_text_angle
  1121. X
  1122. #define COR_reset PC_reset
  1123. X
  1124. #endif /* CORONA */
  1125. X
  1126. X
  1127. #else /* ifndef __TURBOC__ */
  1128. /* all of the Turbo C routines for the different graphics devices go here */
  1129. X
  1130. #define VGA_XMAX 640
  1131. #define VGA_YMAX 480
  1132. X
  1133. #define VGA_XLAST (VGA_XMAX - 1)
  1134. #define VGA_YLAST (VGA_YMAX - 1)
  1135. X
  1136. #define VGA_VCHAR 10
  1137. #define VGA_HCHAR 8
  1138. #define VGA_VTIC 4
  1139. #define VGA_HTIC 5
  1140. X
  1141. #define SVGA_XMAX 640
  1142. #define SVGA_YMAX 480
  1143. X
  1144. #define SVGA_VCHAR 10
  1145. #define SVGA_HCHAR 8
  1146. #define SVGA_VTIC 4
  1147. #define SVGA_HTIC 5
  1148. X
  1149. static int vga256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  1150. static int *vgacolor;
  1151. X
  1152. static int svga_xmax = SVGA_XMAX,
  1153. X       svga_ymax = SVGA_YMAX,
  1154. X       svga_xlast = 639,
  1155. X       svga_ylast = 479;
  1156. X
  1157. #define VGA_reset EGALIB_reset
  1158. #define VGA_text EGALIB_text
  1159. #define VGA_move EGALIB_move
  1160. #define VGA_vector EGALIB_vector
  1161. #define VGA_text_angle PC_text_angle
  1162. #define VGA_justify_text PC_justify_text
  1163. X
  1164. #define SVGA_reset EGALIB_reset
  1165. #define SVGA_text EGALIB_text
  1166. #define SVGA_move EGALIB_move
  1167. #define SVGA_vector EGALIB_vector
  1168. #define SVGA_text_angle PC_text_angle
  1169. #define SVGA_justify_text PC_justify_text
  1170. #define SVGA_linetype VGA_linetype
  1171. X
  1172. int PC_text_angle(ang)
  1173. int ang;
  1174. {
  1175. X    int size = svga_ymax > 600 ? 2 : 1;
  1176. X
  1177. X    pc_angle = ang;
  1178. X
  1179. X    switch (ang) {
  1180. X        case 0 : settextstyle(DEFAULT_FONT,HORIZ_DIR,size);
  1181. X            break;
  1182. X        case 1 : settextstyle(DEFAULT_FONT,VERT_DIR,size);
  1183. X            break;
  1184. X    }
  1185. X    return TRUE;
  1186. }
  1187. X
  1188. int PC_justify_text(mode)
  1189. enum JUSTIFY mode;
  1190. {
  1191. X    switch(mode) {
  1192. X        case LEFT :
  1193. X            settextjustify(LEFT_TEXT,CENTER_TEXT);
  1194. X            break;
  1195. X        case CENTRE :
  1196. X            settextjustify(CENTER_TEXT,CENTER_TEXT);
  1197. X            break;
  1198. X        case RIGHT:
  1199. X            settextjustify(RIGHT_TEXT,CENTER_TEXT);
  1200. X            break;
  1201. X    }
  1202. X    return TRUE;
  1203. }
  1204. X
  1205. VGA_init()
  1206. {
  1207. X    g_driver=VGA;
  1208. X    g_mode=2;
  1209. X    gettextinfo(&tinfo);
  1210. X        initgraph(&g_driver,&g_mode,path);
  1211. X        if(g_driver!=9){
  1212. X          term=0;
  1213. X          switch (g_driver){
  1214. X            case -2: fprintf(stderr,"Graphics card not detected.\n");
  1215. X                     break;
  1216. X            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1217. X                     break;
  1218. X            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1219. X                     break;
  1220. X            case -5: fprintf(stderr,"Insufficient memory to load ",
  1221. X                             "graphics driver.");
  1222. X                     break;
  1223. X            }
  1224. X
  1225. /*          int_error("color VGA board not found",NO_CARET);*/
  1226. X        }
  1227. X        if(g_driver==VGA) vgacolor=vga256color;
  1228. }
  1229. X
  1230. VGA_graphics()
  1231. {       g_driver=VGA;
  1232. X    g_mode=2;
  1233. X    graphics_on = TRUE;
  1234. X    gettextinfo(&tinfo);
  1235. X    setgraphmode(getgraphmode());
  1236. X    VGA_justify_text(LEFT);
  1237. }
  1238. X
  1239. VGA_linetype(linetype)
  1240. {
  1241. X    if (linetype >= 13)
  1242. X        linetype %= 13;
  1243. X    setcolor(vgacolor[linetype+2]);
  1244. }
  1245. X
  1246. VGA_put_text(x,y,str)
  1247. unsigned int x, y;
  1248. char *str;
  1249. {
  1250. X    strcpy((char far *)buf,str);
  1251. X    outtextxy(x,VGA_YLAST-y,buf);
  1252. }
  1253. X
  1254. X
  1255. VGAMONO_linetype(linetype)
  1256. {
  1257. X    if (linetype >= 5)
  1258. X        linetype %= 5;
  1259. X    setlinestyle(4,pattern[linetype+2],1);
  1260. }
  1261. X
  1262. static int huge detect_svga(void)
  1263. {
  1264. X    return g_mode;
  1265. }
  1266. X
  1267. SVGA_init()
  1268. {
  1269. X    char *p, name[128], *SVGA = getenv( "SVGA" );
  1270. X
  1271. X    if (SVGA == NULL)
  1272. X        int_error("'SVGA' driver environment variable is not set",
  1273. X              NO_CARET);
  1274. X
  1275. X    strcpy(name, SVGA);
  1276. X    if ((p = strrchr(name, '.')) == NULL ||
  1277. X        sscanf(&p[1], "%d", &g_mode) != 1)
  1278. X        int_error("'SVGA' envvar should be of the form 'name.mode'",
  1279. X              NO_CARET);
  1280. X
  1281. X    *p = 0;
  1282. X
  1283. X    installuserdriver(name, detect_svga);
  1284. X    gettextinfo(&tinfo);
  1285. X    g_driver = 0;
  1286. X        initgraph(&g_driver,&g_mode,path);
  1287. X        if(g_driver<0){
  1288. X          term=0;
  1289. X          switch (g_driver){
  1290. X            case -2: fprintf(stderr,"Graphics card not detected.\n");
  1291. X                     break;
  1292. X            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1293. X                     break;
  1294. X            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1295. X                     break;
  1296. X            case -5: fprintf(stderr,"Insufficient memory to load ",
  1297. X                             "graphics driver.");
  1298. X                     break;
  1299. X            }
  1300. X
  1301. X        }
  1302. X    else
  1303. X        vgacolor=vga256color;
  1304. X
  1305. X    /* Get the screen size: */
  1306. X    svga_xmax = term_tbl[term].xmax = getmaxx() + 1;
  1307. X        svga_ymax = term_tbl[term].ymax = getmaxy() + 1;
  1308. X    svga_xlast = svga_xmax-1;
  1309. X    svga_ylast = svga_ymax-1;
  1310. X
  1311. X    if (svga_ymax > 600) {               /* Double the tic/font sizes. */
  1312. X        term_tbl[term].h_char = SVGA_HCHAR * 2;
  1313. X        term_tbl[term].v_char = SVGA_VCHAR * 2;
  1314. X        term_tbl[term].h_tic = SVGA_HTIC * 2;
  1315. X        term_tbl[term].v_tic = SVGA_VTIC * 2;
  1316. X        settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
  1317. X     }
  1318. X    else
  1319. X        settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
  1320. }
  1321. X
  1322. SVGA_graphics()
  1323. {
  1324. X    graphics_on = TRUE;
  1325. X    gettextinfo(&tinfo);
  1326. X    setgraphmode(getgraphmode());
  1327. X    VGA_justify_text(LEFT);
  1328. X
  1329. X        svga_ymax = getmaxy() + 1;
  1330. X    if (svga_ymax > 600)               /* Double the tic/font sizes. */
  1331. X        settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
  1332. X    else
  1333. X        settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
  1334. }
  1335. X
  1336. SVGA_put_text(x,y,str)
  1337. unsigned int x, y;
  1338. char *str;
  1339. {
  1340. X    strcpy((char far *)buf,str);
  1341. X    outtextxy(x,svga_ylast-y,buf);
  1342. }
  1343. X
  1344. #define MCGA_XMAX 640
  1345. #define MCGA_YMAX 480
  1346. X
  1347. #define MCGA_XLAST (MCGA_XMAX - 1)
  1348. #define MCGA_YLAST (MCGA_YMAX - 1)
  1349. X
  1350. #define MCGA_VCHAR 10
  1351. #define MCGA_HCHAR 8
  1352. #define MCGA_VTIC 4
  1353. #define MCGA_HTIC 5
  1354. X
  1355. static int *MCGAcolor;
  1356. X
  1357. #define MCGA_reset EGALIB_reset
  1358. #define MCGA_text EGALIB_text
  1359. #define MCGA_move EGALIB_move
  1360. #define MCGA_vector EGALIB_vector
  1361. #define MCGA_text_angle PC_text_angle
  1362. #define MCGA_justify_text PC_justify_text
  1363. X
  1364. MCGA_init()
  1365. {
  1366. X    g_driver=MCGA;
  1367. X    g_mode=5;
  1368. X    gettextinfo(&tinfo);
  1369. X        initgraph(&g_driver,&g_mode,path);
  1370. X        if(g_driver!=2){
  1371. X          term=0;
  1372. X          switch (g_driver){
  1373. X            case -2: fprintf(stderr,"Graphics card not detected.\n");
  1374. X                     break;
  1375. X            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1376. X                     break;
  1377. X            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1378. X                     break;
  1379. X            case -5: fprintf(stderr,"Insufficient memory to load ",
  1380. X                             "graphics driver.");
  1381. X                     break;
  1382. X            }
  1383. X        }
  1384. }
  1385. X
  1386. MCGA_graphics()
  1387. {
  1388. X    graphics_on = TRUE;
  1389. X    gettextinfo(&tinfo);
  1390. X    setgraphmode(getgraphmode());
  1391. X    MCGA_justify_text(LEFT);
  1392. }
  1393. X
  1394. X
  1395. MCGA_put_text(x,y,str)
  1396. unsigned int x, y;
  1397. char *str;
  1398. {
  1399. X    strcpy((char far *)buf,str);
  1400. X    outtextxy(x,MCGA_YLAST-y,buf);
  1401. }
  1402. X
  1403. X
  1404. MCGA_linetype(linetype)
  1405. {
  1406. X    if (linetype >= 5)
  1407. X        linetype %= 5;
  1408. X    setlinestyle(4,pattern[linetype+2],1);
  1409. }
  1410. X
  1411. X
  1412. #define EGALIB_XMAX 640
  1413. #define EGALIB_YMAX 350
  1414. X
  1415. #define EGALIB_XLAST (EGALIB_XMAX - 1)
  1416. #define EGALIB_YLAST (EGALIB_YMAX - 1)
  1417. X
  1418. #define EGALIB_VCHAR 10
  1419. #define EGALIB_HCHAR 8
  1420. #define EGALIB_VTIC 4
  1421. #define EGALIB_HTIC 5
  1422. X
  1423. static int ega64color[] =  {1,1,5,4,3,5,4,3, 5, 4, 3, 5, 4, 3,5};
  1424. static int ega256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  1425. X
  1426. static int *egacolor;
  1427. X
  1428. #define EGALIB_text_angle PC_text_angle
  1429. #define EGALIB_justify_text PC_justify_text
  1430. X
  1431. EGALIB_init()
  1432. {
  1433. X    g_driver=EGA;
  1434. X    g_mode=1;
  1435. X    gettextinfo(&tinfo);
  1436. X        initgraph(&g_driver,&g_mode,path);
  1437. X        if(g_driver<3 || g_driver>4){
  1438. X          term=0;
  1439. X          switch (g_driver){
  1440. X            case -2: fprintf(stderr,"Graphics card not detected.\n");
  1441. X                     break;
  1442. X            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1443. X                     break;
  1444. X            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1445. X                     break;
  1446. X            case -5: fprintf(stderr,"Insufficient memory to load ",
  1447. X                             "graphics driver.");
  1448. X                     break;
  1449. X            }
  1450. X
  1451. /*          int_error("color EGA board not found",NO_CARET);*/
  1452. X        }
  1453. X        if(g_driver==EGA) egacolor=ega256color;
  1454. X        if(g_driver==EGA64) egacolor=ega64color;
  1455. }
  1456. X
  1457. EGALIB_graphics()
  1458. {
  1459. X    graphics_on = TRUE;
  1460. X    gettextinfo(&tinfo);
  1461. X    setgraphmode(getgraphmode());
  1462. X    EGALIB_justify_text(LEFT);
  1463. }
  1464. X
  1465. EGALIB_text()
  1466. {
  1467. X    if (graphics_on) {
  1468. X        graphics_on = FALSE;
  1469. X        pause();
  1470. X    }
  1471. X    restorecrtmode();
  1472. X        textmode(tinfo.currmode);
  1473. X    clrscr();
  1474. X    svga_ymax = SVGA_YMAX; /* Since it may double font size if too high. */
  1475. }
  1476. X
  1477. EGALIB_linetype(linetype)
  1478. {
  1479. X    if (linetype >= 13)
  1480. X        linetype %= 13;
  1481. X    setcolor(egacolor[linetype+2]);
  1482. }
  1483. X
  1484. EGALIB_move(x,y)
  1485. {
  1486. X        moveto(x,getmaxy()-y);
  1487. }
  1488. X
  1489. X
  1490. EGALIB_vector(x,y)
  1491. {
  1492. X    lineto(x,getmaxy()-y);
  1493. }
  1494. X
  1495. X
  1496. EGALIB_put_text(x,y,str)
  1497. unsigned int x, y;
  1498. char *str;
  1499. {
  1500. X    strcpy((char far *)buf,str);
  1501. X    outtextxy(x,EGALIB_YLAST-y,buf);
  1502. }
  1503. X
  1504. X
  1505. EGALIB_reset()
  1506. {
  1507. X      closegraph();
  1508. X        textmode(tinfo.currmode);
  1509. X    clrscr();
  1510. X    svga_ymax = SVGA_YMAX; /* Since it may double font size if too high. */
  1511. }
  1512. X
  1513. X
  1514. #define CGA_XMAX 640
  1515. #define CGA_YMAX 200
  1516. X
  1517. #define CGA_XLAST (CGA_XMAX - 1)
  1518. #define CGA_YLAST (CGA_YMAX - 1)
  1519. X
  1520. #define CGA_VCHAR 10
  1521. #define CGA_HCHAR 8
  1522. #define CGA_VTIC 4
  1523. #define CGA_HTIC 6
  1524. X
  1525. #define CGA_text_angle PC_text_angle
  1526. #define CGA_justify_text PC_justify_text
  1527. #define CGA_reset PC_reset
  1528. X
  1529. CGA_init()
  1530. {
  1531. X    g_driver=CGA;
  1532. X    g_mode=4;
  1533. X    gettextinfo(&tinfo);
  1534. X    initgraph(&g_driver,&g_mode,path);
  1535. X          switch (g_driver){
  1536. X            case -2: fprintf(stderr,"Graphics card not detected.\n");
  1537. X                     break;
  1538. X            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1539. X                     break;
  1540. X            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1541. X                     break;
  1542. X            case -5: fprintf(stderr,"Insufficient memory to load ",
  1543. X                             "graphics driver.");
  1544. X                     break;
  1545. X            }
  1546. /*    PC_color(1);         monochrome */
  1547. X
  1548. }
  1549. X
  1550. CGA_graphics()
  1551. {
  1552. X    graphics_on = TRUE;
  1553. X    gettextinfo(&tinfo);
  1554. X    setgraphmode(getgraphmode());
  1555. X    CGA_justify_text(LEFT);
  1556. X    /*    Vmode(6);*/
  1557. }
  1558. X
  1559. #define CGA_text PC_text
  1560. X
  1561. CGA_linetype(linetype)
  1562. {
  1563. X    if (linetype >= 5)
  1564. X        linetype %= 5;
  1565. X    setlinestyle(4,pattern[linetype+2],1);
  1566. }
  1567. X
  1568. CGA_move(x,y)
  1569. {
  1570. X    moveto(x,getmaxy()-y);
  1571. }
  1572. X
  1573. X
  1574. CGA_vector(x,y)
  1575. {
  1576. X    lineto(x,getmaxy()-y);
  1577. }
  1578. X
  1579. CGA_put_text(x,y,str)
  1580. unsigned int x, y;
  1581. char *str;
  1582. {
  1583. X    strcpy((char far *)buf,str);
  1584. X    outtextxy(x,CGA_YLAST-y,buf);
  1585. }
  1586. X
  1587. X
  1588. X
  1589. #define HERC_XMAX 720
  1590. #define HERC_YMAX 348
  1591. X
  1592. #define HERC_XLAST (HERC_XMAX - 1)
  1593. #define HERC_YLAST (HERC_YMAX - 1)
  1594. X
  1595. #define HERC_VCHAR 10
  1596. #define HERC_HCHAR 8
  1597. #define HERC_VTIC 4
  1598. #define HERC_HTIC 5
  1599. X
  1600. #define HERC_text_angle PC_text_angle
  1601. #define HERC_justify_text PC_justify_text
  1602. #define HERC_reset PC_reset
  1603. X
  1604. HERC_init()
  1605. {
  1606. X    g_driver=HERCMONO;
  1607. X    g_mode=0;
  1608. X    gettextinfo(&tinfo);
  1609. X      initgraph(&g_driver,&g_mode,path);
  1610. X          switch (g_driver){
  1611. X            case -2: fprintf(stderr,"Graphics card not detected.\n");
  1612. X                     break;
  1613. X            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1614. X                     break;
  1615. X            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1616. X                     break;
  1617. X            case -5: fprintf(stderr,"Insufficient memory to load ",
  1618. X                             "graphics driver.");
  1619. X                     break;
  1620. X            }
  1621. }
  1622. X
  1623. HERC_graphics()
  1624. {
  1625. X    gettextinfo(&tinfo);
  1626. X    setgraphmode(getgraphmode());
  1627. X    HERC_justify_text(LEFT);
  1628. X    graphics_on = TRUE;
  1629. }
  1630. X
  1631. HERC_text()
  1632. {
  1633. X    if (graphics_on) {
  1634. X        graphics_on = FALSE;
  1635. X        pause();
  1636. X    }
  1637. X    restorecrtmode();
  1638. X        textmode(tinfo.currmode);
  1639. X    clrscr();
  1640. }
  1641. X
  1642. HERC_linetype(linetype)
  1643. {
  1644. X    if (linetype >= 5)
  1645. X        linetype %= 5;
  1646. X    setlinestyle(4,pattern[linetype+2],1);
  1647. }
  1648. X
  1649. HERC_move(x,y)
  1650. {
  1651. X    if (x < 0)
  1652. X        x = 0;
  1653. X    else if (x > HERC_XLAST)
  1654. X        x = HERC_XLAST;
  1655. X
  1656. X    if (y < 0)
  1657. X        y = 0;
  1658. X    else if (y > HERC_YLAST)
  1659. X        y = HERC_YLAST;
  1660. X    moveto(x,getmaxy()-y);
  1661. }
  1662. X
  1663. HERC_vector(x,y)
  1664. {
  1665. X    if (x < 0)
  1666. X        x = 0;
  1667. X    else if (x > HERC_XLAST)
  1668. X        x = HERC_XLAST;
  1669. X    if (y < 0)
  1670. X        y = 0;
  1671. X    else if (y > HERC_YLAST)
  1672. X        y = HERC_YLAST;
  1673. X
  1674. X    lineto(x,getmaxy()-y);
  1675. }
  1676. X
  1677. X
  1678. HERC_put_text(x,y,str)
  1679. unsigned int x, y;
  1680. char *str;
  1681. {
  1682. X    strcpy((char far *)buf,str);
  1683. X    outtextxy(x,HERC_YLAST-y,buf);
  1684. }
  1685. X
  1686. X
  1687. #ifdef ATT6300
  1688. /* this driver added by rjl@monu1.cc.monash.edu.au */
  1689. X
  1690. #define ATT_XMAX 640
  1691. #define ATT_YMAX 400
  1692. X
  1693. #define ATT_XLAST (ATT_XMAX - 1)
  1694. #define ATT_YLAST (ATT_YMAX - 1)
  1695. X
  1696. #define ATT_VCHAR PC_VCHAR
  1697. #define ATT_HCHAR PC_HCHAR
  1698. #define ATT_VTIC 4
  1699. #define ATT_HTIC 5
  1700. X
  1701. #define ATT_text_angle PC_text_angle
  1702. #define ATT_justify_text PC_justify_text
  1703. #define ATT_reset PC_reset
  1704. X
  1705. ATT_init()
  1706. {
  1707. X    g_driver=ATT400;
  1708. X    g_mode=5;
  1709. X    gettextinfo(&tinfo);
  1710. X      initgraph(&g_driver,&g_mode,path);
  1711. X          switch (g_driver){
  1712. X            case -2: fprintf(stderr,"Graphics card not detected.\n");
  1713. X                     break;
  1714. X            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1715. X                     break;
  1716. X            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1717. X                     break;
  1718. X            case -5: fprintf(stderr,"Insufficient memory to load ",
  1719. X                             "graphics driver.");
  1720. X                     break;
  1721. X            }
  1722. }
  1723. X
  1724. ATT_graphics()
  1725. {
  1726. X    gettextinfo(&tinfo);
  1727. X    setgraphmode(getgraphmode());
  1728. X    ATT_justify_text(LEFT);
  1729. X    graphics_on = TRUE;
  1730. }
  1731. X
  1732. ATT_text()
  1733. {
  1734. X    if (graphics_on) {
  1735. X        graphics_on = FALSE;
  1736. X        pause();
  1737. X    }
  1738. X    restorecrtmode();
  1739. X        textmode(tinfo.currmode);
  1740. X    clrscr();
  1741. }
  1742. X
  1743. ATT_linetype(linetype)
  1744. {
  1745. X    if (linetype >= 5)
  1746. X        linetype %= 5;
  1747. X    setlinestyle(4,pattern[linetype+2],1);
  1748. }
  1749. X
  1750. ATT_move(x,y)
  1751. {
  1752. X    if (x < 0)
  1753. X        x = 0;
  1754. X    else if (x > ATT_XLAST)
  1755. X        x = ATT_XLAST;
  1756. X
  1757. X    if (y < 0)
  1758. X        y = 0;
  1759. X    else if (y > ATT_YLAST)
  1760. X        y = ATT_YLAST;
  1761. X    moveto(x,getmaxy()-y);
  1762. }
  1763. X
  1764. ATT_vector(x,y)
  1765. {
  1766. X    if (x < 0)
  1767. X        x = 0;
  1768. X    else if (x > ATT_XLAST)
  1769. X        x = ATT_XLAST;
  1770. X    if (y < 0)
  1771. X        y = 0;
  1772. X    else if (y > ATT_YLAST)
  1773. X        y = ATT_YLAST;
  1774. X
  1775. X    lineto(x,getmaxy()-y);
  1776. }
  1777. X
  1778. X
  1779. ATT_put_text(x,y,str)
  1780. unsigned int x, y;
  1781. char *str;
  1782. {
  1783. X    strcpy((char far *)buf,str);
  1784. X    outtextxy(x,ATT_YLAST-y,buf);
  1785. }
  1786. #endif /* ifdef ATT6300 */
  1787. X
  1788. #endif /* ifndef __TURBOC__ */
  1789. X
  1790. SHAR_EOF
  1791. chmod 0644 gnuplot/term/pc.trm ||
  1792. echo 'restore of gnuplot/term/pc.trm failed'
  1793. Wc_c="`wc -c < 'gnuplot/term/pc.trm'`"
  1794. test 25264 -eq "$Wc_c" ||
  1795.     echo 'gnuplot/term/pc.trm: original size 25264, current size' "$Wc_c"
  1796. rm -f _shar_wnt_.tmp
  1797. fi
  1798. # ============= gnuplot/term/imagen.trm ==============
  1799. if test -f 'gnuplot/term/imagen.trm' -a X"$1" != X"-c"; then
  1800.     echo 'x - skipping gnuplot/term/imagen.trm (File already exists)'
  1801.     rm -f _shar_wnt_.tmp
  1802. else
  1803. > _shar_wnt_.tmp
  1804. echo 'x - extracting gnuplot/term/imagen.trm (Text)'
  1805. sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/imagen.trm' &&
  1806. /* GNUPLOT - imagen.trm */
  1807. /*
  1808. X * Copyright (C) 1990   
  1809. X *
  1810. X * Permission to use, copy, and distribute this software and its
  1811. X * documentation for any purpose with or without fee is hereby granted, 
  1812. X * provided that the above copyright notice appear in all copies and 
  1813. X * that both that copyright notice and this permission notice appear 
  1814. X * in supporting documentation.
  1815. X *
  1816. X * Permission to modify the software is granted, but not the right to
  1817. X * distribute the modified code.  Modifications are to be distributed 
  1818. X * as patches to released version.
  1819. X *  
  1820. X * This software  is provided "as is" without express or implied warranty.
  1821. X * 
  1822. X * This file is included by ../term.c.
  1823. X *
  1824. X * This terminal driver supports:
  1825. X *   Imagen laser printers
  1826. X *
  1827. X * AUTHORS
  1828. X *   Paul E. McKenney, David Kotz
  1829. X * 
  1830. X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  1831. X * 
  1832. X */
  1833. X
  1834. /*
  1835. X * Original for direct Imagen output (but retaining many of the
  1836. X * LaTeX extensions) by Paul E. McKenney, 1989.
  1837. X * Further modified by David Kotz to fit into gnuplot 2.0.
  1838. X * Information Science and Technology Division, SRI International,
  1839. X * 333 Ravenswood Ave, Menlo Park, CA 94025.
  1840. X * Mail to mckenney@sri.com.
  1841. X */
  1842. X
  1843. #include "impcodes.h"
  1844. X
  1845. #define IMAGEN_PTS_PER_INCH (300)
  1846. X
  1847. #define IMAGEN_XMAX (IMAGEN_PTS_PER_INCH * 10) /* 10.0 inches */
  1848. #define IMAGEN_YMAX (IMAGEN_PTS_PER_INCH * 75 / 10) /* 7.5 inches */
  1849. X
  1850. #define IMAGEN_FONTSIZE 12
  1851. X
  1852. #define IMAGEN_HTIC (20)
  1853. #define IMAGEN_VTIC (20)
  1854. #define IMAGEN_VCHAR (IMAGEN_FONTSIZE*5)
  1855. #define IMAGEN_HCHAR (IMAGEN_VCHAR/2)
  1856. X
  1857. static int IMAGEN_orgx;        /* absolute-pixel-ORIgin of graph.    */
  1858. static int IMAGEN_orgy;
  1859. static int IMAGEN_posx;        /* current drawing position (lines).    */
  1860. static int IMAGEN_posy;
  1861. static int IMAGEN_inplot;
  1862. static int IMAGEN_xmax;        /* width of graph in pixels.        */
  1863. static int IMAGEN_ymax;        /* height of graph in pixels.        */
  1864. static int IMAGEN_hchar;        /* Height of CHAR in current font.    */
  1865. static int IMAGEN_wchar;        /* Width of CHAR in current font.    */
  1866. static int IMAGEN_blofs;        /* BaseLine OFfSet from bounding box.    */
  1867. static int IMAGEN_angle = -1;    /* 0 for horizontal text, 1 for vertical */
  1868. static enum JUSTIFY IMAGEN_justify = LEFT; /* left/center/right */
  1869. X
  1870. static IMAGEN_seq_pos;        /* position in sequence */
  1871. X
  1872. static void IMAGEN_putwd();
  1873. static void IMAGEN_createfamily();
  1874. static void IMAGEN_setfont();
  1875. static void IMAGEN_setpos();
  1876. static char *IMAGEN_cvts();
  1877. X
  1878. IMAGEN_init()
  1879. {
  1880. X    char font[10];            /* font name */
  1881. X
  1882. X    IMAGEN_posx = IMAGEN_posy = 0;
  1883. X
  1884. X    IMAGEN_orgx = (11.0 * IMAGEN_PTS_PER_INCH - IMAGEN_XMAX) / 2;
  1885. X    IMAGEN_orgy = (8.5 * IMAGEN_PTS_PER_INCH - IMAGEN_YMAX)/ 2;
  1886. X
  1887. X    fputs("@document(language impress)", outfile);
  1888. X
  1889. X    putc(imP_SET_HV_SYSTEM, outfile);
  1890. X    putc((3<<3)|5, outfile);
  1891. X
  1892. X    sprintf(font, "cour%02d", IMAGEN_FONTSIZE);
  1893. X    IMAGEN_createfamily(font, IMAGEN_FONTSIZE);
  1894. X    IMAGEN_setfont(IMAGEN_FONTSIZE);
  1895. X
  1896. X    IMAGEN_text_angle(0);
  1897. X
  1898. X    putc(imP_SET_ABS_H, outfile);
  1899. X    IMAGEN_putwd(0);
  1900. X    putc(imP_SET_ABS_V, outfile);
  1901. X    IMAGEN_putwd(0);
  1902. X
  1903. X    IMAGEN_linetype(-1);
  1904. }
  1905. X
  1906. IMAGEN_graphics()
  1907. {
  1908. X    static BOOLEAN first = TRUE;
  1909. X
  1910. X    if (!first)
  1911. X     putc(imP_ENDPAGE, outfile);
  1912. X    first = FALSE;
  1913. X
  1914. X    IMAGEN_move(0, 0);
  1915. }
  1916. X
  1917. IMAGEN_text()
  1918. {
  1919. }
  1920. X
  1921. X
  1922. IMAGEN_linetype(linetype)
  1923. int linetype;
  1924. {
  1925. X    static int lastlinetype = -10;
  1926. X
  1927. X    if (linetype < 0)
  1928. X     linetype = -linetype;
  1929. X    else
  1930. X     linetype *= 2;
  1931. X
  1932. X    if (lastlinetype == linetype)
  1933. X     return;
  1934. X
  1935. X    lastlinetype = linetype;    /* now >= 0 */
  1936. X
  1937. X    putc(imP_SET_PEN, outfile);
  1938. X    putc(linetype, outfile);
  1939. }
  1940. X
  1941. X
  1942. IMAGEN_move(x,y)
  1943. X    unsigned int x,y;
  1944. {
  1945. X    IMAGEN_posx = x;
  1946. X    IMAGEN_posy = y;
  1947. }
  1948. X
  1949. IMAGEN_vector(ux,uy)
  1950. X    unsigned int ux,uy;
  1951. {
  1952. X    /* Create path. */
  1953. X
  1954. X    putc(imP_CREATE_PATH, outfile);
  1955. X    IMAGEN_putwd(2);
  1956. X    IMAGEN_putwd(IMAGEN_posx + IMAGEN_orgx);
  1957. X    IMAGEN_putwd(IMAGEN_posy + IMAGEN_orgy);
  1958. X    IMAGEN_putwd(ux + IMAGEN_orgx);
  1959. X    IMAGEN_putwd(uy + IMAGEN_orgy);
  1960. X
  1961. X    /* Draw path with black pen. */
  1962. X
  1963. X    putc(imP_DRAW_PATH, outfile);
  1964. X    putc(15, outfile);
  1965. X
  1966. X    /* Set current position to end of line. */
  1967. X
  1968. X    IMAGEN_move(ux, uy);
  1969. }
  1970. X
  1971. static void
  1972. IMAGEN_setpos(ux, uy)
  1973. X    int ux,uy;
  1974. {
  1975. X    /* Set x and y position (for text), also set beginning-of-line. */
  1976. X
  1977. X    putc(imP_SET_ABS_H, outfile);
  1978. X    IMAGEN_putwd(ux + IMAGEN_orgx);
  1979. X    putc(imP_SET_ABS_V, outfile);
  1980. X    IMAGEN_putwd(uy + IMAGEN_orgy);
  1981. X    putc(imP_SET_BOL, outfile);
  1982. X    if (IMAGEN_angle == 1)
  1983. X     IMAGEN_putwd(uy + IMAGEN_orgx); /* vertical */
  1984. X    else
  1985. X     IMAGEN_putwd(ux + IMAGEN_orgx); /* horizontal */
  1986. }
  1987. X
  1988. IMAGEN_text_angle(angle)
  1989. X    int angle;
  1990. {
  1991. X    if (IMAGEN_angle != angle) {
  1992. X       IMAGEN_angle = angle;    /* record for later use */
  1993. X       putc(imP_SET_ADV_DIRS, outfile);
  1994. X       putc(angle == 0 ? 0 : 7, outfile); /* 0=>horiz : 7=>vert */
  1995. X    }
  1996. X
  1997. X    return(TRUE);
  1998. }
  1999. X
  2000. IMAGEN_justify_text(mode)
  2001. X    enum JUSTIFY mode;
  2002. {
  2003. X    IMAGEN_justify = mode;
  2004. X    return(TRUE);
  2005. }
  2006. X
  2007. static char *
  2008. IMAGEN_cvts(str, width, height)
  2009. X    char        *str;
  2010. X    int        *width;
  2011. X    int        *height;
  2012. {
  2013. X    char        *cp1;
  2014. X    char        *cp2;
  2015. X    static char    *buf = NULL;
  2016. X    int        h;
  2017. X    int        maxw;
  2018. X    int        w;
  2019. X
  2020. X    /* Free up old buffer, if there is one, get a new one.  Since    */
  2021. X    /* all transformations shorten the string, get a buffer that is    */
  2022. X    /* the same size as the input string.                */
  2023. X
  2024. X    if (buf != NULL)
  2025. X     (void) free(buf);
  2026. X    buf = (char *) alloc(strlen(str), "converted label string");
  2027. X
  2028. X    /* Do the transformations. */
  2029. X
  2030. X    cp1 = str;
  2031. X    cp2 = buf;
  2032. X    h = 1;
  2033. X    maxw = 0;
  2034. X    w = 0;
  2035. X    while (strlen(cp1) > 0) {
  2036. X       switch (*cp1) {
  2037. X          case ' ' :        /* Space character. */
  2038. X            *cp2++ = imP_SP;
  2039. X            w++;
  2040. X            break;
  2041. X            
  2042. X            case  '\\' :    /* Escape sequence. */
  2043. X             if (*++cp1 == '\\') {
  2044. X                /* Begin new line. */
  2045. X                h++;
  2046. X                if (w > maxw)
  2047. X                  maxw = w;
  2048. X                w = 0;
  2049. X                *cp2++ = imP_CRLF;
  2050. X                break;
  2051. X             }
  2052. X            
  2053. X            /* Fall through to just copy next char out.    */
  2054. X            
  2055. X            default :
  2056. X             *cp2++ = *cp1;
  2057. X            w++;
  2058. X            break;
  2059. X        }
  2060. X       cp1++;
  2061. X    }
  2062. X    
  2063. X    *cp2 = '\0';
  2064. X    if (w > maxw)
  2065. X     maxw = w;
  2066. X    
  2067. X    if (height != NULL)
  2068. X     *height = IMAGEN_angle ?
  2069. X       IMAGEN_wchar * maxw :
  2070. X        IMAGEN_hchar * h;
  2071. X    if (width != NULL)
  2072. X     *width = IMAGEN_angle ?
  2073. X       IMAGEN_hchar * h :
  2074. X        IMAGEN_wchar * maxw;
  2075. X    return (buf);
  2076. }
  2077. X
  2078. IMAGEN_put_text(x, y, str)
  2079. X    int x,y;                /* reference point of string */
  2080. X    char str[];            /* the text */
  2081. {
  2082. X    char *cvstr;
  2083. X    int height;
  2084. X    int width;
  2085. X    
  2086. X    cvstr = IMAGEN_cvts(str, &width, &height);
  2087. X
  2088. X    switch (IMAGEN_justify) {
  2089. X       case LEFT: break;
  2090. X       case CENTRE: x -= width/2; break;
  2091. X       case RIGHT: x -= width; break;
  2092. X    }
  2093. X
  2094. X    if (IMAGEN_angle) {        /* vertical */
  2095. X       x += IMAGEN_hchar;
  2096. X       y -= height/2;
  2097. X    } else                /* horizontal */
  2098. X     y += height/2 - IMAGEN_hchar;
  2099. X
  2100. X    IMAGEN_setpos(x, y + IMAGEN_blofs);
  2101. X    fputs(cvstr, outfile);
  2102. }
  2103. X
  2104. X
  2105. IMAGEN_reset()
  2106. {
  2107. X    putc(imP_EOF, outfile);
  2108. }
  2109. X
  2110. static void
  2111. IMAGEN_putwd(w)
  2112. {
  2113. X    putc(w>>8, outfile);
  2114. X    putc(w, outfile);
  2115. }
  2116. X
  2117. static void
  2118. IMAGEN_createfamily(c, sz)
  2119. X    char        *c;
  2120. X    int        sz;
  2121. {
  2122. X    putc(imP_CREATE_FAMILY_TABLE, outfile);
  2123. X    putc(sz, outfile);
  2124. X    putc(1, outfile);
  2125. X    putc(0, outfile);
  2126. X    fputs(c, outfile);
  2127. X    putc(0, outfile);
  2128. }
  2129. X
  2130. static void
  2131. IMAGEN_setfont(sz) 
  2132. X    int sz;
  2133. {
  2134. X    IMAGEN_hchar = sz * 5;
  2135. X    IMAGEN_wchar = IMAGEN_hchar / 2;
  2136. X    IMAGEN_blofs = IMAGEN_hchar / 3;
  2137. X    putc(imP_SET_FAMILY, outfile);
  2138. X    putc(sz, outfile);
  2139. X    putc(imP_SET_SP, outfile);
  2140. X    IMAGEN_putwd(IMAGEN_wchar);
  2141. X    putc(imP_SET_IL, outfile);
  2142. X    IMAGEN_putwd(IMAGEN_hchar);
  2143. }
  2144. SHAR_EOF
  2145. chmod 0666 gnuplot/term/imagen.trm ||
  2146. echo 'restore of gnuplot/term/imagen.trm failed'
  2147. Wc_c="`wc -c < 'gnuplot/term/imagen.trm'`"
  2148. test 7396 -eq "$Wc_c" ||
  2149.     echo 'gnuplot/term/imagen.trm: original size 7396, current size' "$Wc_c"
  2150. rm -f _shar_wnt_.tmp
  2151. fi
  2152. # ============= gnuplot/term/iris4d.trm ==============
  2153. if test -f 'gnuplot/term/iris4d.trm' -a X"$1" != X"-c"; then
  2154.     echo 'x - skipping gnuplot/term/iris4d.trm (File already exists)'
  2155.     rm -f _shar_wnt_.tmp
  2156. else
  2157. > _shar_wnt_.tmp
  2158. echo 'x - extracting gnuplot/term/iris4d.trm (Text)'
  2159. sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/iris4d.trm' &&
  2160. /* GNUPLOT - iris4d.trm */
  2161. /*
  2162. X * Copyright (C) 1990   
  2163. X *
  2164. X * Permission to use, copy, and distribute this software and its
  2165. X * documentation for any purpose with or without fee is hereby granted, 
  2166. X * provided that the above copyright notice appear in all copies and 
  2167. X * that both that copyright notice and this permission notice appear 
  2168. X * in supporting documentation.
  2169. X *
  2170. X * Permission to modify the software is granted, but not the right to
  2171. X * distribute the modified code.  Modifications are to be distributed 
  2172. X * as patches to released version.
  2173. X *  
  2174. X * This software  is provided "as is" without express or implied warranty.
  2175. X * 
  2176. X * This file is included by ../term.c.
  2177. X *
  2178. X * This terminal driver supports:
  2179. X *   IRIS terminals
  2180. X *
  2181. X * AUTHORS
  2182. X *   John H. Merritt 
  2183. X *           (Applied Research Corporation) 7/1/89
  2184. X *           INTERNET: merritt@iris613.gsfc.nasa.gov
  2185. X * 
  2186. X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  2187. X * 
  2188. X */
  2189. X
  2190. #include <gl.h>
  2191. X
  2192. #define IRIS4DRC    ".gnuplot_iris4d"
  2193. X
  2194. #define IRIS4D_XMAX 1024
  2195. #define IRIS4D_YMAX 1024
  2196. X
  2197. #define IRIS4D_XLAST (IRIS4D_XMAX - 1)
  2198. #define IRIS4D_YLAST (IRIS4D_YMAX - 1)
  2199. X
  2200. #define IRIS4D_VCHAR (IRIS4D_YMAX/30)
  2201. #define IRIS4D_HCHAR (IRIS4D_XMAX/72)
  2202. #define IRIS4D_VTIC (IRIS4D_YMAX/80)
  2203. #define IRIS4D_HTIC (IRIS4D_XMAX/80)
  2204. X
  2205. static short colors24bits[][3] =
  2206. {
  2207. X    { 85,  85,  85  },  /* 0. BACK GROUND ( DARKGRAY ) */
  2208. X    { 0,   0,   0   },  /* 1. BLACK */
  2209. X    { 170, 0,   170 },  /* 2. MAGENTA */
  2210. X    { 85,  255, 255 },  /* 3. LIGHTCYAN */
  2211. X    { 170, 0,   0   },  /* 4. RED */
  2212. X    { 0,   170, 0   },  /* 5. GREEN */
  2213. X    { 255, 85,  255 },  /* 6. LIGHTMAGENTA */
  2214. X    { 255, 255, 85  },  /* 7. YELLOW */
  2215. X    { 255, 85,  85  },  /* 8. LIGHTRED */
  2216. X    { 85,  255, 85  },  /* 9. LIGHTGREEN */
  2217. X    { 0,   170, 170 },  /* 10. CYAN */
  2218. X    { 170, 170, 0   },  /* 11. BROWN */
  2219. };
  2220. #define COLOR24_SIZE (sizeof(colors24bits) / (sizeof(short) * 3))
  2221. X
  2222. static iris24bits = FALSE;
  2223. X
  2224. #define IRIS4D_BACKGROUND    0
  2225. #define IRIS4D_BLACK        1
  2226. #define IRIS4D_MAGENTA        2
  2227. #define IRIS4D_LIGHTCYAN    3
  2228. #define IRIS4D_RED        4
  2229. #define IRIS4D_GREEN        5
  2230. #define IRIS4D_LIGHTMAGENTA    6
  2231. #define IRIS4D_YELLOW        7
  2232. #define IRIS4D_LIGHTRED        8
  2233. #define IRIS4D_LIGHTGREEN    9
  2234. #define IRIS4D_CYAN        10
  2235. #define IRIS4D_BROWN        11
  2236. X
  2237. IRIS4D_options()
  2238. {
  2239. X  int i = 0;
  2240. X  struct value a;
  2241. X  extern struct value *const_express();
  2242. X  extern double real();
  2243. X
  2244. X  if (!END_OF_COMMAND) {
  2245. X    i = (int) real(const_express(&a));
  2246. X  }
  2247. X
  2248. X  iris24bits = (i == 24);
  2249. X
  2250. X  sprintf(term_options, "%s",iris24bits ? "24" : "8");
  2251. }
  2252. X
  2253. IRIS4D_init()
  2254. {
  2255. X  int i;
  2256. X  char homedirfile[80], line[80];
  2257. X  FILE *f;
  2258. X
  2259. X  foreground();
  2260. X  winopen("Gnuplot");
  2261. X  if (iris24bits)
  2262. X  {
  2263. X    RGBmode();
  2264. X    gconfig();
  2265. X  }
  2266. X
  2267. X  strcat(strcat(strcpy(homedirfile,getenv("HOME")),"/"),IRIS4DRC);
  2268. X  if ((f = fopen(IRIS4DRC, "r")) != NULL ||
  2269. X      (f = fopen(homedirfile, "r")) != NULL) {
  2270. X    int c1, c2, c3;
  2271. X    for (i = 0; i < COLOR24_SIZE; i++) {
  2272. X      if (fgets(line, 79, f) == NULL ||
  2273. X      sscanf(line, "%d %d %d", &c1, &c2, &c3) != 3)
  2274. X    int_error("Iris4d color file terminated prematurely or wrong format.\n", NO_CARET);
  2275. X      colors24bits[i][0] = c1;
  2276. X      colors24bits[i][1] = c2;
  2277. X      colors24bits[i][2] = c3;
  2278. X    }
  2279. X      
  2280. X    fclose(f);
  2281. X  }
  2282. X  deflinestyle(1, 0x3FFF); /* long dash */
  2283. X  deflinestyle(2, 0x5555); /* dotted */
  2284. X  deflinestyle(3, 0x3333); /* short dash */
  2285. X  deflinestyle(4, 0xB5AD); /* dotdashed */
  2286. X  deflinestyle(5, 0x0F0F); /* dashed */
  2287. X  deflinestyle(6, 0xBBBB); /* dotdashed */
  2288. X  deflinestyle(7, 0x3F3F); /* mid-long dash */
  2289. X  deflinestyle(8, 0x7777); /* mid-long dash */
  2290. X
  2291. X  return;
  2292. }
  2293. X
  2294. IRIS4D_graphics()
  2295. {
  2296. X  reshapeviewport();
  2297. X  ortho2((Coord)0, (Coord)IRIS4D_XMAX, (Coord)0, (Coord)IRIS4D_YMAX);
  2298. X  if (iris24bits)
  2299. X    RGBcolor(colors24bits[IRIS4D_BACKGROUND][0],
  2300. X         colors24bits[IRIS4D_BACKGROUND][1],
  2301. X         colors24bits[IRIS4D_BACKGROUND][2]);
  2302. X  else
  2303. X    color(WHITE);
  2304. X
  2305. X  clear();
  2306. SHAR_EOF
  2307. true || echo 'restore of gnuplot/term/iris4d.trm failed'
  2308. fi
  2309. echo 'End of  part 16'
  2310. echo 'File gnuplot/term/iris4d.trm is continued in part 17'
  2311. echo 17 > _shar_seq_.tmp
  2312. exit 0
  2313.  
  2314. exit 0 # Just in case...
  2315. -- 
  2316. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  2317. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  2318. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  2319. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  2320.