home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / GNU / GNUPLOTsrc.lha / term / iris4d.trm < prev    next >
Encoding:
Text File  |  1996-01-22  |  6.9 KB  |  290 lines

  1. /*
  2.  * $Id: iris4d.trm,v 1.8 1995/12/20 21:47:56 drd Exp $
  3.  *
  4.  */
  5.  
  6. /* GNUPLOT - iris4d.trm */
  7. /*
  8.  * Copyright (C) 1990 - 1993   
  9.  *
  10.  * Permission to use, copy, and distribute this software and its
  11.  * documentation for any purpose with or without fee is hereby granted, 
  12.  * provided that the above copyright notice appear in all copies and 
  13.  * that both that copyright notice and this permission notice appear 
  14.  * in supporting documentation.
  15.  *
  16.  * Permission to modify the software is granted, but not the right to
  17.  * distribute the modified code.  Modifications are to be distributed 
  18.  * as patches to released version.
  19.  *  
  20.  * This software  is provided "as is" without express or implied warranty.
  21.  * 
  22.  * This file is included by ../term.c.
  23.  *
  24.  * This terminal driver supports:
  25.  *   IRIS terminals
  26.  *
  27.  * AUTHORS
  28.  *   John H. Merritt 
  29.  *           (Applied Research Corporation) 7/1/89
  30.  *           INTERNET: merritt@iris613.gsfc.nasa.gov
  31.  * 
  32.  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
  33.  * 
  34.  */
  35. /*
  36.  * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
  37.  */
  38.  
  39. #ifndef GOT_DRIVER_H
  40. #include "driver.h"
  41. #endif
  42.  
  43. #ifdef TERM_REGISTER
  44. register_term(iris4d)
  45. #endif
  46.  
  47. #ifdef TERM_PROTO
  48. TERM_PUBLIC void IRIS4D_options __P((void));
  49. TERM_PUBLIC void IRIS4D_init __P((void));
  50. TERM_PUBLIC void IRIS4D_graphics __P((void));
  51. TERM_PUBLIC void IRIS4D_text __P((void));
  52. TERM_PUBLIC void IRIS4D_linetype __P((int linetype));
  53. TERM_PUBLIC void IRIS4D_move __P((unsigned int x, unsigned int y));
  54. TERM_PUBLIC void IRIS4D_vector __P((unsigned int x, unsigned int y));
  55. TERM_PUBLIC void IRIS4D_put_text __P((unsigned int x, unsigned int y, char *str));
  56. TERM_PUBLIC void IRIS4D_reset __P((void));
  57. #define IRIS4D_XMAX 1024
  58. #define IRIS4D_YMAX 1024
  59. #define IRIS4D_VCHAR (IRIS4D_YMAX/30)
  60. #define IRIS4D_HCHAR (IRIS4D_XMAX/72)
  61. #define IRIS4D_VTIC (IRIS4D_YMAX/80)
  62. #define IRIS4D_HTIC (IRIS4D_XMAX/80)
  63. #endif /* TERM_PROTO */
  64.  
  65. #ifndef TERM_PROTO_ONLY
  66. #ifdef TERM_BODY
  67. void IRIS4D_cmove __P((unsigned int x, unsigned int y));
  68. #include <gl.h>
  69.  
  70. #define IRIS4DRC    ".gnuplot_iris4d"
  71.  
  72. #define IRIS4D_XLAST (IRIS4D_XMAX - 1)
  73. #define IRIS4D_YLAST (IRIS4D_YMAX - 1)
  74.  
  75.  
  76. static short colors24bits[][3] =
  77. {
  78.     { 85,  85,  85  },  /* 0. BACK GROUND ( DARKGRAY ) */
  79.     { 0,   0,   0   },  /* 1. BLACK */
  80.     { 170, 0,   170 },  /* 2. MAGENTA */
  81.     { 85,  255, 255 },  /* 3. LIGHTCYAN */
  82.     { 170, 0,   0   },  /* 4. RED */
  83.     { 0,   170, 0   },  /* 5. GREEN */
  84.     { 255, 85,  255 },  /* 6. LIGHTMAGENTA */
  85.     { 255, 255, 85  },  /* 7. YELLOW */
  86.     { 255, 85,  85  },  /* 8. LIGHTRED */
  87.     { 85,  255, 85  },  /* 9. LIGHTGREEN */
  88.     { 0,   170, 170 },  /* 10. CYAN */
  89.     { 170, 170, 0   },  /* 11. BROWN */
  90. };
  91. #define COLOR24_SIZE (sizeof(colors24bits) / (sizeof(short) * 3))
  92.  
  93. static iris24bits = FALSE;
  94.  
  95. #define IRIS4D_BACKGROUND    0
  96. #define IRIS4D_BLACK        1
  97. #define IRIS4D_MAGENTA        2
  98. #define IRIS4D_LIGHTCYAN    3
  99. #define IRIS4D_RED        4
  100. #define IRIS4D_GREEN        5
  101. #define IRIS4D_LIGHTMAGENTA    6
  102. #define IRIS4D_YELLOW        7
  103. #define IRIS4D_LIGHTRED        8
  104. #define IRIS4D_LIGHTGREEN    9
  105. #define IRIS4D_CYAN        10
  106. #define IRIS4D_BROWN        11
  107.  
  108. TERM_PUBLIC void IRIS4D_options()
  109. {
  110.   int i = 0;
  111.   struct value a;
  112.  
  113.   if (!END_OF_COMMAND) {
  114.     i = (int) real(const_express(&a));
  115.   }
  116.  
  117.   iris24bits = (i == 24);
  118.  
  119.   sprintf(term_options, "%s",iris24bits ? "24" : "8");
  120. }
  121.  
  122. TERM_PUBLIC void IRIS4D_init()
  123. {
  124.   int i;
  125.   char homedirfile[80], line[80];
  126.   FILE *f;
  127.  
  128.   foreground();
  129.   winopen("Gnuplot");
  130.   if (iris24bits)
  131.   {
  132.     RGBmode();
  133.     gconfig();
  134.   }
  135.  
  136.   strcat(strcat(strcpy(homedirfile,getenv("HOME")),"/"),IRIS4DRC);
  137.   if ((f = fopen(IRIS4DRC, "r")) != NULL ||
  138.       (f = fopen(homedirfile, "r")) != NULL) {
  139.     int c1, c2, c3;
  140.     for (i = 0; i < COLOR24_SIZE; i++) {
  141.       if (fgets(line, 79, f) == NULL ||
  142.       sscanf(line, "%d %d %d", &c1, &c2, &c3) != 3)
  143.     int_error("Iris4d color file terminated prematurely or wrong format.\n", NO_CARET);
  144.       colors24bits[i][0] = c1;
  145.       colors24bits[i][1] = c2;
  146.       colors24bits[i][2] = c3;
  147.     }
  148.       
  149.     fclose(f);
  150.   }
  151.   deflinestyle(1, 0x3FFF); /* long dash */
  152.   deflinestyle(2, 0x5555); /* dotted */
  153.   deflinestyle(3, 0x3333); /* short dash */
  154.   deflinestyle(4, 0xB5AD); /* dotdashed */
  155.   deflinestyle(5, 0x0F0F); /* dashed */
  156.   deflinestyle(6, 0xBBBB); /* dotdashed */
  157.   deflinestyle(7, 0x3F3F); /* mid-long dash */
  158.   deflinestyle(8, 0x7777); /* mid-long dash */
  159.  
  160.   return;
  161. }
  162.  
  163. TERM_PUBLIC void IRIS4D_graphics()
  164. {
  165.   reshapeviewport();
  166.   ortho2((Coord)0, (Coord)IRIS4D_XMAX, (Coord)0, (Coord)IRIS4D_YMAX);
  167.   if (iris24bits)
  168.     RGBcolor(colors24bits[IRIS4D_BACKGROUND][0],
  169.          colors24bits[IRIS4D_BACKGROUND][1],
  170.          colors24bits[IRIS4D_BACKGROUND][2]);
  171.   else
  172.     color(WHITE);
  173.  
  174.   clear();
  175.   
  176.   return;
  177. }
  178.  
  179. TERM_PUBLIC void IRIS4D_text()
  180. {
  181.   gflush(); /* flush buffer */
  182.   return; /* enter text from another window!!! */
  183. }
  184.  
  185. TERM_PUBLIC void IRIS4D_linetype(linetype)
  186. int linetype;
  187. {
  188.   static int pen_color_24[11] =
  189.     {
  190.       IRIS4D_BLACK,        /* reserved for border and numbers */
  191.       IRIS4D_MAGENTA,        /* reserved for axis traces */
  192.       IRIS4D_LIGHTCYAN,
  193.       IRIS4D_RED,
  194.       IRIS4D_GREEN,
  195.       IRIS4D_LIGHTMAGENTA,
  196.       IRIS4D_YELLOW,
  197.       IRIS4D_LIGHTRED,
  198.       IRIS4D_LIGHTGREEN,
  199.       IRIS4D_CYAN,
  200.       IRIS4D_BROWN,
  201.     };
  202.   static int pen_color[8] = {0 ,1, 4, 5, 6, 1, 2, 4};
  203.  
  204.   if (iris24bits)
  205.   {
  206.     int pencolor = pen_color_24[linetype < 0 ? linetype + 2 : linetype % 9 + 2];
  207.  
  208.     RGBcolor(colors24bits[pencolor][0],
  209.          colors24bits[pencolor][1],
  210.          colors24bits[pencolor][2]);
  211.     /* Make all lines solid (linestyle 0) upto to the ninth. If more than
  212.      * 9 colors are needed, start to use the different line styles (1 to 8).
  213.      */
  214.     setlinestyle(linetype < 9 ? 0 : (linetype + 2) % 8 + 1);
  215.   }
  216.   else
  217.   {
  218.     linetype = linetype % 8;
  219.     color((Colorindex) pen_color[linetype]);
  220.     setlinestyle(linetype);
  221.   }
  222.   return;
  223. }
  224.  
  225. TERM_PUBLIC void IRIS4D_move(x, y)
  226. unsigned int x, y;
  227. {
  228.   move2i(x, y);
  229.   return;
  230. }
  231.  
  232. void IRIS4D_cmove(x, y)
  233. unsigned int x, y;
  234. {
  235.   cmov2i(x, y);
  236.   return;
  237. }
  238.  
  239. TERM_PUBLIC void IRIS4D_vector(x, y)
  240. unsigned int x, y;
  241. {
  242.   draw2i(x, y);
  243.   return;
  244. }
  245.  
  246.  
  247. TERM_PUBLIC void IRIS4D_put_text(x,y,str)
  248. unsigned int x, y;
  249. char *str;
  250. {
  251.   IRIS4D_cmove(x,y - IRIS4D_VCHAR/2);
  252.   charstr(str);
  253.   return;
  254. }
  255.  
  256.  
  257. TERM_PUBLIC void IRIS4D_reset()
  258. {
  259.   return;
  260. }
  261.  
  262. #endif /* TERM_BODY */
  263.  
  264. #ifdef TERM_TABLE
  265.  
  266. TERM_TABLE_START(iris4d_driver)
  267.     "iris4d", "Silicon Graphics IRIS 4D Series Computer",
  268.        IRIS4D_XMAX, IRIS4D_YMAX, IRIS4D_VCHAR, IRIS4D_HCHAR, 
  269.        IRIS4D_VTIC, IRIS4D_HTIC, IRIS4D_options, IRIS4D_init, IRIS4D_reset, 
  270.        IRIS4D_text, null_scale, IRIS4D_graphics, IRIS4D_move, IRIS4D_vector,
  271.        IRIS4D_linetype, IRIS4D_put_text, null_text_angle, 
  272.        null_justify_text, do_point, do_arrow, set_font_null
  273. TERM_TABLE_END(iris4d_driver)
  274.  
  275. #undef LAST_TERM
  276. #define LAST_TERM iris4d_driver
  277.  
  278. #endif /* TERM_TABLE */
  279. #endif /* TERM_PROTO_ONLY */
  280.  
  281. /*
  282.  * NAME: iris4d
  283.  *
  284.  * OPTIONS: colour-depth (legal 8, 24; default 8) in bit
  285.  *
  286.  * SUPPORTS: Silicon Graphics IRIS 4D Series Computer
  287.  *
  288.  * Further Info: none
  289.  *
  290.  */