Annotation of OpenXM_contrib/gnuplot/term/iris4d.trm, Revision 1.1
1.1 ! maekawa 1: /*
! 2: * $Id: iris4d.trm,v 1.16 1998/04/14 00:17:52 drd Exp $
! 3: *
! 4: */
! 5:
! 6: /* GNUPLOT - iris4d.trm */
! 7:
! 8: /*[
! 9: * Copyright 1990 - 1993, 1998 Thomas Williams, Colin Kelley
! 10: *
! 11: * Permission to use, copy, and distribute this software and its
! 12: * documentation for any purpose with or without fee is hereby granted,
! 13: * provided that the above copyright notice appear in all copies and
! 14: * that both that copyright notice and this permission notice appear
! 15: * in supporting documentation.
! 16: *
! 17: * Permission to modify the software is granted, but not the right to
! 18: * distribute the complete modified source code. Modifications are to
! 19: * be distributed as patches to the released version. Permission to
! 20: * distribute binaries produced by compiling modified sources is granted,
! 21: * provided you
! 22: * 1. distribute the corresponding source modifications from the
! 23: * released version in the form of a patch file along with the binaries,
! 24: * 2. add special version identification to distinguish your version
! 25: * in addition to the base release version number,
! 26: * 3. provide your name and address as the primary contact for the
! 27: * support of your modified version, and
! 28: * 4. retain our contact information in regard to use of the base
! 29: * software.
! 30: * Permission to distribute the released version of the source code along
! 31: * with corresponding source modifications in the form of a patch file is
! 32: * granted with same provisions 2 through 4 for binary distributions.
! 33: *
! 34: * This software is provided "as is" without express or implied warranty
! 35: * to the extent permitted by applicable law.
! 36: ]*/
! 37:
! 38: /*
! 39: * This file is included by ../term.c.
! 40: *
! 41: * This terminal driver supports:
! 42: * IRIS terminals
! 43: *
! 44: * AUTHORS
! 45: * John H. Merritt
! 46: * (Applied Research Corporation) 7/1/89
! 47: * INTERNET: merritt@iris613.gsfc.nasa.gov
! 48: *
! 49: * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
! 50: *
! 51: */
! 52: /*
! 53: * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
! 54: */
! 55:
! 56: #include "driver.h"
! 57:
! 58: #ifdef TERM_REGISTER
! 59: register_term(iris4d)
! 60: #endif
! 61:
! 62: #ifdef TERM_PROTO
! 63: TERM_PUBLIC void IRIS4D_options __PROTO((void));
! 64: TERM_PUBLIC void IRIS4D_init __PROTO((void));
! 65: TERM_PUBLIC void IRIS4D_graphics __PROTO((void));
! 66: TERM_PUBLIC void IRIS4D_text __PROTO((void));
! 67: TERM_PUBLIC void IRIS4D_linetype __PROTO((int linetype));
! 68: TERM_PUBLIC void IRIS4D_move __PROTO((unsigned int x, unsigned int y));
! 69: TERM_PUBLIC void IRIS4D_vector __PROTO((unsigned int x, unsigned int y));
! 70: TERM_PUBLIC void IRIS4D_put_text __PROTO((unsigned int x, unsigned int y, char *str));
! 71: TERM_PUBLIC void IRIS4D_reset __PROTO((void));
! 72: #define IRIS4D_XMAX 1024
! 73: #define IRIS4D_YMAX 1024
! 74: #define IRIS4D_VCHAR (IRIS4D_YMAX/30)
! 75: #define IRIS4D_HCHAR (IRIS4D_XMAX/72)
! 76: #define IRIS4D_VTIC (IRIS4D_YMAX/80)
! 77: #define IRIS4D_HTIC (IRIS4D_XMAX/80)
! 78: #endif /* TERM_PROTO */
! 79:
! 80: #ifndef TERM_PROTO_ONLY
! 81: #ifdef TERM_BODY
! 82: void IRIS4D_cmove __PROTO((unsigned int x, unsigned int y));
! 83: #include <gl.h>
! 84:
! 85: #define IRIS4DRC ".gnuplot_iris4d"
! 86:
! 87: #define IRIS4D_XLAST (IRIS4D_XMAX - 1)
! 88: #define IRIS4D_YLAST (IRIS4D_YMAX - 1)
! 89:
! 90:
! 91: static short colors24bits[][3] =
! 92: {
! 93: {85, 85, 85}, /* 0. BACK GROUND ( DARKGRAY ) */
! 94: {0, 0, 0}, /* 1. BLACK */
! 95: {170, 0, 170}, /* 2. MAGENTA */
! 96: {85, 255, 255}, /* 3. LIGHTCYAN */
! 97: {170, 0, 0}, /* 4. RED */
! 98: {0, 170, 0}, /* 5. GREEN */
! 99: {255, 85, 255}, /* 6. LIGHTMAGENTA */
! 100: {255, 255, 85}, /* 7. YELLOW */
! 101: {255, 85, 85}, /* 8. LIGHTRED */
! 102: {85, 255, 85}, /* 9. LIGHTGREEN */
! 103: {0, 170, 170}, /* 10. CYAN */
! 104: {170, 170, 0}, /* 11. BROWN */
! 105: };
! 106: #define COLOR24_SIZE (sizeof(colors24bits) / (sizeof(short) * 3))
! 107:
! 108: static iris24bits = FALSE;
! 109:
! 110: #define IRIS4D_BACKGROUND 0
! 111: #define IRIS4D_BLACK 1
! 112: #define IRIS4D_MAGENTA 2
! 113: #define IRIS4D_LIGHTCYAN 3
! 114: #define IRIS4D_RED 4
! 115: #define IRIS4D_GREEN 5
! 116: #define IRIS4D_LIGHTMAGENTA 6
! 117: #define IRIS4D_YELLOW 7
! 118: #define IRIS4D_LIGHTRED 8
! 119: #define IRIS4D_LIGHTGREEN 9
! 120: #define IRIS4D_CYAN 10
! 121: #define IRIS4D_BROWN 11
! 122:
! 123: TERM_PUBLIC void IRIS4D_options()
! 124: {
! 125: int i = 0;
! 126: struct value a;
! 127:
! 128: if (!END_OF_COMMAND) {
! 129: i = (int) real(const_express(&a));
! 130: }
! 131: iris24bits = (i == 24);
! 132:
! 133: sprintf(term_options, "%s", iris24bits ? "24" : "8");
! 134: }
! 135:
! 136: TERM_PUBLIC void IRIS4D_init()
! 137: {
! 138: int i;
! 139: char homedirfile[80], line[80];
! 140: FILE *f;
! 141:
! 142: foreground();
! 143: winopen("Gnuplot");
! 144: if (iris24bits) {
! 145: RGBmode();
! 146: gconfig();
! 147: }
! 148: /* BAD CODING STYLE! What about error checking? lh */
! 149: strcat(strcat(strcpy(homedirfile, getenv("HOME")), "/"), IRIS4DRC);
! 150: if ((f = fopen(IRIS4DRC, "r")) != NULL ||
! 151: (f = fopen(homedirfile, "r")) != NULL) {
! 152: int c1, c2, c3;
! 153: for (i = 0; i < COLOR24_SIZE; i++) {
! 154: if (fgets(line, 79, f) == NULL ||
! 155: sscanf(line, "%d %d %d", &c1, &c2, &c3) != 3)
! 156: int_error("Iris4d color file terminated prematurely or wrong format.\n", NO_CARET);
! 157: colors24bits[i][0] = c1;
! 158: colors24bits[i][1] = c2;
! 159: colors24bits[i][2] = c3;
! 160: }
! 161:
! 162: fclose(f);
! 163: }
! 164: deflinestyle(1, 0x3FFF); /* long dash */
! 165: deflinestyle(2, 0x5555); /* dotted */
! 166: deflinestyle(3, 0x3333); /* short dash */
! 167: deflinestyle(4, 0xB5AD); /* dotdashed */
! 168: deflinestyle(5, 0x0F0F); /* dashed */
! 169: deflinestyle(6, 0xBBBB); /* dotdashed */
! 170: deflinestyle(7, 0x3F3F); /* mid-long dash */
! 171: deflinestyle(8, 0x7777); /* mid-long dash */
! 172:
! 173: return;
! 174: }
! 175:
! 176: TERM_PUBLIC void IRIS4D_graphics()
! 177: {
! 178: reshapeviewport();
! 179: ortho2((Coord) 0, (Coord) IRIS4D_XMAX, (Coord) 0, (Coord) IRIS4D_YMAX);
! 180: if (iris24bits)
! 181: RGBcolor(colors24bits[IRIS4D_BACKGROUND][0],
! 182: colors24bits[IRIS4D_BACKGROUND][1],
! 183: colors24bits[IRIS4D_BACKGROUND][2]);
! 184: else
! 185: color(WHITE);
! 186:
! 187: clear();
! 188:
! 189: return;
! 190: }
! 191:
! 192: TERM_PUBLIC void IRIS4D_text()
! 193: {
! 194: gflush(); /* flush buffer */
! 195: return; /* enter text from another window!!! */
! 196: }
! 197:
! 198: TERM_PUBLIC void IRIS4D_linetype(linetype)
! 199: int linetype;
! 200: {
! 201: static int pen_color_24[11] =
! 202: {
! 203: IRIS4D_BLACK, /* reserved for border and numbers */
! 204: IRIS4D_MAGENTA, /* reserved for axis traces */
! 205: IRIS4D_LIGHTCYAN,
! 206: IRIS4D_RED,
! 207: IRIS4D_GREEN,
! 208: IRIS4D_LIGHTMAGENTA,
! 209: IRIS4D_YELLOW,
! 210: IRIS4D_LIGHTRED,
! 211: IRIS4D_LIGHTGREEN,
! 212: IRIS4D_CYAN,
! 213: IRIS4D_BROWN,
! 214: };
! 215: static int pen_color[8] =
! 216: {0, 1, 4, 5, 6, 1, 2, 4};
! 217:
! 218: if (iris24bits) {
! 219: int pencolor = pen_color_24[linetype < 0 ? linetype + 2 : linetype % 9 + 2];
! 220:
! 221: RGBcolor(colors24bits[pencolor][0],
! 222: colors24bits[pencolor][1],
! 223: colors24bits[pencolor][2]);
! 224: /* Make all lines solid (linestyle 0) upto to the ninth. If more than
! 225: * 9 colors are needed, start to use the different line styles (1 to 8).
! 226: */
! 227: setlinestyle(linetype < 9 ? 0 : (linetype + 2) % 8 + 1);
! 228: } else {
! 229: linetype = linetype % 8;
! 230: color((Colorindex) pen_color[linetype]);
! 231: setlinestyle(linetype);
! 232: }
! 233: return;
! 234: }
! 235:
! 236: TERM_PUBLIC void IRIS4D_move(x, y)
! 237: unsigned int x, y;
! 238: {
! 239: move2i(x, y);
! 240: return;
! 241: }
! 242:
! 243: void IRIS4D_cmove(x, y)
! 244: unsigned int x, y;
! 245: {
! 246: cmov2i(x, y);
! 247: return;
! 248: }
! 249:
! 250: TERM_PUBLIC void IRIS4D_vector(x, y)
! 251: unsigned int x, y;
! 252: {
! 253: draw2i(x, y);
! 254: return;
! 255: }
! 256:
! 257:
! 258: TERM_PUBLIC void IRIS4D_put_text(x, y, str)
! 259: unsigned int x, y;
! 260: char *str;
! 261: {
! 262: IRIS4D_cmove(x, y - IRIS4D_VCHAR / 2);
! 263: charstr(str);
! 264: return;
! 265: }
! 266:
! 267:
! 268: TERM_PUBLIC void IRIS4D_reset()
! 269: {
! 270: return;
! 271: }
! 272:
! 273: #endif /* TERM_BODY */
! 274:
! 275: #ifdef TERM_TABLE
! 276:
! 277: TERM_TABLE_START(iris4d_driver)
! 278: "iris4d", "Silicon Graphics IRIS 4D Series Computer",
! 279: IRIS4D_XMAX, IRIS4D_YMAX, IRIS4D_VCHAR, IRIS4D_HCHAR,
! 280: IRIS4D_VTIC, IRIS4D_HTIC, IRIS4D_options, IRIS4D_init, IRIS4D_reset,
! 281: IRIS4D_text, null_scale, IRIS4D_graphics, IRIS4D_move, IRIS4D_vector,
! 282: IRIS4D_linetype, IRIS4D_put_text, null_text_angle,
! 283: null_justify_text, do_point, do_arrow, set_font_null
! 284: TERM_TABLE_END(iris4d_driver)
! 285:
! 286: #undef LAST_TERM
! 287: #define LAST_TERM iris4d_driver
! 288:
! 289: #endif /* TERM_TABLE */
! 290: #endif /* TERM_PROTO_ONLY */
! 291:
! 292: #ifdef TERM_HELP
! 293: START_HELP(iris4d)
! 294: "1 iris4d",
! 295: "?commands set terminal iris4d",
! 296: "?set terminal iris4d",
! 297: "?set term iris4d",
! 298: "?terminal iris4d",
! 299: "?term iris4d",
! 300: "?iris4d",
! 301: " The `iris4d` terminal driver supports Silicon Graphics IRIS 4D computers.",
! 302: " Its only option is 8- or 24-bit color depth. The default is 8.",
! 303: "",
! 304: " Syntax:",
! 305: " set terminal iris4d {8 | 24}",
! 306: "",
! 307: " The color depth is not really a choice -- the value appropriate for the",
! 308: " hardware should be selected.",
! 309: "",
! 310: " When using 24-bit mode, the colors can be directly specified via the file",
! 311: " .gnuplot_iris4d that is searched in the current directory and then in the",
! 312: " home directory specified by the HOME environment variable. This file holds",
! 313: " RGB values for the background, border, labels and nine plotting colors, in",
! 314: " that order. For example, here is a file containing the default colors:",
! 315: "",
! 316: " 85 85 85 Background (dark gray)",
! 317: " 0 0 0 Boundary (black)",
! 318: " 170 0 170 Labeling (magenta)",
! 319: " 85 255 255 Plot Color 1 (light cyan)",
! 320: " 170 0 0 Plot Color 2 (red)",
! 321: " 0 170 0 Plot Color 3 (green)",
! 322: " 255 85 255 Plot Color 4 (light magenta)",
! 323: " 255 255 85 Plot Color 5 (yellow)",
! 324: " 255 85 85 Plot Color 6 (light red)",
! 325: " 85 255 85 Plot Color 7 (light green)",
! 326: " 0 170 170 Plot Color 8 (cyan)",
! 327: " 170 170 0 Plot Color 9 (brown)",
! 328: "",
! 329: " This file must have exactly 12 lines of RGB triples. No empty lines are",
! 330: " allowed, and anything after the third number on a line is ignored."
! 331: END_HELP(iris4d)
! 332: #endif /* TERM_TABLE */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>