home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 500-599 / ff552.lzh / GNUPlot / gnuplot3.lzh / gnuplot / term / iris4d.trm < prev    next >
Text File  |  1991-07-12  |  5KB  |  233 lines

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