argv@island.uu.net (Dan Heller) (07/24/89)
Submitted-by: sun!GARP.MIT.EDU!rochester!lassp!arthur Posting-number: Volume 4, Issue 81 Archive-name: xplot/part01 The following is a very short and simple plot(5) filter for X. It brings up a graphics window which stays around until a button press after the end-of file is reached on input. It can draw interactively. Arthur Smith (arpanet) arthur@helios.tn.cornell.edu (bitnet) arthur@crnlassp # This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # # Wrapped by uttu!arthur on Sat Jul 22 04:52:57 EDT 1989 # Contents: xplot/ xplot/xlibplot/ xplot/Makefile xplot/xplot.c # xplot/xlibplot/xlibplot.c xplot/xlibplot/Imakefile # xplot/xlibplot/Makefile xplot/xplot.man xplot/Imakefile xplot/README echo mkdir - xplot mkdir xplot chmod u=rwx,g=rx,o=rx xplot echo x - xplot/Makefile sed 's/^@//' > "xplot/Makefile" <<'@//E*O*F xplot/Makefile//' # Makefile generated by imake - do not edit! # $XConsortium: imake.c,v 1.37 88/10/08 20:08:30 jim Exp $ # # The cpp used on this machine replaces all newlines and multiple tabs and # spaces in a macro expansion with a single space. Imake tries to compensate # for this, but is not always successful. # ########################################################################### # X Window System Makefile generated from template file Imake.tmpl # $XConsortium: Imake.tmpl,v 1.91 88/10/23 22:37:10 jim Exp $ # # Do not change the body of the imake template file. Server-specific # parameters may be set in the appropriate .macros file; site-specific # parameters (but shared by all servers) may be set in site.def. If you # make any changes, you'll need to rebuild the makefiles using # "make World" (at best) or "make Makefile; make Makefiles" (at least) in # the top level directory. # # If your C preprocessor doesn't define any unique symbols, you'll need # to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing # "make Makefile", "make Makefiles", or "make World"). # # If you absolutely can't get imake to work, you'll need to set the # variables at the top of each Makefile as well as the dependencies at the # bottom (makedepend will do this automatically). # ########################################################################### # platform-specific configuration parameters - edit Sun.macros to change # platform: $XConsortium: Sun.macros,v 1.52 88/10/23 11:00:55 jim Exp $ # operating system: SunOS 3.5 BOOTSTRAPCFLAGS = AS = as CC = cc CPP = /lib/cpp LD = ld LINT = lint INSTALL = install TAGS = ctags RM = rm -f MV = mv LN = ln -s RANLIB = ranlib RANLIBINSTFLAGS = -t AR = ar clq LS = ls LINTOPTS = -axz LINTLIBFLAG = -C MAKE = make STD_CPP_DEFINES = STD_DEFINES = ########################################################################### # site-specific configuration parameters - edit site.def to change # site: $XConsortium: site.def,v 1.16 88/10/12 10:30:24 jim Exp $ ########################################################################### # definitions common to all Makefiles - do not edit SHELL = /bin/sh DESTDIR = USRLIBDIR = $(DESTDIR)/usr/lib BINDIR = $(DESTDIR)/usr/bin/X11 INCDIR = $(DESTDIR)/usr/include/X11 ADMDIR = $(DESTDIR)/usr/adm LIBDIR = $(USRLIBDIR)/X11 LINTLIBDIR = $(USRLIBDIR)/lint FONTDIR = $(LIBDIR)/fonts XINITDIR = $(LIBDIR)/xinit XDMDIR = $(LIBDIR)/xdm UWMDIR = $(LIBDIR)/uwm AWMDIR = $(LIBDIR)/awm TWMDIR = $(LIBDIR)/twm MANPATH = $(DESTDIR)/usr/man MANSOURCEPATH = $(MANPATH)/man MANDIR = $(MANSOURCEPATH)n LIBMANDIR = $(MANSOURCEPATH)3 XAPPLOADDIR = $(LIBDIR)/app-defaults INSTBINFLAGS = -m 0755 INSTUIDFLAGS = -m 4755 INSTLIBFLAGS = -m 0664 INSTINCFLAGS = -m 0444 INSTMANFLAGS = -m 0444 INSTAPPFLAGS = -m 0444 INSTKMEMFLAGS = -m 4755 FCFLAGS = -t CDEBUGFLAGS = -O -DPURDUE PATHSEP = / DEPEND = $(DEPENDSRC)/makedepend IMAKE = $(IMAKESRC)/imake RGB = $(RGBSRC)/rgb FC = $(BDFTOSNFSRC)/bdftosnf MKFONTDIR = $(MKFONTDIRSRC)/mkfontdir MKDIRHIER = $(SCRIPTSSRC)/mkdirhier.sh CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(STD_DEFINES) $(DEFINES) LINTFLAGS = $(LINTOPTS) $(INCLUDES) $(STD_DEFINES) $(DEFINES) -DLINT LDFLAGS = $(CDEBUGFLAGS) $(SYS_LIBRARIES) $(SYSAUX_LIBRARIES) TOP = /usr/src/X11 CLIENTSRC = $(TOP)/clients DEMOSRC = $(TOP)/demos LIBSRC = $(TOP)/lib FONTSRC = $(TOP)/fonts INCLUDESRC = $(TOP)/X11 SERVERSRC = $(TOP)/server UTILSRC = $(TOP)/util SCRIPTSSRC = $(UTILSRC)/scripts EXAMPLESRC = $(TOP)/examples CONTRIBSRC = $(TOP)/contrib DOCSRC = $(TOP)/doc RGBSRC = $(TOP)/rgb DEPENDSRC = $(UTILSRC)/makedepend IMAKESRC = $(UTILSRC)/imake IRULESRC = $(UTILSRC)/imake.includes XLIBSRC = $(LIBSRC)/X XMUSRC = $(LIBSRC)/Xmu TOOLKITSRC = $(LIBSRC)/Xt AWIDGETSRC = $(LIBSRC)/Xaw OLDXLIBSRC = $(LIBSRC)/oldX BDFTOSNFSRC = $(FONTSRC)/bdftosnf MKFONTDIRSRC = $(FONTSRC)/mkfontdir EXTENSIONSRC = $(TOP)/extensions EXTENSIONLIB = $(EXTENSIONSRC)/lib/libXext.a XLIB = $(XLIBSRC)/libX11.a XMULIB = $(XMUSRC)/libXmu.a OLDXLIB = $(OLDXLIBSRC)/liboldX.a XTOOLLIB = $(TOOLKITSRC)/libXt.a XAWLIB = $(AWIDGETSRC)/libXaw.a LINTXLIB = $(XLIBSRC)/llib-lX11.ln LINTXMU = $(XMUSRC)/llib-lXmu.ln LINTXTOOL = $(TOOLKITSRC)/llib-lXt.ln LINTXAW = $(AWIDGETSRC)/llib-lXaw.ln INCLUDES = -I$(TOP) MACROFILE = Sun.macros ICONFIGFILES = $(IRULESRC)/Imake.tmpl \ $(IRULESRC)/$(MACROFILE) $(IRULESRC)/site.def IMAKE_DEFINES = IMAKE_CMD = $(NEWTOP)$(IMAKE) -TImake.tmpl -I$(NEWTOP)$(IRULESRC) \ -s Makefile $(IMAKE_DEFINES) RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a \ .emacs_* tags TAGS make.log MakeOut ########################################################################### # rules: $XConsortium: Imake.rules,v 1.71 88/10/23 22:46:34 jim Exp $ ########################################################################### # start of Imakefile INCLUDES = -I$(TOP)/usr/include -I$(TOP)/usr/include/X11 LOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB) SYS_LIBRARIES = -lm SRCS = xplot.c OBJS = xplot.o PROGRAM = xplot all:: xplot xplot: $(OBJS) $(LOCAL_LIBRARIES) $(RM) $@ $(CC) -o $@ $(OBJS) $(LOCAL_LIBRARIES) $(LDFLAGS) $(SYSLAST_LIBRARIES) relink:: $(RM) $(PROGRAM) $(MAKE) $(MFLAGS) $(PROGRAM) install:: xplot $(INSTALL) -c $(INSTALLFLAGS) xplot $(BINDIR) install.man:: xplot.man $(INSTALL) -c $(INSTMANFLAGS) xplot.man $(MANDIR)/xplot.n depend:: $(DEPEND) depend:: $(DEPEND) -s "# DO NOT DELETE" -- $(CFLAGS) -- $(SRCS) $(DEPEND): @echo "making $@"; \ cd $(DEPENDSRC); $(MAKE) clean:: $(RM) $(PROGRAM) ########################################################################### # Imake.tmpl common rules for all Makefiles - do not edit emptyrule:: clean:: $(RM_CMD) \#* Makefile:: $(IMAKE) Makefile:: Imakefile \ $(IRULESRC)/Imake.tmpl \ $(IRULESRC)/Imake.rules \ $(IRULESRC)/site.def \ $(IRULESRC)/$(MACROFILE) -@if [ -f Makefile ]; then \ echo "$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \ $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \ else exit 0; fi $(IMAKE_CMD) -DTOPDIR=$(TOP) $(IMAKE): @echo "making $@"; \ cd $(IMAKESRC); $(MAKE) BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS) tags:: $(TAGS) -w *.[ch] $(TAGS) -xw *.[ch] > TAGS ########################################################################### # empty rules for directories that do not have SUBDIRS - do not edit install:: @echo "install done" install.man:: @echo "install.man done" Makefiles:: ########################################################################### # dependencies generated by makedepend @//E*O*F xplot/Makefile// chmod u=rw,g=r,o=r xplot/Makefile echo x - xplot/xplot.c sed 's/^@//' > "xplot/xplot.c" <<'@//E*O*F xplot/xplot.c//' #include <stdio.h> #include <math.h> #include <string.h> #include <sgtty.h> #include <fcntl.h> #include <errno.h> #include <X11/Xlib.h> #include <X11/Intrinsic.h> #include <X11/StringDefs.h> #include <X11/Label.h> #define LINE 512 char buf[LINE]; char cptr[LINE]; char *prog; char *index(); Display *dpy; Window widgetwin; Pixmap pixmap; GC gc; XGCValues gcv; XtInputId inid; /*XtAppContext app_context; */ int rwidth = 500, rheight = 500; short xmin, ymax; double xfactor, yfactor; #define MAPX(x) (int) (((x) - xmin) * xfactor) #define MAPY(y) (int) ((ymax - (y)) * yfactor) int spaceset = 0; short curpt[] = {0,0}; FILE *instrm = stdin; int len = 0; int endinp; char *curp; Arg wargs[20]; Widget toplevel; Widget child; main(argc,argv) int argc; char **argv; { struct sgttyb gp; short old; int fd; int argf; prog = argv[0]; fd = fileno(instrm); gtty(fd,&gp); old = gp.sg_flags; gp.sg_flags |= (CBREAK); stty(fd,&gp); fcntl(fd,F_GETFL,argf); fcntl(fd,F_SETFL, argf|O_NDELAY); openpl(argc,argv); fcntl(fd,F_SETFL,argf); gp.sg_flags = old; stty(fd,&gp); } doplot(client_data,fds,id) caddr_t client_data; int *fds; /* None of these arguments are actually used... */ int *id; { char c; short x[6]; void buttonhandler(); while(readit(instrm)){ while((len > 0) && (!endinp)){ len--; c = *curp++; /* printf("%c",c); */ switch(c){ case 'm': /* Move */ if (getcoords(x,2,instrm)) move(x[0],x[1]); break; case 'n': /* Continue */ if (getcoords(x,2,instrm)) cont(x[0],x[1]); break; case 'p': /* Plot */ if (getcoords(x,2,instrm)) point(x[0],x[1]); break; case 'l': /* Draw Line */ if (getcoords(x,4,instrm)) line(x[0],x[1],x[2],x[3]); break; case 't': /* Label */ if (getstring(buf,instrm)) label(buf); break; case 'a': /* Arc */ if (getcoords(x,6,instrm)) arc(x[0],x[1],x[2],x[3],x[4],x[5]); break; case 'c': /* Circle */ if (getcoords(x,3,instrm)) circle(x[0],x[1],x[2]); break; case 'e': /* Erase */ erase(); break; case 'f': /* Linemod */ if (getstring(buf,instrm)) linemod(buf); break; case 's': /* Space */ if (getcoords(x,4,instrm)) space(x[0],x[1],x[2],x[3]); break; default: printf("Error?: character = %d\n",c); break; } } } if (errno != EWOULDBLOCK){ if (fork()) exit(0); XtRemoveInput(inid); XtAddEventHandler(toplevel,ButtonPressMask,False, buttonhandler, NULL); } XClearArea(dpy,widgetwin,0,0,0,0,True); } void buttonhandler(w,client_data,event) Widget w; caddr_t client_data; XEvent *event; { closepl(); exit(0); } drawellipse(x,y,r1,r2) int x,y,r1,r2; { /* XPoint *points; int i,npoints; double delta; npoints = 2 + abs(r1) + abs(r2); points = (XPoint *) (malloc(npoints * sizeof(XPoint))); delta = 2 * M_PI / (npoints - 1); for (i=0;i<npoints-1;i++){ points[i].x = x + r1 * cos(i * delta); points[i].y = y + r2 * sin(i * delta); } points[npoints-1].x = x + r1; points[npoints-1].y = y ; XDrawLines(dpy,pixmap,gc,points,npoints,CoordModeOrigin); */ XDrawArc(dpy,pixmap,gc, x - r1, y - r2, 2 * r1, 2 * r2, 0, 64 * 360 - 1); } drawarc(x,y,x0,y0,x1,y1) int x,y,x0,y0,x1,y1; { int a0,b0,a1,b1; int a02,b02,a12,b12; double ar,br,ar2,br2; double theta0,theta1; a0 = x0 - x; a02 = a0*a0; a1 = x1 - x; a12 = a1*a1; b0 = y0 - y; b02 = b0*b0; b1 = y1 - y; b12 = b1*b1; if (b12 == b02) return 0; ar2 = (a02*b12 - a12*b02)/(b12 - b02); if (ar2 < 0) return 0; ar = sqrt(ar2); br2 = (b02*a12 - b12*a02)/(a12 - a02); if (br2 < 0) return 0; br = sqrt(br2); theta0 = -atan2(b0/br,a0/ar); theta1 = -atan2(b1/br,a1/ar); if (theta0 > theta1) theta1 += 2 * M_PI; if (theta0 < 0){ theta0 += 2 * M_PI; theta1 += 2 * M_PI; } XDrawArc(dpy,pixmap,gc,(int) (x - ar), (int) (y - br), (int)(2 * ar), (int) (2 * br), (int) (64* theta0 * 180/M_PI), (int) (64 * (theta1 - theta0) * 180/M_PI)); } /* Openpl is supposed to set up the X window stuff, by creating a widget, in which the image is to be put in a background pixmap. */ openpl(argc,argv) int argc; char **argv; { int i, dimset, narg; dimset = 0; for (i=0;i<argc;i++){ if (strcmp(argv[i],"-geometry")) continue; else { dimset = 1; rwidth = atoi(argv[i+1]); rheight = atoi(1+index(argv[i+1],'x')); } } toplevel = XtInitialize(argv[0], "xplot",NULL, 0, &argc, argv); dpy = XtDisplay(toplevel); /* app_context = XtCreateApplicationContext(); */ pixmap = XCreatePixmap(dpy,DefaultRootWindow(dpy), rwidth, rheight, 1); gc = XCreateGC(dpy, pixmap, 0L, &gcv); XSetForeground(dpy,gc,1); XtSetArg(wargs[0], XtNbitmap, pixmap); narg = 1; if (dimset == 0) { XtSetArg(wargs[1], XtNheight, rheight); XtSetArg(wargs[2], XtNwidth, rwidth); narg = 3; } child = XtCreateManagedWidget(prog, labelWidgetClass, toplevel, wargs, narg); /* XtCreateManagedWidget(prog, labelWidgetClass, child, wargs, narg); */ XtRealizeWidget(toplevel); widgetwin = XtWindow(child); inid = XtAddInput(fileno(instrm), XtInputReadMask, doplot, NULL); XtMainLoop(); } /* Erase should wait for the current page to be absorbed, before creating a new one (presumably by erasing the pixmap and then redrawing the widget.*/ erase() { /* Wait for button event */ /* Clear pixmap */ XSetForeground(dpy,gc,0); XFillRectangle(dpy,pixmap,gc,0,0,rwidth,rheight); XSetForeground(dpy,gc,1); } /* Don't know how I'm going to do this ! */ label(s) char *s; { XDrawString(dpy,pixmap,gc,MAPX(curpt[0]),MAPY(curpt[1]),s, strlen(s) - 1); } line(x1,y1,x2,y2) short x1,y1,x2,y2; { curpt[0] = x2; curpt[1] = y2; if (spaceset == 0) return; XDrawLine(dpy,pixmap,gc, MAPX(x1), MAPY(y1), MAPX(x2), MAPY(y2)); } circle(x,y,r) short x,y,r; { if (spaceset == 0) return; drawellipse(MAPX(x), MAPY(y), (int) (r * xfactor), (int) (r*yfactor)); } arc(x,y,x0,y0,x1,y1) short x,y,x0,y0,x1,y1; { if (spaceset == 0) return; drawarc(MAPX(x), MAPY(y), MAPX(x0), MAPY(y0), MAPX(x1), MAPY(y1)); } move(x,y) short x,y; { curpt[0] = x; curpt[1] = y; } cont(x,y) short x,y; { line(curpt[0],curpt[1],x,y); } point(x,y) short x,y; { curpt[0] = x; curpt[1] = y; if (spaceset == 0) return; XDrawPoint(dpy,pixmap,gc, MAPX(x), MAPY(y)); } linemod(s) char *s; { int line_style; line_style = gcv.line_style; if (!strcmp(s,"solid\n")) line_style = LineSolid; else if ((!strcmp(s,"dotted\n"))||(!strcmp(s,"shortdashed\n"))) line_style = LineOnOffDash; else if ((!strcmp(s, "longdashed\n"))||(!strcmp(s,"dotdashed\n"))) line_style = LineDoubleDash; gcv.line_style = line_style; XChangeGC(dpy, gc, GCLineStyle, &gcv); } space(x0,y0,x1,y1) short x0,y0,x1,y1; { spaceset = 1; xmin = x0; ymax = y1; xfactor = ((double) rwidth)/(x1 + 1 - x0); yfactor = ((double) rheight)/(y1 + 1 - y0); } closepl() { XFreeGC(dpy,gc); XFreePixmap(dpy,pixmap); XtDestroyWidget(toplevel); } int getcoords(x,n,strm) short *x; int n; FILE *strm; { unsigned char c,d; int i; while (len < 2*n) { len++; curp--; if (!readit(strm)) return 0; len--; curp++; } len -= 2 * n; for (i=0;i< n;i++){ c = *curp++; d = *curp++; x[i] = (short) ((d << 8) | c); /* printf(" %d",x[i]); */ } /* printf("\n"); */ return 1; } int getstring(ptr,strm) char *ptr; FILE *strm; { char *cp; int lenp; while ((cp = index(curp,'\n')) == NULL){ len++; curp--; if (!readit(strm)) return 0; len--; curp++; } lenp = cp - curp + 1; bcopy(curp,ptr,lenp); ptr[lenp] = 0; len -= lenp; curp += lenp; /* printf("%s",ptr); */ return lenp; } /* Have to do my own buffering: */ int readit(strm) FILE *strm; { int lenp; endinp = 0; if (len > 0) bcopy(curp, cptr, len); if ((lenp = fread(cptr+len, 1, LINE - len, strm)) == 0){ endinp = 1; return 0; } len += lenp; curp = cptr; return 1; } @//E*O*F xplot/xplot.c// chmod u=rw,g=r,o=r xplot/xplot.c echo mkdir - xplot/xlibplot mkdir xplot/xlibplot chmod u=rwx,g=rx,o=rx xplot/xlibplot echo x - xplot/xlibplot/xlibplot.c sed 's/^@//' > "xplot/xlibplot/xlibplot.c" <<'@//E*O*F xplot/xlibplot/xlibplot.c//' #include <stdio.h> #include <string.h> #define LINE 256 #define XPLOT "/usr/contrib/bin/xplot" char xplotlib_buf[LINE]; FILE *xplotlib_outstrm; openpl() { xplotlib_outstrm = popen(XPLOT, "w"); } closepl() { pclose(xplotlib_outstrm); } erase() { putentry('e',0); } label(s) char *s; { strcpy(xplotlib_buf,s); putentry('t',strlen(xplotlib_buf)); } line(x1,y1,x2,y2) int x1,y1,x2,y2; { short x[6]; x[0] = x1; x[1] = y1; x[2] = x2; x[3] = y2; convertcoords(x,4); putentry('l',8); } circle(xin,y,r) int xin,y,r; { short x[6]; x[0] = xin; x[1] = y; x[2] = r; convertcoords(x,3); putentry('c',6); } arc(xin,y,x0,y0,x1,y1) { short x[6]; x[0] = xin; x[1] = y; x[2] = x0; x[3] = y0; x[4] = x1; x[5] = y1; convertcoords(x,6); putentry('a',12); } move(xin,y) int xin,y; { short x[6]; x[0] = xin; x[1] = y; convertcoords(x,2); putentry('m',4); } cont(xin,y) int xin,y; { short x[6]; x[0] = xin; x[1] = y; convertcoords(x,2); putentry('n',4); } point(xin,y) int xin,y; { short x[6]; x[0] = xin; x[1] = y; convertcoords(x,2); putentry('p',4); } linemod(s) char *s; { strcpy(xplotlib_buf,s); putentry('f',strlen(xplotlib_buf)); } space(x0,y0,x1,y1) int x0,y0,x1,y1; { short x[6]; x[0] = x0; x[1] = y0; x[2] = x1; x[3] = y1; convertcoords(x,4); putentry('s',8); } convertcoords(x,n) short *x; int n; { int i; for (i=0;i<n;i++){ xplotlib_buf[2*i] = (unsigned char) x[i]; xplotlib_buf[2*i+1] = (unsigned char) (x[i] >> 8) ; } } putentry(c,n) char c; int n; { int i; putc(c,xplotlib_outstrm); fwrite(xplotlib_buf, n, 1, xplotlib_outstrm); fflush(xplotlib_outstrm); } @//E*O*F xplot/xlibplot/xlibplot.c// chmod u=rw,g=r,o=r xplot/xlibplot/xlibplot.c echo x - xplot/xlibplot/Imakefile sed 's/^@//' > "xplot/xlibplot/Imakefile" <<'@//E*O*F xplot/xlibplot/Imakefile//' NormalLibraryObjectRule() NormalLibraryTarget(xplot,xlibplot.o) @//E*O*F xplot/xlibplot/Imakefile// chmod u=rw,g=r,o=r xplot/xlibplot/Imakefile echo x - xplot/xlibplot/Makefile sed 's/^@//' > "xplot/xlibplot/Makefile" <<'@//E*O*F xplot/xlibplot/Makefile//' # Makefile generated by imake - do not edit! # $XConsortium: imake.c,v 1.37 88/10/08 20:08:30 jim Exp $ # # The cpp used on this machine replaces all newlines and multiple tabs and # spaces in a macro expansion with a single space. Imake tries to compensate # for this, but is not always successful. # ########################################################################### # X Window System Makefile generated from template file Imake.tmpl # $XConsortium: Imake.tmpl,v 1.91 88/10/23 22:37:10 jim Exp $ # # Do not change the body of the imake template file. Server-specific # parameters may be set in the appropriate .macros file; site-specific # parameters (but shared by all servers) may be set in site.def. If you # make any changes, you'll need to rebuild the makefiles using # "make World" (at best) or "make Makefile; make Makefiles" (at least) in # the top level directory. # # If your C preprocessor doesn't define any unique symbols, you'll need # to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing # "make Makefile", "make Makefiles", or "make World"). # # If you absolutely can't get imake to work, you'll need to set the # variables at the top of each Makefile as well as the dependencies at the # bottom (makedepend will do this automatically). # ########################################################################### # platform-specific configuration parameters - edit Sun.macros to change # platform: $XConsortium: Sun.macros,v 1.52 88/10/23 11:00:55 jim Exp $ # operating system: SunOS 3.5 BOOTSTRAPCFLAGS = AS = as CC = cc CPP = /lib/cpp LD = ld LINT = lint INSTALL = install TAGS = ctags RM = rm -f MV = mv LN = ln -s RANLIB = ranlib RANLIBINSTFLAGS = -t AR = ar clq LS = ls LINTOPTS = -axz LINTLIBFLAG = -C MAKE = make STD_CPP_DEFINES = STD_DEFINES = ########################################################################### # site-specific configuration parameters - edit site.def to change # site: $XConsortium: site.def,v 1.16 88/10/12 10:30:24 jim Exp $ ########################################################################### # definitions common to all Makefiles - do not edit SHELL = /bin/sh DESTDIR = USRLIBDIR = $(DESTDIR)/usr/lib BINDIR = $(DESTDIR)/usr/bin/X11 INCDIR = $(DESTDIR)/usr/include/X11 ADMDIR = $(DESTDIR)/usr/adm LIBDIR = $(USRLIBDIR)/X11 LINTLIBDIR = $(USRLIBDIR)/lint FONTDIR = $(LIBDIR)/fonts XINITDIR = $(LIBDIR)/xinit XDMDIR = $(LIBDIR)/xdm UWMDIR = $(LIBDIR)/uwm AWMDIR = $(LIBDIR)/awm TWMDIR = $(LIBDIR)/twm MANPATH = $(DESTDIR)/usr/man MANSOURCEPATH = $(MANPATH)/man MANDIR = $(MANSOURCEPATH)n LIBMANDIR = $(MANSOURCEPATH)3 XAPPLOADDIR = $(LIBDIR)/app-defaults INSTBINFLAGS = -m 0755 INSTUIDFLAGS = -m 4755 INSTLIBFLAGS = -m 0664 INSTINCFLAGS = -m 0444 INSTMANFLAGS = -m 0444 INSTAPPFLAGS = -m 0444 INSTKMEMFLAGS = -m 4755 FCFLAGS = -t CDEBUGFLAGS = -O -DPURDUE PATHSEP = / DEPEND = $(DEPENDSRC)/makedepend IMAKE = $(IMAKESRC)/imake RGB = $(RGBSRC)/rgb FC = $(BDFTOSNFSRC)/bdftosnf MKFONTDIR = $(MKFONTDIRSRC)/mkfontdir MKDIRHIER = $(SCRIPTSSRC)/mkdirhier.sh CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(STD_DEFINES) $(DEFINES) LINTFLAGS = $(LINTOPTS) $(INCLUDES) $(STD_DEFINES) $(DEFINES) -DLINT LDFLAGS = $(CDEBUGFLAGS) $(SYS_LIBRARIES) $(SYSAUX_LIBRARIES) TOP = /usr/src/X11 CLIENTSRC = $(TOP)/clients DEMOSRC = $(TOP)/demos LIBSRC = $(TOP)/lib FONTSRC = $(TOP)/fonts INCLUDESRC = $(TOP)/X11 SERVERSRC = $(TOP)/server UTILSRC = $(TOP)/util SCRIPTSSRC = $(UTILSRC)/scripts EXAMPLESRC = $(TOP)/examples CONTRIBSRC = $(TOP)/contrib DOCSRC = $(TOP)/doc RGBSRC = $(TOP)/rgb DEPENDSRC = $(UTILSRC)/makedepend IMAKESRC = $(UTILSRC)/imake IRULESRC = $(UTILSRC)/imake.includes XLIBSRC = $(LIBSRC)/X XMUSRC = $(LIBSRC)/Xmu TOOLKITSRC = $(LIBSRC)/Xt AWIDGETSRC = $(LIBSRC)/Xaw OLDXLIBSRC = $(LIBSRC)/oldX BDFTOSNFSRC = $(FONTSRC)/bdftosnf MKFONTDIRSRC = $(FONTSRC)/mkfontdir EXTENSIONSRC = $(TOP)/extensions EXTENSIONLIB = $(EXTENSIONSRC)/lib/libXext.a XLIB = $(XLIBSRC)/libX11.a XMULIB = $(XMUSRC)/libXmu.a OLDXLIB = $(OLDXLIBSRC)/liboldX.a XTOOLLIB = $(TOOLKITSRC)/libXt.a XAWLIB = $(AWIDGETSRC)/libXaw.a LINTXLIB = $(XLIBSRC)/llib-lX11.ln LINTXMU = $(XMUSRC)/llib-lXmu.ln LINTXTOOL = $(TOOLKITSRC)/llib-lXt.ln LINTXAW = $(AWIDGETSRC)/llib-lXaw.ln INCLUDES = -I$(TOP) MACROFILE = Sun.macros ICONFIGFILES = $(IRULESRC)/Imake.tmpl \ $(IRULESRC)/$(MACROFILE) $(IRULESRC)/site.def IMAKE_DEFINES = IMAKE_CMD = $(NEWTOP)$(IMAKE) -TImake.tmpl -I$(NEWTOP)$(IRULESRC) \ -s Makefile $(IMAKE_DEFINES) RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a \ .emacs_* tags TAGS make.log MakeOut ########################################################################### # rules: $XConsortium: Imake.rules,v 1.71 88/10/23 22:46:34 jim Exp $ ########################################################################### # start of Imakefile @.c.o: $(RM) $@ $(CC) -c $(CFLAGS) $*.c all:: libxplot.a libxplot.a: xlibplot.o $(RM) $@ $(AR) $@ xlibplot.o $(RANLIB) $@ ########################################################################### # Imake.tmpl common rules for all Makefiles - do not edit emptyrule:: clean:: $(RM_CMD) \#* Makefile:: $(IMAKE) Makefile:: Imakefile \ $(IRULESRC)/Imake.tmpl \ $(IRULESRC)/Imake.rules \ $(IRULESRC)/site.def \ $(IRULESRC)/$(MACROFILE) -@if [ -f Makefile ]; then \ echo "$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \ $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \ else exit 0; fi $(IMAKE_CMD) -DTOPDIR=$(TOP) $(IMAKE): @echo "making $@"; \ cd $(IMAKESRC); $(MAKE) BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS) tags:: $(TAGS) -w *.[ch] $(TAGS) -xw *.[ch] > TAGS ########################################################################### # empty rules for directories that do not have SUBDIRS - do not edit install:: @echo "install done" install.man:: @echo "install.man done" Makefiles:: ########################################################################### # dependencies generated by makedepend @//E*O*F xplot/xlibplot/Makefile// chmod u=rw,g=r,o=r xplot/xlibplot/Makefile echo x - xplot/xplot.man sed 's/^@//' > "xplot/xplot.man" <<'@//E*O*F xplot/xplot.man//' @.TH XPLOT 1 "13 October 1988" "X Version 11" @.SH NAME xplot - plot(5) filter for X @.SH SYNOPSIS @.B xplot [-\fItoolkitoption\fP ...] [-option ...] @.SH DESCRIPTION The @.I xplot program brings up a window for viewing plot(5) output, for example from the @.I axis program. The program works interactively, continuing to accept input from stdin and plotting as it goes, until it reaches an end of file, at which point it waits around for a mouse button press to kill the window. @.SH OPTIONS @.I Xplot accepts all of the standard X toolkit command line options, and the initial geometry specification determines the resolution, with a default geometry of 500x500 pixels. @.PP The following standard X Toolkit command line arguments may be used with @.I xplot: @.TP 8 @.B \-bg \fIcolor\fP This option specifies the color to use for the background of the window. The default is \fIwhite\fP. @.TP 8 @.B \-bd \fIcolor\fP This option specifies the color to use for the border of the window. The default is \fIblack\fP. @.TP 8 @.B \-bw \fInumber\fP This option specifies the width in pixels of the border surrounding the window. @.TP 8 @.B \-fg \fIcolor\fP This option specifies the color to use for displaying text. The default is \fIblack\fP. @.TP 8 @.B \-fn \fIfont\fP This option specifies the font to be used for displaying normal text. The default is \fI6x10\fP. @.TP 8 @.B \-rv This option indicates that reverse video should be simulated by swapping the foreground and background colors. @.TP 8 @.B \-geometry \fIgeometry\fP This option specifies the prefered size and position of the clock window. @.TP 8 @.B \-display \fIhost\fP:\fIdisplay\fP This option specifies the X server to contact. @.TP 8 @.B \-xrm \fIresourcestring\fP This option specifies a resource string to be used. @.SH X DEFAULTS This program uses the @.I Label widget in the X Toolkit. It understands all of the core resource names and classes as well as: @.PP @.TP 8 @.B width (\fPclass\fB Width) Specifies the width of the clock. The default for analog clocks is 164 pixels; the default for digital clocks is whatever is needed to hold the clock when displayed in the chosen font. @.TP 8 @.B height (\fPclass\fB Height) Specifies the height of the clock. The default for analog clocks is 164 pixels; the default for digital clocks is whatever is needed to hold the clock when displayed in the chosen font. @.TP 8 @.B reverseVideo (\fPclass\fB ReverseVideo) Specifies that the foreground and background colors should be reversed. @.SH "SEE ALSO" X(1), plot(5), psun(1), axis(1), Athena Label widget @.SH BUGS @.I Xplot works fine. No bugs at all. Right. Actually there are several things that ought to be changed, for example the reversed byte order in plot(5) format (NOT MY FAULT), and maybe it will soon be extended to the superplot format (I'll have to look over that stuff carefully though), and probably also to return mouse position and anything else the locals feel they need. @.PP @.SH AUTHORS Arthur Smith (Lassp, Cornell University) @//E*O*F xplot/xplot.man// chmod u=rw,g=r,o=r xplot/xplot.man echo x - xplot/Imakefile sed 's/^@//' > "xplot/Imakefile" <<'@//E*O*F xplot/Imakefile//' INCLUDES = -I$(TOP)/usr/include -I$(TOP)/usr/include/X11 LOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB) SYS_LIBRARIES = -lm SRCS = xplot.c OBJS = xplot.o ComplexProgramTarget(xplot) @//E*O*F xplot/Imakefile// chmod u=rw,g=r,o=r xplot/Imakefile echo x - xplot/README sed 's/^@//' > "xplot/README" <<'@//E*O*F xplot/README//' RATIONALE Why xplot, when we already have so many graphics programs? Well, first of all it is a simple, straightforward, plot (5) filter. No fancy buttons or options or silly syntax. Just a plain old filter. However, it is implemented as an Athena Labelwidget, so of course all the usual XToolkit options are available. When first called, it immediately brings up a blank window, and as plot(5) data appears on the input stream it draws the stuff right away (it uses CBREAK mode). This means it can be used either interactively, with a pipe, or with a preprocessed file. We have used it here with the data processing program "dra", which allows interective plotting and manipulation of the data. Xplot draws in the background pixmap of the window, so that redrawing is very fast (compared with an xterm tektronix window for example). The disadvantage of this, of course (there had to be one) is that on resizing, the plot does not resize with the window, but retains its original shape (it is properly centered though). Xplot is in general much more convenient than the standard Tek window, since several different windows can be maintained at once, to compare different sets of data, for example. And you don't lose control of your window. Each xplot window is destroyed by a mouse button press anywhere, but not until EOF has been reached on the input stream. PLOT (3X) LIBRARY The subdirectory xlibplot contains the standard plot(3x) routines so that xplot can be called up from within any C program, just by linking to this library. COMPILATION Just make Makefile, then make xplot. If you don't have imake and the X util sources you may have to edit the Makefile, but it should be clear what to do. @//E*O*F xplot/README// chmod u=rw,g=r,o=r xplot/README echo Inspecting for damage in transit... temp=/tmp/shar$$; dtemp=/tmp/.shar$$ trap "rm -f $temp $dtemp; exit" 0 1 2 3 15 cat > $temp <<\!!! 234 800 7270 Makefile 420 1047 7851 xplot.c 143 213 1632 xlibplot.c 2 2 64 Imakefile 209 738 6675 Makefile 89 501 2986 xplot.man 7 20 225 Imakefile 38 295 1723 README 1142 3616 28426 total !!! wc xplot/Makefile xplot/xplot.c xplot/xlibplot/xlibplot.c xplot/xlibplot/Imakefile xplot/xlibplot/Makefile xplot/xplot.man xplot/Imakefile xplot/README | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp if [ -s $dtemp ] then echo "Ouch [diff of wc output]:" ; cat $dtemp else echo "No problems found." fi exit 0