File: eepic.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 (417 lines) | stat: -rw-r--r-- 12,277 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
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
/*
 * $Id: eepic.trm,v 1.8 1998/12/14 18:38:47 lhecking Exp $
 *
 */

/* GNUPLOT - eepic.trm */

/*[
 * Copyright 1990 - 1993, 1998
 *
 * 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:
 *   The EEPIC macros for LaTeX. 
 *
 * AUTHORS
 *   David Kotz
 *
 * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
 * 
 */
/*
 *  This file contains the eepic terminal driver, intended for use with the 
 *  eepic.sty macro package for LaTeX. This is an alternative to the 
 *  latex driver. You need eepic.sty, epic.sty, and a printer driver that
 *  supports the tpic \specials.
 *
 * Although dotted and dashed lines are possible with EEPIC, and are
 * tempting, they do not work well for high-sample-rate curves, mushing
 * the dashes all together into a solid line. For now anyway, the EEPIC
 * driver will have only solid lines. Anyone got a solution?
 *
 * LATEX must also be defined.
 */
/*
 * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
 */

#include "driver.h"

#ifdef TERM_REGISTER
register_term(eepic)
#endif

#ifdef TERM_PROTO
TERM_PUBLIC void EEPIC_init __PROTO((void));
TERM_PUBLIC void EEPIC_graphics __PROTO((void));
TERM_PUBLIC void EEPIC_text __PROTO((void));
TERM_PUBLIC void EEPIC_linetype __PROTO((int linetype));
TERM_PUBLIC void EEPIC_move __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void EEPIC_point __PROTO((unsigned int x, unsigned int y,
				      int number));
TERM_PUBLIC void EEPIC_vector __PROTO((unsigned int ux, unsigned int uy));
TERM_PUBLIC void EEPIC_arrow __PROTO((unsigned int sx, unsigned int sy,
				      unsigned int ex, unsigned int ey,
				      TBOOLEAN head));
TERM_PUBLIC void EEPIC_put_text __PROTO((unsigned int x, unsigned int y,
					 char str[]));
TERM_PUBLIC int EEPIC_justify_text __PROTO((enum JUSTIFY mode));
TERM_PUBLIC int EEPIC_text_angle __PROTO((int ang));
TERM_PUBLIC void EEPIC_reset __PROTO((void));

#define EEPIC_PTS_PER_INCH (72.27)
/* resolution of printer we expect to use */
#define DOTS_PER_INCH (300)
/* dot size in pt */
#define EEPIC_UNIT (EEPIC_PTS_PER_INCH/DOTS_PER_INCH)

/* 5 inches wide by 3 inches high (default) */
/* (EEPIC_PTS_PER_INCH/EEPIC_UNIT*5.0) */
#define EEPIC_XMAX (5*DOTS_PER_INCH)
/* (EEPIC_PTS_PER_INCH/EEPIC_UNIT*3.0) */
#define EEPIC_YMAX (3*DOTS_PER_INCH)

#define EEPIC_HTIC (5*DOTS_PER_INCH/72)		/* (5./EEPIC_UNIT) */
#define EEPIC_VTIC (5*DOTS_PER_INCH/72)		/* (5./EEPIC_UNIT) */
#define EEPIC_HCHAR (DOTS_PER_INCH*53/10/72)	/* (5.3/EEPIC_UNIT) */
#define EEPIC_VCHAR (DOTS_PER_INCH*11/72)	/* (11./EEPIC_UNIT) */
#endif /* TERM_PROTO */

#ifndef TERM_PROTO_ONLY
#ifdef TERM_BODY

static unsigned int EEPIC_posx;
static unsigned int EEPIC_posy;
enum JUSTIFY eepic_justify = LEFT;
static int eepic_angle = 0;

/* for DOTS point style */
#define EEPIC_TINY_DOT "\\rule{.1pt}{.1pt}"

/* POINTS */
#define EEPIC_POINT_TYPES 12	/* we supply more point types */
static char GPFAR *GPFAR EEPIC_points[] =
{
    "\\raisebox{-1.2pt}{\\makebox(0,0){$\\Diamond$}}",
    "\\makebox(0,0){$+$}",
    "\\raisebox{-1.2pt}{\\makebox(0,0){$\\Box$}}",
    "\\makebox(0,0){$\\times$}",
    "\\makebox(0,0){$\\triangle$}",
    "\\makebox(0,0){$\\star$}",
    "\\circle{12}", "\\circle{18}", "\\circle{24}",
    "\\circle*{12}", "\\circle*{18}", "\\circle*{24}"
};

/* LINES */
#define EEPIC_NUMLINES 5	/* number of linetypes below */
static char GPFAR *GPFAR EEPIC_lines[] =
{
    "\\thicklines \\path",	/* -2 border */
    "\\thinlines \\drawline[-50]",	/* -1 axes */
    "\\thinlines \\path",	/*  0 solid thin  */
    "\\thicklines \\path",	/*  1 solid thick */
    "\\Thicklines \\path",	/*  2 solid Thick */
};
/* These are other possibilities
    "\\thinlines \\dottedline{30}",
    "\\thinlines \\drawline[-30]",	
    "\\thinlines \\dottedline{60}",
    "\\thinlines \\drawline[-60]",	
    "\\thinlines \\dashline[-10]{20}[6]"
*/
static int EEPIC_type;		/* current line type */
static TBOOLEAN EEPIC_inline = FALSE;	/* are we in the middle of a line */
void EEPIC_endline __PROTO((void));	/* terminate any line in progress */
static int EEPIC_linecount = 0;	/* number of points in line so far */
#define EEPIC_LINEMAX 50	/* max value for linecount */

/* ARROWS */
/* we use the same code as for LATEX */
/* figure out the best arrow */
void best_latex_arrow __PROTO((int sx, int sy, int ex, int ey, int who,
			       TBOOLEAN head));

TERM_PUBLIC void EEPIC_init()
{
    EEPIC_posx = EEPIC_posy = 0;
    EEPIC_linetype(-1);
    fprintf(gpoutfile, "%% GNUPLOT: LaTeX picture using EEPIC macros\n\
\\setlength{\\unitlength}{%fpt}\n", EEPIC_UNIT);
}


TERM_PUBLIC void EEPIC_graphics()
{
    register struct termentry *t = term;

    fprintf(gpoutfile, "\\begin{picture}(%d,%d)(0,0)\n\
\\footnotesize\n", t->xmax, t->ymax);

}


TERM_PUBLIC void EEPIC_text()
{
    EEPIC_endline();
    fputs("\\end{picture}\n", gpoutfile);
}


TERM_PUBLIC void EEPIC_linetype(linetype)
int linetype;
{
    EEPIC_endline();

    if (linetype >= EEPIC_NUMLINES - 2)
	linetype %= (EEPIC_NUMLINES - 2);

    EEPIC_type = linetype;
}



TERM_PUBLIC void EEPIC_move(x, y)
unsigned int x, y;
{
    EEPIC_endline();

    EEPIC_posx = x;
    EEPIC_posy = y;
}


TERM_PUBLIC void EEPIC_point(x, y, number) /* version of line_and_point */
unsigned int x, y;
int number;			/* type of point */
{
    EEPIC_move(x, y);

    /* Print the character defined by 'number'; number < 0 means 
       to use a dot, otherwise one of the defined points. */
    fprintf(gpoutfile, "\\put(%d,%d){%s}\n", x, y,
	    (number < 0 ? EEPIC_TINY_DOT
	     : EEPIC_points[number % EEPIC_POINT_TYPES]));
}


TERM_PUBLIC void EEPIC_vector(ux, uy)
unsigned int ux, uy;
{
    if (!EEPIC_inline) {
	EEPIC_inline = TRUE;

	/* Start a new line. This depends on line type */
	fprintf(gpoutfile, "%s(%u,%u)",
		EEPIC_lines[EEPIC_type + 2],
		EEPIC_posx, EEPIC_posy);
	EEPIC_linecount = 1;
    } else {
	/* Even though we are in middle of a path, 
	 * we may want to start a new path command. 
	 * If they are too long then latex will choke.
	 */
	if (EEPIC_linecount++ >= EEPIC_LINEMAX) {
	    fprintf(gpoutfile, "\n%s(%u,%u)",
		    EEPIC_lines[EEPIC_type + 2],
		    EEPIC_posx, EEPIC_posy);
	    EEPIC_linecount = 1;
	}
    }
    fprintf(gpoutfile, "(%u,%u)", ux, uy);
    EEPIC_posx = ux;
    EEPIC_posy = uy;
}

void EEPIC_endline()
{
    if (EEPIC_inline) {
	putc('\n', gpoutfile);
	EEPIC_inline = FALSE;
    }
}


TERM_PUBLIC void EEPIC_arrow(sx, sy, ex, ey, head)
unsigned int sx, sy, ex, ey;
TBOOLEAN head;
{
    best_latex_arrow(sx, sy, ex, ey, 2, head);	/* call latex routine */

    EEPIC_posx = ex;
    EEPIC_posy = ey;
}


TERM_PUBLIC void EEPIC_put_text(x, y, str)
unsigned int x, y;		/* reference point of string */
char str[];			/* the text */
{
    EEPIC_endline();

    fprintf(gpoutfile, "\\put(%d,%d)", x, y);
    if ((str[0] == '{') || (str[0] == '[')) {
	fprintf(gpoutfile, "{\\makebox(0,0)%s}\n", str);
    } else
	switch (eepic_angle) {
	case 0:{
		switch (eepic_justify) {
		case LEFT:{
			fprintf(gpoutfile,
				"{\\makebox(0,0)[l]{%s}}\n", str);
			break;
		    }
		case CENTRE:{
			fprintf(gpoutfile,
				"{\\makebox(0,0){%s}}\n", str);
			break;
		    }
		case RIGHT:{
			fprintf(gpoutfile,
				"{\\makebox(0,0)[r]{%s}}\n", str);
			break;
		    }
		}
		break;
	    }
	case 1:{		/* put text in a short stack */
		switch (eepic_justify) {
		case LEFT:{
			fprintf(gpoutfile,
				"{\\makebox(0,0)[lb]{\\shortstack{%s}}}\n", str);
			break;
		    }
		case CENTRE:{
			fprintf(gpoutfile,
				"{\\makebox(0,0)[l]{\\shortstack{%s}}}\n", str);
			break;
		    }
		case RIGHT:{
			fprintf(gpoutfile,
				"{\\makebox(0,0)[lt]{\\shortstack{%s}}}\n", str);
			break;
		    }
		}
		break;
	    }
	}
}



TERM_PUBLIC int EEPIC_justify_text(mode)
enum JUSTIFY mode;
{
    eepic_justify = mode;
    return (TRUE);
}

TERM_PUBLIC int EEPIC_text_angle(ang)
int ang;
{
    /* we can't really write text vertically, but this will 
       put the ylabel centred at the left of the plot, and
       then we'll make a \shortstack */
    eepic_angle = ang;
    return (TRUE);
}

TERM_PUBLIC void EEPIC_reset()
{
    EEPIC_endline();
    EEPIC_posx = EEPIC_posy = 0;
}

#endif

#ifdef TERM_TABLE

TERM_TABLE_START(eepic_driver)
    "eepic", "EEPIC -- extended LaTeX picture environment",
    EEPIC_XMAX, EEPIC_YMAX, EEPIC_VCHAR, EEPIC_HCHAR,
    EEPIC_VTIC, EEPIC_HTIC, options_null, EEPIC_init, EEPIC_reset,
    EEPIC_text, null_scale, EEPIC_graphics, EEPIC_move, EEPIC_vector,
    EEPIC_linetype, EEPIC_put_text, EEPIC_text_angle,
    EEPIC_justify_text, EEPIC_point, EEPIC_arrow, set_font_null
TERM_TABLE_END(eepic_driver)

#undef LAST_TERM
#define LAST_TERM eepic_driver

#endif
#endif

#ifdef TERM_HELP
START_HELP(eepic)
"1 eepic",
"?commands set terminal eepic",
"?set terminal eepic",
"?set term eepic",
"?terminal eepic",
"?term eepic",
"?eepic",
" The `eepic` terminal driver supports the extended LaTeX picture environment.",
" It is an alternative to the `latex` driver.",
"",
" The output of this terminal is intended for use with the \"eepic.sty\" macro",
" package for LaTeX.  To use it, you need \"eepic.sty\", \"epic.sty\" and a",
" printer driver that supports the \"tpic\" \\specials.  If your printer driver",
" doesn't support those \\specials, \"eepicemu.sty\" will enable you to use some",
" of them.",
"",
" Although dotted and dashed lines are possible with `eepic` and are tempting,",
" they do not work well for high-sample-rate curves, fusing the dashes all",
" together into a solid line.  For now, the `eepic` driver creates only solid",
" lines.  There is another gnuplot driver (`tpic`) that supports dashed lines,",
" but it cannot be used if your DVI driver doesn't support \"tpic\" \\specials.",
"",
" All drivers for LaTeX offer a special way of controlling text positioning:",
" If any text string begins with '{', you also need to include a '}' at the",
" end of the text, and the whole text will be centered both horizontally",
" and vertically by LaTeX. --- If the text string begins with '[', you need",
" to continue it with: a position specification (up to two out of t,b,l,r),",
" ']{', the text itself, and finally, '}'. The text itself may be anything",
" LaTeX can typeset as an LR-box. \\rule{}{}'s may help for best positioning.",
"",
" The `eepic` terminal has no options.",
"",
" Examples:",
" About label positioning:",
" Use gnuplot defaults (mostly sensible, but sometimes not really best):",
"        set title '\\LaTeX\\ -- $ \\gamma $'",
" Force centering both horizontally and vertically:",
"        set label '{\\LaTeX\\ -- $ \\gamma $}' at 0,0",
" Specify own positioning (top here):",
"        set xlabel '[t]{\\LaTeX\\ -- $ \\gamma $}'",
" The other label -- account for long ticlabels:",
"        set ylabel '[r]{\\LaTeX\\ -- $ \\gamma $\\rule{7mm}{0pt}'"
END_HELP(eepic)
#endif /* TERM_HELP */