home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume24
/
gnuplot3
/
part18
< prev
next >
Wrap
Text File
|
1991-10-27
|
50KB
|
2,011 lines
Newsgroups: comp.sources.misc
From: gershon%gr@cs.utah.edu (Elber Gershon)
Subject: v24i040: gnuplot3 - interactive function plotting utility, Part18/26
Message-ID: <1991Oct28.002342.12603@sparky.imd.sterling.com>
X-Md4-Signature: f174e0f3272f7425b1b51e2304a17260
Date: Mon, 28 Oct 1991 00:23:42 GMT
Approved: kent@sparky.imd.sterling.com
Submitted-by: gershon%gr@cs.utah.edu (Elber Gershon)
Posting-number: Volume 24, Issue 40
Archive-name: gnuplot3/part18
Environment: UNIX, MS-DOS, VMS
Supersedes: gnuplot2: Volume 11, Issue 65-79
#!/bin/sh
# this is Part.18 (part 18 of a multipart archive)
# do not concatenate these parts, unpack them in order with /bin/sh
# file gnuplot/term/dxf.trm continued
#
if test ! -r _shar_seq_.tmp; then
echo 'Please unpack part 1 first!'
exit 1
fi
(read Scheck
if test "$Scheck" != 18; 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/dxf.trm'
else
echo 'x - continuing file gnuplot/term/dxf.trm'
sed 's/^X//' << 'SHAR_EOF' >> 'gnuplot/term/dxf.trm' &&
X
X stl = 0; while (str[stl] != '\0') ++stl; /* get string length */
X
X if (vector_was_last) fprintf(outfile," 0\nSEQEND\n");
X vector_was_last = FALSE;
X fprintf(outfile," 0\nTEXT\n 8\n%s\n",layer_name[TEXT_LAYER]);
X if (dxf_angle != 90.0)
X {
X switch (dxf_justify)
X {
X case LEFT : xleftpos = (float) x;
X yleftpos = (float)(y-DXF_VCHAR/4.0);
X xrightpos = (float)(x+stl*DXF_TEXTWIDTH);
X yrightpos = yleftpos; break;
X case RIGHT : xleftpos = (float)(x-stl*DXF_TEXTWIDTH);
X yleftpos = (float)(y-DXF_VCHAR/4.0);
X xrightpos = (float) x;
X yrightpos = yleftpos; break;
X case CENTRE: xleftpos = (float)(x-stl*DXF_TEXTWIDTH/2.0);
X yleftpos = (float)(y-DXF_VCHAR/4.0);
X xrightpos = (float) x; /* center point */
X yrightpos = yleftpos;
X break;
X }
X }
X else
X {
X switch (dxf_justify)
X {
X case LEFT : xleftpos = (float)(x+DXF_VCHAR/4.0);
X yleftpos = (float) y;
X xrightpos = xleftpos;
X yrightpos = (float)(y+stl*DXF_TEXTWIDTH); break;
X case RIGHT : xleftpos = (float)(x+DXF_VCHAR/4.0);
X yleftpos = (float)(y-stl*DXF_HCHAR);
X xrightpos = xleftpos;
X yrightpos = (float) y; break;
X case CENTRE: xleftpos = (float)(x+DXF_VCHAR/4.0);
X yleftpos = (float)(y-stl*DXF_TEXTWIDTH/2.0);
X xrightpos = xleftpos;
X yrightpos = (float) y; /* center point */
X break;
X }
X }
X fprintf(outfile," 10\n%-6.3f\n 20\n%-6.3f\n 30\n0.000\n",
X xleftpos/DXF_UNIT,yleftpos/DXF_UNIT);
X fprintf(outfile," 40\n%-6.3f\n 1\n%s\n 50\n%-6.3f\n",
X DXF_TEXTHEIGHT/DXF_UNIT,str,dxf_angle);
X fprintf(outfile," 7\n%s\n",text_style);
X if (dxf_justify != LEFT)
X {
X fprintf(outfile," 72\n%d\n",dxf_justify);
X fprintf(outfile," 11\n%-6.3f\n 21\n%-6.3f\n 31\n0.000\n",
X xrightpos/DXF_UNIT,yrightpos/DXF_UNIT);
X }
}
X
DXF_text_angle(angle)
X int angle;
{
X dxf_angle = 0.0;
X if (angle == 1) dxf_angle = 90.0;
X return(TRUE);
}
X
DXF_justify_text(mode)
X enum JUSTIFY mode;
{
X dxf_justify = mode;
X return(TRUE);
}
X
DXF_reset()
{
X DXF_posx = DXF_posy = 0;
}
X
X
SHAR_EOF
echo 'File gnuplot/term/dxf.trm is complete' &&
chmod 0644 gnuplot/term/dxf.trm ||
echo 'restore of gnuplot/term/dxf.trm failed'
Wc_c="`wc -c < 'gnuplot/term/dxf.trm'`"
test 9980 -eq "$Wc_c" ||
echo 'gnuplot/term/dxf.trm: original size 9980, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/term/qms.trm ==============
if test -f 'gnuplot/term/qms.trm' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/term/qms.trm (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/term/qms.trm (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/qms.trm' &&
/* GNUPLOT - qms.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 * QMS laser printers
X *
X * AUTHORS
X * Colin Kelley, Thomas Williams, Russell Lang
X *
X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
X *
X */
X
#define QMS_XMAX 9000
#define QMS_YMAX 6000
X
#define QMS_XLAST (QMS_XMAX - 1)
#define QMS_YLAST (QMS_YMAX - 1)
X
#define QMS_VCHAR 120
#define QMS_HCHAR 70
#define QMS_VTIC 70
#define QMS_HTIC 70
X
int qms_line = 0; /* to remember current line type */
X
QMS_init()
{
/* This was just ^IOL, but at Rutgers at least we need some more stuff */
X fprintf(outfile,"^PY^-\n^IOL\n^ISYNTAX00000^F^IB11000^IJ00000^IT00000\n");
/* ^ QUIC on ^set defaults ^ set botttom,top,left margins
X ^landscape ^free format */
/* set defaults are: implicit decimal point, units in inches,
X numbers left justified, units in 1/1000 inch, do not ignore spaces */
/* margins are in 1/1000 inch units */
}
X
X
QMS_graphics()
{
X fprintf(outfile,"^IGV\n");
/* ^enter graphics vector mode */
}
X
X
X
QMS_text()
{
/* added ^-, because ^, after an ^I command doesn't actually print a page */
/* Did anybody try this code out? [uhh...-cdk] */
X fprintf(outfile,"^IGE\n^-^,");
/* ^exit graphics vector mode
X ^pass terminator
X ^print page */
}
X
X
QMS_linetype(linetype)
int linetype;
{
static int width[2+9] = {7, 3, 3, 3, 3, 5, 5, 5, 7, 7, 7};
static int type[2+9] = {0, 1, 0, 2, 3, 0, 2, 3, 0, 2, 3};
/*
X * I don't know about Villanova, but on our printer, using ^V without
X * previously setting up a pattern crashes the microcode.
X * [nope, doesn't crash here. -cdk]
X * [it generates a controller error here on dotted lines. - rjl]
X */
/* Code to define patterns added by rjl
X * According to the manual it should work - but it doesn't
X */
X qms_line = linetype;
X if (linetype >= 9)
X linetype %= 9;
X fprintf(outfile,"^PW%02d\n",width[linetype+2]);
/* ^width in dots */
X switch (type[linetype+2]) {
X case 1 : /* short dash */
X fprintf(outfile,"^PV102025^G\n^V1\n");
/* ^PV = define pattern vector, 1 = pattern number,
X 02 = number of pen downs and ups, 025 = .025" length of ups/downs */
X break;
X case 2 : /* medium dash */
X fprintf(outfile,"^PV202050^G\n^V2\n");
X break;
X case 3 : /* long dash */
X fprintf(outfile,"^PV302100^G\n^V3\n");
X break;
X default:
X case 0 :
X fprintf(outfile,"^V0\n");
X break;
X }
}
X
X
QMS_move(x,y)
int x,y;
{
X fprintf(outfile,"^U%05d:%05d\n", 1000 + x, QMS_YLAST + 1000 - y);
/* ^pen up vector*/
}
X
X
QMS_vector(x2,y2)
int x2,y2;
{
X fprintf(outfile,"^D%05d:%05d\n", 1000 + x2, QMS_YLAST + 1000 - y2);
/* ^pen down vector*/
}
X
X
QMS_put_text(x,y,str)
unsigned int x,y;
char str[];
{
char ch;
X QMS_move(x,y + QMS_VCHAR/3);
X fputs("^IGE\n",outfile);
X ch = *str++;
X while(ch!='\0') {
X if (ch=='^')
X putc('^',outfile);
X putc(ch,outfile);
X ch = *str++;
X }
X fputs("\n^IGV\n",outfile);
X QMS_linetype(qms_line); /* restore line type */
}
X
X
QMS_reset()
{
X fprintf(outfile,"^PN^-\n");
/* ^QUIC off*/
}
X
SHAR_EOF
chmod 0666 gnuplot/term/qms.trm ||
echo 'restore of gnuplot/term/qms.trm failed'
Wc_c="`wc -c < 'gnuplot/term/qms.trm'`"
test 3785 -eq "$Wc_c" ||
echo 'gnuplot/term/qms.trm: original size 3785, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/term/regis.trm ==============
if test -f 'gnuplot/term/regis.trm' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/term/regis.trm (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/term/regis.trm (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/regis.trm' &&
/* GNUPLOT - regis.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 * REGIS devices
X *
X * AUTHORS
X * Colin Kelley, Thomas Williams
X *
X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
X *
X */
X
#define REGISXMAX 800
#define REGISYMAX 440
X
#define REGISXLAST (REGISXMAX - 1)
#define REGISYLAST (REGISYMAX - 1)
X
#define REGISVCHAR 20
#define REGISHCHAR 9
#define REGISVTIC 8
#define REGISHTIC 6
X
int REGISang = 0;
X
REGISinit()
{
X fprintf(outfile,"\033[r\033[24;1H");
/* 1 2
X 1. reset scrolling region
X 2. locate cursor on bottom line
*/
}
X
X
/* thanks to calmasd!dko (Dan O'Neill) for adding S(E) for vt125s */
REGISgraphics()
{
X fprintf(outfile,"\033[2J\033P1pS(C0)S(E)");
/* 1 2 3 4 5
X 1. clear screen
X 2. enter ReGIS graphics
X 3. turn off graphics diamond cursor
X 4. clear graphics screen
*/
X (void) REGIStext_angle(0); /* select text size and angle */
}
X
X
REGIStext()
{
X fprintf(outfile,"\033\\\033[24;1H");
/* 1 2
X 1. Leave ReGIS graphics mode
X 2. locate cursor on last line of screen
*/
}
X
X
REGISlinetype(linetype)
int linetype;
{
X /* This will change color in order G,R,B,G-dot,R-dot,B-dot */
static int in_map[9 + 2] = {2, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1};
static int lt_map[9 + 2] = {1, 4, 1, 1, 1, 4, 4, 4, 6, 6, 6};
X
X if (linetype >= 9)
X linetype %= 9;
X fprintf(outfile, "W(I%d)", in_map[linetype + 2]);
X fprintf(outfile, "W(P%d)", lt_map[linetype + 2]);
}
X
X
REGISmove(x,y)
int x,y;
{
X fprintf(outfile,"P[%d,%d]",x,REGISYLAST-y,x,REGISYLAST-y);
}
X
X
REGISvector(x,y)
int x,y;
{
X fprintf(outfile,"v[]v[%d,%d]",x,REGISYLAST - y);
/* the initial v[] is needed to get the first pixel plotted */
}
X
X
/* put_text and text_angle by rjl */
REGISput_text(x,y,str)
int x, y;
char *str;
{
X if (REGISang==1)
X REGISmove(x-REGISVCHAR/2-1,y);
X else
X REGISmove(x,y+REGISVCHAR/2-1);
X (void) putc('T',outfile); (void) putc('\'',outfile);
X while (*str) {
X (void) putc(*str,outfile);
X if (*str == '\'')
X (void) putc('\'',outfile); /* send out another one */
X str++;
X }
X (void) putc('\'',outfile);
}
X
X
int REGIStext_angle(ang)
int ang;
{
X REGISang = ang;
X if (ang == 1)
X fputs("T(D90,S1)",outfile);
X else
X fputs("T(D0,S1)",outfile);
X return TRUE;
}
X
X
REGISreset()
{
X fprintf(outfile,"\033[2J\033[24;1H");
}
X
SHAR_EOF
chmod 0666 gnuplot/term/regis.trm ||
echo 'restore of gnuplot/term/regis.trm failed'
Wc_c="`wc -c < 'gnuplot/term/regis.trm'`"
test 2967 -eq "$Wc_c" ||
echo 'gnuplot/term/regis.trm: original size 2967, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/term/sun.trm ==============
if test -f 'gnuplot/term/sun.trm' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/term/sun.trm (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/term/sun.trm (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/sun.trm' &&
/* GNUPLOT - sun.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 * SUNview windowing system
X *
X * AUTHORS
X * Maurice Castro
X *
X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
X *
X */
X
#include <suntool/sunview.h>
#include <suntool/canvas.h>
#include <suntool/scrollbar.h>
#include <suntool/panel.h>
#include <pixrect/pixrect_hs.h>
X
#define SUN_XMAX 600
#define SUN_YMAX 512
X
#define SUN_VCHAR (12) /* default, will be changed */
#define SUN_HCHAR (8) /* default, will be changed */
#define SUN_VTIC (SUN_YMAX/80)
#define SUN_HTIC (SUN_XMAX/80)
#define MARGIN 5
#define MINWIN 128
X
static Frame frame;
static Canvas canvas;
static Pixwin *pw;
static struct pixfont *sun_font = NULL;
X
static enum JUSTIFY sun_justify=LEFT;
X
static Notify_value local_notice_destroy();
X
extern Notify_error notify_dispatch();
X
/* dotted line generator */
unsigned int sun_value = 1; /* this can be used for colour */
unsigned int sun_line_mask = 0xffff; /* 16 bit mask for dotted lines */
static unsigned int sun_pattern[] = {0xffff, 0x1111,
X 0xffff, 0x5555, 0x3333, 0x7777, 0x3f3f, 0x0f0f, 0x5f5f};
int sun_mask_count = 0;
unsigned int sun_lastx, sun_lasty; /* last pixel set - used by sun_line */
X
X
SUN_init()
{
X struct termentry *t = &term_tbl[term];
X struct pr_subregion bound;
X
X frame = window_create(NULL, FRAME,
X FRAME_LABEL, "Gnuplot",
X 0);
X notify_interpose_destroy_func(frame,local_notice_destroy);
X canvas = window_create(frame, CANVAS,
X CANVAS_AUTO_EXPAND, TRUE,
X CANVAS_AUTO_SHRINK, TRUE,
X CANVAS_MARGIN, MARGIN,
X 0);
X notify_do_dispatch();
X pw = canvas_pixwin(canvas);
X window_set(frame, WIN_SHOW, TRUE, 0);
X
X /* figure out font and rough size */
X sun_font = pf_default();
X pf_textbound(&bound, 1, sun_font, "M");
X t->v_char = bound.size.y;
X t->h_char = bound.size.x;
X
X return;
}
X
SUN_graphics()
{
X term_tbl[term].xmax = (int) window_get(canvas,CANVAS_WIDTH);
X term_tbl[term].ymax = (int) window_get(canvas,CANVAS_HEIGHT);
X pw_writebackground(pw,0,0,term_tbl[term].xmax, term_tbl[term].ymax, PIX_SRC );
X notify_dispatch();
X /* do not let the user make the window too small */
X if ((term_tbl[term].xmax)<MINWIN)
X {
X window_set(frame,
X WIN_WIDTH, MINWIN+2*MARGIN+24,
X 0);
X notify_dispatch();
X SUN_graphics();
X }
X if ((term_tbl[term].ymax) <MINWIN)
X {
X window_set(frame,
X WIN_HEIGHT, MINWIN+2*MARGIN+24,
X 0);
X notify_dispatch();
X SUN_graphics();
X }
X notify_dispatch();
X return;
}
X
SUN_text()
{
X notify_dispatch();
X return; /* enter text from another window!!! */
}
X
SUN_linetype(linetype)
int linetype;
{
X if (linetype>=7)
X linetype %= 7;
X sun_line_mask = sun_pattern[linetype+2];
X sun_mask_count=0;
}
X
X
SUN_move(x, y)
unsigned int x, y;
{
X sun_lastx = x;
X sun_lasty = y;
X notify_dispatch();
X return;
}
X
SUN_vector(x, y)
unsigned int x, y;
{
X if ( (x>=term_tbl[term].xmax) || (y>=term_tbl[term].ymax) )
X return;
X sun_line(sun_lastx,x,sun_lasty,y);
X canvas_pixwin(canvas);
X notify_dispatch();
X return;
}
X
X
SUN_put_text(x,y,str)
unsigned int x, y;
char *str;
{
X struct pr_subregion bound;
X
X if ( (x>=term_tbl[term].xmax) || (y>=term_tbl[term].ymax) )
X return;
X
X pf_textbound(&bound, strlen(str), sun_font, str);
X y = term_tbl[term].ymax-1-y + bound.size.y/3; /* vertical centering */
X
X switch(sun_justify) {
X case LEFT: break;
X case CENTRE: x -= bound.size.x/2; break;
X case RIGHT: x -= bound.size.x; break;
X }
X pw_text(pw, x,y, PIX_SRC | PIX_DST, 0, str);
X canvas_pixwin(canvas);
X notify_dispatch();
X return;
}
X
X
int SUN_justify_text(mode)
X enum JUSTIFY mode;
{
X sun_justify = mode;
X return (TRUE);
}
X
X
X
X
SUN_reset()
{
X
X term_tbl[term].xmax = SUN_XMAX;
X term_tbl[term].ymax = SUN_YMAX;
X window_set(frame, WIN_SHOW, FALSE, 0);
X return;
}
X
X
X
sun_setmaskpixel(x,y,value)
unsigned int x,y,value;
{
X /* dotted line generator */
X if ((sun_line_mask>>sun_mask_count)&(unsigned int)(1)) {
X pw_put(pw,x,term_tbl[term].ymax-1-y,sun_value);
X }
X sun_mask_count= (sun_mask_count+1) % 16;
X sun_lastx= x; /* last pixel set with mask */
X sun_lasty= y;
}
X
X
X
X
sun_line(x1,x2,y1,y2)
unsigned int x1,x2,y1,y2;
{
int runcount;
int dx,dy;
int xinc,yinc;
unsigned int xplot,yplot;
X
X runcount=0;
X dx = abs((int)(x1)-(int)(x2));
X if (x2>x1) xinc= 1;
X if (x2==x1) xinc= 0;
X if (x2<x1) xinc= -1;
X dy = abs((int)(y1)-(int)(y2));
X if (y2>y1) yinc= 1;
X if (y2==y1) yinc= 0;
X if (y2<y1) yinc= -1;
X xplot=x1;
X yplot=y1;
X if (dx>dy) {
X /* iterate x */
X if ( (sun_line_mask==0xffff) ||
X ((xplot!=sun_lastx) && (yplot!=sun_lasty)) )
X sun_setmaskpixel(xplot,yplot,sun_value);
X while (xplot!=x2) {
X xplot+=xinc;
X runcount+=dy;
X if (runcount>=(dx-runcount)) {
X yplot+=yinc;
X runcount-=dx;
X }
X sun_setmaskpixel(xplot,yplot,sun_value);
X }
X } else {
X /* iterate y */
X if ( (sun_line_mask==0xffff) ||
X ((xplot!=sun_lastx) && (yplot!=sun_lasty)) )
X sun_setmaskpixel(xplot,yplot,sun_value);
X while (yplot!=y2) {
X yplot+=yinc;
X runcount+=dx;
X if (runcount>=(dy-runcount)) {
X xplot+=xinc;
X runcount-=dy;
X }
X sun_setmaskpixel(xplot,yplot,sun_value);
X }
X }
}
X
X
static Notify_value local_notice_destroy(frame, status)
X Frame frame;
X Destroy_status status;
{
X if (status != DESTROY_CHECKING)
X {
X SUN_reset();
X term_init = FALSE;
X }
X return(NOTIFY_DONE);
X }
X
SHAR_EOF
chmod 0666 gnuplot/term/sun.trm ||
echo 'restore of gnuplot/term/sun.trm failed'
Wc_c="`wc -c < 'gnuplot/term/sun.trm'`"
test 6147 -eq "$Wc_c" ||
echo 'gnuplot/term/sun.trm: original size 6147, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/term/t410x.trm ==============
if test -f 'gnuplot/term/t410x.trm' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/term/t410x.trm (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/term/t410x.trm (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/t410x.trm' &&
/* GNUPLOT - t410x.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: Tektronix 410x and 420x series terminals
X *
X * AUTHORS
X * Colin Kelley, Thomas Williams
X *
X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
X *
X */
X
/* Tektronix 410X and 420X driver written by Cary D. Renzema.
X * email address: caryr@vice.ico.tek.com
X *
X * I've tested this driver on the following terminals: 4106, 4107A, 4109
X * and 4207. It should work, without editing, on other terminals in the
X * 410x and 420x families. It will probably need to be changed to work
X * on a 4105 (screen size and character rotation are two guesses). This
X * file can also be used as a start for a 411x driver.
X *
X * Cary R.
X * April 5, 1990
X */
X
#ifdef T410X
X
#define T410XXMAX 4095
#define T410XYMAX 3131
X
#define T410XVCHAR 71
#define T410XHCHAR 51
#define T410XVTIC 36
#define T410XHTIC 36
X
static int T410X_angle=0;
X
T410X_init()
{
X (void) fprintf(outfile, "\033%%!0\033MN0\033MCB7C;\033MQ1\033MT1");
X (void) fprintf(outfile, "\033MG1\033RK!\033SK!\033LZ\033%%!1");
/*
X 1. set tek mode
X 2. set character path to 0 (characters placed equal to rotation)
X 3. set character size to 59 height
X 4. set character precision to string
X 5. set character text index to 1
X 6. set character write mode to overstrike
X 7. clear the view
X 8. clear the segments
X 9. clear the dialog buffer
X 10. set ansi mode
*/
X (void) fflush(outfile);
}
X
X
T410X_reset()
{
X (void) fprintf(outfile, "\033%%!0\033LZ\033%%!1");
/*
X 1. set tek mode
X 2. clear the dialog buffer
X 3. set ansi mode
*/
X (void) fflush(outfile);
}
X
X
T410X_graphics()
{
X (void) fprintf(outfile, "\033%%!0\033\014\033LV0");
/*
X 1. set tek mode
X 2. clear the screen
X 3. set dialog area invisible
*/
X (void) fflush(outfile);
}
X
T410X_text()
{
X (void) fprintf(outfile, "\033LV1\033%%!1");
/*
X 1. set dialog area visible
X 2. set ansi mode
*/
X (void) fflush(outfile);
}
X
X
T410X_move(x, y)
unsigned int x, y;
{
X (void) fprintf(outfile, "\033LF");
X (void) T410X_encode_x_y(x, y);
X (void) fflush(outfile);
}
X
X
T410X_vector(x, y)
unsigned int x, y;
{
X (void) fprintf(outfile, "\033LG");
X (void) T410X_encode_x_y(x, y);
X (void) fflush(outfile);
}
X
X
T410X_point(x, y, number)
unsigned int x, y;
int number;
{
X (void) fprintf(outfile, "\033MM");
X (void) T410X_encode_int(max(number, 0)%11);
X (void) fprintf(outfile, "\033LH");
X (void) T410X_encode_x_y(x, y);
X (void) fflush(outfile);
}
X
X
T410X_linetype(linetype)
int linetype;
{
X switch (linetype) {
X case -1:
X (void) fprintf(outfile, "\033ML5");
X break;
X case -2:
X (void) fprintf(outfile, "\033ML?");
X break;
X default:
X (void) fprintf(outfile, "\033ML");
X (void) T410X_encode_int(linetype%14+2);
X break;
X }
X (void) fprintf(outfile, "\033MV");
X (void) T410X_encode_int(max(linetype, 0)%8);
X (void) fflush(outfile);
}
X
X
T410X_put_text(x, y, str)
unsigned int x, y;
char str[];
{
X extern int T410X_angle;
X
X if (T410X_angle == 0) {
X (void) T410X_move(x, y-T410XVCHAR/2+6);
X (void) fprintf(outfile, "\033MR00");
X } else {
X (void) T410X_move(x+T410XHCHAR/2-6, y);
X (void) fprintf(outfile, "\033MRE:0");
X }
X (void) fprintf(outfile, "\033LT");
X (void) T410X_encode_int(strlen(str));
X (void) fputs(str, outfile);
X (void) fflush(outfile);
}
X
T410X_text_angle(ang)
int ang;
{
X extern int T410X_angle;
X
X T410X_angle = ang;
X return(TRUE);
}
X
/* These last two routines are based on fortran code found in the
X * 4106/4107/4109/CX PROGRAMMERS manual.
X */
X
T410X_encode_x_y(x, y)
unsigned int x, y;
{
X static char chix=0, chiy=0, cloy=0, ceb=0;
X
X register unsigned int hix, lox, hiy, loy, eb, lx, ly;
X
X lx = (x <= T410XXMAX) ? x : T410XXMAX;
X ly = (y <= T410XYMAX) ? y : T410XYMAX;
X
X hix = lx/128 + 32;
X lox = (lx/4)%32 + 64;
X hiy = ly/128 + 32;
X loy = (ly/4)%32 + 96;
X eb = (ly%4)*4 + lx%4 + 96;
X
X if (chiy != hiy) (void) putc(hiy, outfile);
X if (ceb != eb) (void) putc(eb, outfile);
X if ((cloy!=loy) || (ceb!=eb) || (chix!=hix)) (void) putc(loy, outfile);
X if (chix != hix) (void) putc(hix, outfile);
X (void) putc(lox, outfile);
X
X chix = hix;
X chiy = hiy;
X cloy = loy;
X ceb = eb;
}
X
X
T410X_encode_int(number)
int number;
{
X register unsigned int mag, hi1, hi2, lo;
X
X mag = abs(number);
X
X hi1 = mag/1024 + 64;
X hi2 = (mag/16)%64 + 64;
X lo = mag%16 + 32;
X
X if (number >= 0) lo += 16;
X
X if (hi1 != 64) (void) putc(hi1, outfile);
X if ((hi2 != 64) || (hi1 != 64)) (void) putc(hi2, outfile);
X (void) putc(lo, outfile);
X
}
X
X
#endif /* T410X */
SHAR_EOF
chmod 0666 gnuplot/term/t410x.trm ||
echo 'restore of gnuplot/term/t410x.trm failed'
Wc_c="`wc -c < 'gnuplot/term/t410x.trm'`"
test 5056 -eq "$Wc_c" ||
echo 'gnuplot/term/t410x.trm: original size 5056, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/term/tek.trm ==============
if test -f 'gnuplot/term/tek.trm' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/term/tek.trm (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/term/tek.trm (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/tek.trm' &&
/* GNUPLOT - tek.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 * tek40xx, bitgraph, kermit_color_tek40xx, kermit_mono_tek40xx, selanar
X * ln03plus
X *
X * AUTHORS
X * Colin Kelley, Thomas Williams, Russell Lang
X *
X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
X *
X */
X
#ifdef TEK
X
#define TEK40XMAX 1024
#define TEK40YMAX 780
X
#define TEK40XLAST (TEK40XMAX - 1)
#define TEK40YLAST (TEK40YMAX - 1)
X
#define TEK40VCHAR 25
#define TEK40HCHAR 14
#define TEK40VTIC 11
#define TEK40HTIC 11
X
#define HX 0x20 /* bit pattern to OR over 5-bit data */
#define HY 0x20
#define LX 0x40
#define LY 0x60
X
#define LOWER5 31
#define UPPER5 (31<<5)
X
X
TEK40init()
{
}
X
X
TEK40graphics()
{
#ifdef vms
X term_pasthru();
#endif /* vms */
X fprintf(outfile,"\033\014");
/* 1
X 1. clear screen
*/
X (void) fflush(outfile);
X sleep(1);
X /* sleep 1 second to allow screen time to clear on real
X tektronix terminals */
}
X
TEK40text()
{
X TEK40move(0,12);
X fprintf(outfile,"\037");
/* 1
X 1. into alphanumerics
*/
#ifdef vms
X term_nopasthru();
#endif /* vms */
}
X
X
TEK40linetype(linetype)
int linetype;
{
}
X
TEK40move(x,y)
unsigned int x,y;
{
X (void) putc('\035', outfile); /* into graphics */
X TEK40vector(x,y);
}
X
X
TEK40vector(x,y)
unsigned int x,y;
{
X (void) putc((HY | (y & UPPER5)>>5), outfile);
X (void) putc((LY | (y & LOWER5)), outfile);
X (void) putc((HX | (x & UPPER5)>>5), outfile);
X (void) putc((LX | (x & LOWER5)), outfile);
}
X
X
TEK40put_text(x,y,str)
unsigned int x,y;
char str[];
{
X TEK40move(x,y-11);
X fprintf(outfile,"\037%s\n",str);
}
X
X
TEK40reset()
{
}
X
#endif /* TEK */
X
X
X
/* thanks to dukecdu!evs (Ed Simpson) for the BBN BitGraph driver */
X
#ifdef BITGRAPH
X
#define BG_XMAX 768 /* width of plot area */
#define BG_YMAX 768 /* height of plot area */
#define BG_SCREEN_HEIGHT 1024 /* full screen height */
X
#define BG_XLAST (BG_XMAX - 1)
#define BG_YLAST (BG_YMAX - 1)
X
#define BG_VCHAR 16
#define BG_HCHAR 9
#define BG_VTIC 8
#define BG_HTIC 8
X
X
#define BG_init TEK40init
X
#define BG_graphics TEK40graphics
X
X
#define BG_linetype TEK40linetype
X
#define BG_move TEK40move
X
#define BG_vector TEK40vector
X
X
BG_text()
{
X BG_move(0, BG_SCREEN_HEIGHT - 2 * BG_VCHAR);
X fprintf(outfile,"\037");
/* 1
X 1. into alphanumerics
*/
}
X
X
BG_put_text(x,y,str)
unsigned int x,y;
char str[];
{
X BG_move(x,y-11);
X fprintf(outfile,"\037%s\n",str);
}
X
X
#define BG_reset TEK40reset
X
#endif /* BITGRAPH */
X
X
/* Color and Monochrome specials for the MS-Kermit Tektronix Emulator
X by Russell Lang, eln272v@monu1.cc.monash.oz */
X
#ifdef KERMIT
X
#define KTEK40HCHAR 13
X
KTEK40graphics()
{
#ifdef vms
X term_mode_tek();
X term_pasthru();
#endif /* vms */
X fprintf(outfile,"\033\014");
/* 1
X 1. clear screen
*/
X /* kermit tektronix emulation doesn't need to wait */
}
X
KTEK40Ctext()
{
X TEK40text();
X KTEK40Clinetype(0); /* change to green */
#ifdef vms
X term_nopasthru();
#endif /* vms */
}
X
/* special color linetypes for MS-DOS Kermit v2.31 tektronix emulator */
/* 0 = normal, 1 = bright
X foreground color (30-37) = 30 + colors
X where colors are 1=red, 2=green, 4=blue */
static char *kermit_color[15]= {"\033[0;37m","\033[1;30m",
X "\033[0;32m","\033[0;36m","\033[0;31m","\033[0;35m",
X "\033[1;34m","\033[1;33m","\033[1;31m","\033[1;37m",
X "\033[1;35m","\033[1;32m","\033[1;36m","\033[0;34m",
X "\033[0;33m"};
X
KTEK40Clinetype(linetype)
int linetype;
{
X if (linetype >= 13)
X linetype %= 13;
X fprintf(outfile,"%s",kermit_color[linetype+2]);
}
X
X
/* linetypes for MS-DOS Kermit v2.30 tektronix emulator */
/* `=solid, a=fine dots, b=short dashes, c=dash dot,
X d=long dash dot, e=dash dot dot */
static char *kerm_linetype = "`a`abcde" ;
X
KTEK40Mlinetype(linetype)
int linetype;
{
X if (linetype >= 6)
X linetype %= 6;
X fprintf(outfile,"\033%c",kerm_linetype[linetype+2]);
}
X
KTEK40reset()
{
X fprintf(outfile,"\030\n"); /* turn off Tek emulation */
#ifdef vms
X term_mode_native();
#endif /* vms */
}
X
#endif /* KERMIT */
X
X
/* thanks to sask!macphed (Geoff Coleman and Ian Macphedran) for the
X Selanar driver */
X
#ifdef SELANAR
X
SEL_init()
{
X fprintf(outfile,"\033\062");
/* 1
X 1. set to ansi mode
*/
}
X
X
SEL_graphics()
{
X fprintf(outfile,"\033[H\033[J\033\061\033\014");
/* 1 2 3
X 1. clear ANSI screen
X 2. set to TEK mode
X 3. clear screen
*/
}
X
X
SEL_text()
{
X TEK40move(0,12);
X fprintf(outfile,"\033\062");
/* 1
X 1. into ANSI mode
*/
}
X
SEL_reset()
{
X fprintf(outfile,"\033\061\033\012\033\062\033[H\033[J");
/* 1 2 3 4
1 set tek mode
2 clear screen
3 set ansi mode
4 clear screen
*/
}
#endif /* SELANAR */
X
#ifdef VTTEK
X
VTTEK40init()
{
X fprintf(outfile,"\033[?38h");
X fflush(outfile);
X sleep(1);
X /* sleep 1 second to allow screen time to clear on some terminals */
#ifdef vms
X term_mode_tek();
#endif /* vms */
}
X
VTTEK40reset()
{
X fprintf(outfile,"\033[?38l");
X fflush(outfile);
X sleep(1);
X /* sleep 1 second to allow screen time to clear on some terminals */
#ifdef vms
X term_mode_native();
#endif /* vms */
}
X
/* linetypes for VT-type terminals in tektronix emulator mode */
/* `=solid, a=fine dots, b=short dashes, c=dash dot,
X d=long dash dot, h=bold solid, i=bold fine dots, j=bold short dashes,
X k=bold dash dot, l=bold long dash dot */
static char *vt_linetype = "`a`abcdhijkl" ;
static int last_vt_linetype = 0;
VTTEK40linetype(linetype)
int linetype;
{
X if (linetype >= 10)
X linetype %= 10;
X fprintf(outfile,"\033%c",vt_linetype[linetype+2]);
X last_vt_linetype = linetype;
}
X
VTTEK40put_text(x,y,str)
unsigned int x,y;
char str[];
{
X int linetype;
X linetype = last_vt_linetype;
X VTTEK40linetype(0);
X TEK40put_text(x,y,str);
X VTTEK40linetype(linetype);
}
X
#endif /* VTTEK */
X
#ifdef LN03P
X
LN03Pinit()
{
X fprintf(outfile,"\033[?38h");
}
X
LN03Preset()
{
X fprintf(outfile,"\033[?38l");
}
#endif LN03P
SHAR_EOF
chmod 0644 gnuplot/term/tek.trm ||
echo 'restore of gnuplot/term/tek.trm failed'
Wc_c="`wc -c < 'gnuplot/term/tek.trm'`"
test 6716 -eq "$Wc_c" ||
echo 'gnuplot/term/tek.trm: original size 6716, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/term/unixpc.trm ==============
if test -f 'gnuplot/term/unixpc.trm' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/term/unixpc.trm (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/term/unixpc.trm (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/unixpc.trm' &&
/* GNUPLOT - unixpc.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 * Unix PC's (ATT 3b1)
X *
X * AUTHORS
X * John Campbell
X *
X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
X *
X */
X
/*
>From: John Campbell (...!arizona!naucse!jdc)
X
I originally ported gnuplot to the ATT 3b1 (ATT7300) on 12/4/88, and then
added the minimal code needed to bring it up to 2.0 level on 1/28/90. The
3b1, as I view it, is a 720x300 bitmapped, monochrome display (often people
don't use the top 12 scan lines and thus the effective size is 720x288). I
tried to maximize the size of the graph area, by using these top 12 lines
(normally reserved) and set up a signal handler to restore them upon exit,
abort, etc.
X
Line styles were "fudged" (they do not know the aspect ratio). The same
line style may look different depending upon the slope of the curve. Due to
this only 4 line styles were implemented. While more line types are possible,
the current styles were chosen as distinguishable.
X
The 3b1 has 4 "special" rows at the bottom that I could not use in graphics
mode. It has been suggested that we use these lines for command prompting.
Others have requested that we have a graphics window and a command window.
My experience with gnuplot only includes relatively dumb graphics devices--
hence gnuplot "looks and feels" normal to me the way I implemented it.
I welcome either of these changes from someone else, however.
*/
X
#include <sys/window.h> /* Started with tam.h--too much trouble. */
#include <sys/signal.h>
#include <errno.h>
X
#define uPC_HIGH_BIT (0x8000)
X
typedef unsigned short Scr_type;
typedef unsigned char Scr_kluge;
X
#define uPC_XMAX 720
#define uPC_YMAX 300
X
#define uPC_XSIZE 45 /* Short ints. */
#define uPC_YSIZE uPC_YMAX
X
Scr_type uPC_display[uPC_YSIZE][uPC_XSIZE];
int uPC_width = 2*uPC_XSIZE;
int uPC_sx=0, uPC_sy=0;
int uPC_cur_linetype=0;
int uPC_angle = 0;
unsigned short uPC_raster_count=0;
static Scr_type lookup[] = {
X 0x0001, 0x0002, 0x0004, 0x0008,
X 0x0010, 0x0020, 0x0040, 0x0080,
X 0x0100, 0x0200, 0x0400, 0x0800,
X 0x1000, 0x2000, 0x4000, 0x8000,
X };
X
#define uPC_XLAST (uPC_XMAX - 1)
#define uPC_YLAST (uPC_YMAX - 1)
X
#define uPC_VCHAR FNT5X9_VCHAR
#define uPC_HCHAR FNT5X9_HCHAR
#define uPC_VTIC uPC_VCHAR/2 /* Was 8 */
#define uPC_HTIC uPC_HCHAR /* Was 12 */
X
extern errno, sys_nerr;
extern char *sys_errlist[];
X
static struct urdata uPC_ur = {(unsigned short *)uPC_display, 2*uPC_XSIZE, 0, 0,
X 0, 0, 0, 0, uPC_XMAX, uPC_YMAX, SRCSRC, DSTOR, 0};
X
#define IfErrOut(e1,e2,s1,s2) if (e1 e2) {\
fprintf(stderr, "%s:: %s %s\n", sys_errlist[errno], s1, s2);\
uPC_fixwind(0);\
exit(-1);}
X
uPC_init()
{
/* This routine will ioctl to change 0 size */
X int i;
X struct uwdata uw;
X int uPC_fixwind();
X short gw;
X
/* Check that we are on the bitmapped window. */
X if (iswind() != 0) {
X fprintf (stderr, "Sorry--must run from the bitmapped terminal\n");
X exit(-1);
X }
X for (i=1; i<=16; i++) {
X if (i != SIGINT && i != SIGFPE) /* Two are caught in plot.c */
X signal (i, uPC_fixwind);
X }
X
/* Increase the screen size */
X uw.uw_x = 0;
X uw.uw_y = 0; /* Leave room for top status line. */
X uw.uw_width = uPC_XMAX; /* 720 */
X uw.uw_height = uPC_YMAX; /* 288 normal--we clobber 12 (top row)*/
X uw.uw_uflags = 1; /* Creates with no border */
X
X IfErrOut (ioctl(1, WIOCSETD, &uw), <0, "ioctl failed on", "WIOCSETD");
}
X
X
uPC_graphics()
{
/* This routine will clear the uPC_display buffer and window. */
X register Scr_type *j;
X register int i;
X
X j = (Scr_type *)uPC_display;
X i = uPC_YSIZE*uPC_XSIZE + 1;
X
X while (--i)
X *j++ = 0;
/*
X Position the cursor to the bottom of the screen so when we come back to
X text mode we are just below the graph.
*/
X printf ("\033[25;1H");
X
X uPC_ur.ur_dstop = DSTSRC; /* replace (clear screen). */
X IfErrOut (ioctl(1, WIOCRASTOP, &uPC_ur), <0,
X "ioctl failed", "WIOCRASTOP");
X uPC_ur.ur_dstop = DSTOR; /* Or in (show text) */
}
X
X
uPC_text()
{
/* This routine will flush the display. */
X
X IfErrOut (ioctl(1, WIOCRASTOP, &uPC_ur), <0,
X "ioctl failed", "WIOCRASTOP");
}
X
X
uPC_linetype(linetype)
int linetype;
{
/* This routine records the current linetype. */
X if (uPC_cur_linetype != linetype) {
X uPC_raster_count = 0;
X uPC_cur_linetype = linetype;
X }
}
X
X
uPC_move(x,y)
unsigned int x,y;
{
/* This routine just records x and y in uPC_sx, uPC_sy */
X uPC_sx = x;
X uPC_sy = y;
}
X
X
/* Was just (*(a)|=(b)) */
#define uPC_PLOT(a,b) (uPC_cur_linetype != 0 ? uPC_plot_word (a,b) :\
X (*(a)|=(b)))
X
uPC_plot_word(a,b)
Scr_type *a, b;
/*
X Weak attempt to make line styles. The real problem is the aspect
X ratio. This routine is called only when a bit is to be turned on in
X a horizontal word. A better line style routine would know something
X about the slope of the line around the current point (in order to
X change weighting).
X
X This yields 3 working linetypes plus a usable axis line type.
*/
{
/* Various line types */
X switch (uPC_cur_linetype) {
X case -1:
X /* Distinguish between horizontal and vertical axis. */
X if (uPC_sx > uPC_XMAX/8 && uPC_sx < 7*uPC_XMAX/8) {
X /* Fuzzy tolerance because we don't know exactly where the y axis is */
X if (++uPC_raster_count % 2 == 0) *(a) |= b;
X }
X else {
X /* Due to aspect ratio, take every other y pixel and every third x. */
X *(a) |= (b & 0x9999);
X }
X break;
X case 1:
X case 5:
X /* Make a | |----| |----| type of line. */
X if ((1<<uPC_raster_count) & 0xF0F0) *(a) |= b;
X if (++uPC_raster_count > 15) uPC_raster_count = 0;
X break;
X case 2:
X case 6:
X /* Make a |----|----|----|--- | | type of line. */
X if ((1<<uPC_raster_count) & 0x0EFFF) *(a) |= b;
X if (++uPC_raster_count > 19) uPC_raster_count = 0;
X break;
X case 3:
X case 7:
X /* Make a | - | - | - | - | type of line. */
X if ((1<<uPC_raster_count) & 0x4444) *(a) |= b;
X if (++uPC_raster_count > 15) uPC_raster_count = 0;
X break;
X case 4:
X case 8:
X default:
X *(a) |= b;
X break;
X }
}
X
uPC_vector(x,y)
unsigned int x,y;
{
/* This routine calls line with x,y */
X int x1 = uPC_sx, y1=uPC_sy, x2 = x, y2 = y;
X register int c, e, dx, dy, width;
X register Scr_type mask, *a;
X
/* Record new sx, sy for next call to the vector routine. */
X uPC_sx = x2;
X uPC_sy = y2;
X
X a = &uPC_display[(uPC_YSIZE - 1) - y1][x1 >> 4];
X mask = lookup[x1 & 0x0f];
X width = uPC_width;
X
X if ((dx = x2 - x1) > 0) {
X if ((dy = y2 - y1) > 0) {
X if (dx > dy) { /* dx > 0, dy > 0, dx > dy */
X dy <<= 1;
X e = dy - dx;
X c = dx + 2;
X dx <<= 1;
X
X while (--c) {
X uPC_PLOT(a, mask);
X if (e >= 0) {
X (Scr_kluge *)a -= width;
X e -= dx;
X }
X if (mask & uPC_HIGH_BIT) {
X mask = 1;
X a++;
X } else
X mask <<= 1;
X e += dy;
X }
X } else { /* dx > 0, dy > 0, dx <= dy */
X dx <<= 1;
X e = dx - dy;
X c = dy + 2;
X dy <<= 1;
X
X while (--c) {
X uPC_PLOT(a, mask);
X if (e >= 0) {
X if (mask & uPC_HIGH_BIT) {
X mask = 1;
X a++;
X } else
X mask <<= 1;
X e -= dy;
X }
X (Scr_kluge *)a -= width;
X e += dx;
X }
X }
X } else {
X dy = -dy;
X if (dx > dy) { /* dx > 0, dy <= 0, dx > dy */
X dy <<= 1;
X e = dy - dx;
X c = dx + 2;
X dx <<= 1;
X
X while (--c) {
X uPC_PLOT(a, mask);
X if (e >= 0) {
X (Scr_kluge *)a += width;
X e -= dx;
X }
X if (mask & uPC_HIGH_BIT) {
X mask = 1;
X a++;
X } else
X mask <<= 1;
X e += dy;
X }
X } else { /* dx > 0, dy <= 0, dx <= dy */
X dx <<= 1;
X e = dx - dy;
X c = dy + 2;
X dy <<= 1;
X
X while (--c) {
X uPC_PLOT(a, mask);
X if (e >= 0) {
X if (mask & uPC_HIGH_BIT) {
X mask = 1;
X a++;
X } else
X mask <<= 1;
X e -= dy;
X }
X (Scr_kluge *)a += width;
X e += dx;
X }
X }
X }
X } else {
X dx = -dx;
X if ((dy = y2 - y1) > 0) {
X if (dx > dy) { /* dx <= 0, dy > 0, dx > dy */
X dy <<= 1;
X e = dy - dx;
X c = dx + 2;
X dx <<= 1;
X
X while (--c) {
X uPC_PLOT(a, mask);
X if (e >= 0) {
X (Scr_kluge *)a -= width;
X e -= dx;
X }
X if (mask & 1) {
X mask = uPC_HIGH_BIT;
X a--;
X } else
X mask >>= 1;
X e += dy;
X }
X } else { /* dx <= 0, dy > 0, dx <= dy */
X dx <<= 1;
X e = dx - dy;
X c = dy + 2;
X dy <<= 1;
X
X while (--c) {
X uPC_PLOT(a, mask);
X if (e >= 0) {
X if (mask & 1) {
X mask = uPC_HIGH_BIT;
X a--;
X } else
X mask >>= 1;
X e -= dy;
X }
X (Scr_kluge *)a -= width;
X e += dx;
X }
X }
X } else {
X dy = -dy;
X if (dx > dy) { /* dx <= 0, dy <= 0, dx > dy */
X dy <<= 1;
X e = dy - dx;
X c = dx + 2;
X dx <<= 1;
X
X while (--c) {
X uPC_PLOT(a, mask);
X if (e >= 0) {
X (Scr_kluge *)a += width;
X e -= dx;
X }
X if (mask & 1) {
X mask = uPC_HIGH_BIT;
X a--;
X } else
X mask >>= 1;
X e += dy;
X }
X } else { /* dx <= 0, dy <= 0, dx <= dy */
X dx <<= 1;
X e = dx - dy;
X c = dy + 2;
X dy <<= 1;
X
X while (--c) {
X uPC_PLOT(a, mask);
X if (e >= 0) {
X if (mask & 1) {
X mask = uPC_HIGH_BIT;
X a--;
X } else
X mask >>= 1;
X e -= dy;
X }
X (Scr_kluge *)a += width;
X e += dx;
X }
X }
X }
X }
}
X
X
#ifdef uPC_NOT_USED
/* Added by Russell Lang, eln272v@monu1.cc.monash.oz
X This placement to the nearest character cell worked, and I'm leaving
X it here so the calculations involved won't be lost! (jdc)
*/
uPC_put_text(x,y,str)
unsigned int x,y;
char str[];
{
/* This routine puts the text at the cursor location nearest
X to (x,y). Obviously the exact postion would look better */
X
/* Just use the ANSI escape sequence CUP (iswind said that was ok!) */
X printf ("\033[%d;%dH%s\033[25;1H", (int)(24-(y-uPC_VCHAR/2)*25/uPC_YMAX),
X (int)(x*80/uPC_XMAX), str);
X fflush (stdout);
}
#endif
X
X
uPC_put_text(x,y,str)
unsigned int x,y;
char str[];
{
X if (uPC_angle == 1)
X x += uPC_VCHAR/2;
X else
X y -= uPC_VCHAR/2;
X
X switch (uPC_angle) {
X case 0:
X for (; *str; ++str, x += uPC_HCHAR)
X uPC_putc (x, y, *str, uPC_angle);
X break;
X case 1:
X for (; *str; ++str, y += uPC_HCHAR)
X uPC_putc (x, y, *str, uPC_angle);
X break;
X }
}
X
X
uPC_putc (x, y, c, angle)
unsigned int x, y;
int c, angle;
/*
X Put a character at an x,y location in the bit map (using the fnt5x9
X array. This is mostly just copied from the bitmap.c driver.
*/
{
X int i, j, k;
X register Scr_type mask, *a;
X char_row fc;
X unsigned int pixelon;
X
X i = c - ' ';
X for (j=0; j<FNT5X9_VBITS; j++) {
X fc = fnt5x9[i][j];
X for (k=0; k<FNT5X9_HBITS; k++) {
X pixelon = ((unsigned int)(fc))>>k & 1;
X if (pixelon) {
X switch (angle) {
X case 0:
X mask = lookup[x+k+1 & 0x0f];
X a = &uPC_display[(uPC_YSIZE - 1) - (y+j)][(x+k+1) >> 4];
X break;
X case 1:
X mask = lookup[x-j & 0x0f];
X a = &uPC_display[(uPC_YSIZE - 1) - (y+k+1)][(x-j) >> 4];
X break;
X }
X *(a) |= (mask); /* see uPC_PLOT macro */
X }
X }
X }
}
X
X
uPC_text_angle (ang)
int ang;
{
X uPC_angle = ang;
X return TRUE;
}
X
X
uPC_reset()
{
/* Reset window to normal size. */
X uPC_fixwind (0);
}
X
X
X
uPC_fixwind(signo)
int signo;
{
X static struct uwdata wreset = { 0, 12, 720, 288, 0x1};
X struct utdata ut;
X
/* Reset the window to the right size. */
X ioctl(1, WIOCSETD, &wreset); /* 0, not wncur here! */
X
/* Scroll the screen once. (avoids typing over the same line) */
X fprintf (stderr, "\n");
X
X if (signo) {
X if (signo == SIGILL || signo == SIGTRAP || signo == SIGPWR)
X signal (signo, SIG_DFL);
X kill (0,signo); /* Redo the signal (as if we never trapped it). */
X }
}
SHAR_EOF
chmod 0644 gnuplot/term/unixpc.trm ||
echo 'restore of gnuplot/term/unixpc.trm failed'
Wc_c="`wc -c < 'gnuplot/term/unixpc.trm'`"
test 14242 -eq "$Wc_c" ||
echo 'gnuplot/term/unixpc.trm: original size 14242, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/term/unixplot.trm ==============
if test -f 'gnuplot/term/unixplot.trm' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/term/unixplot.trm (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/term/unixplot.trm (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/unixplot.trm' &&
/* GNUPLOT -- unixplot.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 * Unix plot(5) graphics language
X *
X * AUTHORS
X * Colin Kelley, Thomas Williams, Russell Lang
X *
X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
X *
X */
X
/*
Unixplot library writes to stdout. A fix was put in place by
..!arizona!naucse!jdc to let set term and set output redirect
stdout. All other terminals write to outfile.
*/
X
#define UP_XMAX 4096
#define UP_YMAX 4096
X
#define UP_XLAST (UP_XMAX - 1)
#define UP_YLAST (UP_YMAX - 1)
X
#define UP_VCHAR (UP_YMAX/30) /* just a guess--no way to know this! */
#define UP_HCHAR (UP_XMAX/60) /* just a guess--no way to know this! */
#define UP_VTIC (UP_YMAX/80)
#define UP_HTIC (UP_XMAX/80)
X
UP_init()
{
X openpl();
X space(0, 0, UP_XMAX, UP_YMAX);
}
X
X
UP_graphics()
{
X erase();
}
X
X
UP_text()
{
}
X
X
UP_linetype(linetype)
int linetype;
SHAR_EOF
true || echo 'restore of gnuplot/term/unixplot.trm failed'
fi
echo 'End of part 18'
echo 'File gnuplot/term/unixplot.trm is continued in part 19'
echo 19 > _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.