laser-lovers@uw-beaver (07/18/85)
From: JRBRINKEMA@USC-ISI.arpa Somewhere I came upon a reference to a QMS plot program (equiv to the UNIX plot(1) command) called Qplot (I think). Does anyone have a pointer to it? tia.
laser-lovers@uw-beaver (07/21/85)
From: allegra!packard!harvard!bu-cs!root@uw-beaver.arpa (BostonU SysMgr)
Here is an implementation of a unix plot library (libqms.a) I wrote
some time back. I am sure it's got some bugs and misfeatures but
the other choice is to sit on it till I get some time to go over
it, which isn't likely to happen this century. (I'll bet some of it
is laughable, but as I remember it worked.)
The idea was you use standard unix graphics calls and link a program
cc .... -lqms
You should be aware that for output it popen()'s to "qpr -q" as an
output device, you may have to adjust this for your site (see the
#define PCMD in qms.h, should be a trivial fix even for a non-programmer,
just find out what program on your system can read raw QUIC commands
through a pipe to its std input and change PCMD.)
It's short, bug fixes etc welcome.
-Barry Shein, Boston University
------ AS-IS Software Inc---
#!/bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #!/bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# Makefile
# arc.c
# circle.c
# closepl.c
# cont.c
# erase.c
# label.c
# line.c
# linemod.c
# move.c
# openpl.c
# point.c
# qms.h
# space.c
# This archive created: Sat Jul 20 13:41:12 1985
export PATH; PATH=/bin:$PATH
if test -f 'Makefile'
then
echo shar: over-writing existing file "'Makefile'"
fi
cat << \SHAR_EOF > 'Makefile'
CFLAGS= -O
OBJS= arc.o circle.o closepl.o cont.o erase.o label.o line.o\
linemod.o move.o openpl.o point.o space.o
LIBDIR= /usr/lib
libqms.a: ${OBJS}
ar cu libqms.a ${OBJS} ; ranlib libqms.a
arc.o: arc.c qms.h
circle.o: circle.c qms.h
closepl.o: closepl.c qms.h
cont.o: cont.c qms.h
erase.o: erase.c qms.h
label.o: label.c qms.h
line.o: line.c qms.h
linemod.o: linemod.c qms.h
move.o: move.c qms.h
openpl.o: openpl.c qms.h
point.o: point.c qms.h
space.o: space.c qms.h
install: libqms.a
cp libqms.a ${LIBDIR}/libqms.a
clean:
rm *.o libqms.a
SHAR_EOF
chmod +x 'Makefile'
if test -f 'arc.c'
then
echo shar: over-writing existing file "'arc.c'"
fi
cat << \SHAR_EOF > 'arc.c'
#include "qms.h"
arc(x,y,x0,y0,x1,y1) int x, y, x0, y0, x1, y1 ;
{
extern double atan(), hypot() ;
double fx, fy ;
PUTS("^LA") ;
/* center */
fprintf(qmspipe,"%05d%05d",toinch(x),toinch(y)) ;
/* radius */
fprintf(qmspipe,"%05d",
toinch((int) hypot((double)(x-x0),(double)(y-y0)))) ;
/* starting and ending angles */
fx = x0 - x ;
fy = y0 - y ;
if(fy == 0.0) x = ((fx > 0.0) ? 90 : 270) ;
else x = radde(atan(fx/fy)) ;
if(x < 0) x += 360 ;
fprintf(qmspipe,"%03d",x) ;
fx = x1 - x ;
fy = y1 - y ;
if(fy == 0.0) x = ((fx > 0.0) ? 90 : 270) ;
else x = radde(atan(fx/fy)) ;
if(x < 0) x += 360 ;
fprintf(qmspipe,"%03d",x) ;
/* pen width */
fprintf(qmspipe,"%02d",qmspen & 037) ;
/* done */
PUTS("^G") ;
qmslasty = y1 ;
}
SHAR_EOF
chmod +x 'arc.c'
if test -f 'circle.c'
then
echo shar: over-writing existing file "'circle.c'"
fi
cat << \SHAR_EOF > 'circle.c'
#include "qms.h"
circle(x,y,r) int x, y, r ;
{
/* Indicate integer arc */
PUTS("^LA") ;
/* center in thousandths of inches */
fprintf(qmspipe,"%05d%05d",toinch(x),toinch(y)) ;
/* arc radius in thousands of inches */
fprintf(qmspipe,"%05d",toinch(r)) ;
/* start/stop angles: 0,0 means circle */
PUTS("000000") ;
/* pen width */
fprintf(qmspipe,"%02d",qmspen & 037) ;
/* done */
PUTS("^G") ;
qmslasty = y ;
}
SHAR_EOF
chmod +x 'circle.c'
if test -f 'closepl.c'
then
echo shar: over-writing existing file "'closepl.c'"
fi
cat << \SHAR_EOF > 'closepl.c'
#include "qms.h"
closepl()
{
PUTS(QUICOFF) ;
return(pclose(qmspipe)) ;
}
SHAR_EOF
chmod +x 'closepl.c'
if test -f 'cont.c'
then
echo shar: over-writing existing file "'cont.c'"
fi
cat << \SHAR_EOF > 'cont.c'
#include "qms.h"
cont(x,y) int x, y ;
{
PUTS("^IGV^P") ;
fprintf(qmspipe,"W%02d",qmspen & 037) ;
PUTS("^D") ;
fprintf(qmspipe,"%05d:",toinch(x)) ;
fprintf(qmspipe,"%05d",toinch(y)) ;
PUTS("^IGE^-") ;
qmslasty = y ;
}
SHAR_EOF
chmod +x 'cont.c'
if test -f 'erase.c'
then
echo shar: over-writing existing file "'erase.c'"
fi
cat << \SHAR_EOF > 'erase.c'
#include "qms.h"
erase()
{
PUTS("^,^-") ;
qmslasty = 0 ;
}
SHAR_EOF
chmod +x 'erase.c'
if test -f 'label.c'
then
echo shar: over-writing existing file "'label.c'"
fi
cat << \SHAR_EOF > 'label.c'
#include "qms.h"
label(s) char *s ;
{
fprintf(qmspipe,"%s%03d%03d%05d%s\r",qrot[qmsrot],
qmshtch,qmswdch,toinch(qmslasty),s) ;
}
SHAR_EOF
chmod +x 'label.c'
if test -f 'line.c'
then
echo shar: over-writing existing file "'line.c'"
fi
cat << \SHAR_EOF > 'line.c'
#include "qms.h"
line(x1,y1,x2,y2) int x1, y1, x2, y2 ;
{
/* put into vector grafx and set pen width */
fprintf(qmspipe,"^IGV^PW%02d",qmspen & 037) ;
PUTS("^U") ; /* move to first position with pen up */
/* scale into .001 inches */
fprintf(qmspipe,"%05d:%05d",toinch(x1),toinch(y1)) ;
/* set pen down and move to second position */
PUTS("^D") ;
fprintf(qmspipe,"%05d:%05d",toinch(x2),toinch(y2)) ;
/* exit vector graphics drawing */
PUTS("^IGE") ;
qmslasty = y2 ;
}
SHAR_EOF
chmod +x 'line.c'
if test -f 'linemod.c'
then
echo shar: over-writing existing file "'linemod.c'"
fi
cat << \SHAR_EOF > 'linemod.c'
#include "qms.h"
linemod(s) char *s ;
{
/* not supported */
return(0) ;
}
SHAR_EOF
chmod +x 'linemod.c'
if test -f 'move.c'
then
echo shar: over-writing existing file "'move.c'"
fi
cat << \SHAR_EOF > 'move.c'
#include "qms.h"
move(x,y) int x, y ;
{
fprintf(qmspipe,"^IGV^PW^U%05d:%05d^D+%05d:+%05d^IGE\r",
toinch(x),toinch(y),0,0) ;
qmslasty = y ;
}
SHAR_EOF
chmod +x 'move.c'
if test -f 'openpl.c'
then
echo shar: over-writing existing file "'openpl.c'"
fi
cat << \SHAR_EOF > 'openpl.c'
#include "qms.h"
openpl()
{
if((qmspipe = popen(PCMD,"w")) == NULL)
{
perror("openpl") ;
exit(1) ;
}
qmshtch = DEFHT ;
qmswdch = DEFWD ;
qmspen = DEFPEN ;
qmslasty = 0 ;
PUTS(QUICON) ;
}
SHAR_EOF
chmod +x 'openpl.c'
if test -f 'point.c'
then
echo shar: over-writing existing file "'point.c'"
fi
cat << \SHAR_EOF > 'point.c'
#include "qms.h"
point(x,y) int x,y ;
{
line(x-3,y,x,y) ;
qmslasty = y ;
}
SHAR_EOF
chmod +x 'point.c'
if test -f 'qms.h'
then
echo shar: over-writing existing file "'qms.h'"
fi
cat << \SHAR_EOF > 'qms.h'
#include <stdio.h>
/*
* UNIX standard plot filter for the QMS
* QMS definitions
*/
#define PUTS(s) fputs(s,qmspipe)
FILE *qmspipe, *popen() ;
#define PCMD "/usr/bin/qpr -q"
#define MAXX (300.0 * 8.5) /* 8.5 inches, 300 dots per inch */
#define MAXY (300.0 * 11) /* 11 inches, 300 dots per inch */
#define derad(x) (1.745329251994328e-2 * (x))
#define radde(x) (57.29577951308232 * (x))
#define toinch(x) ((1000 * (x)) / 300) /* to 1000ths of inch */
/*
* externals available to the user
*/
int qmspen ; /* qms pen width 03..31 */
#define DEFPEN 5
int qmsrot ; /* rotation of chars */
#define ROT0 0
#define ROT270 1
#define ROT90 2
#define ROT180 3
static char *qrot[] = { "^M", "^E", "^V", "^U" } ;
int qmshtch ; /* ie. about 8lpi */
int qmswdch ; /* about 12cpi */
#define DEFHT (100/8)
#define DEFWD (100/12)
int qmslasty ; /* This blasted thing is needed by label! */
#define QUICON "\r^PY^-\r"
#define QUICOFF "\r^-^PN^-\r"
SHAR_EOF
chmod +x 'qms.h'
if test -f 'space.c'
then
echo shar: over-writing existing file "'space.c'"
fi
cat << \SHAR_EOF > 'space.c'
#include "qms.h"
space(x0,y0,x1,y1)
{
/* not supported */
return(0) ;
}
SHAR_EOF
chmod +x 'space.c'
# End of shell archive
exit 0