home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
misc
/
volume24
/
gnuplot3
/
part17
< prev
next >
Wrap
Text File
|
1991-10-27
|
49KB
|
1,741 lines
Newsgroups: comp.sources.misc
From: gershon%gr@cs.utah.edu (Elber Gershon)
Subject: v24i039: gnuplot3 - interactive function plotting utility, Part17/26
Message-ID: <1991Oct28.002324.12536@sparky.imd.sterling.com>
X-Md4-Signature: 2e7b599a6d9e532057d6defc66706ba1
Date: Mon, 28 Oct 1991 00:23:24 GMT
Approved: kent@sparky.imd.sterling.com
Submitted-by: gershon%gr@cs.utah.edu (Elber Gershon)
Posting-number: Volume 24, Issue 39
Archive-name: gnuplot3/part17
Environment: UNIX, MS-DOS, VMS
Supersedes: gnuplot2: Volume 11, Issue 65-79
#!/bin/sh
# this is Part.17 (part 17 of a multipart archive)
# do not concatenate these parts, unpack them in order with /bin/sh
# file gnuplot/term/iris4d.trm continued
#
if test ! -r _shar_seq_.tmp; then
echo 'Please unpack part 1 first!'
exit 1
fi
(read Scheck
if test "$Scheck" != 17; then
echo Please unpack part "$Scheck" next!
exit 1
else
exit 0
fi
) < _shar_seq_.tmp || exit 1
if test ! -f _shar_wnt_.tmp; then
echo 'x - still skipping gnuplot/term/iris4d.trm'
else
echo 'x - continuing file gnuplot/term/iris4d.trm'
sed 's/^X//' << 'SHAR_EOF' >> 'gnuplot/term/iris4d.trm' &&
X
X return;
}
X
IRIS4D_text()
{
X return; /* enter text from another window!!! */
}
X
IRIS4D_linetype(linetype)
int linetype;
{
X static int pen_color_24[11] =
X {
X IRIS4D_BLACK, /* reserved for border and numbers */
X IRIS4D_MAGENTA, /* reserved for axis traces */
X IRIS4D_LIGHTCYAN,
X IRIS4D_RED,
X IRIS4D_GREEN,
X IRIS4D_LIGHTMAGENTA,
X IRIS4D_YELLOW,
X IRIS4D_LIGHTRED,
X IRIS4D_LIGHTGREEN,
X IRIS4D_CYAN,
X IRIS4D_BROWN,
X };
X static int pen_color[8] = {0 ,1, 4, 5, 6, 1, 2, 4};
X
X if (iris24bits)
X {
X int pencolor = pen_color_24[linetype < 0 ? linetype + 2 : linetype % 9 + 2];
X
X RGBcolor(colors24bits[pencolor][0],
X colors24bits[pencolor][1],
X colors24bits[pencolor][2]);
X /* Make all lines solid (linestyle 0) upto to the ninth. If more than
X * 9 colors are needed, start to use the different line styles (1 to 8).
X */
X setlinestyle(linetype < 9 ? 0 : (linetype + 2) % 8 + 1);
X }
X else
X {
X linetype = linetype % 8;
X color((Colorindex) pen_color[linetype]);
X setlinestyle(linetype);
X }
X return;
}
X
IRIS4D_move(x, y)
unsigned int x, y;
{
X move2i(x, y);
X return;
}
X
IRIS4D_cmove(x, y)
unsigned int x, y;
{
X cmov2i(x, y);
X return;
}
X
IRIS4D_vector(x, y)
unsigned x, y;
{
X draw2i(x, y);
X return;
}
X
X
IRIS4D_put_text(x,y,str)
int x, y;
char *str;
{
X IRIS4D_cmove(x,y - IRIS4D_VCHAR/2);
X charstr(str);
X return;
}
X
X
IRIS4D_reset()
{
X return;
}
X
SHAR_EOF
echo 'File gnuplot/term/iris4d.trm is complete' &&
chmod 0644 gnuplot/term/iris4d.trm ||
echo 'restore of gnuplot/term/iris4d.trm failed'
Wc_c="`wc -c < 'gnuplot/term/iris4d.trm'`"
test 5305 -eq "$Wc_c" ||
echo 'gnuplot/term/iris4d.trm: original size 5305, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/term/kyo.trm ==============
if test -f 'gnuplot/term/kyo.trm' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/term/kyo.trm (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/term/kyo.trm (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/kyo.trm' &&
/* Prescribe (KYOCERA) driver - Michael Waldor */
/* Modified for gnuplot 2.0 sk@sun4 24-Apr-1990 13:23 */
#ifdef PRESCRIBE
X
#define PRE_XMAX 2567
#define PRE_YMAX 1815 /* X:Y = sqrt(2) */
X
#define PRE_XLAST (PRE_XMAX - 1)
#define PRE_YLAST (PRE_YMAX - 1)
X
#define PRE_VCHAR (PRE_YMAX/30)
#define PRE_HCHAR 33 /* about 9 chars per inch */
#define PRE_HTIC (PRE_XMAX/80)
#define PRE_VTIC PRE_HTIC
X
/* for Courier font: */
#define KYO_VCHAR (14*(300/72)) /* 12 pt + 2 pt baselineskip */
#define KYO_HCHAR (300/10) /* 10 chars per inch */
X
enum JUSTIFY pre_justify=LEFT; /* text is flush left */
X
PRE_init()
{
X (void) fprintf(outfile,"!R! RES;\n") ;
X /* UNIT: units are dots, 300 dots = 1 in = 72 pt */
X /* SPO: landscape format */
X /* STM, SLM set top, left margin*/
X /* Font: bold Helvetica (proportional font) */
X (void) fprintf(outfile,"PAGE; UNIT D; SPO L; STM 280; SLM 440;\n") ;
X (void) fprintf(outfile,"FTMD 15; FONT 29; SCPI 9;\n") ;
}
X
KYO_init()
{
X (void) fprintf(outfile,"!R! RES;\n") ;
X /* UNIT: units are dots, 300 dots = 1 in = 72 pt */
X /* SPO: landscape format */
X /* STM, SLM set top, left margin */
X /* Font: Courier (fixed width font) */
X (void) fprintf(outfile,"PAGE; UNIT D; SPO L; STM 280; SLM 440;\n") ;
X (void) fprintf(outfile,"FTMD 15; FONT 17; SCPI 10;\n") ;
}
X
PRE_graphics()
{
}
X
PRE_text() /* eject page after each plot */
{
X (void) fprintf(outfile,"PAGE;\n") ;
}
X
PRE_linetype(linetype)
int linetype ;
{
X /* actually choose pendiameter */
X if (linetype < 0) linetype = -linetype;
X else linetype = 3;
X (void) fprintf(outfile,"SPD %d;\n", linetype) ;
}
X
PRE_move(x,y)
unsigned int x,y ;
{
X (void) fprintf(outfile,"MAP %1d,%1d;\n",x,PRE_YMAX-y) ;
}
X
PRE_vector(x,y)
unsigned int x,y ;
{
X (void) fprintf(outfile,"DAP %1d, %1d;\n",x,PRE_YMAX-y) ;
}
X
PRE_put_text(x, y, str)
unsigned int x,y ;
char *str;
{
X PRE_move(x,y);
X switch(pre_justify){
X case RIGHT:
X (void) fprintf(outfile,"RTXT \"%s\", B;\n",str) ;
X break;
X default:
X (void) fprintf(outfile,"TEXT \"%s\", B;\n",str) ;
X }
}
X
int PRE_justify_text(mode)
enum JUSTIFY mode;
{
X pre_justify=mode;
X switch(pre_justify){
X case LEFT:
X case RIGHT:
X return(TRUE);
X default:
X return(FALSE);
X }
X
}
X
PRE_reset()
{
X (void) fprintf(outfile,"PAGE; RES; EXIT;\n");
}
X
#endif /* PRESCRIBE */
SHAR_EOF
chmod 0666 gnuplot/term/kyo.trm ||
echo 'restore of gnuplot/term/kyo.trm failed'
Wc_c="`wc -c < 'gnuplot/term/kyo.trm'`"
test 2313 -eq "$Wc_c" ||
echo 'gnuplot/term/kyo.trm: original size 2313, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/term/latex.trm ==============
if test -f 'gnuplot/term/latex.trm' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/term/latex.trm (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/term/latex.trm (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/latex.trm' &&
/* GNUPLOT - latex.trm */
/*
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 (latex).
X * LaTeX pictures with emTeX specials (emtex).
X *
X * AUTHORS
X * David Kotz, Russell Lang
X *
X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
X *
X */
X
/* modified to optimize use of \rule for long lines */
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, David.Kotz@Dartmouth.edu.
X Since then it has been further extended by David Kotz.
X EmTeX driver by Russell Lang. */
X
X
#define LATEX_PTS_PER_INCH (72.27)
#define DOTS_PER_INCH (300) /* resolution of printer we expect to use */
#define LATEX_UNIT (LATEX_PTS_PER_INCH/DOTS_PER_INCH) /* dot size in pt */
X
/* 5 inches wide by 3 inches high (default) */
#define LATEX_XMAX (5*DOTS_PER_INCH) /* (LATEX_PTS_PER_INCH/LATEX_UNIT*5.0) */
#define LATEX_YMAX (3*DOTS_PER_INCH) /* (LATEX_PTS_PER_INCH/LATEX_UNIT*3.0) */
X
#define LATEX_HTIC (5*DOTS_PER_INCH/72) /* (5./LATEX_UNIT) */
#define LATEX_VTIC (5*DOTS_PER_INCH/72) /* (5./LATEX_UNIT) */
#define LATEX_HCHAR (DOTS_PER_INCH*53/10/72) /* (5.3/LATEX_UNIT) */
#define LATEX_VCHAR (DOTS_PER_INCH*11/72) /* (11./LATEX_UNIT) */
X
static int LATEX_posx;
static int LATEX_posy;
static enum JUSTIFY latex_justify=LEFT;
static int latex_angle=0;
X
/* Default line-drawing character */
/* the definition of plotpoint varies with linetype */
#define LATEX_DOT "\\usebox{\\plotpoint}"
#define LATEX_TINY_DOT "\\rule{.1pt}{.1pt}" /* for dots plot style */
X
/* POINTS */
#define LATEX_POINT_TYPES 12 /* we supply more point types */
static char *LATEX_points[] = {
X "\\raisebox{-1.2pt}{\\makebox(0,0){$\\Diamond$}}",
X "\\makebox(0,0){$+$}",
X "\\raisebox{-1.2pt}{\\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
/* LINES */
static float LATEX_size = 0; /* current thick of line in points */
static float LATEX_dotspace = 0; /* current dotspace of line in points */
#define LATEX_LINE_TYPES 6 /* number of line types below */
#define LATEX_THIN_LINE 0 /* the thinnest solid line type */
static struct {
X float size; /* size of dot, or thick of line in points */
X float dotspace; /* inter-dot space in points; 0 for lines */
} LATEX_lines[] = {
X {.35, 0.0}, /* thin solid line */
X {.7, 0.0}, /* thick solid line */
X {1.0, 0.0}, /* Thick solid line */
X {.5, 5.0}, /* dotted line */
X {.5, 9.0}, /* widely dotted line */
X {.5, 13.0} /* really widely dotted line */
};
/* for drawing dotted and solid lines */
static void LATEX_dot_line();
static void LATEX_solid_line();
static void LATEX_rule();
static void LATEX_flushdot();
#define LATEX_flushrule() LATEX_rule(2, 0.,0.,0.,0.) /* flush old rule */
static BOOLEAN LATEX_moved = TRUE; /* pen is up after move */
static float LATEX_dotsize; /* size of LATEX_DOT in units */
static BOOLEAN LATEX_needsdot = FALSE;/* does dotted line need termination? */
X
#ifdef EMTEX
BOOLEAN emtex=FALSE; /* not currently using emtex */
static void EMTEX_solid_line();
#endif
X
/* ARROWS */
/* the set of non-vertical/non-horizontal LaTeX vector slopes */
/* except negatives - they are handled specially */
static struct vslope {
X int dx, dy;
} 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 */
};
static void best_latex_arrow(); /* figure out the best arrow */
X
LATEX_init()
{
#ifdef EMTEX
X emtex = FALSE;
#endif
X LATEX_posx = LATEX_posy = 0;
X fprintf(outfile, "%% GNUPLOT: LaTeX picture\n");
X fprintf(outfile, "\\setlength{\\unitlength}{%fpt}\n", LATEX_UNIT);
X fprintf(outfile,
X "\\ifx\\plotpoint\\undefined\\newsavebox{\\plotpoint}\\fi\n");
X LATEX_linetype(-1);
}
X
X
LATEX_scale(xs, ys)
X double xs, ys; /* scaling factors */
{
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
LATEX_graphics()
{
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
LATEX_text()
{
X LATEX_flushrule();
X LATEX_flushdot();
X fprintf(outfile, "\\end{picture}\n");
X LATEX_posx = LATEX_posy = 0; /* current position */
X LATEX_moved = TRUE; /* pen is up after move */
}
X
LATEX_linetype(linetype)
X int linetype;
{
X float size;
X
X if (linetype >= LATEX_LINE_TYPES)
X linetype %= LATEX_LINE_TYPES;
X
#ifdef EMTEX
X if (!emtex)
#endif
X LATEX_flushrule();
X LATEX_flushdot();
X
X /* Find the new desired line thickness. */
X /* negative linetypes (for axes) use a thin line */
X /* only relevant for drawing axes/border in 3d */
X size = (linetype >= 0 ? LATEX_lines[linetype].size
X : LATEX_lines[LATEX_THIN_LINE].size);
X
X /* If different from current size, redefine \plotpoint */
X if (size != LATEX_size) {
X fprintf(outfile,
X "\\sbox{\\plotpoint}{\\rule[%.3fpt]{%.3fpt}{%.3fpt}}%%\n",
X -size/2, size, size);
#ifdef EMTEX
X if (emtex) /* change line width */
X fprintf(outfile, "\\special{em:linewidth %.1fpt}%%\n", size);
#endif
X }
X
X LATEX_size = size;
X LATEX_dotsize = size / LATEX_UNIT;
X LATEX_dotspace = (linetype >= 0) ? LATEX_lines[linetype].dotspace : 0;
X LATEX_moved = TRUE; /* reset */
}
X
LATEX_move(x,y)
X unsigned int x,y;
{
X LATEX_flushdot();
X
X LATEX_posx = x;
X LATEX_posy = y;
X LATEX_moved = TRUE; /* reset */
}
X
X
LATEX_point(x,y, number) /* version of line_and_point */
X unsigned int x,y;
X int number; /* type of point */
{
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
LATEX_vector(ux,uy)
X unsigned int ux,uy;
{
X if (LATEX_dotspace == 0.0) {
X /* solid line */
#ifdef EMTEX
X if (emtex)
X EMTEX_solid_line(LATEX_posx, (int)ux, LATEX_posy, (int)uy);
X else
#endif
X LATEX_solid_line(LATEX_posx, (int)ux, LATEX_posy, (int)uy);
X } else
X /* dotted line */
X LATEX_dot_line(LATEX_posx, (int)ux, LATEX_posy, (int)uy);
X
X LATEX_posx = ux;
X LATEX_posy = uy;
}
X
static void
LATEX_solid_line(x1,x2, y1,y2)
X int x1,x2, y1,y2;
{
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 current line thickness (size) */
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, (double)x1, (double)y1,
X LATEX_dotsize, (double)y2-y1);
X else if (y1 == y2) /* horizontal line - special case */
X LATEX_rule(code, (double)x1, (double)y1, (double)x2-x1,
X 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
/* 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 */
static void
LATEX_rule(code, x,y, width, height)
X int code; /* how do we treat this rule? */
X double x, y;
X double width;
X double height;
{
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 (valid && combine) {
X /* try to combine new rule with old rule */
X if ((int)lastx == (int)x && lastw == width) { /* vertical rule */
X if (lasth * height >= 0) { /* same sign */
X lasth += height;
X return;
X }
X } else if ((int)lasty == (int)y && lasth == height){ /* horiz rule */
X if (lastw * width >= 0) { /* same sign */
X lastw += width;
X return;
X }
X }
X /* oh well, output last and remember the new one */
X }
X
X if (valid) {
X /* output the rule */
X if (lastw < 0) {
X lastx += lastw;
X lastw = -lastw;
X }
X if (lasth < 0) {
X lasty += lasth;
X lasth = -lasth;
X }
X
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
X if (flush) {
X valid = FALSE;
X } else {
X lastx = x; lasty = y;
X lastw = width; lasth = height;
X valid = TRUE;
X }
}
X
static void
LATEX_dot_line(x1,x2, y1,y2)
X int x1,x2, y1,y2;
{
X static float LATEX_left; /* fraction of space left after last dot */
#ifndef AMIGA_AC_5
X extern double sqrt();
#endif
X /* we draw a dotted line using the current dot spacing */
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_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) / abs(xinc);
X else
X LATEX_left += abs(x2-x1) / abs(xinc);
X else
X if (lasty >= 0)
X LATEX_left = abs(y2 - lasty) / abs(yinc);
X else
X LATEX_left += abs(y2-y1) / abs(yinc);
X }
X
X LATEX_needsdot = (LATEX_left > 0);
X
X LATEX_moved = FALSE;
}
X
static void
LATEX_flushdot()
{
X if (LATEX_needsdot)
X fprintf(outfile, "\\put(%d,%d){%s}\n",
X LATEX_posx, LATEX_posy, LATEX_DOT);
X LATEX_needsdot = FALSE;
}
X
LATEX_arrow(sx,sy, ex,ey, head)
X int sx,sy, ex,ey;
X BOOLEAN head;
{
X best_latex_arrow(sx,sy, ex,ey, 1, head);
X
X LATEX_posx = ex;
X LATEX_posy = ey;
}
X
static void best_latex_arrow(sx,sy, ex,ey, who, head)
X int sx,sy, ex,ey; /* start and end points */
X int who; /* 1=LATEX, 2=EEPIC */
X BOOLEAN head;
{
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 = 0; /* 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){\\%s(0,%d){%d}}\n",
X sx, sy, head ? "vector":"line",
X sign(ey-sy), abs(ey-sy));
X } else if (dy == 0) {
X /* horizontal arrow */
X fprintf(outfile, "\\put(%d,%d){\\%s(%d,0){%d}}\n",
X sx, sy, head ? "vector":"line",
X 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 minerror = 0; /* to shut up turbo C */
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){\\%s(%d,%d){%d}}\n",
X sx, sy, head ? "vector" : "line",
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 */
#ifdef EMTEX
X if (emtex) {
X LATEX_linetype(LATEX_THIN_LINE);
X EMTEX_solid_line(sx,ex,sy,ey);
X } else
#endif
X if (who == 1) {
X LATEX_linetype(LATEX_THIN_LINE);
X LATEX_solid_line(sx,ex,sy,ey);
X }
#ifdef EEPIC
X else {
X EEPIC_move(sx,sy);
X EEPIC_vector(ex,ey);
X }
#endif /* EEPIC */
X /* and then draw an arrowhead (a short vector) there */
X if (head)
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
LATEX_put_text(x, y, str)
X int x,y; /* reference point of string */
X char str[]; /* the text */
{
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
int LATEX_justify_text(mode)
X enum JUSTIFY mode;
{
X latex_justify = mode;
X return (TRUE);
}
X
int LATEX_text_angle(angle)
X int angle;
{
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
LATEX_reset()
{
X LATEX_posx = LATEX_posy = 0; /* current position */
X LATEX_moved = TRUE; /* pen is up after move */
}
X
X
#ifdef EMTEX
X
EMTEX_init()
{
X emtex=TRUE;
X LATEX_posx = LATEX_posy = 0;
X fprintf(outfile, "%% GNUPLOT: LaTeX picture with emtex specials\n");
X fprintf(outfile, "\\setlength{\\unitlength}{%fpt}\n", LATEX_UNIT);
X fprintf(outfile,
X "\\ifx\\plotpoint\\undefined\\newsavebox{\\plotpoint}\\fi\n");
X LATEX_linetype(-1);
}
X
X
EMTEX_reset()
{
X emtex=FALSE;
X LATEX_posx = LATEX_posy = 0;
}
X
X
EMTEX_text()
{
X fprintf(outfile, "\\end{picture}\n");
}
X
X
static void
EMTEX_solid_line(x1,x2, y1,y2)
X int x1,x2, y1,y2;
{
X /* emtex special solid line */
X if (LATEX_moved)
X fprintf(outfile, "\\put(%d,%d){\\special{em:moveto}}\n", x1, y1);
X if ( (x1!=x2) || (y1!=y2) )
X fprintf(outfile, "\\put(%d,%d){\\special{em:lineto}}\n", x2, y2);
X LATEX_posx = x2;
X LATEX_posy = y2;
X LATEX_moved = FALSE;
}
X
X
#endif /* EMTEX */
SHAR_EOF
chmod 0644 gnuplot/term/latex.trm ||
echo 'restore of gnuplot/term/latex.trm failed'
Wc_c="`wc -c < 'gnuplot/term/latex.trm'`"
test 17764 -eq "$Wc_c" ||
echo 'gnuplot/term/latex.trm: original size 17764, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/term/object.h ==============
if test -f 'gnuplot/term/object.h' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/term/object.h (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/term/object.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/object.h' &&
/*
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%
*/
#define DEFAULT -1
X
typedef struct f_pattern {
X int w, h;
X int *p;
X }
X F_pattern;
X
typedef struct f_pen {
X int x, y;
X int *p;
X }
X F_pen;
X
typedef struct f_point {
X int x, y;
X struct f_point *next;
X }
X F_point;
X
typedef struct f_pos {
X int x, y;
X }
X F_pos;
X
typedef struct f_arrow {
X int type;
X int style;
X float thickness;
X float wid;
X float ht;
X }
X F_arrow;
X
typedef struct f_ellipse {
X int type;
#define T_ELLIPSE_BY_RAD 1
#define T_ELLIPSE_BY_DIA 2
#define T_CIRCLE_BY_RAD 3
#define T_CIRCLE_BY_DIA 4
X int style;
X int thickness;
X int color;
#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;
#define UNFILLED (F_pattern *)0
#define BLACK_FILL (F_pattern *)1
#define DARK_GRAY_FILL (F_pattern *)2
#define MED_GRAY_FILL (F_pattern *)3
#define LIGHT_GRAY_FILL (F_pattern *)4
#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
typedef struct f_arc {
X int type;
#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
typedef struct f_line {
X int type;
#define T_POLYLINE 1
#define T_BOX 2
#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
typedef struct f_text {
X int type;
#define T_LEFT_JUSTIFIED 0
#define T_CENTER_JUSTIFIED 1
#define T_RIGHT_JUSTIFIED 2
X int font;
#define DEFAULT_FONT 0
#define ROMAN_FONT 1
#define BOLD_FONT 2
#define ITALIC_FONT 3
#define MODERN_FONT 4
#define TYPEWRITER_FONT 5
X int size; /* point size */
X int color;
X int depth;
X float angle; /* in radian */
X int style;
#define PLAIN 1
#define ITALIC 2
#define BOLD 4
#define OUTLINE 8
#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
typedef struct f_control {
X float lx, ly, rx, ry;
X struct f_control *next;
X }
X F_control;
X
#define int_spline(s) (s->type & 0x2)
#define normal_spline(s) (!(s->type & 0x2))
#define closed_spline(s) (s->type & 0x1)
#define open_spline(s) (!(s->type & 0x1))
X
typedef struct f_spline {
X int type;
#define T_OPEN_NORMAL 0
#define T_CLOSED_NORMAL 1
#define T_OPEN_INTERPOLATED 2
#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
typedef 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
#define ARROW_SIZE sizeof(struct f_arrow)
#define POINT_SIZE sizeof(struct f_point)
#define CONTROL_SIZE sizeof(struct f_control)
#define ELLOBJ_SIZE sizeof(struct f_ellipse)
#define ARCOBJ_SIZE sizeof(struct f_arc)
#define LINOBJ_SIZE sizeof(struct f_line)
#define TEXOBJ_SIZE sizeof(struct f_text)
#define SPLOBJ_SIZE sizeof(struct f_spline)
#define COMOBJ_SIZE sizeof(struct f_compound)
X
/********************** object codes **********************/
X
#define O_ELLIPSE 1
#define O_POLYLINE 2
#define O_SPLINE 3
#define O_TEXT 4
#define O_ARC 5
#define O_COMPOUND 6
#define O_END_COMPOUND -O_COMPOUND
#define O_ALL_OBJECT 99
X
/************ object styles (except for f_text) ************/
X
#define SOLID_LINE 0
#define DASH_LINE 1
#define DOTTED_LINE 2
X
#define CLOSED_PATH 0
#define OPEN_PATH 1
SHAR_EOF
chmod 0666 gnuplot/term/object.h ||
echo 'restore of gnuplot/term/object.h failed'
Wc_c="`wc -c < 'gnuplot/term/object.h'`"
test 5063 -eq "$Wc_c" ||
echo 'gnuplot/term/object.h: original size 5063, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/term/post.trm ==============
if test -f 'gnuplot/term/post.trm' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/term/post.trm (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/term/post.trm (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/post.trm' &&
/* GNUPLOT - post.trm */
/*
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 * postscript
X *
X * AUTHORS
X * Russell Lang
X *
X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
X *
X * The 'postscript' driver produces landscape output 10" wide and 7" high.
X * To get a smaller epsf output use 'set size 0.5,0.5',
X * 'set term postscript portrait', make only one plot per file
X * and change the first line of the postscript file from
X * '%!PS-Adobe-2.0' to '%!PS-Adobe-2.0 EPSF-2.0'
X * To change font to Times-Roman and font size to 20pts use
X * 'set term postscript "Times-Roman" 20'.
X */
X
X
/* PostScript driver by Russell Lang, rjl@monu1.cc.monash.edu.au */
X
char ps_font[MAX_ID_LEN+1] = "Courier" ; /* name of font */
int ps_fontsize = 14; /* size of font in pts */
BOOLEAN ps_portrait = FALSE; /* vertical page */
BOOLEAN ps_color = FALSE;
int ps_page=0; /* page count */
int ps_path_count=0; /* count of lines in path */
int ps_ang=0; /* text angle */
enum JUSTIFY ps_justify=LEFT; /* text is flush left */
X
char *PS_header[] = {
"/vpt2 vpt 2 mul def\n",
"/hpt2 hpt 2 mul def\n",
/* flush left show */
"/Lshow { currentpoint stroke moveto\n",
" 0 vshift rmoveto show } def\n",
/* flush right show */
"/Rshow { currentpoint stroke moveto\n",
" dup stringwidth pop neg vshift rmoveto show } def\n",
/* centred show */
"/Cshow { currentpoint stroke moveto\n",
" dup stringwidth pop -2 div vshift rmoveto show } def\n",
/* Dash or Color Line */
"/DL { Color {setrgbcolor [] 0 setdash pop}\n",
" {pop pop pop 0 setdash} ifelse } def\n",
/* Border Lines */
"/BL { stroke gnulinewidth 2 mul setlinewidth } def\n",
/* Axes Lines */
"/AL { stroke gnulinewidth 2 div setlinewidth } def\n",
/* Plot Lines */
"/PL { stroke gnulinewidth setlinewidth } def\n",
/* Line Types */
"/LTb { BL [] 0 0 0 DL } def\n", /* border */
"/LTa { AL [1 dl 2 dl] 0 setdash 0 0 0 setrgbcolor } def\n", /* axes */
"/LT0 { PL [] 0 1 0 DL } def\n",
"/LT1 { PL [4 dl 2 dl] 0 0 1 DL } def\n",
"/LT2 { PL [2 dl 3 dl] 1 0 0 DL } def\n",
"/LT3 { PL [1 dl 1.5 dl] 1 0 1 DL } def\n",
"/LT4 { PL [5 dl 2 dl 1 dl 2 dl] 0 1 1 DL } def\n",
"/LT5 { PL [4 dl 3 dl 1 dl 3 dl] 1 1 0 DL } def\n",
"/LT6 { PL [2 dl 2 dl 2 dl 4 dl] 0 0 0 DL } def\n",
"/LT7 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 1 0.3 0 DL } def\n",
"/LT8 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 0.5 0.5 0.5 DL } def\n",
"/M {moveto} def\n",
"/L {lineto} def\n",
"/P { stroke [] 0 setdash\n", /* Point */
" currentlinewidth 2 div sub moveto\n",
" 0 currentlinewidth rlineto stroke } def\n",
"/D { stroke [] 0 setdash 2 copy vpt add moveto\n", /* Diamond */
" hpt neg vpt neg rlineto hpt vpt neg rlineto\n",
" hpt vpt rlineto hpt neg vpt rlineto closepath stroke\n",
" P } def\n",
"/A { stroke [] 0 setdash vpt sub moveto 0 vpt2 rlineto\n", /* Plus (Add) */
" currentpoint stroke moveto\n",
" hpt neg vpt neg rmoveto hpt2 0 rlineto stroke\n",
" } def\n",
"/B { stroke [] 0 setdash 2 copy exch hpt sub exch vpt add moveto\n", /* Box */
" 0 vpt2 neg rlineto hpt2 0 rlineto 0 vpt2 rlineto\n",
" hpt2 neg 0 rlineto closepath stroke\n",
" P } def\n",
"/C { stroke [] 0 setdash exch hpt sub exch vpt add moveto\n", /* Cross */
" hpt2 vpt2 neg rlineto currentpoint stroke moveto\n",
" hpt2 neg 0 rmoveto hpt2 vpt2 rlineto stroke } def\n",
"/T { stroke [] 0 setdash 2 copy vpt 1.12 mul add moveto\n", /* Triangle */
" hpt neg vpt -1.62 mul rlineto\n",
" hpt 2 mul 0 rlineto\n",
" hpt neg vpt 1.62 mul rlineto closepath stroke\n",
" P } def\n",
"/S { 2 copy A C} def\n", /* Star */
NULL
};
X
#define PS_XOFF 50 /* page offset in pts */
#define PS_YOFF 50
X
#define PS_XMAX 7200
#define PS_YMAX 5040
X
#define PS_XLAST (PS_XMAX - 1)
#define PS_YLAST (PS_YMAX - 1)
X
#define PS_VTIC (PS_YMAX/80)
#define PS_HTIC (PS_YMAX/80)
X
#define PS_SC (10) /* scale is 1pt = 10 units */
#define PS_LW (0.5*PS_SC) /* linewidth = 0.5 pts */
X
#define PS_VCHAR (14*PS_SC) /* default is 14 point characters */
#define PS_HCHAR (14*PS_SC*6/10)
X
X
PS_options()
{
X extern struct value *const_express();
X extern double real();
X
X if (!END_OF_COMMAND) {
X if (almost_equals(c_token,"p$ortrait")) {
X ps_portrait=TRUE;
X c_token++;
X }
X else if (almost_equals(c_token,"l$andscape")) {
X ps_portrait=FALSE;
X c_token++;
X }
X else if (almost_equals(c_token,"d$efault")) {
X ps_portrait=FALSE;
X ps_color=FALSE;
X strcpy(ps_font,"Courier");
X ps_fontsize = 14;
X c_token++;
X }
X }
X
X if (!END_OF_COMMAND) {
X if (almost_equals(c_token,"m$onochrome")) {
X ps_color=FALSE;
X c_token++;
X }
X else if (almost_equals(c_token,"c$olor")) {
X ps_color=TRUE;
X c_token++;
X }
X }
X
X if (!END_OF_COMMAND && isstring(c_token)) {
X quote_str(ps_font,c_token);
X c_token++;
X }
X
X if (!END_OF_COMMAND) {
X /* We have font size specified */
X struct value a;
X ps_fontsize = (int)real(const_express(&a));
X c_token++;
X term_tbl[term].v_char = (unsigned int)(ps_fontsize*PS_SC);
X term_tbl[term].h_char = (unsigned int)(ps_fontsize*PS_SC*6/10);
X }
X
X sprintf(term_options,"%s %s \"%s\" %d",
X ps_portrait ? "portrait" : "landscape",
X ps_color ? "color" : "monochrome",ps_font,ps_fontsize);
}
X
X
PS_init()
{
struct termentry *t = &term_tbl[term];
int i;
X ps_page = 0;
X fprintf(outfile,"%%!PS-Adobe-2.0\n");
X fprintf(outfile,"%%%%Creator: gnuplot\n");
X fprintf(outfile,"%%%%DocumentFonts: %s\n", ps_font);
X fprintf(outfile,"%%%%BoundingBox: %d %d ", PS_XOFF,PS_YOFF);
X if (ps_portrait)
X fprintf(outfile,"%d %d\n",
X (int)(xsize*(PS_XMAX)/PS_SC+0.5+PS_XOFF),
X (int)(ysize*(PS_YMAX)/PS_SC+0.5+PS_YOFF) );
X else
X fprintf(outfile,"%d %d\n",
X (int)(ysize*(PS_YMAX)/PS_SC+0.5+PS_XOFF),
X (int)(xsize*(PS_XMAX)/PS_SC+0.5+PS_YOFF) );
X fprintf(outfile,"%%%%Pages: (atend)\n");
X fprintf(outfile,"%%%%EndComments\n");
X fprintf(outfile,"/gnudict 40 dict def\ngnudict begin\n");
X fprintf(outfile,"/Color %s def\n",ps_color ? "true" : "false");
X fprintf(outfile,"/gnulinewidth %.3f def\n",PS_LW);
X fprintf(outfile,"/vshift %d def\n", (int)(t->v_char)/(-3));
X fprintf(outfile,"/dl {%d mul} def\n",PS_SC); /* dash length */
X fprintf(outfile,"/hpt %.1f def\n",PS_HTIC/2.0);
X fprintf(outfile,"/vpt %.1f def\n",PS_VTIC/2.0);
X for ( i=0; PS_header[i] != NULL; i++)
X fprintf(outfile,"%s",PS_header[i]);
X fprintf(outfile,"end\n");
X fprintf(outfile,"%%%%EndProlog\n");
}
X
X
PS_graphics()
{
struct termentry *t = &term_tbl[term];
X ps_page++;
X fprintf(outfile,"%%%%Page: %d %d\n",ps_page,ps_page);
X fprintf(outfile,"gnudict begin\n");
X fprintf(outfile,"gsave\n");
X fprintf(outfile,"%d %d translate\n",PS_XOFF,PS_YOFF);
X if (ps_portrait) {
X fprintf(outfile,"%.3f %.3f scale\n", xsize/PS_SC, ysize/PS_SC);
X }
X else {
X fprintf(outfile,"%.3f %.3f scale\n", ysize/PS_SC, xsize/PS_SC);
X fprintf(outfile,"90 rotate\n0 %d translate\n", -PS_YMAX);
X }
X fprintf(outfile,"0 setgray\n");
X fprintf(outfile,"/%s findfont %d ", ps_font, (t->v_char) );
X fprintf(outfile,"scalefont setfont\n");
X fprintf(outfile,"newpath\n");
X ps_path_count = 0;
}
X
X
PS_text()
{
X ps_path_count = 0;
X fprintf(outfile,"stroke\ngrestore\nend\nshowpage\n");
}
X
X
PS_reset()
{
X fprintf(outfile,"%%%%Trailer\n");
X fprintf(outfile,"%%%%Pages: %d\n",ps_page);
}
X
X
PS_linetype(linetype)
int linetype;
{
char *line = "ba012345678";
X fprintf(outfile,"LT%c\n", line[(linetype%9)+2]);
X ps_path_count = 0;
}
X
X
PS_move(x,y)
unsigned int x,y;
{
X fprintf(outfile,"%d %d M\n", x, y);
X ps_path_count += 1;
}
X
X
PS_vector(x,y)
unsigned int x,y;
{
X fprintf(outfile,"%d %d L\n", x, y);
X ps_path_count += 1;
X if (ps_path_count >= 400) {
X fprintf(outfile,"currentpoint stroke moveto\n");
X ps_path_count = 0;
X }
}
X
X
PS_put_text(x,y,str)
unsigned int x, y;
char *str;
{
char ch;
X PS_move(x,y);
X if (ps_ang != 0)
X fprintf(outfile,"currentpoint gsave translate %d rotate 0 0 moveto\n"
X ,ps_ang*90);
X putc('(',outfile);
X ch = *str++;
X while(ch!='\0') {
X if ( (ch=='(') || (ch==')') || (ch=='\\') )
X putc('\\',outfile);
X putc(ch,outfile);
X ch = *str++;
X }
X switch(ps_justify) {
X case LEFT : fprintf(outfile,") Lshow\n");
X break;
X case CENTRE : fprintf(outfile,") Cshow\n");
X break;
X case RIGHT : fprintf(outfile,") Rshow\n");
X break;
X }
X if (ps_ang != 0)
X fprintf(outfile,"grestore\n");
X ps_path_count = 0;
}
X
int PS_text_angle(ang)
int ang;
{
X ps_ang=ang;
X return TRUE;
}
X
int PS_justify_text(mode)
enum JUSTIFY mode;
{
X ps_justify=mode;
X return TRUE;
}
X
/* postscript point routines */
PS_point(x,y,number)
int x,y;
int number;
{
char *point = "PDABCTS";
X number %= POINT_TYPES;
X if (number < -1)
X number = -1; /* negative types are all 'dot' */
X fprintf(outfile,"%d %d %c\n", x, y, point[number+1]);
X ps_path_count = 0;
}
X
SHAR_EOF
chmod 0644 gnuplot/term/post.trm ||
echo 'restore of gnuplot/term/post.trm failed'
Wc_c="`wc -c < 'gnuplot/term/post.trm'`"
test 9281 -eq "$Wc_c" ||
echo 'gnuplot/term/post.trm: original size 9281, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/term/dxf.trm ==============
if test -f 'gnuplot/term/dxf.trm' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/term/dxf.trm (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/term/dxf.trm (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/dxf.trm' &&
/* GNUPLOT - dxf.trm */
/*
X * Copyright (C) 1991
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 * AutoCad (Release 10.x) dxf file format (import with AutoCad dxfin command)
X *
X *
X * AUTHOR
X * Florian Hiss (fhis1231@w204zrz.zrz.tu-berlin.de)
X *
X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
*/
X
#define DXF_UNIT 60.0
#define LINEWIDTH 0.0351 /* default line width is 1 pt */
X
/* 120 (autocad units) wide by 80 (autocad units) high (default)
X use the GNUPLOT 'set size' command to change the defaults */
#define DXF_XMAX (120.0 * DXF_UNIT)
#define DXF_YMAX (80.0 * DXF_UNIT)
#define DXF_HTIC (0.01 * DXF_XMAX) /* 1.0 percent */
#define DXF_VTIC (0.01 * DXF_YMAX) /* 1.0 percent */
#define DXF_HCHAR (0.014 * DXF_XMAX) /* 1.4 percent */
#define DXF_VCHAR (0.026 * DXF_YMAX) /* 2.6 percent */
#define DXF_TEXTHEIGHT (0.7 * DXF_VCHAR) /* actual text height */
#define DXF_TEXTWIDTH (0.7 * DXF_HCHAR) /* actual text width,
X only a guess, we don't know the width of a character of given height
X of the AutoCad STANDARD text font, so change it if you like */
#define DXF_LINE_TYPES 7 /* number of line types we support. see below */
#define MAX_LAYER 7 /* number of layers used for the drawing. see below */
#define LT_SCALE 1 /* line type scaling */
X
static unsigned int DXF_posx;
static unsigned int DXF_posy;
static unsigned int dxf_linetype; /* linetype is mapped to a layer. see below. */
enum JUSTIFY dxf_justify = LEFT;
static float dxf_angle = 0.0; /* either 0 (horizontal) or 90.0 (vertical) */
X
/* text style used in the entire drawing */
static char *text_style = "STANDARD";
/* text always resides on layer 0 */
#define TEXT_LAYER 0
/* each linetype resides on its own layer. each layer has its own color.
X this avoids difficulties that AutoCad has with proper scaling of
X the linetypes.
X change the colors according to your needs */
static char *layer_name[] = {"0","1","2","3","4","5","6"};
/* the colours are white, red, yellow, green, cyan, blue, magenta.
X change them according to your needs.
X when using a black and white plotting device the colours map to different
X line thicknesses. see description of AutoCad print / plot command */
static char *layer_colour[] = {"7","1","2","3","4","5","6"};
/* support line types AutoCad has to offer by default. */
static char *layer_lines[] = {"CONTINUOUS","DASHED","HIDDEN","CENTER","PHANTOM",
X "DOT","DASHDOT"};
X
static BOOLEAN vector_was_last = FALSE;
X
DXF_init()
{
X DXF_posx = DXF_posy = 0;
X dxf_linetype = 0;
X dxf_angle = 0.0;
X vector_was_last = FALSE;
}
X
DXF_graphics()
{
X register struct termentry *t = &term_tbl[term];
X int i;
X
X fprintf(outfile,"999\n");
X fprintf(outfile,"%% GNUPLOT: dxf file for AutoCad\n");
X fprintf(outfile," 0\nSECTION\n 2\nHEADER\n");
X fprintf(outfile," 9\n$EXTMIN\n");
X fprintf(outfile," 10\n0.000\n 20\n0.000\n");
X fprintf(outfile," 9\n$EXTMAX\n");
X fprintf(outfile," 10\n%-6.3f\n 20\n%-6.3f\n",t->xmax/DXF_UNIT,t->ymax/DXF_UNIT);
X fprintf(outfile," 9\n$LIMMIN\n");
X fprintf(outfile," 10\n0.000\n 20\n0.000\n");
X fprintf(outfile," 9\n$LIMMAX\n");
X fprintf(outfile," 10\n%-6.3f\n 20\n%-6.3f\n",t->xmax/DXF_UNIT,t->ymax/DXF_UNIT);
X fprintf(outfile," 9\n$TEXTSTYLE\n 7\n%s\n",text_style);
X fprintf(outfile," 9\n$TEXTSIZE\n 40\n%-6.3f\n",DXF_TEXTHEIGHT/DXF_UNIT);
X fprintf(outfile," 9\n$PLINEWID\n 40\n%-6.4f\n",LINEWIDTH);
X fprintf(outfile," 9\n$LTSCALE\n 40\n%-6.3f\n",LT_SCALE);
X fprintf(outfile," 9\n$COORDS\n 70\n 1\n");
X fprintf(outfile," 9\n$CELTYPE\n 6\nBYLAYER\n"); /* entity line type name */
X fprintf(outfile," 9\n$CLAYER\n 8\n0\n"); /* current layer */
X fprintf(outfile," 9\n$CECOLOR\n 62\n %s\n",layer_colour[0]);
X fprintf(outfile," 9\n$MENU\n 1\nacad\n");
X fprintf(outfile," 0\nENDSEC\n");
X fprintf(outfile," 0\nSECTION\n 2\nTABLES\n");
X /* the linetype table */
X fprintf(outfile,"0\nTABLE\n 2\nLTYPE\n 70\n %d\n",DXF_LINE_TYPES);
X fprintf(outfile,"0\nLTYPE\n 2\nCONTINUOUS\n 70\n 64\n");
X fprintf(outfile," 3\nSolid line\n 72\n 65\n 73\n 0\n 40\n0.0\n");
X fprintf(outfile," 0\nLTYPE\n 2\nDASHED\n 70\n 64\n");
X fprintf(outfile," 3\n__ __ __ __ __ __ __ __ __ __ __ __ __ __ __\n");
X fprintf(outfile," 72\n 65\n 73\n 2\n 40\n0.75\n 49\n0.5\n 49\n-0.25\n");
X fprintf(outfile," 0\nLTYPE\n 2\nHIDDEN\n 70\n 64\n");
X fprintf(outfile," 3\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n");
X fprintf(outfile," 72\n 65\n 73\n 2\n 40\n0.375\n 49\n0.25\n 49\n-0.125\n");
X fprintf(outfile," 0\nLTYPE\n 2\nCENTER\n 70\n 64\n");
X fprintf(outfile," 3\n____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____\n");
X fprintf(outfile," 72\n 65\n 73\n 4\n 40\n2.0\n 49\n1.25\n 49\n-0.25\n");
X fprintf(outfile," 49\n0.25\n 49\n-0.25\n");
X fprintf(outfile," 0\nLTYPE\n 2\nPHANTOM\n 70\n 64\n");
X fprintf(outfile," 3\n_____ _ _ _____ _ _ _____ _ _ _____ _ _ ____\n");
X fprintf(outfile," 72\n 65\n 73\n 6\n 40\n2.5\n 49\n1.25\n");
X fprintf(outfile," 49\n-0.25\n 49\n0.25\n 49\n-0.25\n 49\n0.25\n 49\n-0.25\n");
X fprintf(outfile," 0\nLTYPE\n 2\nDOT\n 70\n 64\n");
X fprintf(outfile," 3\n...............................................\n");
X fprintf(outfile," 72\n 65\n 73\n 2\n 40\n0.25\n 49\n0.0\n 49\n-0.25\n");
X fprintf(outfile," 0\nLTYPE\n 2\nDASHDOT\n 70\n 64\n");
X fprintf(outfile," 3\n__ . __ . __ . __ . __ . __ . __ . __ . __ . __\n");
X fprintf(outfile," 72\n 65\n 73\n 4\n 40\n1.0\n 49\n0.5\n 49\n-0.25\n");
X fprintf(outfile," 49\n0.0\n 49\n-0.25\n");
X fprintf(outfile," 0\nENDTAB\n");
X /* the layer table */
X fprintf(outfile," 0\nTABLE\n 2\nLAYER\n 70\n %-d\n",MAX_LAYER);
X for (i = 1; i <= MAX_LAYER; i++)
X fprintf(outfile," 0\nLAYER\n 2\n%s\n 70\n 64\n62\n %s\n 6\n%s\n",
X layer_name[i-1],layer_colour[i-1],layer_lines[i-1]);
X fprintf(outfile," 0\nENDTAB\n0\nENDSEC\n");
X /* no blocks for insertion */
X fprintf(outfile," 0\nSECTION\n 2\nBLOCKS\n 0\nENDSEC\n");
X /* start the entity section */
X fprintf(outfile," 0\nSECTION\n");
X fprintf(outfile," 2\nENTITIES\n");
}
X
DXF_text()
{
X if (vector_was_last) fprintf(outfile," 0\nSEQEND\n");
X fprintf(outfile," 0\nENDSEC\n 0\nEOF\n");
}
X
DXF_linetype(linetype)
X int linetype;
{
X linetype = abs(linetype);
X linetype = linetype%DXF_LINE_TYPES;
X dxf_linetype = linetype;
}
X
DXF_move(x, y)
X unsigned int x, y;
{
X DXF_posx = x;
X DXF_posy = y;
X if (vector_was_last) fprintf(outfile," 0\nSEQEND\n");
X vector_was_last = FALSE;
X fprintf(outfile," 0\nPOLYLINE\n 8\n%s\n 66\n 1\n",layer_name[dxf_linetype]);
X fprintf(outfile," 6\n%s\n",layer_lines[dxf_linetype]);
X fprintf(outfile," 0\nVERTEX\n 8\n%s\n",layer_name[dxf_linetype]);
X fprintf(outfile," 6\n%s\n",layer_lines[dxf_linetype]);
X fprintf(outfile," 10\n%-6.3f\n 20\n%-6.3f\n 30\n0.000\n",DXF_posx/DXF_UNIT,DXF_posy/DXF_UNIT);
}
X
DXF_vector(ux, uy)
X unsigned int ux, uy;
{
X DXF_posx = ux;
X DXF_posy = uy;
X vector_was_last = TRUE;
X fprintf(outfile," 0\nVERTEX\n 8\n%s\n",layer_name[dxf_linetype]);
X fprintf(outfile," 6\n%s\n",layer_lines[dxf_linetype]);
X fprintf(outfile," 10\n%-6.3f\n 20\n%-6.3f\n 30\n0.000\n",
X DXF_posx/DXF_UNIT,DXF_posy/DXF_UNIT);
}
X
DXF_put_text(x, y, str)
X int x, y;
X char str[];
{
X int stl;
X float xleftpos, yleftpos, xrightpos,yrightpos;
X /* ignore empty strings */
X if (str[0] == '\0') return;
SHAR_EOF
true || echo 'restore of gnuplot/term/dxf.trm failed'
fi
echo 'End of part 17'
echo 'File gnuplot/term/dxf.trm is continued in part 18'
echo 18 > _shar_seq_.tmp
exit 0
exit 0 # Just in case...
--
Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
Sterling Software, IMD UUCP: uunet!sparky!kent
Phone: (402) 291-8300 FAX: (402) 291-4362
Please send comp.sources.misc-related mail to kent@uunet.uu.net.