v09i046: xengine: reciprocating engine for X, Part01/01

Kazuhiko Shutoh kddlab!isl.yamaha.co.jp!shutoh at uunet.UU.NET
Mon Sep 24 15:20:42 AEST 1990


Submitted-by: kddlab!isl.yamaha.co.jp!shutoh at uunet.UU.NET (Kazuhiko Shutoh)
Posting-number: Volume 9, Issue 46
Archive-name: xengine/part01

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  Imakefile Makefile README patchlevel.h xengine.c
#   xengine.man
# Wrapped by shutoh at uni on Wed Sep 19 16:33:25 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Imakefile'\"
else
echo shar: Extracting \"'Imakefile'\" \(752 characters\)
sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
X# SCCS ID : @(#)Imakefile	1.1   9/12/90
X#
X#   Imakefile - Imakefile for xengine
X# 
X#   Author: Kazuhiko Shutoh, 1990.
X#
X#   Permission to use, copy, modify and distribute without charge this
X#   software, documentation, images, etc. is granted, provided that this 
X#   comment and the author's name is retained.  The author assumes no 
X#   responsibility for lost sleep as a consequence of use of this software.
X#
X#   Send any comments, bug reports, etc. to: shutoh at isl.yamaha.JUNET or, 
X#   for oversea: shutoh%isl.yamaha.JUNET%kddlab at uunet.uu.net  
X#
X
X       INCLUDES = -I$(TOP)/X11
XLOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
X  SYS_LIBRARIES = -lm
X           SRCS = xengine.c
X           OBJS = xengine.o
X
XComplexProgramTarget(xengine)
END_OF_FILE
if test 752 -ne `wc -c <'Imakefile'`; then
    echo shar: \"'Imakefile'\" unpacked with wrong size!
fi
# end of 'Imakefile'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(9481 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# Makefile generated by imake - do not edit!
X# $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $
X#
X# The cpp used on this machine replaces all newlines and multiple tabs and
X# spaces in a macro expansion with a single space.  Imake tries to compensate
X# for this, but is not always successful.
X#
X
X###########################################################################
X# Makefile generated from "Imake.tmpl" and </tmp/IIf.a02029>
X# $XConsortium: Imake.tmpl,v 1.77 89/12/18 17:01:37 jim Exp $
X#
X# Platform-specific parameters may be set in the appropriate .cf
X# configuration files.  Site-wide parameters may be set in the file
X# site.def.  Full rebuilds are recommended if any parameters are changed.
X#
X# If your C preprocessor doesn't define any unique symbols, you'll need
X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
X# "make Makefile", "make Makefiles", or "make World").
X#
X# If you absolutely can't get imake to work, you'll need to set the
X# variables at the top of each Makefile as well as the dependencies at the
X# bottom (makedepend will do this automatically).
X#
X
X###########################################################################
X# platform-specific configuration parameters - edit sun.cf to change
X
X# platform:  $XConsortium: sun.cf,v 1.38 89/12/23 16:10:10 jim Exp $
X# operating system:  SunOS 4.0.3
X
X###########################################################################
X# site-specific configuration parameters - edit site.def to change
X
X# site:  $XConsortium: site.def,v 1.21 89/12/06 11:46:50 jim Exp $
X
X            SHELL = /bin/sh
X
X              TOP = .
X      CURRENT_DIR = .
X
X               AR = ar cq
X  BOOTSTRAPCFLAGS =
X               CC = cc
X
X         COMPRESS = compress
X              CPP = /lib/cpp $(STD_CPP_DEFINES)
X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
X          INSTALL = install
X               LD = ld
X             LINT = lint
X      LINTLIBFLAG = -C
X         LINTOPTS = -axz
X               LN = ln -s
X             MAKE = make
X               MV = mv
X               CP = cp
X           RANLIB = ranlib
X  RANLIBINSTFLAGS =
X               RM = rm -f
X     STD_INCLUDES =
X  STD_CPP_DEFINES =
X      STD_DEFINES =
X EXTRA_LOAD_FLAGS =
X  EXTRA_LIBRARIES =
X             TAGS = ctags
X
X    SHAREDCODEDEF = -DSHAREDCODE
X         SHLIBDEF = -DSUNSHLIB
X
X    PROTO_DEFINES =
X
X     INSTPGMFLAGS =
X
X     INSTBINFLAGS = -m 0755
X     INSTUIDFLAGS = -m 4755
X     INSTLIBFLAGS = -m 0664
X     INSTINCFLAGS = -m 0444
X     INSTMANFLAGS = -m 0444
X     INSTDATFLAGS = -m 0444
X    INSTKMEMFLAGS = -m 4755
X
X          DESTDIR =
X
X     TOP_INCLUDES = -I$(INCROOT)
X
X      CDEBUGFLAGS = -O
X        CCOPTIONS =
X      COMPATFLAGS = -DXAW_BC
X
X      ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES)
X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS)
X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS)
X   LDCOMBINEFLAGS = -X -r
X
X        MACROFILE = sun.cf
X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
X
X    IMAKE_DEFINES =
X
X         IRULESRC = $(CONFIGDIR)
X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
X
X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
X			$(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
X			$(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
X
X###########################################################################
X# X Window System Build Parameters
X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
X
X###########################################################################
X# X Window System make variables; this need to be coordinated with rules
X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
X
X          PATHSEP = /
X        USRLIBDIR = $(DESTDIR)/usr/lib
X           BINDIR = $(DESTDIR)/usr/bin/X11
X          INCROOT = $(DESTDIR)/usr/include
X     BUILDINCROOT = $(TOP)
X      BUILDINCDIR = $(BUILDINCROOT)/X11
X      BUILDINCTOP = ..
X           INCDIR = $(INCROOT)/X11
X           ADMDIR = $(DESTDIR)/usr/adm
X           LIBDIR = $(USRLIBDIR)/X11
X        CONFIGDIR = $(LIBDIR)/config
X       LINTLIBDIR = $(USRLIBDIR)/lint
X
X          FONTDIR = $(LIBDIR)/fonts
X         XINITDIR = $(LIBDIR)/xinit
X           XDMDIR = $(LIBDIR)/xdm
X           AWMDIR = $(LIBDIR)/awm
X           TWMDIR = $(LIBDIR)/twm
X           GWMDIR = $(LIBDIR)/gwm
X          MANPATH = $(DESTDIR)/usr/man
X    MANSOURCEPATH = $(MANPATH)/man
X           MANDIR = $(MANSOURCEPATH)n
X        LIBMANDIR = $(MANSOURCEPATH)3
X      XAPPLOADDIR = $(LIBDIR)/app-defaults
X
X        SOXLIBREV = 4.2
X          SOXTREV = 4.0
X         SOXAWREV = 4.0
X        SOOLDXREV = 4.0
X         SOXMUREV = 4.0
X        SOXEXTREV = 4.0
X
X       FONTCFLAGS = -t
X
X     INSTAPPFLAGS = $(INSTDATFLAGS)
X
X            IMAKE = imake
X           DEPEND = makedepend
X              RGB = rgb
X            FONTC = bdftosnf
X        MKFONTDIR = mkfontdir
X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier.sh
X
X        CONFIGSRC = $(TOP)/config
X        CLIENTSRC = $(TOP)/clients
X          DEMOSRC = $(TOP)/demos
X           LIBSRC = $(TOP)/lib
X          FONTSRC = $(TOP)/fonts
X       INCLUDESRC = $(TOP)/X11
X        SERVERSRC = $(TOP)/server
X          UTILSRC = $(TOP)/util
X        SCRIPTSRC = $(UTILSRC)/scripts
X       EXAMPLESRC = $(TOP)/examples
X       CONTRIBSRC = $(TOP)/../contrib
X           DOCSRC = $(TOP)/doc
X           RGBSRC = $(TOP)/rgb
X        DEPENDSRC = $(UTILSRC)/makedepend
X         IMAKESRC = $(CONFIGSRC)
X         XAUTHSRC = $(LIBSRC)/Xau
X          XLIBSRC = $(LIBSRC)/X
X           XMUSRC = $(LIBSRC)/Xmu
X       TOOLKITSRC = $(LIBSRC)/Xt
X       AWIDGETSRC = $(LIBSRC)/Xaw
X       OLDXLIBSRC = $(LIBSRC)/oldX
X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
X     MKFONTDIRSRC = $(FONTSRC)/mkfontdir
X     EXTENSIONSRC = $(TOP)/extensions
X
X  DEPEXTENSIONLIB = $(USRLIBDIR)/libXext.a
X     EXTENSIONLIB =  -lXext
X
X          DEPXLIB = $(DEPEXTENSIONLIB)
X             XLIB = $(EXTENSIONLIB) -lX11
X
X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
X         XAUTHLIB =  -lXau
X
X        DEPXMULIB =
X           XMULIB = -lXmu
X
X       DEPOLDXLIB =
X          OLDXLIB = -loldX
X
X      DEPXTOOLLIB =
X         XTOOLLIB = -lXt
X
X        DEPXAWLIB =
X           XAWLIB = -lXaw
X
X LINTEXTENSIONLIB = $(USRLIBDIR)/llib-lXext.ln
X         LINTXLIB = $(USRLIBDIR)/llib-lX11.ln
X          LINTXMU = $(USRLIBDIR)/llib-lXmu.ln
X        LINTXTOOL = $(USRLIBDIR)/llib-lXt.ln
X          LINTXAW = $(USRLIBDIR)/llib-lXaw.ln
X
X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
X
X         DEPLIBS1 = $(DEPLIBS)
X         DEPLIBS2 = $(DEPLIBS)
X         DEPLIBS3 = $(DEPLIBS)
X
X###########################################################################
X# Imake rules for building libraries, programs, scripts, and data files
X# rules:  $XConsortium: Imake.rules,v 1.67 89/12/18 17:14:15 jim Exp $
X
X###########################################################################
X# start of Imakefile
X
X# SCCS ID : %W%   %G%
X#
X#   Imakefile - Imakefile for xengine
X#
X#   Author: Kazuhiko Shutoh, 1990.
X#
X#   Permission to use, copy, modify and distribute without charge this
X#   software, documentation, images, etc. is granted, provided that this
X#   comment and the author's name is retained.  The author assumes no
X#   responsibility for lost sleep as a consequence of use of this software.
X#
X#   Send any comments, bug reports, etc. to: shutoh at isl.yamaha.JUNET or,
X#   for oversea: shutoh%isl.yamaha.JUNET%kddlab at uunet.uu.net
X#
X
X       INCLUDES = -I$(TOP)/X11
XLOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
X  SYS_LIBRARIES = -lm
X           SRCS = xengine.c
X           OBJS = xengine.o
X
X PROGRAM = xengine
X
Xall:: xengine
X
Xxengine: $(OBJS) $(DEPLIBS)
X	$(RM) $@
X	$(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
X
Xsaber_xengine:
X	#load $(ALLDEFINES) $(SRCS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
X
Xosaber_xengine:
X	#load $(ALLDEFINES) $(OBJS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
X
Xinstall:: xengine
X	$(INSTALL) -c $(INSTPGMFLAGS)   xengine $(BINDIR)
X
Xinstall.man:: xengine.man
X	$(INSTALL) -c $(INSTMANFLAGS) xengine.man $(MANDIR)/xengine.n
X
Xdepend::
X	$(DEPEND) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
X
Xlint:
X	$(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
Xlint1:
X	$(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
X
Xclean::
X	$(RM) $(PROGRAM)
X
X###########################################################################
X# common rules for all Makefiles - do not edit
X
Xemptyrule::
X
Xclean::
X	$(RM_CMD) \#*
X
XMakefile::
X	- at if [ -f Makefile ]; then \
X	echo "	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
X	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
X	else exit 0; fi
X	$(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
X
Xtags::
X	$(TAGS) -w *.[ch]
X	$(TAGS) -xw *.[ch] > TAGS
X
Xsaber:
X	#load $(ALLDEFINES) $(SRCS)
X
Xosaber:
X	#load $(ALLDEFINES) $(OBJS)
X
X###########################################################################
X# empty rules for directories that do not have SUBDIRS - do not edit
X
Xinstall::
X	@echo "install in $(CURRENT_DIR) done"
X
Xinstall.man::
X	@echo "install.man in $(CURRENT_DIR) done"
X
XMakefiles::
X
Xincludes::
X
X###########################################################################
X# dependencies generated by makedepend
X
END_OF_FILE
if test 9481 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(2136 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X
X
X	xengine - reciprocating engine for X :-)
X
X   	Author: Kazuhiko Shutoh
X
X	Permission to use, copy, modify and distribute without charge this
X	software, documentation, images, etc. is granted, provided that this 
X	comment and the author's name is retained.  The author assumes no 
X	responsibility for lost sleep as a consequence of use of this software.
X
X--- Compile
X
X	If you can't use imake, Please manually compile, 
X	
X	cc -O -o xengine xengine.c -lXaw -lXmu -lXt -lX11 -lXext -lm
X	or
X	cc -O -o xengine xengine.c -lXaw -lXmu -lXt -lX11 -lm
X
X--- Note
X
X	Xengine is count rotational per minutes 10 times, And indicate mean 
X	value.
X       	Xengine request protocol as (one cycle) :
X
X	code  count  name 
X	 43     2    GetInputFocus
X	 56     7    ChangeGC
X	 62    20    CopyArea
X	 66    20    PolySegment
X	 70   120    PolyFillRectangle
X	 71   100    PolyFillArc
X
X
X--- Benchmarks **
X
XMachine				Server Release			rpm
X-----------------------------------------------------------------------------
XSparcStation 370 Memory 56M     X11R4(fix-14),256 color         230
XSparcStation 1  		X11R4(applied fix-14) 256 color	186.33
Xluna-88K,2 CPU,mach Memory 32M  X11R4, 16 color   		180  *1
XSun 3/60C(CG4)			X11R4 fix-14 gcc-1.35.1	16color about 90
XSun 3/60C       		X11R4 no-fix 			73.3
XCIT-X Terminal  		X11R3 mono			45.5
XX-mint Memory 8M                X11R3,mono                      45
XX-station Memory 8M             X11R3,256 color                 40
XNEWS841 memory 16M              X11R2, 16 color                 11
XX640				X11R3?(mono)			10.4
XMASSCOMP RTU    		X11R2? 16 color			8.5
X
X*1 beta version OS(MACH).
X
X** These rpm are *not* official. If you want exact server's performance,
X   use other benchmark tools (such as xperf or xtest).
X
X--- Special thanks to:
X	
X	Yasushi Ohba(YAMAHA/ISL)	Mathematical suggestion. 
X	Toshihisa Sadakata(YAMAHA/ISL)	Engine movement suggestion. 
X	Susumu Mukawa (NTT)		Benchmark data correction.
X	Kazunari "ISSEY" Nakamura (NKK) Benchmark data correction.
X
X	Send any comments, bug reports, etc. are welcome.
X
X
X--
X						Kazuhiko Shutoh
X						InSoft System Lab.
X						YAMAHA Corp.
X						shutoh at isl.yamama.co.jp
X
END_OF_FILE
if test 2136 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'patchlevel.h'\"
else
echo shar: Extracting \"'patchlevel.h'\" \(22 characters\)
sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
X
X#define PATCHLEVEL 0
END_OF_FILE
if test 22 -ne `wc -c <'patchlevel.h'`; then
    echo shar: \"'patchlevel.h'\" unpacked with wrong size!
fi
# end of 'patchlevel.h'
fi
if test -f 'xengine.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xengine.c'\"
else
echo shar: Extracting \"'xengine.c'\" \(11425 characters\)
sed "s/^X//" >'xengine.c' <<'END_OF_FILE'
Xstatic char     sccsid[] = "@(#)xengine.c	1.9   9/19/90";
X
X/*
X * xengine - reciprocating engine for X     :-)
X * 
X * Author: Kazuhiko Shutoh, 1990.
X * 
X * Permission to use, copy, modify and distribute without charge this software,
X * documentation, images, etc. is granted, provided that this comment and the
X * author's name is retained.  The author assumes no responsibility for lost
X * sleep as a consequence of use of this software.
X * 
X * Send any comments, bug reports, etc. to: shutoh at isl.yamaha.JUNET or, for
X * oversea: shutoh%isl.yamaha.JUNET%kddlab at uunet.uu.net
X * 
X */
X
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/Xaw/Box.h>
X#include <X11/Xaw/Form.h>
X#include <X11/Xaw/AsciiText.h>
X#include <X11/Xaw/Cardinals.h>
X#include <X11/Xos.h>
X#include <stdio.h>
X#include <math.h>
X
X#include "patchlevel.h"
X
X#define	PI	3.141592654
X
XXtCallbackProc  redraw_callback();
XXtTimerCallbackProc Cylcle();
X
XWidget          toplevel, base, rpm_info, engine;
XGC              gcPiston, gcShaft, gcCylinder, gcRoter, gcBack, gcDep, gcPre, gcEngine;
XPixmap          enginePixmap;
Xint             width, height;
X
XString          colors[] = {"gray", "lightseagreen", "dimgrey", "forestgreen", "black", "red", "cyan", "firebrick"};
X
Xmain(argc, argv)
X	int             argc;
X	char          **argv;
X{
X
X	Arg             args[10];
X	XtTranslations  newTranslations;
X	static XtActionsRec redrawActions[] = {
X		{"expose", (XtCallbackProc) redraw_callback},
X	};
X
X	static char    *overrideTranslations =
X	"<Expose>:	expose() \n\
X	 <ResReq>:	expose()";
X
X	XColor          srcColor, dummyColor;
X
X	int             i;
X	int             count;
X
X	XtTimerCallbackProc Cycle();
X
X	toplevel = XtInitialize("xengine", "XEngine", NULL, 0, &argc, argv);
X
X	for (count = 1; count < argc; count++) {
X		if ((strcmp("-piston", argv[count]) == 0) && (count + 1 <= argc))
X			strcpy(colors[0], argv[++count]);
X		else if ((strcmp("-shaft", argv[count]) == 0) && (count + 1 <= argc))
X			strcpy(colors[1], argv[++count]);
X		else if ((strcmp("-cylinder", argv[count]) == 0) && (count + 1 <= argc))
X			strcpy(colors[2], argv[++count]);
X		else if ((strcmp("-roter", argv[count]) == 0) && (count + 1 <= argc))
X			strcpy(colors[3], argv[++count]);
X		else if ((strcmp("-back", argv[count]) == 0) && (count + 1 <= argc))
X			strcpy(colors[4], argv[++count]);
X		else if ((strcmp("-dep", argv[count]) == 0) && (count + 1 <= argc))
X			strcpy(colors[5], argv[++count]);
X		else if ((strcmp("-pre", argv[count]) == 0) && (count + 1 <= argc))
X			strcpy(colors[6], argv[++count]);
X		else if ((strcmp("-patchlevel", argv[count]) == 0) && (count + 1 <= argc))
X		  {
X		  printf("xengine - written by Kazuhiko Shutoh\nSCCS ID : %s\nPatchlevel : %d\n", sccsid, PATCHLEVEL);
X		  exit(0);
X		}
X		else if ((strcmp("-mono", argv[count]) == 0) && (count + 1 <= argc)) {
X			for (i = 0; i < 8; i++)
X				strcpy(colors[i], "white");
X			strcpy(colors[4], "black");
X		} else {
X			fprintf(stderr, "Usage : xengine [Toolkit-Options][-piston piston_color][-shaft shaft_color][-cylinder cylinder_color][-roter roter_color][-back background_color][-dep depression_colore][-pre pression color][-mono][-patchlevel]\n");
X			exit(0);
X		}
X	}
X
X	base = XtCreateManagedWidget("base", formWidgetClass, toplevel, NULL, 0);
X
X	i = 0;
X	XtSetArg(args[i], XtNwidth, 200);
X	i++;
X	XtSetArg(args[i], XtNheight, 200);
X	i++;
X	engine = XtCreateManagedWidget("engine", boxWidgetClass, base, args, i);
X	width = height = 200;
X
X	i = 0;
X	XtSetArg(args[i], XtNfromHoriz, engine);
X	i++;
X	XtSetArg(args[i], XtNheight, 200);
X	i++;
X	rpm_info = XtCreateManagedWidget("rpm_info", asciiTextWidgetClass, base, args, i);
X
X	XtAddActions(redrawActions, XtNumber(redrawActions));
X	newTranslations = XtParseTranslationTable(overrideTranslations);
X	XtOverrideTranslations(engine, newTranslations);
X
X	XtRealizeWidget(toplevel);
X
X	/* Get graphic context	 */
X
X	gcPiston = XCreateGC(XtDisplay(engine), XtWindow(engine), (unsigned long) 0, NULL);
X	XAllocNamedColor(XtDisplay(engine), DefaultColormap(XtDisplay(engine), 0), colors[0], &srcColor, &dummyColor);
X
X	XSetForeground(XtDisplay(engine), gcPiston, srcColor.pixel);
X
X	gcShaft = XCreateGC(XtDisplay(engine), XtWindow(engine), (unsigned long) 0, NULL);
X	XAllocNamedColor(XtDisplay(engine), DefaultColormap(XtDisplay(engine), 0), colors[1], &srcColor, &dummyColor);
X
X	XSetForeground(XtDisplay(engine), gcShaft, srcColor.pixel);
X	XSetLineAttributes(XtDisplay(engine), gcShaft, 2, LineSolid, CapButt, JoinMiter);
X
X	gcCylinder = XCreateGC(XtDisplay(engine), XtWindow(engine), (unsigned long) 0, NULL);
X	XAllocNamedColor(XtDisplay(engine), DefaultColormap(XtDisplay(engine), 0), colors[2], &srcColor, &dummyColor);
X
X	XSetForeground(XtDisplay(engine), gcCylinder, srcColor.pixel);
X
X	gcRoter = XCreateGC(XtDisplay(engine), XtWindow(engine), (unsigned long) 0, NULL);
X	XAllocNamedColor(XtDisplay(engine), DefaultColormap(XtDisplay(engine), 0), colors[3], &srcColor, &dummyColor);
X
X	XSetForeground(XtDisplay(engine), gcRoter, srcColor.pixel);
X
X	gcBack = XCreateGC(XtDisplay(engine), XtWindow(engine), (unsigned long) 0, NULL);
X	XAllocNamedColor(XtDisplay(engine), DefaultColormap(XtDisplay(engine), 0), colors[4], &srcColor, &dummyColor);
X
X	XSetForeground(XtDisplay(engine), gcBack, srcColor.pixel);
X
X	gcDep = XCreateGC(XtDisplay(engine), XtWindow(engine), (unsigned long) 0, NULL);
X	XAllocNamedColor(XtDisplay(engine), DefaultColormap(XtDisplay(engine), 0), colors[5], &srcColor, &dummyColor);
X
X	XSetForeground(XtDisplay(engine), gcDep, srcColor.pixel);
X
X	gcPre = XCreateGC(XtDisplay(engine), XtWindow(engine), (unsigned long) 0, NULL);
X	XAllocNamedColor(XtDisplay(engine), DefaultColormap(XtDisplay(engine), 0), colors[6], &srcColor, &dummyColor);
X
X	XSetForeground(XtDisplay(engine), gcPre, srcColor.pixel);
X
X	gcEngine = XCreateGC(XtDisplay(engine), XtWindow(engine), (unsigned long) 0, NULL);
X	XAllocNamedColor(XtDisplay(engine), DefaultColormap(XtDisplay(engine), 0), colors[7], &srcColor, &dummyColor);
X
X	XSetForeground(XtDisplay(engine), gcEngine, srcColor.pixel);
X
X	/* Create engine Pixmap */
X
X	enginePixmap = XCreatePixmap(XtDisplay(engine), XtWindow(engine), width, height, DefaultDepth(XtDisplay(engine), 0));
X
X	/* Interval timer start	 */
X	XtAddTimeOut(1, Cycle, NULL);
X
X	XtMainLoop();
X}
X
XXtCallbackProc
Xredraw_callback(w, event, params, nparams)
X	Widget          w;
X	XEvent         *event;
X	String         *params;
X	Cardinal       *nparams;
X{
X
X	Arg             args[10];
X
X	XtSetArg(args[0], XtNwidth, 0);
X	XtSetArg(args[1], XtNheight, 0);
X	XtGetValues(w, args, 2);
X
X	width = args[0].value;
X	height = args[1].value;
X
X	XFreePixmap(XtDisplay(engine), enginePixmap);
X	enginePixmap = XCreatePixmap(XtDisplay(engine), XtWindow(engine), width, height, DefaultDepth(XtDisplay(engine), 0));
X
X}
X
XXtTimerCallbackProc
XCycle(client_data, id)
X	caddr_t         client_data;
X	XtIntervalId    id;
X{
X
X	Arg             args[10];
X	static char     label[256];
X	char            tmp_str[16];
X	static int      i = 0;
X	static int      sample_count = 0;
X	static double   mean = 0.0;
X	double          DrawEngine();
X
X	if (i++ > 10) {
X		sprintf(tmp_str, "%4.1f rpm\n", mean / 10.0);
X
X		if (sample_count++ > 14) {
X			strcpy(label, "");
X			sample_count = 0;
X		}
X		strcat(label, tmp_str);
X		XtSetArg(args[0], XtNstring, label);
X		XtSetValues(rpm_info, args, 1);
X		i = 0;
X		mean = 0.0;
X	}
X	mean += DrawEngine();
X	XtAddTimeOut(1, Cycle, NULL);
X}
X
Xdouble
XDrawEngine()
X{
X
X	double          cycle;
X	static int      sw = 1;
X	double          angle, theta;
X	double          piston_x1, piston_y1;
X	double          piston_x2, piston_y2;
X	struct timeval  start, end;
X	struct timezone dummy;
X
X	sw ^= 1;
X
X	XSync(XtDisplay(engine), 0);
X	gettimeofday(&start, &dummy);
X	for (angle = -180; angle < 180; angle += 18) {
X		theta = angle * (PI / 180.0);
X		piston_x1 = sin(theta) * (width * 0.1) + (width / 2);
X		piston_y1 = cos(theta) * (height * 0.1) + (height * 0.7);
X		piston_x2 = width / 2;
X		piston_y2 = piston_y1 - (height * 0.3);
X
X		/* Crear Window */
X
X		XFillRectangle(XtDisplay(engine), enginePixmap, gcBack, 0, 0, width, height);
X
X		/* Draw heat sink */
X
X		XFillRectangle(XtDisplay(engine), enginePixmap, gcEngine,
X			       (int) (width * 0.35), (int) (height * 0.3),
X			       (int) (width * 0.3), (int) (height * 0.02));
X
X		XFillRectangle(XtDisplay(engine), enginePixmap, gcEngine,
X			       (int) (width * 0.35), (int) (height * 0.35),
X			       (int) (width * 0.3), (int) (height * 0.02));
X
X		XFillRectangle(XtDisplay(engine), enginePixmap, gcEngine,
X			       (int) (width * 0.35), (int) (height * 0.4),
X			       (int) (width * 0.3), (int) (height * 0.02));
X
X		/* Draw Cylinder */
X
X		XFillRectangle(XtDisplay(engine), enginePixmap, gcEngine,
X			       (int) (width * 0.42), (int) (height * 0.24),
X			       (int) (width * 0.16), (int) (height * 0.5));
X
X		XFillArc(XtDisplay(engine), enginePixmap, gcEngine,
X			 (int) (piston_x2 - (width * 0.15)), (int) ((height * 0.7) - (height * 0.15)), (int) (width * 0.3), (int) (height * 0.3), 0 * 64, 360 * 64);
X
X		XFillArc(XtDisplay(engine), enginePixmap, gcBack,
X			 (int) (piston_x2 - (width * 0.14)), (int) ((height * 0.7) - (height * 0.14)), (int) (width * 0.28), (int) (height * 0.28), 0 * 64, 360 * 64);
X
X		XFillRectangle(XtDisplay(engine), enginePixmap, gcBack,
X			       (int) (width * 0.43), (int) (height * 0.25),
X			       (int) (width * 0.14), (int) (height * 0.5));
X
X		/* Draw Gas */
X
X		if (sw != 0) {
X			XFillRectangle(XtDisplay(engine), enginePixmap, gcPre,
X			       (int) (width * 0.435), (int) (height * 0.25),
X				       (int) (width * 0.13), (int) (piston_y2 - (height * 0.05) - (height * 0.26) + (height * 0.1)));
X		} else {
X			XFillRectangle(XtDisplay(engine), enginePixmap, gcDep,
X			       (int) (width * 0.435), (int) (height * 0.25),
X				       (int) (width * 0.13), (int) (piston_y2 - (height * 0.05) - (height * 0.26) + (height * 0.1)));
X		}
X
X		/* Draw Piston arm */
X
X		XDrawLine(XtDisplay(engine), enginePixmap, gcShaft,
X			  (int) piston_x1, (int) piston_y1, (int) piston_x2, (int) piston_y2);
X		XDrawLine(XtDisplay(engine), enginePixmap, gcShaft,
X			  (int) piston_x1, (int) piston_y1, (int) piston_x2, (int) (height * 0.7));
X
X
X		/* Draw Piston & ring */
X
X		XFillRectangle(XtDisplay(engine), enginePixmap, gcPiston,
X		 (int) (width * 0.435), (int) (piston_y2 - (height * 0.05)),
X			       (int) (width * 0.13), (int) (height * 0.1));
X
X		XFillRectangle(XtDisplay(engine), enginePixmap, gcShaft,
X		(int) (width * 0.435), (int) (piston_y2 - (height * 0.045)),
X			       (int) (width * 0.13), (int) (height * 0.01));
X
X		XFillArc(XtDisplay(engine), enginePixmap, gcShaft,
X			 (int) (piston_x2 - (width * 0.015)), (int) (piston_y2 - (height * 0.015)), (int) (width * 0.03), (int) (height * 0.03), 0, 360 * 64);
X
X		/* Draw Roter */
X		XFillArc(XtDisplay(engine), enginePixmap, gcRoter,
X			 (int) (piston_x2 - (width * 0.1)), (int) ((height * 0.7) - (height * 0.1)), (int) (width * 0.2), (int) (height * 0.2), (int) (angle + 30) * 64, 120 * 64);
X
X		XFillArc(XtDisplay(engine), enginePixmap, gcPiston,
X			 (int) (piston_x2 - (width * 0.025)), (int) ((height * 0.7) - (height * 0.025)), (int) (width * 0.05), (int) (height * 0.05), 0, 360 * 64);
X
X		XCopyArea(XtDisplay(engine), enginePixmap, XtWindow(engine), gcCylinder, 0, 0, width, height, 0, 0);
X	}
X
X	XSync(XtDisplay(engine), 0);
X	gettimeofday(&end, &dummy);
X
X	cycle = 60 / ((double) ((end.tv_sec * 1000000 + end.tv_usec) - (start.tv_sec * 1000000 + start.tv_usec)) / 1000000);
X
X
X	return (cycle);
X
X}
X
END_OF_FILE
if test 11425 -ne `wc -c <'xengine.c'`; then
    echo shar: \"'xengine.c'\" unpacked with wrong size!
fi
# end of 'xengine.c'
fi
if test -f 'xengine.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xengine.man'\"
else
echo shar: Extracting \"'xengine.man'\" \(1142 characters\)
sed "s/^X//" >'xengine.man' <<'END_OF_FILE'
X.TH XENGINE 1 "19 September 1990" "X Version 11"
X.SH NAME
Xxengine - reciprocationg engine for X.
X.SH SYNOPSIS
X.B xengine
X[-\fItoolkitoption\fP ...] [-patchlevel] [-piston \fIpiston-color\fP] [-cylinder \fIcylinder-color\fP] [-roter \fIroter-color\fP] [-back \fIbackground-color\fP] [-dep \fIdepression-color\fP] [-pre \fIpression-color\fP]
X.SHb DESCRIPTION
XThe 
X.I xengine
Xdisplays a animating reciprocating engine. Please don't ask me why. :-) 
X.SH OPTIONS
X.PP
X.I Xtacho
Xaccepts all of the standard X Toolkit command line options along with the 
Xfollowing additional options:
X.PP
X.TP 8
X.B \-patchlevel
XThis option specifies the show patchlevel.
X.TP 8
X.B \-(parts-name) \fIparts-color\fP
XThis option specifies the color each parts of engine.  
X.SH SEE ALSO
XX(1), X Toolkit Athena widgets.
X.SH COPYRIGHT NOTICE
XPermission to use, copy, modify and distribute without charge this
Xsoftware, documentation, images, etc. is granted, provided that this 
Xcomment and the author's name is retained.  The author assumes no 
Xresponsibility for lost sleep as a consequence of use of this software.
X.SH AUTHOR
XKazuhiko Shutoh 
X.br
Xshutoh at isl.yamaha.co.jp
END_OF_FILE
if test 1142 -ne `wc -c <'xengine.man'`; then
    echo shar: \"'xengine.man'\" unpacked with wrong size!
fi
# end of 'xengine.man'
fi
echo shar: End of shell archive.
exit 0


dan
----------------------------------------------------
O'Reilly && Associates   argv at sun.com / argv at ora.com
Opinions expressed reflect those of the author only.



More information about the Comp.sources.x mailing list