File: gnugraph.trm

package info (click to toggle)
gnuplot 3.5beta6.340-5
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 4,792 kB
  • ctags: 4,205
  • sloc: ansic: 41,878; asm: 539; makefile: 498; objc: 379; csh: 297; sh: 277; pascal: 194; perl: 138; lisp: 88
file content (282 lines) | stat: -rw-r--r-- 7,176 bytes parent folder | download
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
/* GNUPLOT -- gnugraph.trm */
/*
 * Copyright (C) 1993, 1997
 *
 * 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 modified code.  Modifications are to be distributed 
 * as patches to released version.
 *  
 * This software  is provided "as is" without express or implied warranty.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  GNU plot(5) graphics language
 *
 * AUTHORS
 *  Tony Richardson from the unixplot.trm by Colin Kelley, Thomas Williams,
 *  and Russell Lang and from post.trm by Russell Lang.
 * 
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 */

/*
 * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
 */

/*
 * This version of the 'unixplot' driver produces device independent
 * output.  I've chosen parameter values so that the PostScript output
 * produced by plot2ps is 5" x 3".  You can use the 'set size' command
 * to get output up to 8.25" x 8.25", i.e. size values larger than
 * 1 are okay.
 */

/*
Unixplot library writes to stdout.  A fix was put in place by
..!arizona!naucse!jdc to let set term and set output redirect
stdout.  All other terminals write to outfile.
*/

/* This is a device independent format, so the output should look
 * look "reasonable" on any output device.  I set things up there so
 * that the output of plot2ps is 5" x 3" (standard GNUPLOT size).
 * You can use GNUPLOT's size command to obtain plots to almost the
 * 8.25" x 8.25" limit.
 */

#ifndef GOT_DRIVER_H
#include "driver.h"
#endif

#ifdef TERM_REGISTER
register_term(unixplot)
#endif

#ifdef TERM_PROTO
TERM_PUBLIC void UP_options __PROTO((void));
TERM_PUBLIC void UP_init __PROTO((void));
TERM_PUBLIC void UP_graphics __PROTO((void));
TERM_PUBLIC void UP_text __PROTO((void));
TERM_PUBLIC void UP_linetype __PROTO((int linetype));
TERM_PUBLIC void UP_move __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void UP_vector __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void UP_put_text __PROTO((unsigned int x, unsigned int y, char str[]));
TERM_PUBLIC int UP_text_angle __PROTO((int ang));
TERM_PUBLIC int UP_justify_text __PROTO((enum JUSTIFY mode));
TERM_PUBLIC void UP_reset __PROTO((void));
#define UP_XMAX 19859
#define UP_YMAX 11565
/* UP_VCHAR = ((UP_FONTSIZE*UP_YMAX)/(UP_YINCHES*72)) 
            = UP_FONTSIZE*UP_VFONTSC
   UP_HCHAR = ((UP_FONTSIZE/2)*UP_XMAX)/(UP_XINCHES*72))
            = UP_FONTSIZE*UP_HFONTSC
*/

#define UP_VFONTSC  53.5
#define UP_VCHAR    535   /* 10 * VFONTSC */
#define UP_HFONTSC  27.6
#define UP_HCHAR    276   /* 10 * HFONTSC */

#define UP_VTIC (UP_YMAX/80)
#define UP_HTIC (UP_XMAX/80)
#endif /* TERM_PROTO */

#ifndef TERM_PROTO_ONLY
#ifdef TERM_BODY


char up_font[MAX_ID_LEN+1] = "Courier" ; /* name of font */
int up_fontsize = 10;

/* plot2ps produces a 8.25" x 8.25" square. */
#define UP_SCREENX 32768
#define UP_SCREENY 32768
#define UP_SCRXINC 8.25
#define UP_SCRYINC 8.25

/* We want a 5" x 3" graph by default. */
#define UP_XINCHES 5
#define UP_YINCHES 3
/* UP_XMAX = (UP_SCREENX*UP_XINCHES)/UP_SCRXINC
   UP_YMAX (UP_SCREENY*UP_YINCHES)/UP_SCRYINC */

#define UP_XLAST (UP_XMAX - 1)
#define UP_YLAST (UP_YMAX - 1)

/* These offsets center plot2ps output in the middle of the page.  The
 * amount of resizing that can be done is limited. */
/*
 * #define UP_XOFF 6454
 * #define UP_YOFF 10601
 */

/* These offsets give a 1" offset from the lower left corner.  This
 * gives a greater range of permissible values in GNUPLOT's size
 * command. */
#define UP_XOFF 3972
#define UP_YOFF 3972

enum JUSTIFY up_justify=LEFT;

TERM_PUBLIC void UP_options()
{
	if(!END_OF_COMMAND) {
	  if(almost_equals(c_token,"d$efault")) {
		strcpy(up_font,"Courier");
		up_fontsize = 10;
		term->v_char = (unsigned int)(up_fontsize*UP_VFONTSC);
		term->h_char = (unsigned int)(up_fontsize*UP_HFONTSC);
		c_token++;
	  }
	}

        if (!END_OF_COMMAND && isstring(c_token)) {
                quote_str(up_font,c_token, MAX_ID_LEN);
                c_token++;
        }

        if (!END_OF_COMMAND) {
                /* We have font size specified */
                struct value a;
                up_fontsize = (int)real(const_express(&a));
                term->v_char = (unsigned int)(up_fontsize*UP_VFONTSC);
                term->h_char = (unsigned int)(up_fontsize*UP_HFONTSC);
        }

	sprintf(term_options,"\"%s\" %d",up_font,up_fontsize);
}

TERM_PUBLIC void UP_init()
{
	openpl();
	space(0,0,UP_SCREENX-1,UP_SCREENY-1);
	fontname(up_font);
	fontsize(up_fontsize);
}


TERM_PUBLIC void UP_graphics()
{
	erase();
}


TERM_PUBLIC void UP_text()
{
	/* Flush here so that output will be complete. */
	fflush(stdout);
}


TERM_PUBLIC void UP_linetype(linetype)
int linetype;
{
static char *lt[2+5] = {"solid", "longdashed", "solid", "dotted","shortdashed",
	"dotdashed", "longdashed"};

	if (linetype >= 5)
		linetype %= 5;
	linemod(lt[linetype+2]);
}


TERM_PUBLIC void UP_move(x,y)
unsigned int x,y;
{
	move(x+UP_XOFF,y+UP_YOFF);
}


TERM_PUBLIC void UP_vector(x,y)
unsigned int x,y;
{
	cont(x+UP_XOFF,y+UP_YOFF);
}


TERM_PUBLIC void UP_put_text(x,y,str)
unsigned int x,y;
char str[];
{
	UP_move(x,y); /* Don't adjust x and y! It's done in UP_move. */
	switch(up_justify) {
	 case LEFT:
	  alabel('l','c',str);
	  break;
	 case CENTRE:
	  alabel('c','c',str);
	  break;
	 case RIGHT:
	  alabel('r','c',str);
	  break;
	}

}

TERM_PUBLIC int UP_text_angle(ang)
int ang;
{
	rotate(0,0,90*ang);
	return TRUE;
}

TERM_PUBLIC int UP_justify_text(mode)
enum JUSTIFY mode;
{
	up_justify=mode;
	return TRUE;
}

TERM_PUBLIC void UP_reset()
{
	closepl();
}

#endif /* TERM_BODY */

#ifdef TERM_TABLE 

TERM_TABLE_START(unixplot_driver)
    "unixplot", "GNU plot(1) format [\042fontname\042 font_size]",
	   UP_XMAX, UP_YMAX, UP_VCHAR, UP_HCHAR,
	   UP_VTIC, UP_HTIC, UP_options, UP_init, UP_reset,
	   UP_text, null_scale, UP_graphics, UP_move, UP_vector,
	   UP_linetype, UP_put_text, UP_text_angle,
	   UP_justify_text, line_and_point, do_arrow, set_font_null
TERM_TABLE_END(unixplot_driver)

#undef LAST_TERM
#define LAST_TERM unixplot_driver

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

#ifdef TERM_HELP
START_HELP(unixplot)
"1 unixplot",
"?set terminal unixplot",
"?set term unixplot",
"?terminal unixplot",
"?term unixplot",
"?unixplot",
" The `unixplot` driver produces device-independent output in the GNU plot",
" graphics language.  The default size of the PostScript results generated by",
" \"plot2ps\" is 5 x 3 inches; this can be increased up to about 8.25 x 8.25 by",
" `set size`.",
"",
" Syntax:",
"       set terminal unixplot {\"<fontname>\"} {<fontsize>}",
"",
" which defaults to 10-point \"Courier\".",
"",
" There is a non-GNU version of the `unixplot` driver which cannot be compiled",
" unless this version is left out."
END_HELP(unixplot)
#endif