File: eepic.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 (369 lines) | stat: -rw-r--r-- 10,374 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
/*
 * $Id: eepic.trm,v 1.16 1997/05/27 01:29:51 drd Exp $
 *
 */

/* GNUPLOT - eepic.trm */
/*
 * Copyright (C) 1990 - 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:
 *   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)
 */

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

#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 angle));
TERM_PUBLIC void EEPIC_reset __PROTO((void));

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

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

#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) */
#define GOT_EEPIC_PROTO
#endif

#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 */
void best_latex_arrow __PROTO((int sx, int sy, int ex, int ey, int who, TBOOLEAN head)); /* figure out the best arrow */

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


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

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


TERM_PUBLIC void EEPIC_text()
{
    EEPIC_endline();
    fprintf(outfile, "\\end{picture}\n");
}


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(outfile, "\\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(outfile, "%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(outfile, "\n");
		  fprintf(outfile, "%s(%u,%u)", 
				EEPIC_lines[EEPIC_type+2], 
				EEPIC_posx, EEPIC_posy);
		  EEPIC_linecount = 1;
	   }
    }
    fprintf(outfile, "(%u,%u)", ux,uy);
    EEPIC_posx = ux;
    EEPIC_posy = uy;
}

void
EEPIC_endline()
{
    if (EEPIC_inline) {
	   fprintf(outfile, "\n");
	   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(outfile, "\\put(%d,%d)",x,y);
    switch(eepic_angle) {  
 	   case 0: {
		  switch(eepic_justify) {
			 case LEFT: {
				fprintf(outfile,
					   "{\\makebox(0,0)[l]{%s}}\n", str);
				break;
			 }
			 case CENTRE: {
				fprintf(outfile,
					   "{\\makebox(0,0){%s}}\n", str);
				break;
			 }
			 case RIGHT: {
				fprintf(outfile,
					   "{\\makebox(0,0)[r]{%s}}\n", str);
				break;
			 }
		  }
		  break;
	   }
	   case 1: {			/* put text in a short stack */
		  switch(eepic_justify) {
			 case LEFT: {
				fprintf(outfile,
					   "{\\makebox(0,0)[lb]{\\shortstack{%s}}}\n", str);
				break;
			 }
			 case CENTRE: {
				fprintf(outfile,
					   "{\\makebox(0,0)[l]{\\shortstack{%s}}}\n", str);
				break;
			 }
			 case RIGHT: {
				fprintf(outfile,
					   "{\\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(angle)
	int angle;
{
    /* 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 = angle;
    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",
"?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.",
"",
" The `eepic` terminal has no options."
END_HELP(eepic)
#endif