home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-03-25 | 42.8 KB | 1,712 lines |
- Newsgroups: comp.sources.misc
- organization: Pixar -- Marin County, California
- subject: v11i076: Gnuplot 2.0 - 11 of 14
- From: thaw@ucbvax.Berkeley.EDU@pixar.UUCP (Tom Williams)
- Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 11, Issue 76
- Submitted-by: thaw@ucbvax.Berkeley.EDU@pixar.UUCP (Tom Williams)
- Archive-name: gnuplot2/part11
-
- This is gnuplot.sh11
-
- --- CUT HERE ---
- #! /bin/sh
- echo x - term/imPcodes.h
- sed 's/^X//' >term/imPcodes.h <<'*-*-END-of-term/imPcodes.h-*-*'
- X/*
- X * Copyright (c) 1985 Regents of the University of California.
- X * All rights reserved. The Berkeley software License Agreement
- X * specifies the terms and conditions for redistribution.
- X *
- X * @(#)imPcodes.h 5.1 (Berkeley) 9/21/85
- X */
- X
- X#define imP_SP 128
- X#define imP_SP1 129
- X#define imP_OLD_MMOVE 130
- X#define imP_MPLUS 131
- X#define imP_MMINUS 132
- X#define imP_MMOVE 133
- X#define imP_SMOVE 134
- X
- X#define imP_SET_ABS_H 135
- X#define imP_SET_REL_H 136
- X#define imP_SET_ABS_V 137
- X#define imP_SET_REL_V 138
- X
- X#define imP_SRULE 192
- X#define imP_BRULE 193
- X
- X#define imP_SET_HPOS 195
- X#define imP_SET_VPOS 196
- X#define imP_CRLF 197
- X#define imP_SGLY 198
- X#define imP_BGLY 199
- X#define imP_DELG 200
- X#define imP_DELC 201
- X#define imP_DELF 202
- X
- X#define imP_SET_HV_SYSTEM 205
- X#define imP_SET_ADV_DIRS 206
- X#define imP_SET_FAMILY 207
- X#define imP_SET_IL 208
- X#define imP_SET_BOL 209
- X#define imP_SET_SP 210
- X#define imP_PUSH 211
- X#define imP_POP 212
- X#define imP_PAGE 213
- X#define imP_SET_PUSH_MASK 214
- X#define imP_ENDPAGE 219
- X
- X#define imP_CREATE_FAMILY_TABLE 221
- X#define imP_CREATE_MAP 222
- X
- X#define imP_CREATE_PATH 230
- X#define imP_SET_TEXTURE 231
- X#define imP_SET_PEN 232
- X#define imP_FILL_PATH 233
- X#define imP_DRAW_PATH 234
- X#define imP_BITMAP 235
- X#define imP_SET_MAGN 236
- X
- X#define imP_EOF 255
- X
- X
- *-*-END-of-term/imPcodes.h-*-*
- echo x - term/imagen.trm
- sed 's/^X//' >term/imagen.trm <<'*-*-END-of-term/imagen.trm-*-*'
- X/* GNUPLOT - imagen.trm */
- X/*
- X * Copyright (C) 1990
- X *
- X * Permission to use, copy, and distribute this software and its
- X * documentation for any purpose with or without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and
- X * that both that copyright notice and this permission notice appear
- X * in supporting documentation.
- X *
- X * Permission to modify the software is granted, but not the right to
- X * distribute the modified code. Modifications are to be distributed
- X * as patches to released version.
- X *
- X * This software is provided "as is" without express or implied warranty.
- X *
- X * This file is included by ../term.c.
- X *
- X * This terminal driver supports:
- X * Imagen laser printers
- X *
- X * AUTHORS
- X * Paul E. McKenney, David Kotz
- X *
- X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
- X *
- X */
- X
- X/*
- X * Original for direct Imagen output (but retaining many of the
- X * LaTeX extensions) by Paul E. McKenney, 1989.
- X * Further modified by David Kotz to fit into gnuplot 2.0.
- X * Information Science and Technology Division, SRI International,
- X * 333 Ravenswood Ave, Menlo Park, CA 94025.
- X * Mail to mckenney@sri.com.
- X */
- X
- X#include "imPcodes.h"
- X
- X#define IMAGEN_PTS_PER_INCH (300)
- X
- X#define IMAGEN_XMAX (10.0 * IMAGEN_PTS_PER_INCH) /* 10.0 inches */
- X#define IMAGEN_YMAX (7.5 * IMAGEN_PTS_PER_INCH) /* 7.5 inches */
- X
- X#define IMAGEN_FONTSIZE 12
- X
- X#define IMAGEN_HTIC (20)
- X#define IMAGEN_VTIC (20)
- X#define IMAGEN_VCHAR (IMAGEN_FONTSIZE*5)
- X#define IMAGEN_HCHAR (IMAGEN_VCHAR/2)
- X
- Xstatic int IMAGEN_orgx; /* absolute-pixel-ORIgin of graph. */
- Xstatic int IMAGEN_orgy;
- Xstatic int IMAGEN_posx; /* current drawing position (lines). */
- Xstatic int IMAGEN_posy;
- Xstatic int IMAGEN_inplot;
- Xstatic int IMAGEN_xmax; /* width of graph in pixels. */
- Xstatic int IMAGEN_ymax; /* height of graph in pixels. */
- Xstatic int IMAGEN_hchar; /* Height of CHAR in current font. */
- Xstatic int IMAGEN_wchar; /* Width of CHAR in current font. */
- Xstatic int IMAGEN_blofs; /* BaseLine OFfSet from bounding box. */
- Xstatic int IMAGEN_angle = -1; /* 0 for horizontal text, 1 for vertical */
- Xstatic enum JUSTIFY IMAGEN_justify = LEFT; /* left/center/right */
- X
- Xstatic IMAGEN_seq_pos; /* position in sequence */
- X
- Xstatic void IMAGEN_putwd();
- Xstatic void IMAGEN_createfamily();
- Xstatic void IMAGEN_setfont();
- Xstatic void IMAGEN_setpos();
- Xstatic char *IMAGEN_cvts();
- X
- XIMAGEN_init()
- X{
- X char font[10]; /* font name */
- X
- X IMAGEN_posx = IMAGEN_posy = 0;
- X
- X IMAGEN_orgx = (11.0 * IMAGEN_PTS_PER_INCH - IMAGEN_XMAX) / 2;
- X IMAGEN_orgy = (8.5 * IMAGEN_PTS_PER_INCH - IMAGEN_YMAX)/ 2;
- X
- X fputs("@document(language impress)", outfile);
- X
- X putc(imP_SET_HV_SYSTEM, outfile);
- X putc((3<<3)|5, outfile);
- X
- X sprintf(font, "cour%02d", IMAGEN_FONTSIZE);
- X IMAGEN_createfamily(font, IMAGEN_FONTSIZE);
- X IMAGEN_setfont(IMAGEN_FONTSIZE);
- X
- X IMAGEN_text_angle(0);
- X
- X putc(imP_SET_ABS_H, outfile);
- X IMAGEN_putwd(0);
- X putc(imP_SET_ABS_V, outfile);
- X IMAGEN_putwd(0);
- X
- X IMAGEN_linetype(-1);
- X}
- X
- XIMAGEN_graphics()
- X{
- X static BOOLEAN first = TRUE;
- X
- X if (!first)
- X putc(imP_ENDPAGE, outfile);
- X first = FALSE;
- X
- X IMAGEN_move(0, 0);
- X}
- X
- XIMAGEN_text()
- X{
- X}
- X
- X
- XIMAGEN_linetype(linetype)
- Xint linetype;
- X{
- X static int lastlinetype = -10;
- X
- X if (linetype < 0)
- X linetype = -linetype;
- X else
- X linetype *= 2;
- X
- X if (lastlinetype == linetype)
- X return;
- X
- X lastlinetype = linetype; /* now >= 0 */
- X
- X putc(imP_SET_PEN, outfile);
- X putc(linetype, outfile);
- X}
- X
- X
- XIMAGEN_move(x,y)
- X unsigned int x,y;
- X{
- X IMAGEN_posx = x;
- X IMAGEN_posy = y;
- X}
- X
- XIMAGEN_vector(ux,uy)
- X unsigned int ux,uy;
- X{
- X /* Create path. */
- X
- X putc(imP_CREATE_PATH, outfile);
- X IMAGEN_putwd(2);
- X IMAGEN_putwd(IMAGEN_posx + IMAGEN_orgx);
- X IMAGEN_putwd(IMAGEN_posy + IMAGEN_orgy);
- X IMAGEN_putwd(ux + IMAGEN_orgx);
- X IMAGEN_putwd(uy + IMAGEN_orgy);
- X
- X /* Draw path with black pen. */
- X
- X putc(imP_DRAW_PATH, outfile);
- X putc(15, outfile);
- X
- X /* Set current position to end of line. */
- X
- X IMAGEN_move(ux, uy);
- X}
- X
- Xstatic void
- XIMAGEN_setpos(ux, uy)
- X int ux,uy;
- X{
- X /* Set x and y position (for text), also set beginning-of-line. */
- X
- X putc(imP_SET_ABS_H, outfile);
- X IMAGEN_putwd(ux + IMAGEN_orgx);
- X putc(imP_SET_ABS_V, outfile);
- X IMAGEN_putwd(uy + IMAGEN_orgy);
- X putc(imP_SET_BOL, outfile);
- X if (IMAGEN_angle == 1)
- X IMAGEN_putwd(uy + IMAGEN_orgx); /* vertical */
- X else
- X IMAGEN_putwd(ux + IMAGEN_orgx); /* horizontal */
- X}
- X
- XIMAGEN_text_angle(angle)
- X int angle;
- X{
- X if (IMAGEN_angle != angle) {
- X IMAGEN_angle = angle; /* record for later use */
- X putc(imP_SET_ADV_DIRS, outfile);
- X putc(angle == 0 ? 0 : 7, outfile); /* 0=>horiz : 7=>vert */
- X }
- X
- X return(TRUE);
- X}
- X
- XIMAGEN_justify_text(mode)
- X enum JUSTIFY mode;
- X{
- X IMAGEN_justify = mode;
- X return(TRUE);
- X}
- X
- Xstatic char *
- XIMAGEN_cvts(str, width, height)
- X char *str;
- X int *width;
- X int *height;
- X{
- X char *cp1;
- X char *cp2;
- X static char *buf = NULL;
- X int h;
- X int maxw;
- X int w;
- X
- X /* Free up old buffer, if there is one, get a new one. Since */
- X /* all transformations shorten the string, get a buffer that is */
- X /* the same size as the input string. */
- X
- X if (buf != NULL)
- X (void) free(buf);
- X buf = (char *) alloc(strlen(str), "converted label string");
- X
- X /* Do the transformations. */
- X
- X cp1 = str;
- X cp2 = buf;
- X h = 1;
- X maxw = 0;
- X w = 0;
- X while (*cp1 != NULL) {
- X switch (*cp1) {
- X case ' ' : /* Space character. */
- X *cp2++ = imP_SP;
- X w++;
- X break;
- X
- X case '\\' : /* Escape sequence. */
- X if (*++cp1 == '\\') {
- X /* Begin new line. */
- X h++;
- X if (w > maxw)
- X maxw = w;
- X w = 0;
- X *cp2++ = imP_CRLF;
- X break;
- X }
- X
- X /* Fall through to just copy next char out. */
- X
- X default :
- X *cp2++ = *cp1;
- X w++;
- X break;
- X }
- X cp1++;
- X }
- X
- X *cp2 = '\0';
- X if (w > maxw)
- X maxw = w;
- X
- X if (height != NULL)
- X *height = IMAGEN_angle ?
- X IMAGEN_wchar * maxw :
- X IMAGEN_hchar * h;
- X if (width != NULL)
- X *width = IMAGEN_angle ?
- X IMAGEN_hchar * h :
- X IMAGEN_wchar * maxw;
- X return (buf);
- X}
- X
- XIMAGEN_put_text(x, y, str)
- X int x,y; /* reference point of string */
- X char str[]; /* the text */
- X{
- X char *cvstr;
- X int height;
- X int width;
- X
- X cvstr = IMAGEN_cvts(str, &width, &height);
- X
- X switch (IMAGEN_justify) {
- X case LEFT: break;
- X case CENTRE: x -= width/2; break;
- X case RIGHT: x -= width; break;
- X }
- X
- X if (IMAGEN_angle) { /* vertical */
- X x += IMAGEN_hchar;
- X y -= height/2;
- X } else /* horizontal */
- X y += height/2 - IMAGEN_hchar;
- X
- X IMAGEN_setpos(x, y + IMAGEN_blofs);
- X fputs(cvstr, outfile);
- X}
- X
- X
- XIMAGEN_reset()
- X{
- X putc(imP_EOF, outfile);
- X}
- X
- Xstatic void
- XIMAGEN_putwd(w)
- X{
- X putc(w>>8, outfile);
- X putc(w, outfile);
- X}
- X
- Xstatic void
- XIMAGEN_createfamily(c, sz)
- X char *c;
- X int sz;
- X{
- X putc(imP_CREATE_FAMILY_TABLE, outfile);
- X putc(sz, outfile);
- X putc(1, outfile);
- X putc(0, outfile);
- X fputs(c, outfile);
- X putc(0, outfile);
- X}
- X
- Xstatic void
- XIMAGEN_setfont(sz)
- X int sz;
- X{
- X IMAGEN_hchar = sz * 5;
- X IMAGEN_wchar = IMAGEN_hchar / 2;
- X IMAGEN_blofs = IMAGEN_hchar / 3;
- X putc(imP_SET_FAMILY, outfile);
- X putc(sz, outfile);
- X putc(imP_SET_SP, outfile);
- X IMAGEN_putwd(IMAGEN_wchar);
- X putc(imP_SET_IL, outfile);
- X IMAGEN_putwd(IMAGEN_hchar);
- X}
- *-*-END-of-term/imagen.trm-*-*
- echo x - term/object.h
- sed 's/^X//' >term/object.h <<'*-*-END-of-term/object.h-*-*'
- X/*
- X * FIG : Facility for Interactive Generation of figures
- X *
- X * (c) copy right 1985 by Supoj Sutanthavibul (supoj@sally.utexas.edu)
- X * January 1985.
- X * 1st revision : Aug 1985.
- X * 2nd revision : Feb 1988.
- X *
- X * %W% %G%
- X*/
- X#define DEFAULT -1
- X
- Xtypedef struct f_pattern {
- X int w, h;
- X int *p;
- X }
- X F_pattern;
- X
- Xtypedef struct f_pen {
- X int x, y;
- X int *p;
- X }
- X F_pen;
- X
- Xtypedef struct f_point {
- X int x, y;
- X struct f_point *next;
- X }
- X F_point;
- X
- Xtypedef struct f_pos {
- X int x, y;
- X }
- X F_pos;
- X
- Xtypedef struct f_arrow {
- X int type;
- X int style;
- X float thickness;
- X float wid;
- X float ht;
- X }
- X F_arrow;
- X
- Xtypedef struct f_ellipse {
- X int type;
- X#define T_ELLIPSE_BY_RAD 1
- X#define T_ELLIPSE_BY_DIA 2
- X#define T_CIRCLE_BY_RAD 3
- X#define T_CIRCLE_BY_DIA 4
- X int style;
- X int thickness;
- X int color;
- X#define BLACK 0
- X int depth;
- X int direction;
- X float style_val;
- X float angle;
- X struct f_pen *pen;
- X struct f_pattern *area_fill;
- X#define UNFILLED (F_pattern *)0
- X#define BLACK_FILL (F_pattern *)1
- X#define DARK_GRAY_FILL (F_pattern *)2
- X#define MED_GRAY_FILL (F_pattern *)3
- X#define LIGHT_GRAY_FILL (F_pattern *)4
- X#define WHITE_FILL (F_pattern *)4
- X struct f_pos center;
- X struct f_pos radiuses;
- X struct f_pos start;
- X struct f_pos end;
- X struct f_ellipse *next;
- X }
- X F_ellipse;
- X
- Xtypedef struct f_arc {
- X int type;
- X#define T_3_POINTS_ARC 1
- X int style;
- X int thickness;
- X int color;
- X int depth;
- X struct f_pen *pen;
- X struct f_pattern *area_fill;
- X float style_val;
- X int direction;
- X struct f_arrow *for_arrow;
- X struct f_arrow *back_arrow;
- X struct {float x, y;} center;
- X struct f_pos point[3];
- X struct f_arc *next;
- X }
- X F_arc;
- X
- Xtypedef struct f_line {
- X int type;
- X#define T_POLYLINE 1
- X#define T_BOX 2
- X#define T_POLYGON 3
- X int style;
- X int thickness;
- X int color;
- X int depth;
- X float style_val;
- X struct f_pen *pen;
- X struct f_pattern *area_fill;
- X struct f_arrow *for_arrow;
- X struct f_arrow *back_arrow;
- X struct f_point *points;
- X struct f_line *next;
- X }
- X F_line;
- X
- Xtypedef struct f_text {
- X int type;
- X#define T_LEFT_JUSTIFIED 0
- X#define T_CENTER_JUSTIFIED 1
- X#define T_RIGHT_JUSTIFIED 2
- X int font;
- X#define DEFAULT_FONT 0
- X#define ROMAN_FONT 1
- X#define BOLD_FONT 2
- X#define ITALIC_FONT 3
- X#define MODERN_FONT 4
- X#define TYPEWRITER_FONT 5
- X int size; /* point size */
- X int color;
- X int depth;
- X float angle; /* in radian */
- X int style;
- X#define PLAIN 1
- X#define ITALIC 2
- X#define BOLD 4
- X#define OUTLINE 8
- X#define SHADOW 16
- X int height; /* pixels */
- X int length; /* pixels */
- X int base_x;
- X int base_y;
- X struct f_pen *pen;
- X char *cstring;
- X struct f_text *next;
- X }
- X F_text;
- X
- Xtypedef struct f_control {
- X float lx, ly, rx, ry;
- X struct f_control *next;
- X }
- X F_control;
- X
- X#define int_spline(s) (s->type & 0x2)
- X#define normal_spline(s) (!(s->type & 0x2))
- X#define closed_spline(s) (s->type & 0x1)
- X#define open_spline(s) (!(s->type & 0x1))
- X
- Xtypedef struct f_spline {
- X int type;
- X#define T_OPEN_NORMAL 0
- X#define T_CLOSED_NORMAL 1
- X#define T_OPEN_INTERPOLATED 2
- X#define T_CLOSED_INTERPOLATED 3
- X int style;
- X int thickness;
- X int color;
- X int depth;
- X float style_val;
- X struct f_pen *pen;
- X struct f_pattern *area_fill;
- X struct f_arrow *for_arrow;
- X struct f_arrow *back_arrow;
- X /*
- X For T_OPEN_NORMAL and T_CLOSED_NORMAL points
- X are control points while they are knots for
- X T_OPEN_INTERPOLATED and T_CLOSED_INTERPOLTED
- X whose control points are stored in controls.
- X */
- X struct f_point *points;
- X struct f_control *controls;
- X struct f_spline *next;
- X }
- X F_spline;
- X
- Xtypedef struct f_compound {
- X struct f_pos nwcorner;
- X struct f_pos secorner;
- X struct f_line *lines;
- X struct f_ellipse *ellipses;
- X struct f_spline *splines;
- X struct f_text *texts;
- X struct f_arc *arcs;
- X struct f_compound *compounds;
- X struct f_compound *next;
- X }
- X F_compound;
- X
- X#define ARROW_SIZE sizeof(struct f_arrow)
- X#define POINT_SIZE sizeof(struct f_point)
- X#define CONTROL_SIZE sizeof(struct f_control)
- X#define ELLOBJ_SIZE sizeof(struct f_ellipse)
- X#define ARCOBJ_SIZE sizeof(struct f_arc)
- X#define LINOBJ_SIZE sizeof(struct f_line)
- X#define TEXOBJ_SIZE sizeof(struct f_text)
- X#define SPLOBJ_SIZE sizeof(struct f_spline)
- X#define COMOBJ_SIZE sizeof(struct f_compound)
- X
- X/********************** object codes **********************/
- X
- X#define O_ELLIPSE 1
- X#define O_POLYLINE 2
- X#define O_SPLINE 3
- X#define O_TEXT 4
- X#define O_ARC 5
- X#define O_COMPOUND 6
- X#define O_END_COMPOUND -O_COMPOUND
- X#define O_ALL_OBJECT 99
- X
- X/************ object styles (except for f_text) ************/
- X
- X#define SOLID_LINE 0
- X#define DASH_LINE 1
- X#define DOTTED_LINE 2
- X
- X#define CLOSED_PATH 0
- X#define OPEN_PATH 1
- *-*-END-of-term/object.h-*-*
- echo x - term/fig.trm
- sed 's/^X//' >term/fig.trm <<'*-*-END-of-term/fig.trm-*-*'
- X/* GNUPLOT - fig.trm */
- X/*
- X * Copyright (C) 1990
- X *
- X * Permission to use, copy, and distribute this software and its
- X * documentation for any purpose with or without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and
- X * that both that copyright notice and this permission notice appear
- X * in supporting documentation.
- X *
- X * Permission to modify the software is granted, but not the right to
- X * distribute the modified code. Modifications are to be distributed
- X * as patches to released version.
- X *
- X * This software is provided "as is" without express or implied warranty.
- X *
- X * This file is included by ../term.c.
- X *
- X * This terminal driver supports:
- X * Fig graphics language
- X *
- X * AUTHORS
- X * Micah Beck, David Kotz
- X *
- X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
- X *
- X */
- X
- X/*
- X * Original for Fig code output by Micah Beck, 1989
- X * Department of Computer Science, Cornell University
- X * Updated by David Kotz for gnuplot 2.0
- X */
- X#include "object.h" /* from the TransFig distribution */
- X
- X#ifndef FIG_RES
- X/* Must be 80 for the Fig editor, but may be increased if used
- X * only by TransFig filters.
- X * Represents resolution per inch.
- X */
- X#define FIG_RES 80
- X#endif
- X
- X#define FIG_COORD_SYS 2
- X
- X#define FIG_MAGIC "#FIG 1.4-TFX"
- X#define FIG_HTIC (5*FIG_RES/80)
- X#define FIG_VTIC (5*FIG_RES/80)
- X#define FIG_HCHAR (6*FIG_RES/80)
- X#define FIG_VCHAR (12*FIG_RES/80)
- X
- X#define FIG_ARROW_WIDTH FIG_HTIC
- X#define FIG_ARROW_HEIGHT FIG_HTIC
- X
- Xstatic long FIG_xbase = FIG_RES/2;
- Xstatic long FIG_ybase = FIG_RES/2;
- X
- Xstatic long FIG_posx;
- Xstatic long FIG_posy;
- X/* 5 inches wide by 3 inches high */
- X#define FIG_XMAX (5 * FIG_RES)
- X#define FIG_YMAX (3 * FIG_RES)
- X
- Xstatic int FIG_type; /* negative types use real lines */
- Xstatic float FIG_spacing; /* length of dash or dot spacing */
- Xstatic int FIG_justify; /* Fig justification T_*_JUSTIFIED */
- Xstatic float FIG_angle; /* Fig text angle 0=horiz, Pi/2=vert */
- X
- X#define FIG_POINT_TYPES POINT_TYPES /* we use the same points */
- X
- XFIG_init()
- X{
- X FIG_posx = FIG_posy = 0;
- X FIG_linetype(-1);
- X FIG_justify_text(LEFT);
- X FIG_text_angle(0);
- X
- X fprintf(outfile, "%s\n", FIG_MAGIC);
- X fprintf(outfile, "%d %d\n", FIG_RES, FIG_COORD_SYS);
- X}
- X
- X
- XFIG_graphics()
- X{
- X FIG_posx = FIG_posy = 0;
- X /* there is no way to have separate pictures in a FIG file */
- X}
- X
- X
- XFIG_text()
- X{
- X /* there is no way to have separate pictures in a FIG file */
- X}
- X
- X
- X/* Line types for FIG work like this:
- X * -2 : solid (border)
- X * -1 : dashed 4 (axes)
- X * 0 : solid (first curve)
- X * 1 : dotted 3
- X * 2 : dashed 3
- X * 3 : dotted 6
- X * 4 : dashed 6
- X * ... ...
- X */
- X
- XFIG_linetype(linetype)
- X int linetype; /* expect linetype >= -2 */
- X{
- X switch (linetype) {
- X case 0:
- X case -2: {
- X FIG_type = 0; /* solid line */
- X FIG_spacing = 0.0;
- X break;
- X }
- X case -1: {
- X FIG_type = 1; /* dashed */
- X FIG_spacing = 4.0; /* dash length */
- X break;
- X }
- X default: {
- X linetype = abs(linetype); /* shouldn't be negative anyway */
- X /* now linetype >= 1 */
- X FIG_type = linetype % 2 + 1; /* dotted, dashed, ... */
- X FIG_spacing = (linetype+1) / 2 * 3;
- X break;
- X }
- X }
- X}
- X
- XFIG_move(x,y)
- X unsigned int x,y;
- X{
- X FIG_posx = x;
- X FIG_posy = y;
- X}
- X
- XFIG_vector(ux,uy)
- X unsigned int ux,uy;
- X{
- X int x=ux, y=uy;
- X
- X fprintf(outfile, "%d %d %d %d %d %d %d %d %6.3f %d %d\n",
- X O_POLYLINE, T_POLYLINE,
- X FIG_type, 1, DEFAULT, DEFAULT, DEFAULT, DEFAULT, FIG_spacing,
- X 0, 0);
- X fprintf(outfile, "%d %d %d %d 9999 9999\n",
- X FIG_posx, FIG_YMAX-FIG_posy, x, FIG_YMAX-y);
- X
- X FIG_posx = x;
- X FIG_posy = y;
- X}
- X
- XFIG_arrow(sx, sy, ex, ey)
- X int sx, sy; /* start coord */
- X int ex, ey; /* end coord */
- X{
- X fprintf(outfile, "%d %d %d %d %d %d %d %d %6.3f %d %d\n",
- X O_POLYLINE, T_POLYLINE,
- X FIG_type, 1, DEFAULT, DEFAULT, DEFAULT, DEFAULT, FIG_spacing,
- X 1, 0);
- X /* arrow line */
- X fprintf(outfile, "%d %d %.3f %.3f %.3f\n",
- X 0, 0, 1.0, (float)FIG_ARROW_WIDTH, (float)FIG_ARROW_HEIGHT);
- X fprintf(outfile, "%d %d %d %d 9999 9999\n",
- X sx, FIG_YMAX-sy, ex, FIG_YMAX-ey);
- X
- X FIG_posx = ex;
- X FIG_posy = ey;
- X}
- X
- XFIG_put_text(x, y, str)
- X int x, y;
- X char *str;
- X{
- X y = y - FIG_VCHAR/2; /* assuming vertical center justified */
- X
- X fprintf(outfile, "%d %d %d %d %d %d %d %6.3f %d %d %d %d %d %s\01\n",
- X O_TEXT, FIG_justify,
- X ROMAN_FONT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, FIG_angle,
- X DEFAULT, 16, 8*strlen(str), x, FIG_YMAX-y, str);
- X}
- X
- Xint FIG_justify_text(mode)
- X enum JUSTIFY mode;
- X{
- X switch(mode) {
- X case LEFT: FIG_justify = T_LEFT_JUSTIFIED; break;
- X case CENTRE: FIG_justify = T_CENTER_JUSTIFIED; break;
- X case RIGHT: FIG_justify = T_RIGHT_JUSTIFIED; break;
- X /* shouldn't happen */
- X default: FIG_justify = T_LEFT_JUSTIFIED; break;
- X }
- X return (TRUE);
- X}
- X
- Xint FIG_text_angle(angle)
- X int angle;
- X{
- X if (angle)
- X FIG_angle = Pi / 2.0; /* vertical is pi/2 radians */
- X else
- X FIG_angle = 0.0; /* horizontal */
- X return (TRUE);
- X}
- X
- XFIG_reset()
- X{
- X FIG_posx = FIG_posy = 0;
- X}
- *-*-END-of-term/fig.trm-*-*
- echo x - term/latex.trm
- sed 's/^X//' >term/latex.trm <<'*-*-END-of-term/latex.trm-*-*'
- X/* GNUPLOT - latex.trm */
- X/*
- X * Copyright (C) 1990
- X *
- X * Permission to use, copy, and distribute this software and its
- X * documentation for any purpose with or without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and
- X * that both that copyright notice and this permission notice appear
- X * in supporting documentation.
- X *
- X * Permission to modify the software is granted, but not the right to
- X * distribute the modified code. Modifications are to be distributed
- X * as patches to released version.
- X *
- X * This software is provided "as is" without express or implied warranty.
- X *
- X * This file is included by ../term.c.
- X *
- X * This terminal driver supports:
- X * LaTeX pictures
- X *
- X * AUTHORS
- X * David Kotz, Russell Lang
- X *
- X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
- X *
- X */
- X
- X/* modified to optimize use of \rule for long lines */
- X
- X/* the following LATEX driver has been modified by
- X Russell Lang, eln272v@monu1.cc.monash.oz from the
- X GnuTeX 1.3 driver by David Kotz, dfk@cs.duke.edu
- X And further extended by David Kotz */
- X
- X
- X#define LATEX_PTS_PER_INCH (72.27)
- X#define DOTS_PER_INCH (300) /* resolution of printer we expect to use */
- X#define LATEX_UNIT (LATEX_PTS_PER_INCH/DOTS_PER_INCH) /* dot size in pt */
- X
- X/* 5 inches wide by 3 inches high (default) */
- X#define LATEX_XMAX (unsigned int)(LATEX_PTS_PER_INCH/LATEX_UNIT*5.0)
- X#define LATEX_YMAX (unsigned int)(LATEX_PTS_PER_INCH/LATEX_UNIT*3.0)
- X
- X#define LATEX_HTIC (5./LATEX_UNIT)
- X#define LATEX_VTIC (5./LATEX_UNIT)
- X#define LATEX_HCHAR (5.3/LATEX_UNIT)
- X#define LATEX_VCHAR (11./LATEX_UNIT)
- X
- Xstatic int LATEX_posx;
- Xstatic int LATEX_posy;
- Xenum JUSTIFY latex_justify=LEFT;
- Xstatic int latex_angle=0;
- X
- X/* Default line-drawing character */
- X/* the definition of plotpoint varies with linetype */
- X#define LATEX_DOT "\\usebox{\\plotpoint}"
- X#define LATEX_TINY_DOT "\\rule{.1pt}{.1pt}" /* for dots plot style */
- X
- X/* POINTS */
- X#define LATEX_POINT_TYPES 12 /* we supply more point types */
- Xstatic char *LATEX_points[] = {
- X "\\makebox(0,0){$\\Diamond$}",
- X "\\makebox(0,0){$+$}",
- X "\\makebox(0,0){$\\Box$}",
- X "\\makebox(0,0){$\\times$}",
- X "\\makebox(0,0){$\\triangle$}",
- X "\\makebox(0,0){$\\star$}",
- X "\\circle{12}", "\\circle{18}", "\\circle{24}",
- X "\\circle*{12}", "\\circle*{18}", "\\circle*{24}"
- X};
- X
- X/* LINES */
- Xstatic int LATEX_type; /* negative types use real lines */
- X#define LATEX_LINE_TYPES 6 /* number of line types below */
- X#define LATEX_THIN_LINE 0 /* the thinnest solid line type */
- Xstatic struct {
- X float size; /* size of dot, or thick of line in points */
- X float dotspace; /* inter-dot space in points; 0 for lines */
- X} LATEX_lines[] = {
- X {.4, 0}, /* thin solid line */
- X {1.0, 0}, /* thick solid line */
- X {2.0, 0}, /* Thick solid line */
- X {.4, 5}, /* dotted line */
- X {.4, 10}, /* widely dotted line */
- X {.4, 15} /* really widely dotted line */
- X};
- X/* for drawing dotted and solid lines */
- Xstatic void LATEX_dot_line();
- Xstatic void LATEX_solid_line();
- Xstatic void LATEX_rule();
- X#define LATEX_flushrule() LATEX_rule(2, 0.,0.,0.,0.) /* flush old rule */
- Xstatic BOOLEAN LATEX_moved = TRUE; /* pen is up after move */
- Xstatic float LATEX_dotsize; /* size of LATEX_DOT in units */
- X
- X/* ARROWS */
- X/* the set of non-vertical/non-horizontal LaTeX vector slopes */
- X/* except negatives - they are handled specially */
- Xstatic struct vslope {
- X int dx, dy;
- X} LATEX_slopes[] = {
- X {1,1}, {1,2}, {1,3}, {1,4},
- X {2,1}, {2,3},
- X {3,1}, {3,2}, {3,4},
- X {4,1}, {4,3},
- X {0,0} /* terminator */
- X};
- Xstatic void best_latex_arrow(); /* figure out the best arrow */
- X
- XLATEX_init()
- X{
- X LATEX_posx = LATEX_posy = 0;
- X LATEX_linetype(-1);
- X fprintf(outfile, "%% GNUPLOT: LaTeX picture\n");
- X fprintf(outfile, "\\setlength{\\unitlength}{%fpt}\n", LATEX_UNIT);
- X}
- X
- X
- XLATEX_scale(xs, ys)
- X float xs, ys; /* scaling factors */
- X{
- X register struct termentry *t = &term_tbl[term];
- X
- X /* we change the table for use in graphics.c and LATEX_graphics */
- X t->xmax = (unsigned int)(LATEX_XMAX * xs);
- X t->ymax = (unsigned int)(LATEX_YMAX * ys);
- X
- X return(TRUE);
- X}
- X
- XLATEX_graphics()
- X{
- X register struct termentry *t = &term_tbl[term];
- X
- X fprintf(outfile, "\\begin{picture}(%d,%d)(0,0)\n", t->xmax, t->ymax);
- X fprintf(outfile, "\\tenrm\n");
- X fprintf(outfile,
- X "\\ifx\\plotpoint\\undefined\\newsavebox{\\plotpoint}\\fi\n");
- X}
- X
- X
- XLATEX_text()
- X{
- X LATEX_flushrule();
- X fprintf(outfile, "\\end{picture}\n");
- X}
- X
- X
- XLATEX_linetype(linetype)
- X int linetype;
- X{
- X if (linetype >= LATEX_LINE_TYPES)
- X linetype %= LATEX_LINE_TYPES;
- X
- X LATEX_flushrule();
- X
- X if (linetype >= 0 &&
- X LATEX_lines[linetype].size != LATEX_lines[LATEX_type].size)
- X /* redefine \plotpoint */
- X fprintf(outfile, "\\sbox{\\plotpoint}{\\rule[%.3fpt]{%.3fpt}{%.3fpt}}\n",
- X -LATEX_lines[linetype].size/2,
- X LATEX_lines[linetype].size,
- X LATEX_lines[linetype].size);
- X
- X LATEX_type = linetype;
- X LATEX_dotsize = LATEX_lines[linetype].size / LATEX_UNIT;
- X LATEX_moved = TRUE; /* reset */
- X}
- X
- X
- XLATEX_move(x,y)
- X unsigned int x,y;
- X{
- X LATEX_posx = x;
- X LATEX_posy = y;
- X LATEX_moved = TRUE; /* reset */
- X}
- X
- X
- XLATEX_point(x,y, number) /* version of line_and_point */
- X unsigned int x,y;
- X int number; /* type of point */
- X{
- X LATEX_move(x,y);
- X
- X /* Print the character defined by 'number'; number < 0 means
- X to use a dot, otherwise one of the defined points. */
- X fprintf(outfile, "\\put(%d,%d){%s}\n", x, y,
- X (number < 0 ? LATEX_TINY_DOT
- X : LATEX_points[number % LATEX_POINT_TYPES]));
- X}
- X
- X
- XLATEX_vector(ux,uy)
- X unsigned int ux,uy;
- X{
- X /* Negative linestyles are straight lines for frame and axes. */
- X /* These are vertical and horizontal lines only. */
- X if (LATEX_type < 0) {
- X int x=ux, y=uy;
- X if (x == LATEX_posx) { /* vertical */
- X fprintf(outfile, "\\put(%d,%d){\\line(0,%d){%d}}\n",
- X LATEX_posx, LATEX_posy,
- X sign(y - LATEX_posy), abs(y - LATEX_posy));
- X } else if (y == LATEX_posy) { /* horizontal */
- X fprintf(outfile, "\\put(%d,%d){\\line(%d,0){%d}}\n",
- X LATEX_posx, LATEX_posy,
- X sign(x - LATEX_posx), abs(x - LATEX_posx));
- X }
- X } else { /* drawing real curves */
- X if (LATEX_lines[LATEX_type].dotspace == 0.0)
- X LATEX_solid_line(LATEX_posx, (int)ux, LATEX_posy, (int)uy);
- X else
- X LATEX_dot_line(LATEX_posx, (int)ux, LATEX_posy, (int)uy);
- X }
- X LATEX_posx = ux;
- X LATEX_posy = uy;
- X}
- X
- Xstatic void
- XLATEX_solid_line(x1,x2, y1,y2)
- X int x1,x2, y1,y2;
- X{
- X float slope;
- X int inc;
- X float next;
- X float x,y;
- X int code; /* possibly combine with previous rule */
- X
- X /* we draw a solid line using the thickness for this linetype */
- X /* we do it with lots of \\rules */
- X
- X if (x1 == x2 && y1 == y2) { /* zero-length line - just a dot */
- X if (LATEX_moved) {
- X LATEX_flushrule();
- X /* plot a dot */
- X fprintf(outfile, "\\put(%u,%u){%s}\n", x1, y1, LATEX_DOT);
- X }
- X } else {
- X code = (LATEX_moved ? 0 : 1); /* no combine after move */
- X if (x1 == x2) /* vertical line - special case */
- X LATEX_rule(code, (float)x1, (float)y1, LATEX_dotsize, (float)y2-y1);
- X else if (y1 == y2) /* horizontal line - special case */
- X LATEX_rule(code, (float)x1, (float)y1, (float)x2-x1, LATEX_dotsize);
- X else {
- X slope = ((float)y2-y1)/((float)x2-x1);
- X if (abs(slope) <= 1.0) {
- X /* longer than high */
- X inc = sign(y2-y1);
- X for (x = x1, y = y1; (y2-y)*inc >= 0; y += inc) {
- X next = inc/slope + x;
- X if ((x2>x1 && next > x2) || (x2<x1 && next < x2)) {
- X LATEX_rule(code, x,y, x2-x, LATEX_dotsize);
- X break;
- X } else {
- X LATEX_rule(code, x,y, next-x, LATEX_dotsize);
- X x = next;
- X }
- X code = 0;
- X }
- X } else {
- X /* higher than long */
- X inc = sign(x2-x1);
- X for (x = x1, y = y1; (x2-x)*inc >= 0; x += inc) {
- X next = inc*slope + y;
- X if ((y2>y1 && next > y2) || (y2<y1 && next < y2)) {
- X LATEX_rule(code, x,y, LATEX_dotsize, y2-y);
- X break;
- X } else {
- X LATEX_rule(code, x,y, LATEX_dotsize, next-y);
- X y = next;
- X }
- X code = 0;
- X }
- X }
- X }
- X }
- X LATEX_moved = FALSE;
- X}
- X
- X/* Draw a \rule. Width or height may be negative; we can correct.
- X * The rule is never output immediately. The previous rule is output
- X * as-is if code is 0, and the previous rule is
- X * combined with the current rule (if possible) if code is 1.
- X * The previous rule is output, and the new one ignored, if code is 2.
- X */
- Xstatic void
- XLATEX_rule(code, x,y, width, height)
- X int code; /* how do we treat this rule? */
- X float x, y;
- X float width;
- X float height;
- X{
- X static float lastx, lasty;
- X static float lastw, lasth;
- X static BOOLEAN valid = FALSE; /* is 'last' data valid? */
- X BOOLEAN combine = (code == 1);
- X BOOLEAN flush = (code == 2);
- X
- X if (!flush)
- X if (width == 0 || height == 0)
- X return; /* ignore this rule */
- X
- X if (width < 0) {
- X x += width;
- X width = -width;
- X }
- X if (height < 0) {
- X y += height;
- X height = -height;
- X }
- X
- X if (valid && combine) {
- X /* try to combine new rule with old rule */
- X if ((int)lastx == (int)x && lastw == width) { /* vertical rule */
- X lasth += height;
- X return;
- X } else if ((int)lasty == (int)y && lasth == height){ /* horiz rule */
- X lastw += width;
- X return;
- X }
- X /* oh well, output last and remember the new one */
- X }
- X
- X if (valid)
- X /* if very small use canned dot */
- X if (lastw < LATEX_dotsize || lasth < LATEX_dotsize)
- X fprintf(outfile, "\\put(%d,%d){%s}\n",
- X (int)lastx, (int)lasty, LATEX_DOT);
- X else
- X fprintf(outfile, "\\put(%d,%d){\\rule[%.3fpt]{%.3fpt}{%.3fpt}}\n",
- X (int)lastx, (int)lasty, -LATEX_dotsize*LATEX_UNIT/2,
- X lastw*LATEX_UNIT, lasth*LATEX_UNIT);
- X
- X if (flush) {
- X valid = FALSE;
- X } else {
- X lastx = x; lasty = y;
- X lastw = width; lasth = height;
- X valid = TRUE;
- X }
- X}
- X
- Xstatic void
- XLATEX_dot_line(x1,x2, y1,y2)
- X int x1,x2, y1,y2;
- X{
- X static float LATEX_left; /* fraction of space left after last dot */
- X extern double sqrt();
- X
- X /* we draw a dotted line using the dot spacing for this linetype */
- X
- X if (LATEX_moved)
- X LATEX_left = 1.0; /* reset after a move */
- X
- X /* zero-length line? */
- X if (x1 == x2 && y1 == y2) {
- X if (LATEX_moved)
- X /* plot a dot */
- X fprintf(outfile, "\\put(%u,%u){%s}\n", x1, y1, LATEX_DOT);
- X } else {
- X float dotspace = LATEX_lines[LATEX_type].dotspace / LATEX_UNIT;
- X float x,y; /* current position */
- X float xinc, yinc; /* increments */
- X float slope; /* slope of line */
- X float lastx = -1; /* last x point plotted */
- X float lasty = -1; /* last y point plotted */
- X
- X /* first, figure out increments for x and y */
- X if (x2 == x1) {
- X xinc = 0.0;
- X yinc = dotspace;
- X } else {
- X slope = ((float)y2-y1)/((float)x2-x1);
- X xinc = dotspace / sqrt(1 + slope*slope) * sign(x2-x1);
- X yinc = slope * xinc;
- X }
- X
- X /* now draw the dotted line */
- X /* we take into account where we last placed a dot */
- X for (x=x1 + xinc*(1-LATEX_left), y=y1 + yinc*(1-LATEX_left);
- X (x2-x)*xinc >= 0 && (y2-y)*yinc >= 0; /* same sign or zero */
- X lastx = x, x += xinc,
- X lasty = y, y += yinc)
- X fprintf(outfile, "\\put(%d,%d){%s}\n", (int)x, (int)y, LATEX_DOT);
- X
- X /* how much is left over, as a fraction of dotspace? */
- X if (xinc != 0.0) /* xinc must be nonzero */
- X if (lastx >= 0)
- X LATEX_left = abs(x2 - lastx) / xinc;
- X else
- X LATEX_left += abs(x2-x1) / xinc;
- X else
- X if (lasty >= 0)
- X LATEX_left = abs(y2 - lasty) / yinc;
- X else
- X LATEX_left += abs(y2-y1) / yinc;
- X }
- X
- X LATEX_moved = FALSE;
- X}
- X
- XLATEX_arrow(sx,sy, ex,ey)
- X int sx,sy, ex,ey;
- X{
- X best_latex_arrow(sx,sy, ex,ey, 1);
- X
- X LATEX_posx = ex;
- X LATEX_posy = ey;
- X}
- X
- Xstatic void best_latex_arrow(sx,sy, ex,ey, who)
- X int sx,sy, ex,ey; /* start and end points */
- X int who; /* 1=LATEX, 2=EEPIC */
- X{
- X int dx = ex - sx;
- X int dy = ey - sy;
- X int x, y; /* points near sx,sy */
- X float m; /* slope of line */
- X float arrowslope; /* slope of arrow */
- X float minerror; /* best-case error */
- X struct vslope *slope; /* one of the slopes */
- X struct vslope *bestslope; /* the slope with min error */
- X BOOLEAN horiz; /* was it the horiz line that was best? */
- X
- X /* We try to draw a real arrow (ie, \vector). If we can't get
- X * a slope that is close, we draw a bent arrow.
- X */
- X
- X if (dx == 0) {
- X /* vertical arrow */
- X fprintf(outfile, "\\put(%d,%d){\\vector(0,%d){%d}}\n",
- X sx, sy, sign(ey-sy), abs(ey-sy));
- X } else if (dy == 0) {
- X /* horizontal arrow */
- X fprintf(outfile, "\\put(%d,%d){\\vector(%d,0){%d}}\n",
- X sx, sy, sign(ex-sx), abs(ex-sx));
- X } else {
- X /* Slanted arrow. We'll give it a try.
- X * we try to find the closest-slope arrowhead.
- X */
- X bestslope = NULL;
- X m = abs((float)dy/dx); /* the slope we want */
- X for (slope = LATEX_slopes; slope->dx != 0.0; slope++) {
- X /* find the slope of the arrow */
- X arrowslope = (float) slope->dy / slope->dx;
- X if (bestslope == NULL || abs(m-arrowslope) < minerror) {
- X minerror = abs(m-arrowslope);
- X bestslope = slope;
- X }
- X }
- X
- X /* now we have the best slope arrow */
- X /* maybe it's exactly the right slope! */
- X if (minerror == 0.0) /* unlikely but possible */
- X fprintf(outfile, "\\put(%d,%d){\\vector(%d,%d){%d}}\n",
- X sx, sy,
- X bestslope->dx*sign(ex-sx), bestslope->dy*sign(ey-sy),
- X abs(ex-sx));
- X else {
- X /* we draw the line the usual way, with thin lines */
- X if (who == 1) {
- X LATEX_linetype(LATEX_THIN_LINE);
- X LATEX_solid_line(sx,ex,sy,ey);
- X }
- X#ifdef EEPIC
- X else {
- X EEPIC_move(sx,sy);
- X EEPIC_vector(ex,ey);
- X }
- X#endif /* EEPIC */
- X /* and then draw an arrowhead (a short vector) there */
- X fprintf(outfile, "\\put(%d,%d){\\vector(%d,%d){0}}\n",
- X ex, ey,
- X bestslope->dx*sign(ex-sx), bestslope->dy*sign(ey-sy));
- X }
- X }
- X}
- X
- X
- XLATEX_put_text(x, y, str)
- X int x,y; /* reference point of string */
- X char str[]; /* the text */
- X{
- X /* ignore empty strings */
- X if (str[0] == '\0')
- X return;
- X
- X fprintf(outfile, "\\put(%d,%d)",x,y);
- X switch(latex_angle) {
- X case 0: {
- X switch(latex_justify) {
- X case LEFT: {
- X fprintf(outfile,
- X "{\\makebox(0,0)[l]{%s}}\n", str);
- X break;
- X }
- X case CENTRE: {
- X fprintf(outfile,
- X "{\\makebox(0,0){%s}}\n", str);
- X break;
- X }
- X case RIGHT: {
- X fprintf(outfile,
- X "{\\makebox(0,0)[r]{%s}}\n", str);
- X break;
- X }
- X }
- X break;
- X }
- X case 1: { /* put text in a short stack */
- X switch(latex_justify) {
- X case LEFT: {
- X fprintf(outfile,
- X "{\\makebox(0,0)[lb]{\\shortstack{%s}}}\n", str);
- X break;
- X }
- X case CENTRE: {
- X fprintf(outfile,
- X "{\\makebox(0,0)[l]{\\shortstack{%s}}}\n", str);
- X break;
- X }
- X case RIGHT: {
- X fprintf(outfile,
- X "{\\makebox(0,0)[lt]{\\shortstack{%s}}}\n", str);
- X break;
- X }
- X }
- X break;
- X }
- X }
- X}
- X
- X
- X
- Xint LATEX_justify_text(mode)
- X enum JUSTIFY mode;
- X{
- X latex_justify = mode;
- X return (TRUE);
- X}
- X
- Xint LATEX_text_angle(angle)
- X int angle;
- X{
- X /* we can't really write text vertically, but this will
- X put the ylabel centred at the left of the plot, and
- X then we'll make a \shortstack */
- X latex_angle = angle;
- X return (TRUE);
- X}
- X
- XLATEX_reset()
- X{
- X LATEX_posx = LATEX_posy = 0;
- X}
- X
- *-*-END-of-term/latex.trm-*-*
- echo x - term/eepic.trm
- sed 's/^X//' >term/eepic.trm <<'*-*-END-of-term/eepic.trm-*-*'
- X/* GNUPLOT - eepic.trm */
- X/*
- X * Copyright (C) 1990
- X *
- X * Permission to use, copy, and distribute this software and its
- X * documentation for any purpose with or without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and
- X * that both that copyright notice and this permission notice appear
- X * in supporting documentation.
- X *
- X * Permission to modify the software is granted, but not the right to
- X * distribute the modified code. Modifications are to be distributed
- X * as patches to released version.
- X *
- X * This software is provided "as is" without express or implied warranty.
- X *
- X * This file is included by ../term.c.
- X *
- X * This terminal driver supports:
- X * The EEPIC macros for LaTeX.
- X *
- X * AUTHORS
- X * David Kotz
- X *
- X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
- X *
- X */
- X/*
- X * This file contains the eepic terminal driver, intended for use with the
- X * eepic.sty macro package for LaTeX. This is an alternative to the
- X * latex driver. You need eepic.sty, epic.sty, and a printer driver that
- X * supports the tpic \specials.
- X *
- X * Although dotted and dashed lines are possible with EEPIC, and are
- X * tempting, they do not work well for high-sample-rate curves, mushing
- X * the dashes all together into a solid line. For now anyway, the EEPIC
- X * driver will have only solid lines. Anyone got a solution?
- X *
- X * LATEX must also be defined.
- X */
- X
- X#define EEPIC_PTS_PER_INCH (72.27)
- X#define DOTS_PER_INCH (300) /* resolution of printer we expect to use */
- X#define EEPIC_UNIT (EEPIC_PTS_PER_INCH/DOTS_PER_INCH) /* dot size in pt */
- X
- X/* 5 inches wide by 3 inches high (default) */
- X#define EEPIC_XMAX (unsigned int)(EEPIC_PTS_PER_INCH/EEPIC_UNIT*5.0)
- X#define EEPIC_YMAX (unsigned int)(EEPIC_PTS_PER_INCH/EEPIC_UNIT*3.0)
- X
- X#define EEPIC_HTIC (5./EEPIC_UNIT)
- X#define EEPIC_VTIC (5./EEPIC_UNIT)
- X#define EEPIC_HCHAR (5.3/EEPIC_UNIT)
- X#define EEPIC_VCHAR (11./EEPIC_UNIT)
- X
- Xstatic unsigned int EEPIC_posx;
- Xstatic unsigned int EEPIC_posy;
- Xenum JUSTIFY eepic_justify=LEFT;
- Xstatic int eepic_angle=0;
- X
- X/* for DOTS point style */
- X#define EEPIC_TINY_DOT "\\rule{.1pt}{.1pt}"
- X
- X/* POINTS */
- X#define EEPIC_POINT_TYPES 12 /* we supply more point types */
- Xstatic char *EEPIC_points[] = {
- X "\\makebox(0,0){$\\Diamond$}",
- X "\\makebox(0,0){$+$}",
- X "\\makebox(0,0){$\\Box$}",
- X "\\makebox(0,0){$\\times$}",
- X "\\makebox(0,0){$\\triangle$}",
- X "\\makebox(0,0){$\\star$}",
- X "\\circle{12}", "\\circle{18}", "\\circle{24}",
- X "\\circle*{12}", "\\circle*{18}", "\\circle*{24}"
- X};
- X
- X/* LINES */
- X#define EEPIC_NUMLINES 5 /* number of linetypes below */
- Xstatic char *EEPIC_lines[] = {
- X "\\thicklines \\path", /* -2 border */
- X "\\thinlines \\drawline[-50]", /* -1 axes */
- X "\\thinlines \\path", /* 0 solid thin */
- X "\\thicklines \\path", /* 1 solid thick */
- X "\\Thicklines \\path", /* 2 solid Thick */
- X};
- X/* These are other possibilities
- X "\\thinlines \\dottedline{30}",
- X "\\thinlines \\drawline[-30]",
- X "\\thinlines \\dottedline{60}",
- X "\\thinlines \\drawline[-60]",
- X "\\thinlines \\dashline[-10]{20}[6]"
- X*/
- Xstatic int EEPIC_type; /* current line type */
- Xstatic BOOLEAN EEPIC_inline = FALSE; /* are we in the middle of a line */
- Xstatic void EEPIC_endline(); /* terminate any line in progress */
- X
- X/* ARROWS */
- X/* we use the same code as for LATEX */
- Xstatic void best_latex_arrow(); /* figure out the best arrow */
- X
- XEEPIC_init()
- X{
- X EEPIC_posx = EEPIC_posy = 0;
- X EEPIC_linetype(-1);
- X fprintf(outfile, "%% GNUPLOT: LaTeX picture using EEPIC macros\n");
- X fprintf(outfile, "\\setlength{\\unitlength}{%fpt}\n", EEPIC_UNIT);
- X}
- X
- X
- XEEPIC_scale(xs, ys)
- X float xs, ys; /* scaling factors */
- X{
- X register struct termentry *t = &term_tbl[term];
- X
- X /* we change the table for use in graphics.c and EEPIC_graphics */
- X t->xmax = (unsigned int)(EEPIC_XMAX * xs);
- X t->ymax = (unsigned int)(EEPIC_YMAX * ys);
- X
- X return(TRUE);
- X}
- X
- XEEPIC_graphics()
- X{
- X register struct termentry *t = &term_tbl[term];
- X
- X fprintf(outfile, "\\begin{picture}(%d,%d)(0,0)\n", t->xmax, t->ymax);
- X fprintf(outfile, "\\tenrm\n");
- X}
- X
- X
- XEEPIC_text()
- X{
- X EEPIC_endline();
- X fprintf(outfile, "\\end{picture}\n");
- X}
- X
- X
- XEEPIC_linetype(linetype)
- X int linetype;
- X{
- X EEPIC_endline();
- X
- X if (linetype >= EEPIC_NUMLINES-2)
- X linetype %= (EEPIC_NUMLINES-2);
- X
- X EEPIC_type = linetype;
- X}
- X
- X
- X
- XEEPIC_move(x,y)
- X unsigned int x,y;
- X{
- X EEPIC_endline();
- X
- X EEPIC_posx = x;
- X EEPIC_posy = y;
- X}
- X
- X
- XEEPIC_point(x,y, number) /* version of line_and_point */
- X unsigned int x,y;
- X int number; /* type of point */
- X{
- X EEPIC_move(x,y);
- X
- X /* Print the character defined by 'number'; number < 0 means
- X to use a dot, otherwise one of the defined points. */
- X fprintf(outfile, "\\put(%d,%d){%s}\n", x, y,
- X (number < 0 ? EEPIC_TINY_DOT
- X : EEPIC_points[number % EEPIC_POINT_TYPES]));
- X}
- X
- X
- XEEPIC_vector(ux,uy)
- X unsigned int ux,uy;
- X{
- X if (!EEPIC_inline) {
- X EEPIC_inline = TRUE;
- X
- X /* Start a new line. This depends on line type */
- X fprintf(outfile, "%s(%u,%u)",
- X EEPIC_lines[EEPIC_type+2],
- X EEPIC_posx, EEPIC_posy);
- X }
- X
- X /* add new point to line */
- X fprintf(outfile, "(%u,%u)", ux,uy);
- X EEPIC_posx = ux;
- X EEPIC_posy = uy;
- X}
- X
- Xstatic void
- XEEPIC_endline()
- X{
- X if (EEPIC_inline) {
- X fprintf(outfile, "\n");
- X EEPIC_inline = FALSE;
- X }
- X}
- X
- X
- XEEPIC_arrow(sx,sy, ex,ey)
- X int sx,sy, ex,ey;
- X{
- X best_latex_arrow(sx,sy, ex,ey, 2); /* call latex routine */
- X
- X EEPIC_posx = ex;
- X EEPIC_posy = ey;
- X}
- X
- X
- XEEPIC_put_text(x, y, str)
- X int x,y; /* reference point of string */
- X char str[]; /* the text */
- X{
- X EEPIC_endline();
- X
- X fprintf(outfile, "\\put(%d,%d)",x,y);
- X switch(eepic_angle) {
- X case 0: {
- X switch(eepic_justify) {
- X case LEFT: {
- X fprintf(outfile,
- X "{\\makebox(0,0)[l]{%s}}\n", str);
- X break;
- X }
- X case CENTRE: {
- X fprintf(outfile,
- X "{\\makebox(0,0){%s}}\n", str);
- X break;
- X }
- X case RIGHT: {
- X fprintf(outfile,
- X "{\\makebox(0,0)[r]{%s}}\n", str);
- X break;
- X }
- X }
- X break;
- X }
- X case 1: { /* put text in a short stack */
- X switch(eepic_justify) {
- X case LEFT: {
- X fprintf(outfile,
- X "{\\makebox(0,0)[lb]{\\shortstack{%s}}}\n", str);
- X break;
- X }
- X case CENTRE: {
- X fprintf(outfile,
- X "{\\makebox(0,0)[l]{\\shortstack{%s}}}\n", str);
- X break;
- X }
- X case RIGHT: {
- X fprintf(outfile,
- X "{\\makebox(0,0)[lt]{\\shortstack{%s}}}\n", str);
- X break;
- X }
- X }
- X break;
- X }
- X }
- X}
- X
- X
- X
- Xint EEPIC_justify_text(mode)
- X enum JUSTIFY mode;
- X{
- X eepic_justify = mode;
- X return (TRUE);
- X}
- X
- Xint EEPIC_text_angle(angle)
- X int angle;
- X{
- X /* we can't really write text vertically, but this will
- X put the ylabel centred at the left of the plot, and
- X then we'll make a \shortstack */
- X eepic_angle = angle;
- X return (TRUE);
- X}
- X
- XEEPIC_reset()
- X{
- X EEPIC_endline();
- X EEPIC_posx = EEPIC_posy = 0;
- X}
- X
- *-*-END-of-term/eepic.trm-*-*
- exit
-
-
-