File: iris4d.trm

package info (click to toggle)
gnuplot 3.7.1p1-4
  • links: PTS
  • area: main
  • in suites: potato
  • size: 5,808 kB
  • ctags: 4,418
  • sloc: ansic: 43,279; lisp: 661; makefile: 647; asm: 539; sh: 416; objc: 379; csh: 297; pascal: 194; perl: 138
file content (332 lines) | stat: -rw-r--r-- 9,465 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
/*
 * $Id: iris4d.trm,v 1.6 1998/12/14 18:40:12 lhecking Exp $
 *
 */

/* GNUPLOT - iris4d.trm */

/*[
 * Copyright 1990 - 1993, 1998   Thomas Williams, Colin Kelley
 *
 * Permission to use, copy, and distribute this software and its
 * documentation for any purpose with or without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.
 *
 * Permission to modify the software is granted, but not the right to
 * distribute the complete modified source code.  Modifications are to
 * be distributed as patches to the released version.  Permission to
 * distribute binaries produced by compiling modified sources is granted,
 * provided you
 *   1. distribute the corresponding source modifications from the
 *    released version in the form of a patch file along with the binaries,
 *   2. add special version identification to distinguish your version
 *    in addition to the base release version number,
 *   3. provide your name and address as the primary contact for the
 *    support of your modified version, and
 *   4. retain our contact information in regard to use of the base
 *    software.
 * Permission to distribute the released version of the source code along
 * with corresponding source modifications in the form of a patch file is
 * granted with same provisions 2 through 4 for binary distributions.
 *
 * This software is provided "as is" without express or implied warranty
 * to the extent permitted by applicable law.
]*/

/*
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *   IRIS terminals
 *
 * AUTHORS
 *   John H. Merritt 
 *           (Applied Research Corporation) 7/1/89
 *           INTERNET: merritt@iris613.gsfc.nasa.gov
 * 
 * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
 * 
 */
/*
 * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
 */

#include "driver.h"

#ifdef TERM_REGISTER
register_term(iris4d)
#endif

#ifdef TERM_PROTO
TERM_PUBLIC void IRIS4D_options __PROTO((void));
TERM_PUBLIC void IRIS4D_init __PROTO((void));
TERM_PUBLIC void IRIS4D_graphics __PROTO((void));
TERM_PUBLIC void IRIS4D_text __PROTO((void));
TERM_PUBLIC void IRIS4D_linetype __PROTO((int linetype));
TERM_PUBLIC void IRIS4D_move __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void IRIS4D_vector __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void IRIS4D_put_text __PROTO((unsigned int x, unsigned int y, char *str));
TERM_PUBLIC void IRIS4D_reset __PROTO((void));
#define IRIS4D_XMAX 1024
#define IRIS4D_YMAX 1024
#define IRIS4D_VCHAR (IRIS4D_YMAX/30)
#define IRIS4D_HCHAR (IRIS4D_XMAX/72)
#define IRIS4D_VTIC (IRIS4D_YMAX/80)
#define IRIS4D_HTIC (IRIS4D_XMAX/80)
#endif /* TERM_PROTO */

#ifndef TERM_PROTO_ONLY
#ifdef TERM_BODY
void IRIS4D_cmove __PROTO((unsigned int x, unsigned int y));
#include <gl.h>

#define IRIS4DRC    ".gnuplot_iris4d"

#define IRIS4D_XLAST (IRIS4D_XMAX - 1)
#define IRIS4D_YLAST (IRIS4D_YMAX - 1)


static short colors24bits[][3] =
{
    {85, 85, 85},		/* 0. BACK GROUND ( DARKGRAY ) */
    {0, 0, 0},			/* 1. BLACK */
    {170, 0, 170},		/* 2. MAGENTA */
    {85, 255, 255},		/* 3. LIGHTCYAN */
    {170, 0, 0},		/* 4. RED */
    {0, 170, 0},		/* 5. GREEN */
    {255, 85, 255},		/* 6. LIGHTMAGENTA */
    {255, 255, 85},		/* 7. YELLOW */
    {255, 85, 85},		/* 8. LIGHTRED */
    {85, 255, 85},		/* 9. LIGHTGREEN */
    {0, 170, 170},		/* 10. CYAN */
    {170, 170, 0},		/* 11. BROWN */
};
#define COLOR24_SIZE (sizeof(colors24bits) / (sizeof(short) * 3))

static iris24bits = FALSE;

#define IRIS4D_BACKGROUND	0
#define IRIS4D_BLACK		1
#define IRIS4D_MAGENTA		2
#define IRIS4D_LIGHTCYAN	3
#define IRIS4D_RED		4
#define IRIS4D_GREEN		5
#define IRIS4D_LIGHTMAGENTA	6
#define IRIS4D_YELLOW		7
#define IRIS4D_LIGHTRED		8
#define IRIS4D_LIGHTGREEN	9
#define IRIS4D_CYAN		10
#define IRIS4D_BROWN		11

TERM_PUBLIC void IRIS4D_options()
{
    int i = 0;
    struct value a;

    if (!END_OF_COMMAND) {
	i = (int) real(const_express(&a));
    }
    iris24bits = (i == 24);

    sprintf(term_options, "%s", iris24bits ? "24" : "8");
}

TERM_PUBLIC void IRIS4D_init()
{
    int i;
    char homedirfile[80], line[80];
    FILE *f;

    foreground();
    winopen("Gnuplot");
    if (iris24bits) {
	RGBmode();
	gconfig();
    }
    /* BAD CODING STYLE! What about error checking? lh */
    strcat(strcat(strcpy(homedirfile, getenv("HOME")), "/"), IRIS4DRC);
    if ((f = fopen(IRIS4DRC, "r")) != NULL ||
	(f = fopen(homedirfile, "r")) != NULL) {
	int c1, c2, c3;
	for (i = 0; i < COLOR24_SIZE; i++) {
	    if (fgets(line, 79, f) == NULL ||
		sscanf(line, "%d %d %d", &c1, &c2, &c3) != 3)
		int_error("Iris4d color file terminated prematurely or wrong format.\n", NO_CARET);
	    colors24bits[i][0] = c1;
	    colors24bits[i][1] = c2;
	    colors24bits[i][2] = c3;
	}

	fclose(f);
    }
    deflinestyle(1, 0x3FFF);	/* long dash */
    deflinestyle(2, 0x5555);	/* dotted */
    deflinestyle(3, 0x3333);	/* short dash */
    deflinestyle(4, 0xB5AD);	/* dotdashed */
    deflinestyle(5, 0x0F0F);	/* dashed */
    deflinestyle(6, 0xBBBB);	/* dotdashed */
    deflinestyle(7, 0x3F3F);	/* mid-long dash */
    deflinestyle(8, 0x7777);	/* mid-long dash */

    return;
}

TERM_PUBLIC void IRIS4D_graphics()
{
    reshapeviewport();
    ortho2((Coord) 0, (Coord) IRIS4D_XMAX, (Coord) 0, (Coord) IRIS4D_YMAX);
    if (iris24bits)
	RGBcolor(colors24bits[IRIS4D_BACKGROUND][0],
		 colors24bits[IRIS4D_BACKGROUND][1],
		 colors24bits[IRIS4D_BACKGROUND][2]);
    else
	color(WHITE);

    clear();

    return;
}

TERM_PUBLIC void IRIS4D_text()
{
    gflush();			/* flush buffer */
    return;			/* enter text from another window!!! */
}

TERM_PUBLIC void IRIS4D_linetype(linetype)
int linetype;
{
    static int pen_color_24[11] =
    {
	IRIS4D_BLACK,		/* reserved for border and numbers */
	IRIS4D_MAGENTA,		/* reserved for axis traces */
	IRIS4D_LIGHTCYAN,
	IRIS4D_RED,
	IRIS4D_GREEN,
	IRIS4D_LIGHTMAGENTA,
	IRIS4D_YELLOW,
	IRIS4D_LIGHTRED,
	IRIS4D_LIGHTGREEN,
	IRIS4D_CYAN,
	IRIS4D_BROWN,
    };
    static int pen_color[8] =
    {0, 1, 4, 5, 6, 1, 2, 4};

    if (iris24bits) {
	int pencolor = pen_color_24[linetype < 0 ? linetype + 2 : linetype % 9 + 2];

	RGBcolor(colors24bits[pencolor][0],
		 colors24bits[pencolor][1],
		 colors24bits[pencolor][2]);
	/* Make all lines solid (linestyle 0) upto to the ninth. If more than
	 * 9 colors are needed, start to use the different line styles (1 to 8).
	 */
	setlinestyle(linetype < 9 ? 0 : (linetype + 2) % 8 + 1);
    } else {
	linetype = linetype % 8;
	color((Colorindex) pen_color[linetype]);
	setlinestyle(linetype);
    }
    return;
}

TERM_PUBLIC void IRIS4D_move(x, y)
unsigned int x, y;
{
    move2i(x, y);
    return;
}

void IRIS4D_cmove(x, y)
unsigned int x, y;
{
    cmov2i(x, y);
    return;
}

TERM_PUBLIC void IRIS4D_vector(x, y)
unsigned int x, y;
{
    draw2i(x, y);
    return;
}


TERM_PUBLIC void IRIS4D_put_text(x, y, str)
unsigned int x, y;
char *str;
{
    IRIS4D_cmove(x, y - IRIS4D_VCHAR / 2);
    charstr(str);
    return;
}


TERM_PUBLIC void IRIS4D_reset()
{
    return;
}

#endif /* TERM_BODY */

#ifdef TERM_TABLE

TERM_TABLE_START(iris4d_driver)
    "iris4d", "Silicon Graphics IRIS 4D Series Computer",
    IRIS4D_XMAX, IRIS4D_YMAX, IRIS4D_VCHAR, IRIS4D_HCHAR,
    IRIS4D_VTIC, IRIS4D_HTIC, IRIS4D_options, IRIS4D_init, IRIS4D_reset,
    IRIS4D_text, null_scale, IRIS4D_graphics, IRIS4D_move, IRIS4D_vector,
    IRIS4D_linetype, IRIS4D_put_text, null_text_angle,
    null_justify_text, do_point, do_arrow, set_font_null
TERM_TABLE_END(iris4d_driver)

#undef LAST_TERM
#define LAST_TERM iris4d_driver

#endif /* TERM_TABLE */
#endif /* TERM_PROTO_ONLY */

#ifdef TERM_HELP
START_HELP(iris4d)
"1 iris4d",
"?commands set terminal iris4d",
"?set terminal iris4d",
"?set term iris4d",
"?terminal iris4d",
"?term iris4d",
"?iris4d",
" The `iris4d` terminal driver supports Silicon Graphics IRIS 4D computers.",
" Its only option is 8- or 24-bit color depth.  The default is 8.",
"",
" Syntax:",
"       set terminal iris4d {8 | 24}",
"",
" The color depth is not really a choice -- the value appropriate for the",
" hardware should be selected.",
"",
" When using 24-bit mode, the colors can be directly specified via the file",
" .gnuplot_iris4d that is searched in the current directory and then in the",
" home directory specified by the HOME environment variable.  This file holds",
" RGB values for the background, border, labels and nine plotting colors, in",
" that order.  For example, here is a file containing the default colors:",
"",
"       85   85   85     Background   (dark gray)",
"       0    0    0      Boundary     (black)",
"       170  0    170    Labeling     (magenta)",
"       85   255  255    Plot Color 1 (light cyan)",
"       170  0    0      Plot Color 2 (red)",
"       0    170  0      Plot Color 3 (green)",
"       255  85   255    Plot Color 4 (light magenta)",
"       255  255  85     Plot Color 5 (yellow)",
"       255  85   85     Plot Color 6 (light red)",
"       85   255  85     Plot Color 7 (light green)",
"       0    170  170    Plot Color 8 (cyan)",
"       170  170  0      Plot Color 9 (brown)",
"",
" This file must have exactly 12 lines of RGB triples.  No empty lines are",
" allowed, and anything after the third number on a line is ignored."
END_HELP(iris4d)
#endif /* TERM_TABLE */