diff --git a/books/Makefile.pamphlet b/books/Makefile.pamphlet
index c8af5f5..621d35f 100644
--- a/books/Makefile.pamphlet
+++ b/books/Makefile.pamphlet
@@ -17,6 +17,7 @@ PDF=${AXIOM}/doc
 IN=${SPD}/books
 LATEX=latex
 MAKEINDEX=makeindex
+DVIPDFM=dvipdfm
 DVIPS=dvips -Ppdf
 PS2PDF=ps2pdf
 RM=rm -f
@@ -36,19 +37,19 @@ ${PDF}/%.pdf: ${IN}/%.pamphlet
 	  cp -pr ${IN}/ps ${PDF} ; \
 	  ${WEAVE} -delay $*.pamphlet >$*.tex ; \
 	  if [ -z "${NOISE}" ] ; then \
+	    ${RM} $*.toc ; \
 	    ${LATEX} $*.tex ; \
 	    ${MAKEINDEX} $* >/dev/null ; \
 	    ${LATEX} $*.tex >/dev/null ; \
-	    ${DVIPS} $*.dvi 2>/dev/null ; \
-	    ${PS2PDF} $*.ps >/dev/null ; \
+	    ${DVIPDFM} $*.dvi 2>/dev/null ; \
 	    ${RM} $*.aux $*.dvi $*.log $*.ps $*.idx $*.tex $*.pamphlet ; \
 	  else \
+	    ${RM} $*.toc ; \
 	    ${LATEX} $*.tex >${TMP}/trace ; \
 	    echo ...first latex complete ; \
 	    ${MAKEINDEX} $* >${TMP}/trace ; \
 	    ${LATEX} $*.tex >${TMP}/trace ; \
-	    ${DVIPS} $*.dvi 2>${TMP}/trace  ; \
-	    ${PS2PDF} $*.ps >${TMP}/trace  ; \
+	    ${DVIPDFM} $*.dvi 2>${TMP}/trace ; \
 	    ${RM} $*.aux $*.dvi $*.log $*.ps $*.idx $*.tex $*.pamphlet ; \
 	  fi )
 
@@ -56,6 +57,31 @@ ${PDF}/%.pdf: ${IN}/%.pamphlet
 \section{Combined Table of Contents}
 This is the table of contents from the existing volumes combined into
 one document for easy reference.
+
+It turns out that the hyperref package adds junk on the end of the 
+lines in the .toc files. We use these files to create the combined
+table of contents so we need to clean up after hyperref. These 
+patterns remove the last braced item in the line. If a new one
+shows up you'll have to add the pattern here to remove it.
+
+The cruft I've found so far has the forms:
+\begin{itemize}
+\item \verb|{chapter.1}|
+\item \verb|{section.1.1}|
+\item \verb|{subsection.1.1}|
+\item \verb|{appendix.A}|
+\item \verb|{section.A.1}|
+\item \verb|{subsection.A.1}|
+\end{itemize}
+The sed patterns to match and remove them (in order) are:
+<<sed pattern>>=
+	sed -e 's/{chapter.[0-9]*}//' \
+            -e 's/{section.[0-9]*.[0-9]*}//' \
+            -e 's/{subsection.[0-9]*.[0-9]*.[0-9]*}//' \
+            -e 's/{appendix.*}//' \
+            -e 's/{section.[A-Z]*.[0-9]*}//' \
+            -e 's/{subsection.[A-Z]*.[0-9]*.[0-9]*}//' \
+@
 <<*>>=
 ${PDF}/toc.pdf: ${BOOKS}
 	@echo 13 making ${PDF}/toc.pdf
@@ -81,52 +107,65 @@ ${PDF}/toc.pdf: ${BOOKS}
 	echo "\\tableofcontents" >>toc.tex ; \
 	echo "\\end{document}" >>toc.tex ; \
 	echo "\\section*{Volume 0: Axiom Jenks and Sutor}" >>toc.toc ; \
-	cat bookvol0.toc >>toc.toc ; \
+<<sed pattern>>
+            <bookvol0.toc >>toc.toc ; \
 	echo "\\newpage" >>toc.toc ; \
 	echo "\\section*{Volume 1: Axiom Tutorial}" >>toc.toc ; \
-	cat bookvol1.toc >>toc.toc ; \
+<<sed pattern>>
+            <bookvol1.toc >>toc.toc ; \
 	echo "\\newpage" >>toc.toc ; \
 	echo "\\section*{Volume 2: Axiom Users Guide}" >>toc.toc ; \
-	cat bookvol2.toc >>toc.toc ; \
+<<sed pattern>>
+            <bookvol2.toc >>toc.toc ; \
 	echo "\\newpage" >>toc.toc ; \
 	echo "\\section*{Volume 3: Axiom Programmers Guide}" >>toc.toc ; \
-	cat bookvol3.toc >>toc.toc ; \
+<<sed pattern>>
+            <bookvol3.toc >>toc.toc ; \
 	echo "\\newpage" >>toc.toc ; \
 	echo "\\section*{Volume 4: Axiom Developers Guide}" >>toc.toc ; \
-	cat bookvol4.toc >>toc.toc ; \
+<<sed pattern>>
+            <bookvol4.toc >>toc.toc ; \
 	echo "\\newpage" >>toc.toc ; \
 	echo "\\section*{Volume 5: Axiom Interpreter}" >>toc.toc ; \
-	cat bookvol5.toc >>toc.toc ; \
+<<sed pattern>>
+            <bookvol5.toc >>toc.toc ; \
 	echo "\\newpage" >>toc.toc ; \
 	echo "\\section*{Volume 6: Axiom Command}" >>toc.toc ; \
-	cat bookvol6.toc >>toc.toc ; \
+<<sed pattern>>
+            <bookvol6.toc >>toc.toc ; \
 	echo "\\newpage" >>toc.toc ; \
 	echo "\\section*{Volume 7: Axiom Hyperdoc}" >>toc.toc ; \
-	cat bookvol7.toc >>toc.toc ; \
+<<sed pattern>>
+            <bookvol7.toc >>toc.toc ; \
 	echo "\\newpage" >>toc.toc ; \
 	echo "\\section*{Volume 8: Axiom Graphics}" >>toc.toc ; \
-	cat bookvol8.toc >>toc.toc ; \
+<<sed pattern>>
+            <bookvol8.toc >>toc.toc ; \
 	echo "\\newpage" >>toc.toc ; \
 	echo "\\section*{Volume 9: Axiom Compiler}" >>toc.toc ; \
-	cat bookvol9.toc >>toc.toc ; \
+<<sed pattern>>
+            <bookvol9.toc >>toc.toc ; \
 	echo "\\newpage" >>toc.toc ; \
 	echo "\\section*{Volume 10: Axiom Algebra}" >>toc.toc ; \
-	cat bookvol10.toc >>toc.toc ; \
+<<sed pattern>>
+            <bookvol10.toc >>toc.toc ; \
 	echo "\\newpage" >>toc.toc ; \
 	echo "\\section*{Volume 11: Axiom Browser}" >>toc.toc ; \
-	cat bookvol11.toc >>toc.toc ; \
+<<sed pattern>>
+            <bookvol11.toc >>toc.toc ; \
 	echo "\\newpage" >>toc.toc ; \
 	echo "\\section*{Volume 12: Axiom Crystal}" >>toc.toc ; \
-	cat bookvol12.toc >>toc.toc ; \
+<<sed pattern>>
+            <bookvol12.toc >>toc.toc ; \
 	if [ -z "${NOISE}" ] ; then \
 	  ${LATEX} toc.tex ; \
 	  ${DVIPS} toc.dvi 2>/dev/null ; \
-	  ${PS2PDF} toc.ps >/dev/null ; \
+	  ${PS2PDF} toc.ps 2>/dev/null ; \
 	  ${RM} -f toc.aux toc.dvi toc.log toc.ps toc.tex toc.toc ; \
 	else \
 	  ${LATEX} toc.tex >${TMP}/trace ; \
 	  ${DVIPS} toc.dvi 2>${TMP}/trace ; \
-	  ${PS2PDF} toc.ps >${TMP}/trace ; \
+	  ${PS2PDF} toc.ps 2>${TMP}/trace ; \
 	  ${RM} -f toc.aux toc.dvi toc.log toc.ps toc.tex toc.toc ; \
 	fi )
 
diff --git a/books/bookvol0.pamphlet b/books/bookvol0.pamphlet
index ca200f4..4e56328 100644
--- a/books/bookvol0.pamphlet
+++ b/books/bookvol0.pamphlet
@@ -1,5 +1,6 @@
-\documentclass{book}
+\documentclass[dvipdfm]{book}
 %\usepackage{axiom}
+\usepackage{hyperref}
 \usepackage{makeidx}
 \makeindex
 \usepackage{graphicx}
diff --git a/books/bookvol1.pamphlet b/books/bookvol1.pamphlet
index c758fce..34f6ff8 100644
--- a/books/bookvol1.pamphlet
+++ b/books/bookvol1.pamphlet
@@ -1,4 +1,5 @@
-\documentclass{book}
+\documentclass[dvipdfm]{book}
+\usepackage{hyperref}
 \usepackage{axiom}
 \usepackage{makeidx}
 \makeindex
diff --git a/books/bookvol10.pamphlet b/books/bookvol10.pamphlet
index 1148bd8..bf3b0c4 100644
--- a/books/bookvol10.pamphlet
+++ b/books/bookvol10.pamphlet
@@ -1,4 +1,5 @@
-\documentclass{book}
+\documentclass[dvipdfm]{book}
+\usepackage{hyperref}
 \usepackage{amssymb}
 \usepackage{axiom}
 \usepackage{makeidx}
diff --git a/books/bookvol11.pamphlet b/books/bookvol11.pamphlet
index 710be18..8e552df 100644
--- a/books/bookvol11.pamphlet
+++ b/books/bookvol11.pamphlet
@@ -1,4 +1,5 @@
-\documentclass{book}
+\documentclass[dvipdfm]{book}
+\usepackage{hyperref}
 \usepackage{axiom}
 \usepackage{makeidx}
 \makeindex
diff --git a/books/bookvol12.pamphlet b/books/bookvol12.pamphlet
index d47dd24..3b75fb7 100644
--- a/books/bookvol12.pamphlet
+++ b/books/bookvol12.pamphlet
@@ -1,4 +1,5 @@
-\documentclass{book}
+\documentclass[dvipdfm]{book}
+\usepackage{hyperref}
 \usepackage{axiom}
 \usepackage{makeidx}
 \makeindex
diff --git a/books/bookvol2.pamphlet b/books/bookvol2.pamphlet
index e9cf201..5cc5820 100644
--- a/books/bookvol2.pamphlet
+++ b/books/bookvol2.pamphlet
@@ -1,4 +1,5 @@
-\documentclass{book}
+\documentclass[dvipdfm]{book}
+\usepackage{hyperref}
 \usepackage{axiom}
 \usepackage{makeidx}
 \makeindex
diff --git a/books/bookvol3.pamphlet b/books/bookvol3.pamphlet
index ebb060f..cf709e7 100644
--- a/books/bookvol3.pamphlet
+++ b/books/bookvol3.pamphlet
@@ -1,4 +1,5 @@
-\documentclass{book}
+\documentclass[dvipdfm]{book}
+\usepackage{hyperref}
 \usepackage{axiom}
 \usepackage{makeidx}
 \makeindex
diff --git a/books/bookvol4.pamphlet b/books/bookvol4.pamphlet
index b114afb..61b7321 100644
--- a/books/bookvol4.pamphlet
+++ b/books/bookvol4.pamphlet
@@ -1,4 +1,5 @@
-\documentclass{book}
+\documentclass[dvipdfm]{book}
+\usepackage{hyperref}
 \usepackage{axiom}
 \usepackage{makeidx}
 \makeindex
diff --git a/books/bookvol5.pamphlet b/books/bookvol5.pamphlet
index 1bfbd48..4d56731 100644
--- a/books/bookvol5.pamphlet
+++ b/books/bookvol5.pamphlet
@@ -1,4 +1,5 @@
-\documentclass{book}
+\documentclass[dvipdfm]{book}
+\usepackage{hyperref}
 \usepackage{axiom}
 \usepackage{makeidx}
 \makeindex
diff --git a/books/bookvol6.pamphlet b/books/bookvol6.pamphlet
index d9a8933..9ac5576 100644
--- a/books/bookvol6.pamphlet
+++ b/books/bookvol6.pamphlet
@@ -22,7 +22,7 @@ Jonathan\ Steinbach    & Robert\ Sutor    & Barry\ Trager \\
 Stephen\ Watt          & Jim\ Wen         & Clifton\ Williamson
 \end{array}
 $$
-\center{\large{Volume 6: Axiom Command}}
+\center{\large{VOLUME 6: AXIOM COMMAND}}
 \end{titlepage}
 \pagenumbering{roman}
 
@@ -7138,6 +7138,133 @@ WildFunctionFieldIntegralBasis
 XExponentialPackage
 ZeroDimensionalSolvePackage
 @
+\chapter{Makefile}
+\section{Environment variables}
+<<make.environment>>=
+BOOK=${SPD}/books/bookvol6.pamphlet
+
+# this is where we are compiling from
+IN=     ${SRC}/sman
+
+# this is the intermediate place 
+MID=    ${INT}/sman
+
+# this is the intermediate place 
+MIDOBJ=    ${OBJ}/${SYS}/sman
+
+# this is where to put the various commands
+OUT=	${MNT}/${SYS}/bin
+OUTLIB=	${MNT}/${SYS}/lib
+
+# this is where the include files live
+INC=    ${SRC}/include
+
+# this is where we hid the libspad library
+LIB=	${OBJ}/${SYS}/lib
+
+# this is where the documentation ends up
+DOC=    ${MNT}/${SYS}/doc
+CFLAGS=	${CCF} 
+LDFLAGS= -L${LIB} -lspad ${LDF}
+
+SMANOBJS= ${LIB}/libspad.a
+
+@
+\section{The axiom command}
+<<make.axiomcmd>>=
+${OUT}/axiom: ${BOOK}
+	@echo 1 making ${OUT}/axiom from ${BOOK}
+	@ (cd ${OUT} ; \
+           ${TANGLE} -R"axiomcmd" ${BOOK} >axiom )
+	@chmod +x ${OUT}/axiom
+	@ cp ${OUT}/axiom ${MID}
+
+@
+\section{session}
+<<make.session>>=
+${OUTLIB}/session: ${SMANOBJS} ${MIDOBJ}/session.o
+	@ echo 1 linking session
+	@ ${CC} -o ${OUTLIB}/session ${MIDOBJ}/session.o ${SMANOBJS} 
+
+${MID}/session.c: ${BOOK}
+	@ echo 2 making ${MID}/session.c from ${BOOK}
+	@ (cd ${MID} ; \
+          ${TANGLE} -R"session" ${BOOK} >session.c )
+
+${MIDOBJ}/session.o: ${MID}/session.c ${INC}/session.h1
+	@ echo 3 making ${MIDOBJ}/session.o from ${MID}/session.c
+	@ ( cd ${MIDOBJ} ; ${CC} -c ${CFLAGS} ${MID}/session.c -I${INC} )
+
+@
+\section{nagman}
+Note that we do not build the nagman component as we do not have the
+necessary code (for instance, [[callnag]]).
+<<make.nagman>>=
+${OUT}/nagman:	${SMANOBJS} ${MIDOBJ}/nagman.o
+	@ echo 5 linking nagman
+	@ ${CC} -o ${OUT}/nagman ${MIDOBJ}/nagman.o ${SMANOBJS} 
+
+${MID}/nagman.c: ${BOOK}
+	@ echo 6 making ${MID}/nagman.c from ${IN}/bookvol6.pamphlet
+	@ (cd ${MID} ; \
+           ${TANGLE} -R"nagman" ${BOOK} >nagman.c )
+
+${MIDOBJ}/nagman.o: ${MID}/nagman.c ${INC}/nagman.h1
+	@ echo 7 making ${MIDOBJ}/nagman.o from ${MID}/nagman.c
+	@ ( cd ${MIDOBJ} ; ${CC} -c ${CFLAGS} ${MID}/nagman.c -I${INC} )
+
+@
+\section{spadclient}
+<<make.spadclient>>=
+${OUTLIB}/spadclient: ${SMANOBJS} ${MIDOBJ}/spadclient.o
+	@ echo 9 linking spadclient
+	@ ${CC} -o ${OUTLIB}/spadclient ${MIDOBJ}/spadclient.o  ${SMANOBJS} 
+
+${MID}/spadclient.c: ${BOOK}
+	@ echo 10 making ${MID}/spadclient.c from ${IN}/bookvol6.pamphlet
+	@ (cd ${MID} ; \
+           ${TANGLE} -R"spadclient" ${BOOK} >spadclient.c )
+
+${MIDOBJ}/spadclient.o: ${MID}/spadclient.c ${INC}/spadclient.h1
+	@ echo 11 making ${MIDOBJ}/spadclient.o from ${MID}/spadclient.c
+	@ ( cd ${MIDOBJ} ; ${CC} -c ${CFLAGS} ${MID}/spadclient.c -I${INC} )
+
+@
+\section{sman}
+<<make.sman>>=
+${OUT}/sman: ${SMANOBJS} ${MIDOBJ}/sman.o
+	@ echo 13 linking sman
+	@ ${CC} -o ${OUT}/sman ${MIDOBJ}/sman.o ${SMANOBJS} 
+
+${MID}/sman.h: ${BOOK}
+	@ echo 00 making ${MID}/sman.h from ${IN}/bookvol6.pamphlet
+	@ (cd ${MID} ; \
+           ${TANGLE} -R"sman.h" ${BOOK} >sman.h )
+
+${MID}/sman.c: ${MID}/sman.h ${BOOK}
+	@ echo 14 making ${MID}/sman.c from ${IN}/bookvol6.pamphlet
+	@ (cd ${MID} ; \
+           ${TANGLE} -R"sman" ${BOOK} >sman.c )
+
+${MIDOBJ}/sman.o: ${MID}/sman.c ${INC}/sman.h1
+	@ echo 15 making ${MIDOBJ}/sman.o from ${MID}/sman.c
+	@ ( cd ${MIDOBJ} ; ${CC} -I${INC} -I${MID} -c ${CFLAGS} ${MID}/sman.c )
+
+@
+<<*>>=
+<<make.environment>>
+all:	${OUTLIB}/session ${OUTLIB}/spadclient ${OUT}/sman ${OUT}/axiom 
+	@ echo 18 finished ${IN}
+
+clean:
+	@echo 19 cleaning ${SRC}/sman
+
+<<make.axiomcmd>>
+<<make.sman>>
+<<make.session>>
+<<make.spadclient>>
+<<make.nagman>>
+@
 \begin{thebibliography}{99}
 \bibitem{1} Jenks, R.J. and Sutor, R.S. \\
 ``Axiom -- The Scientific Computation System''\\
@@ -7147,8 +7274,8 @@ ISBN 0-387-97855-0
 Center for the Study of Language and Information
 ISBN 0-937073-81-4
 Stanford CA (1992) 
-\bibitem{3} Daly, Timothy, ``The Axiom Wiki Website''\\
-{\bf http://axiom.axiom-developer.org}
+\bibitem{3} Page, William, ``The Axiom Wiki Website''\\
+{\bf http://wiki.axiom-developer.org}
 \bibitem{4} Watt, Stephen, ``Aldor'',\\
 {\bf http://www.aldor.org}
 \bibitem{5} Lamport, Leslie,\\
@@ -7162,10 +7289,9 @@ Addison-Wesley, New York ISBN 0-201-52983-1
 \bibitem{8} Axiom Book Volume 8 -- Graphics\\
 {\bf file://usr/local/axiom/src/graph/bookvol8.pamphlet}
 \bibitem{9} AIX Version 3.2 and 4 Performance Tuning Guide\\
-{\bf http://www.rs6000.ibm.com/doc\_link/en\_US/\\
+{\bf 
+http://www.rs6000.ibm.com/doc\_link/en\_US/\\
 {\hbox {\hskip 1.0cm}}a\_doc\_lib/aixbman/prftungd/toc.htm}
-\bibitem{10} Daly, Timothy, "The Axiom Literate Documentation"\\
-{\bf http://axiom.axiom-developer.org/axiom-website/documentation.html}
 \end{thebibliography}
 \printindex
 \end{document}
diff --git a/books/bookvol7.pamphlet b/books/bookvol7.pamphlet
index e851b24..f616d79 100644
--- a/books/bookvol7.pamphlet
+++ b/books/bookvol7.pamphlet
@@ -1,4 +1,5 @@
-\documentclass{book}
+\documentclass[dvipdfm]{book}
+\usepackage{hyperref}
 \usepackage{axiom}
 \usepackage{makeidx}
 \makeindex
diff --git a/books/bookvol8.pamphlet b/books/bookvol8.pamphlet
index fc2404c..a85e844 100644
--- a/books/bookvol8.pamphlet
+++ b/books/bookvol8.pamphlet
@@ -1,4 +1,5 @@
-\documentclass{book}
+\documentclass[dvipdfm]{book}
+\usepackage{hyperref}
 \usepackage{axiom}
 \usepackage{makeidx}
 \makeindex
@@ -224,6 +225,107 @@ functions for the X routines, as in GDrawArc versus XDrawArc.
 When the Xoption is set the X routine is called. When the PSoption 
 is set the postscript routines are generated.
 
+\section{Standard Curves and Surfaces}
+In order to have an organized and thorough evaluation of the Axiom
+graphics code we turn to the CRC Standard Curves and Surfaces\cite{8} (SCC).
+This volume was written years after the Axiom graphics code was written so
+there was no attempt to match the two until now. However, the SCC volume
+will give us a solid foundation to both evaluate the features of the 
+current code and suggest future directions.
+
+According to the SCC we can organize the various curves by the taxonomy:
+\begin{enumerate}
+\item[1] {\bf random}
+\begin{enumerate}
+\item[1.1] {\bf fractal}
+\item[1.2] {\bf gaussian}
+\item[1.3] {\bf non-gaussian}
+\end{enumerate}
+\item[2] {\bf determinate}
+\begin{enumerate}
+\item[2.1] {\bf algebraic} -- A polynomial is defined as a summation of terms
+composed of integral powers of $x$ and $y$. An algebraic curve is one whose
+implicit function 
+\[f(x,y)=0\] is a polynomial in $x$ and $y$ (after rationalization, if
+necessary). Because a curve is often defined in the explicit form
+\[y=f(x)\] there is a need to distinguish rational and irrational 
+functions of $x$. 
+\begin{enumerate}
+\item[2.1.1] {\bf irrational} -- An irrational function of $x$ is a quotient
+of two polynomials, one or both of which has a term (or terms) with power
+$p/q$, where $p$ and $q$ are integers.
+\item[2.1.2] {\bf rational} -- A rational function of $x$ is a quotient of two
+polynomials in $x$, both having only integer powers.
+\begin{enumerate}
+\item[2.1.2.1] {\bf polynomial}
+\item[2.1.2.2] {\bf non-polynomial}
+\end{enumerate}
+\end{enumerate}
+\item[2.2] {\bf integral} -- Certain continuous functions are not expressible 
+in algebraic or transcendental forms but are familiar mathematical tools. 
+These curves are equal to the integrals of algebraic or transcendental 
+curves by definition; examples include Bessel functions, Airy integrals, 
+Fresnel integrals, and the error function.
+\item[2.3] {\bf transcendental} -- The transcendental curves cannot be 
+expressed as polynomials in $x$ and $y$. These are curves containing one 
+or more of the following forms: exponential ($e^x$), 
+logarithmic ($\log(x)$), or trigonometric ($\sin(x)$, $\cos(x)$). 
+\begin{enumerate}
+\item[2.3.1] {\bf exponential}
+\item[2.3.2] {\bf logarithmic}
+\item[2.3.3] {\bf trigonometric}
+\end{enumerate}
+\item[2.4] {\bf piecewise continuous} -- Other curves, except at a few 
+singular points, are smooth and differentiable. The class of 
+nondifferentiable curves have discontinuity of the first derivative as a 
+basic attribute. They are often composed of straight-line segments. 
+Simple polygonal forms, regular fractal curves, and turtle tracks are 
+examples.
+\begin{enumerate}
+\item[2.4.1] {\bf periodic}
+\item[2.4.2] {\bf non-periodic}
+\item[2.4.3] {\bf polygonal}
+\begin{enumerate}
+\item[2.4.3.1] {\bf regular}
+\item[2.4.3.2] {\bf irregular}
+\item[2.4.3.3] {\bf fractal}
+\end{enumerate}
+\end{enumerate}
+\end{enumerate}
+\end{enumerate}
+
+\section{CRC graphs}
+\begin{verbatim}
+)clear all
+)set mes auto off
+vp:=makeViewport2D()
+lineColorDefault(green())
+f(c,x,n) == c*x^n
+viewport1:=draw(f(1,x,1), x=-2..2, adaptive==true, unit==[1.0,1.0], title=="p27 2.1.1")
+graph2111:=getGraph(viewport1,1)
+
+lineColorDefault(blue())
+viewport2:=draw(f(1,x,3), x=-2..2, adaptive==true, unit==[1.0,1.0])
+graph2112:=getGraph(viewport2,1)
+
+lineColorDefault(red())
+viewport3:=draw(f(1,x,5), x=-2..2, adaptive==true, unit==[1.0,1.0])
+graph2113:=getGraph(viewport3,1)
+
+putGraph(viewport1,graph2112,2)
+putGraph(viewport1,graph2113,3)
+units(viewport1,1,"on")
+points(viewport1,1,"off")
+points(viewport1,2,"off")
+points(viewport1,3,"off")
+
+makeViewport2D(viewport1)
+write(viewport1,"p27-2.1.1")
+\end{verbatim}
+\center{\includegraphics[height=8cm,width=8cm]{ps/CRCp27-2.1.1.ps}}
+\label{CRCp27-2.1.1}
+\index{figures!CRCp27-2.1.1}
+
 \section{Environment Settings}
 \subsection{X11 .Xdefaults}
 \begin{itemize}
@@ -1084,9 +1186,6 @@ typedef struct _LLLPoint { /* meaning list of list of list of points */
 @
 \section{g.h}
 <<include/g.h>>=
-#ifndef _G_H_
-#define _G_H_ 1
-
 #define Xoption		0	/* Gdraw routine option */
 #define PSoption		1	/* Gdraw routine option */
 
@@ -1141,24 +1240,9 @@ typedef struct _GCstruct {
   struct _GCstruct *next;
 } GCstruct, *GCptr;
 
-
-/*
- * These global variables are expected to be declared somewehere in the
- * client application source, eg, in main.c for view2d and view3d.
- */
-
-extern char *PSfilename;  /* User-definable output file name. */
-
-extern int   psInit;	  /* Flag for one-time PS initialization routine. */
-
-extern GCptr GChead;      /* Points to the head of GCstruct linked list. */
-
-#endif
 @
 \section{nox10.h}
 <<include/nox10.h>>=
-#ifndef _X10_H_
-#define _X10_H_
 
 /* Used in XDraw and XDrawFilled */
 
@@ -1216,8 +1300,6 @@ typedef struct _XAssocTable {
 } XAssocTable;
 
 
-#endif /* _X10_H_ */
-
 @
 \section{override.h}
 <<include/override.h>>=
@@ -1261,7 +1343,6 @@ typedef struct _HLS {
 \section{spadcolors.h}
 This seems unused.
 <<include/spadcolors.h>>=
-#include <X11/X.h>
 #define numOfColors 240
 #define totalHuesConst   27 
 #define totalShadesConst 5 
@@ -1287,7 +1368,6 @@ This seems unused.
 extern int       smoothHue;
 extern Colormap  colorMap;
 extern int       num;
-extern int       scrn;
 
 #define maxColors DisplayCells(dsply,scrn)-1
 
@@ -1647,15 +1727,13 @@ exitWithAck(RootWindow(dsply,scrn),Window,-1); \
    Note that the numbers in this list is also the order
    in which they should appear in the Axiom file (e.g. view3D.spad) */
 
-#define Pixmap		1
-#define Bitmap		2
-#define Postscript	3
-#define Image		4
+#define aPixmap	1
+#define aBitmap 2
+#define aPostscript 3
+#define anImage	4
 @
 \section{xdefs.h}
 <<include/xdefs.h>>=
-#ifdef view3D
-
 /***      default fonts      ***/
 #ifdef  RTplatform
 #define messageFontDefault    "Rom14.500"
@@ -1664,6 +1742,8 @@ exitWithAck(RootWindow(dsply,scrn),Window,-1); \
 #define titleFontDefault      "Rom14.500"
 #define lightingFontDefault   "6x10"
 #define volumeFontDefault     "Rom8.500"
+#define graphFontDefault      "fg-22"
+#define unitFontDefault       "6x10"
 #endif
 
 #if defined(PS2platform) || defined(RIOSplatform) || defined(AIX370platform)
@@ -1673,6 +1753,8 @@ exitWithAck(RootWindow(dsply,scrn),Window,-1); \
 #define titleFontDefault    "Rom14"
 #define lightingFontDefault "Rom10"
 #define volumeFontDefault   "Rom8"
+#define graphFontDefault    "Rom22"
+#define unitFontDefault     "6x10"
 #else
 #define messageFontDefault  "9x15"
 #define buttonFontDefault   "8x13"
@@ -1680,45 +1762,10 @@ exitWithAck(RootWindow(dsply,scrn),Window,-1); \
 #define titleFontDefault    "9x15"
 #define lightingFontDefault "6x13"
 #define volumeFontDefault   "6x10"
-#endif
-
-
-#endif
-
-/************************/
-/***      view2d      ***/
-/************************/
-#ifdef view2d
-
-/***      default fonts      ***/
-#ifdef  RTplatform
-#define messageFontDefault "Rom14.500"
-#define buttonFontDefault  "vtbold"
-#define headerFontDefault  "Itl14.500"
-#define titleFontDefault   "Rom14.500"
-#define graphFontDefault   "fg-22"
-#define unitFontDefault    "6x10"
-#endif
-
-#if defined(PS2platform) || defined(RIOSplatform) || defined(AIX370platform)
-#define messageFontDefault "Rom14"
-#define buttonFontDefault  "Rom11"
-#define headerFontDefault  "Itl14"
-#define titleFontDefault   "Rom14"
-#define graphFontDefault   "Rom22"
-#define unitFontDefault    "6x10"
-#else
-#define messageFontDefault  "9x15"
-#define buttonFontDefault   "8x13"
-#define headerFontDefault   "9x15"
-#define titleFontDefault    "9x15"
 #define unitFontDefault     "6x10"
 #define graphFontDefault    "9x15"
 #endif
 
-
-#endif
-
 @
 \section{include/purty}
 \subsection{include/purty/spadbitmap.bitmap}
@@ -1780,6 +1827,8 @@ static char volumeMask_bits[] = {
 
 \chapter{viewman}
 \label{viewman}
+\section{Constants and Headers}
+\subsection{defines}
 <<viewman>>=
       /* Viewport Commands */
 #define makeViewport -1
@@ -1794,6 +1843,9 @@ static char volumeMask_bits[] = {
 #define components
 #define spadActionMode
 
+@
+\subsection{System includes}
+<<viewman>>=
 #include <assert.h>
 #ifdef SGIplatform
 #include <bstring.h>
@@ -1810,6 +1862,9 @@ static char volumeMask_bits[] = {
 #include <sys/wait.h>
 #include <unistd.h>
 
+@
+\subsection{Local includes}
+<<viewman>>=
 <<include/actions.h>>
 <<include/view2d.h>>
 <<include/view3d.h>>
@@ -1821,6 +1876,9 @@ static char volumeMask_bits[] = {
 #include "sockio-c.h1"
 #include "util.h1"
 
+@
+\subsection{extern references}
+<<viewman>>=
 extern int acknow;
 extern int checkClosedChild;
 extern int currentGraph;
@@ -1845,6 +1903,9 @@ extern int viewOkay;
 extern viewManager *viewports;
 extern int viewType;
 
+@
+\subsection{forward references}
+<<viewman>>=
 int readViewport(viewManager *viewPort,void *info,int size);
 void discardGraph(graphStruct *theGraph);
 void sendGraphToView2D(int i,int there,viewManager *viewport,
@@ -1853,9 +1914,9 @@ void makeView2DFromSpadData(view2DStruct *viewdata,
                             graphStateStruct graphState[]);
 void makeView3DFromSpadData(view3DStruct *viewdata,int typeOfViewport);
 
-
-/************* global variables **************/
-
+@
+\subsection{global variables}
+<<viewman>>=
 Display *dsply;
 Window  root;
 XEvent  viewmanEvent;
@@ -1882,6 +1943,7 @@ char        *s1,
 
 
 @
+\section{Code}
 \subsection{endChild}
 \index{viewman!endChild}
 \index{endChild viewman}
@@ -2983,46 +3045,28 @@ int main(void) {
 }
 
 @
-\section{viewman Makefile}
-<<viewman/Makefile>>=
-BOOK=${SPD}/books/bookvol8.pamphlet
-MIDINT=	${INT}/graph/viewman
-MIDOBJ=	${OBJ}/${SYS}/graph/viewman
-OUT=	${MNT}/${SYS}/lib
-LIB=    ${OBJ}/${SYS}/lib
-
-CFLAGS  = ${CCF} -I${SRC}/include
-LDFLAGS = ${LDF} -lX11
-
-OBJS=   ${MIDOBJ}/viewman.o ${OBJ}/${SYS}/lib/sockio-c.o
-
-all: ${OBJS} ${OUT}/viewman 
-	@ echo 30 finished viewman from bookvol8
-
-${OUT}/viewman: ${OBJS} ${LIB}/util.o ${LIB}/bsdsignal.o
-	@ echo 1 linking ${OUT}/viewman
-	@ ${CC} ${OBJS} -o ${OUT}/viewman ${LIB}/util.o \
-            ${LIB}/bsdsignal.o ${LDFLAGS}
-
-${MIDOBJ}/viewman.o: ${SRC}/include/com.h ${BOOK}
-	@ echo 3 making ${MIDOBJ}/viewman.o from ${BOOK}
-	@( cd ${MIDINT} ; ${TANGLE} -R"viewman" ${BOOK} >viewman.c )
-	@ ( cd ${MIDOBJ} ;  ${CC} ${CFLAGS} -c ${MIDINT}/viewman.c )
-
-@
 \chapter{viewalone}
 \label{viewalone}
+\section{Constants and Headers}
+\subsection{System includes}
 <<viewalone>>=
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
 #include <stdio.h>
+
+@
+\subsection{Local includes}
+<<viewalone>>=
 <<include/view3d.h>>
 <<include/view2d.h>>
 <<include/actions.h>>
 <<include/viewcommand.h>>
 #include "util.h1"
 
+@
+\subsection{defines}
+<<viewalone>>=
       /* Viewport Commands */
 #define makeViewport -1
 #define makeGraph    -1
@@ -3037,6 +3081,10 @@ ${MIDOBJ}/viewman.o: ${SRC}/include/com.h ${BOOK}
 #define spadActionMode
 #define yes 1
 
+@
+\subsection{extern references}
+<<viewalone>>=
+
 extern viewManager viewP;
 extern view3DStruct doView3D;
 extern view2DStruct doView2D;
@@ -3054,7 +3102,9 @@ extern FILE *viewFile;
 extern char filename[256];
 extern char pathname[256];
 
-/************* global variables **************/
+@
+\subsection{global variables}
+<<viewalone>>=
 
 viewManager viewP;   /* note that in viewman, this is called viewports */
 
@@ -3079,16 +3129,8 @@ FILE *viewFile;
 int viewOkay  = 0;
 int viewType;
 
-/*
-extern void spoonView2D(void);
-extern void makeView2DFromFileData(view2DStruct * );
-extern void sendGraphToView2D(int  , int  , viewManager * );
-extern void spoonView3D(int );
-extern void makeView3DFromFileData(int );
-extern int main(int  , char * []);
-*/
-
 @
+\section{Code}
 \subsection{sendGraphToView2D}
 \index{viewalone!sendGraphToView2D}
 \index{sendGraphToView2D viewalone}
@@ -3644,368 +3686,436 @@ file to use for viewalone. The parabola example is detailed in the
 chapter on Graphics File Formats. The directory parabola.view will
 contain the data and graph0 files and is autogenerated from the
 documentation in that chapter.
-\section{viewalone Makefile}
-<<viewalone/Makefile>>=
-BOOK=${SPD}/books/bookvol8.pamphlet
-MIDINT=	${INT}/graph/viewalone
-MIDOBJ=	${OBJ}/${SYS}/graph/viewalone
-OUT=	${MNT}/${SYS}/bin
-TESTFILE=${MNT}/${SYS}/graph/parabola.view
+\chapter{view2d}
+\label{view2d}
+\section{Constants and Headers}
+\subsection{System includes}
+<<view2d>>=
+#include <limits.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xresource.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#ifdef RIOSplatform
+#include <sys/select.h>
+#endif
 
-CFLAGS = ${CCF} -I${SRC}/include
-LDFLAGS= ${LDF}
+@
+\subsection{local includes}
+<<view2d>>=
+#include "bsdsignal.h"
+#include "bsdsignal.h1"
+#include "hash.h"
+#include "hash.h1"
+#include "pixmap.h1"
+#include "util.h1"
+#include "xspadfill.h1"
 
-OBJS=  
+<<include/actions.h>>
+<<include/g.h>>
+<<include/nox10.h>>
+<<include/override.h>>
+<<include/view.h>>
+<<include/viewcommand.h>>
+<<include/view2d.h>>
+<<include/write.h>>
+<<include/xdefs.h>>
 
-all: ${OUT}/viewalone ${TESTFILE}
-	@echo 12 finished viewalone from ${BOOK}
+@
+\subsection{static variables}
+<<view2d>>=
+static void drawControlPushButton(int  , int );
 
-${OUT}/viewalone: ${MIDOBJ}/viewalone.o ${OBJ}/${SYS}/lib/util.o
-	@ echo 1 linking viewalone
-	@ ${CC} ${MIDOBJ}/viewalone.o ${OBJ}/${SYS}/lib/util.o \
-               -o ${OUT}/viewalone ${LDFLAGS} -lX11
+static int doit=0;  /* globish variable for picking/dropping/clearing */
+      /* - all sorts of 2 button sequence events (command & graph #). */
 
-${MIDOBJ}/viewalone.o: ${BOOK}
-	@ echo 3 making ${MIDOBJ}/viewalone.o from ${BOOK}
-	@ ( cd ${MIDINT} ; ${TANGLE} -R"viewalone" ${BOOK} >viewalone.c )
-	@ ( cd ${MIDOBJ} ; ${CC} -c ${CFLAGS} ${MIDINT}/viewalone.c )
+@
+\subsection{structs}
+\index{struct!buttonStruct}
+\index{buttonStruct struct}
+<<view2d>>=
+typedef struct _buttonStruct {
+  int buttonKey, pot, mask, graphNum, graphSelect;
+  short buttonX,buttonY,buttonWidth,buttonHeight,xHalf,yHalf;
+  Window self;
+  char text[40];
+  int textColor, textHue, textShade;
+} buttonStruct;
 
-${TESTFILE}: ${BOOK}
-	@ echo 10 making ${TESTFILE} from ${BOOK}
-	@ mkdir -p ${TESTFILE}
-	@ (cd ${TESTFILE} ; \
-	   ${TANGLE} -R"parabola.view/data" ${BOOK} >data ; \
-	   ${TANGLE} -R"parabola.view/graph0" ${BOOK} >graph0 )
+@
+\index{struct!controlPanelStruct}
+\index{controlPanelStruct struct}
+<<view2d>>=
+typedef struct _controlPanelStruct {
+  int                  numOfButtons;
+  Window               controlWindow,messageWindow,colormapWindow;
+  char                 message[40];
+  struct _buttonStruct buttonQueue[maxButtons2D];
+} controlPanelStruct;
 
 @
-\chapter{view2d}
-\label{view2d}
-\section{main function}
-The main function performs the following steps
-\begin{enumerate}
-\item calls XOpenDisplay 
-(See \ref{XOpenDisplay} on page~\pageref{XOpenDisplay}), 
-using the DISPLAY variable from the environment, to choose the display.
-\item uses the DefaultScreen macro 
-(See \ref{DefaultScreen} on page~\pageref{DefaultScreen}), to get the
-user's default screen.
-\item uses the RootWindow macro 
-(See \ref{RootWindow} on page~\pageref{RootWindow}), to get the
-root window on the user's display and screen.
-\item calls XCreateAssocTable to create an association table with
-{\tt nbuckets} which is elsewhere defined to be 128. Note that we
-do not actually use the X10 definition of this function but use our
-own version. See \ref{XCreateAssocTable} on page~\pageref{XCreateAssocTable}.
-This table is used to hold an association between the control panel buttons
-and the window they control.
-\end{enumerate}
-<<view2d/main2d.c/main>>=
-int main(void) 
-{
-  XGCValues    controlGCVals;
-  int          i,code;
-  view2DStruct viewData;
-  char         property[256];
-  char         *prop = &property[0];
-  char         *str_type[20];
-  XrmValue     value;
-  if ((dsply = XOpenDisplay(getenv("DISPLAY"))) == NULL)
-    fprintf(stderr,"Could not open the display.\n");
-  scrn  = DefaultScreen(dsply);
-  rtWindow  = RootWindow(dsply,scrn);
-  
-  /**** link Xwindows to viewports - X10 feature ****/
-  table        = XCreateAssocTable(nbuckets);  
-  
-  /**** Create Axiom color map ****/
-  totalColors = XInitSpadFill(dsply,scrn,&colorMap,
-                              &totalHues,&totalSolidShades,
-                              &totalDitheredAndSolids,&totalShades);
-  
-  if (totalColors < 0) {
-    fprintf(stderr,">>Error: Could not allocate all the necessary colors.\n");
-    exitWithAck(RootWindow(dsply,scrn),Window,-1);
-  }
-  
-  mergeDatabases();
-  
-  
-  /*** Determine whether monochrome or color is used ***/
-  if (XrmGetResource(rDB,"Axiom.2D.monochrome","",str_type,&value) == True)
-    (void) strncpy(prop,value.addr,(int)value.size);
-  else 
-    (void) strcpy(prop, "off");
-  
-  mono = ((totalSolid == 2) || (strcmp(prop,"on") == 0));
-  
-  if (XrmGetResource(rDB,"Axiom.2D.inverse","",str_type,&value) == True)
-    (void) strncpy(prop,value.addr,(int)value.size);
-  else 
-    (void) strcpy(prop, "off");
-  
-  if (mono) 
-    if (strcmp(prop,"on") == 0) {  	      /* 0 if equal (inverse video) */
-      foregroundColor = WhitePixel(dsply,scrn);
-      backgroundColor = BlackPixel(dsply,scrn);
-    } else {  				      /* off (no inverse video) */
-      foregroundColor = BlackPixel(dsply,scrn);
-      backgroundColor = WhitePixel(dsply,scrn);
-    }
-  else   /* inverse of inverse in color (for some strange reason) */
-    if (strcmp(prop,"on") == 0) {         /* 0 if equal (inverse video) */
-      foregroundColor = WhitePixel(dsply,scrn);
-      backgroundColor = BlackPixel(dsply,scrn);
-    } else {                                  /* off (no inverse video) */
-      foregroundColor = BlackPixel(dsply,scrn);
-      backgroundColor = WhitePixel(dsply,scrn);
-    }
-  
-  
-  /* read default file name for postScript output */
-  if (XrmGetResource(rDB,
-		     "Axiom.2D.postscriptFile",
-		     "",
-		     str_type, &value) == True)
-    (void) strncpy(prop,value.addr,(int)value.size);
-  else 
-    (void) strcpy(prop, "axiom2d.ps");
-     
-  PSfilename = (char *)malloc(strlen(prop)+1);
-  strcpy(PSfilename,prop);
-  
-  
-  
-  /**** Open global fonts ****/
-  serverFont = XQueryFont(dsply,XGContextFromGC(DefaultGC(dsply,scrn)));
+\index{struct!mouseCoord}
+\index{mouseCoord struct}
+<<view2d>>=
+typedef struct _mouseCoord {
+    float x,y;
+} mouseCoord;
 
-  if (XrmGetResource(rDB,
-		     "Axiom.2D.messageFont",
-		     "Axiom.2D.Font",
-		     str_type, &value) == True)
-    (void) strncpy(prop,value.addr,(int)value.size);
-  else      
-    (void) strcpy(prop,messageFontDefault);  
-  if ((globalFont = XLoadQueryFont(dsply, prop)) == NULL) {
-    fprintf(stderr, 
-	    "Warning:  could not get the %s font for messageFont\n",prop);
-    globalFont = serverFont;
-  }
-  
-  if (XrmGetResource(rDB,
-		     "Axiom.2D.buttonFont",
-		     "Axiom.2D.Font",
-		     str_type, &value) == True)
-    (void) strncpy(prop,value.addr,(int)value.size);
-  else 
-    (void) strcpy(prop,buttonFontDefault);
-  if ((buttonFont = XLoadQueryFont(dsply, prop)) == NULL) {
-    fprintf(stderr, 
-	    "Warning:  could not get the %s font for buttonFont\n",prop);
-    buttonFont = serverFont;
-  }
-  
-  if (XrmGetResource(rDB,
-		     "Axiom.2D.headerFont",
-		     "Axiom.2D.Font",
-		     str_type, &value) == True)
-     (void) strncpy(prop,value.addr,(int)value.size);
-  else
-    (void) strcpy(prop,headerFontDefault);
-  
-  if ((headerFont = XLoadQueryFont(dsply, prop)) == NULL) {
-    fprintf(stderr, 
-	    "Warning:  could not get the %s font for headerFont\n",prop);
-    headerFont = serverFont;
-  }
+@
+\index{struct!viewPoints}
+\index{viewPoints struct}
+<<view2d>>=
+typedef struct _viewPoints {
+  int                 viewportKey;
+  char                title[80];
+  Window              viewWindow,titleWindow;
+  controlPanelStruct  *controlPanel;
+  int                 justMadeControl,haveControl,
+                      axesOn,unitsOn,pointsOn,linesOn,splineOn,closing,
+                      allowDraw;
+  struct _viewPoints  *prevViewport,*nextViewport;
+} viewPoints;
 
-  if (XrmGetResource(rDB,
-		     "Axiom.2D.titleFont",
-		     "Axiom.2D.Font",
-		     str_type,&value) == True)
-    (void) strncpy(prop,value.addr,(int)value.size);
-  else 
-    (void) strcpy(prop,titleFontDefault);
-  
-  if ((titleFont = XLoadQueryFont(dsply, prop)) == NULL) {
-    fprintf(stderr, 
-	    "Warning:  could not get the %s font for titleFont\n",prop);
-    titleFont = serverFont;
-  }
-  
-  if (XrmGetResource(rDB,
-		     "Axiom.2D.graphFont",
-		     "Axiom.2D.Font",
-		     str_type,&value) == True)
-    (void) strncpy(prop,value.addr,(int)value.size);
-  else 
-    (void) strcpy(prop,graphFontDefault);
-  
-  if ((graphFont = XLoadQueryFont(dsply, prop)) == NULL) {
-    fprintf(stderr, 
-	    "Warning:  could not get the %s font for graphFont\n",prop);
-    graphFont = serverFont;
-  }
-  
-  if (XrmGetResource(rDB,
-		     "Axiom.2D.unitFont",
-		     "Axiom.2D.Font",
-		     str_type,&value) == True)
-    (void) strncpy(prop,value.addr,(int)value.size);
-  else 
-    (void) strcpy(prop,unitFontDefault);
-  
-  if ((unitFont = XLoadQueryFont(dsply, prop)) == NULL) {
-     fprintf(stderr, 
-	     "Warning:  could not get the %s font for unitFont\n",prop);
-     unitFont = serverFont;
-  }
+@
+\index{struct!controlXY}
+\index{controlXY struct}
+<<view2d>>=
+typedef struct _controlXY {
+  int putX,putY;
+} controlXY;
 
+@
+\index{struct!xPointStruct}
+\index{xPointStruct struct}
+<<view2d>>=
+typedef struct _xPointStruct {
+  XPoint *xPoint;
+  Vertex *x10Point;
+  XArc   *arc;
+} xPointStruct;
 
-  /**** Create widely used Graphic Contexts ****/
-  PSGlobalInit();       
-  /* must initiate before using any G/PS functions 
-     need character name: used as postscript GC variable 
-     need to create ps GCs for all GCs used by drawings in viewWindow */
+@
+\subsection{defines}
+<<view2d>>=
+#define numBits (8*sizeof(int))
 
-  /* globalGC1 */
+/* for xdefs */
+#define view2d 
 
-  controlGCVals.foreground = monoColor(axesColorDefault);
-  controlGCVals.background = backgroundColor;
-  globalGC1 = XCreateGC(dsply,rtWindow,GCForeground | GCBackground ,
-			&controlGCVals);  
-  carefullySetFont(globalGC1,globalFont);
-  
-  
-  /* create the equivalent GCs for ps */
-  PSCreateContext(globalGC1, "globalGC1", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-  
-  /* controlMessageGC */
+#define bColor		98
+#define graphColor	138
 
-  controlGCVals.foreground = controlMessageColor;
-  controlMessageGC = XCreateGC(dsply,rtWindow,GCForeground | GCBackground 
-			       ,&controlGCVals);
-  carefullySetFont(controlMessageGC,globalFont);
-  
-  /* globalGC2 */
+#define NotPoint	(SHRT_MAX)
+#define eqNANQ(x)	(x == NotPoint)
 
-  controlGCVals.foreground = monoColor(labelColor);
-  controlGCVals.background = backgroundColor;
-  globalGC2 = XCreateGC(dsply,rtWindow,GCForeground | GCBackground,
-			&controlGCVals);
-  carefullySetFont(globalGC2,buttonFont);
-  PSCreateContext(globalGC2, "globalGC2", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-  
-  /* trashGC  */
-  
-  trashGC = XCreateGC(dsply,rtWindow,0,&controlGCVals);
-  carefullySetFont(trashGC,buttonFont);
-  PSCreateContext(trashGC, "trashGC", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-  
-  /* globGC */
-  
-  globGC = XCreateGC(dsply,rtWindow,0,&controlGCVals);
-  carefullySetFont(globGC,headerFont);
-  PSCreateContext(globGC, "globGC", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-  
-  /* anotherGC  */
-  
-  controlGCVals.line_width = colorWidth;
-  anotherGC  = XCreateGC(dsply,rtWindow,GCBackground,&controlGCVals);
-  carefullySetFont(anotherGC,titleFont);
-  PSCreateContext(anotherGC, "anotherGC", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-  
-  /* processGC */
-  
-  gcVals.background = backgroundColor;
-  processGC         = XCreateGC(dsply,rtWindow,GCBackground ,&gcVals);
-  carefullySetFont(processGC,buttonFont);
-  
-  /* graphGC */
-  
-  graphGC           = XCreateGC(dsply,rtWindow,GCBackground,&gcVals);
-  carefullySetFont(graphGC,graphFont);
-  PSCreateContext(graphGC, "graphGC", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-  
-  /* unitGC */
-  
-  unitGC            = XCreateGC(dsply,rtWindow,GCBackground ,&gcVals);
-  carefullySetFont(unitGC,unitFont);
-  PSCreateContext(unitGC, "unitGC", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-  
-  /**** Initialize Graph States ****/
-  
-  for (i=0; i<maxGraphs; i++) {
-    graphStateArray[i].scaleX = 0.9;
-    graphStateArray[i].scaleY = 0.9;
-    graphStateArray[i].deltaX = 0.0;
-    graphStateArray[i].deltaY = 0.0;
-    graphStateArray[i].centerX = 0.0;
-    graphStateArray[i].centerY = 0.0;
-    graphStateArray[i].pointsOn  = yes;
-    graphStateArray[i].connectOn = yes;
-    graphStateArray[i].splineOn  = no;
-    graphStateArray[i].axesOn    = yes;
-    graphStateArray[i].unitsOn   = no;
-    graphStateArray[i].showing   = no;
-    graphStateArray[i].selected  = no;
-    graphStateBackupArray[i] = graphStateArray[i];
-  } 
-  
-  /**** Get Data from the Viewport Manager ****/
-  
-  i = 123;
-  code=check(write(Socket,&i,intSize));
-  
-  /* Check if I am getting stuff from Axiom or, if I am viewAlone. */
-  readViewman(&viewAloned,intSize);
-  readViewman(&viewData,sizeof(view2DStruct));
-  readViewman(&i,intSize);
-  
-  if (!(viewData.title = (char *)malloc(i))) {
-    fprintf(stderr,
-	    "ERROR: Ran out of memory trying to receive the title.\n");
-    exitWithAck(RootWindow(dsply,scrn),Window,-1);
-  }
-  readViewman(viewData.title,i);
-  
-  for (i=0; i<maxGraphs; i++) {
-    readViewman(&(graphArray[i].key),intSize);
-    if (graphArray[i].key) {  		/** this graph slot has data **/
-      getGraphFromViewman(i);
-    } /* if graph exists (graphArray[i].key is not zero) */
-  } /* for i in graphs */
-  
-  viewport = makeView2D(&viewData);
-  control = viewport->controlPanel;
-  
-  bsdSignal(SIGTERM,goodbye,DontRestartSystemCalls);
-  
-  /* send acknowledgement to viewport manager */
-  i = 345;
-  check(write(Socket,&(viewport->viewWindow),sizeof(Window)));
-  
-  processEvents();
+#define mouseBitmap_width 16
+#define mouseBitmap_height 16
+#define mouseBitmap_x_hot 8
+#define mouseBitmap_y_hot 0
+static char mouseBitmap_bits[] = {
+   0x00, 0x01, 0x00, 0x01, 0x80, 0x02, 0x40, 0x04, 0xc0, 0x06, 0x20, 0x08,
+   0x20, 0x08, 0x30, 0x18, 0x50, 0x14, 0x58, 0x34, 0x90, 0x12, 0x20, 0x08,
+   0xc0, 0x47, 0x00, 0x21, 0x80, 0x10, 0x00, 0x0f};
+#define mouseMask_width 16
+#define mouseMask_height 16
+static char mouseMask_bits[] = {
+   0x00, 0x01, 0x00, 0x01, 0x80, 0x03, 0xc0, 0x07, 0xc0, 0x07, 0xe0, 0x0f,
+   0xe0, 0x0f, 0xf0, 0x1f, 0xf0, 0x1f, 0xf8, 0x3f, 0xf0, 0x1f, 0xe0, 0x0f,
+   0xc0, 0x47, 0x00, 0x21, 0x80, 0x10, 0x00, 0x0f};
+
+#define spadBitmap_width 34
+#define spadBitmap_height 20
+#define spadBitmap_x_hot 15
+#define spadBitmap_y_hot 10
+static char spadBitmap_bits[] = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00,
+   0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
+   0xe6, 0xf8, 0x76, 0x00, 0x84, 0x98, 0x44, 0x49, 0x00, 0xc0, 0x98, 0x42,
+   0x49, 0x00, 0xb8, 0x98, 0x42, 0x49, 0x00, 0x84, 0x95, 0x42, 0x49, 0x00,
+   0x44, 0xa5, 0x22, 0x49, 0x00, 0x78, 0x63, 0x1d, 0xdb, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00,
+   0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00};
+
+#define spadMask_width 34
+#define spadMask_height 20
+#define spadMask_x_hot 15
+#define spadMask_y_hot 10
+static char spadMask_bits[] = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
+   0x01, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00,
+   0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x01, 0xfe,
+   0xff, 0xff, 0xff, 0x01, 0xfe, 0xff, 0xff, 0xff, 0x01, 0xfe, 0xff, 0xff,
+   0xff, 0x01, 0xfe, 0xff, 0xff, 0xff, 0x01, 0xfe, 0xff, 0xff, 0xff, 0x01,
+   0xfe, 0xff, 0xff, 0xff, 0x01, 0xfe, 0xff, 0xff, 0xff, 0x01, 0xfc, 0xff,
+   0xff, 0xff, 0x01, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00,
+   0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00};
+
+/* Defines the pixmap for the arrow displayed in the scale window */
+
+#define scaleArrowN 11
+static XPoint scaleArrow[scaleArrowN] = {
+  {55,14},{64,23},{59,23},
+  {66,45},{79,45},
+  {55,69},
+  {31,45},{44,45},
+  {51,23},{46,23},{55,14} };
+
+/* Defines the pixmap for the arrows displayed in the translate window */
+
+#define translateArrowN 25
+static XPoint translateArrow[translateArrowN] = {
+  {55,2},{60,10},{58,10},{58,37},
+  {85,37},{85,35},{93,40},{85,45},{85,43},{58,43},
+  {58,70},{60,70},{55,78},{50,70},{52,70},{52,43},
+  {25,43}, {25,45}, {17,40},  {25,35}, {25,37}, {52,37},
+  {52,10},{50,10},{55,2} };
+
+
+#define carefullySetFont(gc,font) if (font != serverFont) XSetFont(dsply,gc,font->fid)
+
+#define controlMASK (ButtonPressMask + ExposureMask)
+#define potMASK     (ButtonPressMask + ButtonReleaseMask + ButtonMotionMask + LeaveWindowMask)
+#define buttonMASK  (ButtonPressMask + ButtonReleaseMask + LeaveWindowMask)
+#define colorMASK   (ButtonPressMask + ButtonReleaseMask + LeaveWindowMask)
+
+/* make mouse grab for stationery mouse on a potentiometer slower */
+#define mouseWait 50 
+
+#define controlCreateMASK (CWBackPixel | CWBorderPixel | CWEventMask | CWCursor |CWColormap | CWOverrideRedirect)
+#define buttonCreateMASK    CWEventMask  
+#define messageCreateMASK   0
+#define colormapCreateMASK  CWEventMask
+
+#define controlWidth  236
+#define controlHeight 400
+
+#define closeLeft cp->buttonQueue[closeAll2D].buttonX - 5
+#define closeTop  cp->buttonQueue[closeAll2D].buttonY - 5
+
+#define controlBackground WhitePixel(dsply,scrn)
+#define controlCursorForeground monoColor(4)
+#define controlCursorBackground monoColor(44)
+#define controlTitleColor       monoColor(36)
+#define controlPotHeaderColor   monoColor(52)
+#define controlColorColor       monoColor(13)
+#define controlColorSignColor   monoColor(22)
+
+#define controlMessageHeight globalFont->max_bounds.ascent + globalFont->max_bounds.descent+4
+#define messageBot controlMessageY + controlMessageHeight
+
+#define headerHeight headerFont->max_bounds.ascent
+#define graphHeaderHeight messageBot + headerHeight
+
+#define graphBarTop    graphHeaderHeight + 12
+#define graphBarLeft   66
+#define graphBarWidth  graphFont->max_bounds.width
+#define graphBarHeight graphFont->max_bounds.ascent + graphFont->max_bounds.descent
+
+#define colormapX 10
+#define colormapY 235
+#define colormapW 280
+#define colormapH 60
+
+#define colorWidth   8
+#define colorHeight  12
   
-  goodbye(-1);
-  return(0);  /* control never reaches here but compiler complains */
-} /* main() */
+#define colorOffset  3
+#define colorOffsetX 24
+#define colorOffsetY 20
+#define colorPointer 18
 
-@
+#define buttonColor monoColor(105) 
 
-\section{buttons2d.c}
-<<view2d/buttons2d.c>>=
-#define _BUTTONS2D_C
+#define graphBarDefaultColor    monoColor(15)
+#define graphBarShowingColor    monoColor(15)
+#define graphBarHiddenColor     monoColor(138)
+#define graphBarSelectColor     monoColor(15)
+#define graphBarNotSelectColor  monoColor(138)
 
-#include <string.h>
+#define rint(z) ((int)(z))
+
+#define viewportCreateMASK (CWBackPixel|CWBorderPixel|CWEventMask|CWCursor|CWColormap)
+#define viewportTitleCreateMASK (CWBackPixel|CWBorderPixel|CWCursor|CWColormap|CWEventMask|CWOverrideRedirect)
+
+#define viewportMASK (KeyPressMask + ButtonPressMask + ExposureMask)
+#define titleMASK    ExposureMask
+
+#define lineWidth  1
+#define lineHeight 1
+
+#define titleColor     monoColor(36)
+#define titleHeight    24
+#define appendixHeight 0
+
+#define viewWidth  400
+#define viewHeight 400
+
+#define viewBorderWidth 0
+#define borderWidth     22
+#define borderHeight	45
+
+#define initDeltaX 0.0
+#define initDeltaY 0.0
+#define initScale  1.3
+
+#define minScale  0.01
+#define maxScale  1000.0
+#define maxDelta  1000.0
+
+#define scaleFactor     0.5
+#define translateFactor 10
+
+#define viewCursorForeground monoColor(166)
+#define viewCursorBackground monoColor(5)
+
+#define axisLength 100.0    
+
+#define axesColorDefault  35
+#define labelColor 22
+
+#define meshOutline      monoColor(132)
+#define opaqueOutline    monoColor(53)
+#define opaqueForeground monoColor(236)
+
+#define drawWireFrame 0
+#define drawOpaque    1
+#define drawRendered  2
+
+
+#define numOfColors 240
 
-<<view2d/header2.h>>
+#define totalHuesConst   27
+#define totalShadesConst 8
+#define hueEnd 360
+#define hueStep hueEnd/totalHuesConst
+
+#define numPlanes 1
+#define numColors 10
+#define startColor 0
+#define endColor   startColor+numColors
+#define maxColors DisplayCells(dsply,scrn)-1
+
+#define colorStep (maxColors+1)/numColors
+
+
+#define physicalWidth  DisplayWidth(dsply,scrn)
+#define physicalHeight DisplayHeight(dsply,scrn)
+#define deep           DisplayPlanes(dsply,scrn)
+
+#define basicScreen 19
+
+#define yes 1
+#define no  0
+
+#define potA  25   /* line dividing potentiometers from stuff above it */
+#define potB 173   /* line dividing potentiometers from title */
+#define butA 260   /* line dividing buttons from stuff above it */
+
+#define controlMessageY     181
+#define controlMessageColor monoColor(29)
+
+#define pi_half         1.570796326794896619231321691639751442099
+#define pi              3.141592653589793238462643383279502884197
+#define three_pi_halves 4.712388980384689857693965074919254326296
+#define two_pi          6.283185307179586476925286766559005768394
+
+#define degrees_in_two_pi 57
+#define d2Pi 57
+
+#define viewBackground 0
+
+#define nbuckets         128
+
+#define anywhere 0
+
+
+#define intSize sizeof(int)
+#define floatSize sizeof(float)
+
+/* type is X, PS,... */
+
+#define drawViewport(type) drawTheViewport(type);
+#define spadDrawViewport() spadMode++; drawTheViewport(X); spadMode--;
+
+#define calcUnitX(ii) (vwInfo.width * \
+		       ((graphArray[0].unitX * ii + \
+                     	graphArray[0].originX - graphStateArray[0].centerX) *\
+			graphStateArray[0].scaleX + 0.5))
+#define calcUnitY(ii) (vwInfo.height * aspectR * \
+		       (1 - ((graphArray[0].unitY*aspectR * ii + \
+			      graphArray[0].originY*aspectR - \
+			      graphStateArray[0].centerY) * \
+			     graphStateArray[0].scaleY + 0.5*aspectR )))
+
+#define projX(x,w,i) ((((float)x/w-0.5)/graphStateArray[i].scaleX + \
+		       graphStateArray[i].centerX + 0.5) / 	\
+		      graphArray[i].xNorm + graphArray[i].xmin)
+
+#define projY(y,h,i) (((0.5-(float)y/h*aspectR)/graphStateArray[i].scaleY + \
+		       graphStateArray[i].centerY + 0.5) / 	\
+		      graphArray[i].yNorm + graphArray[i].ymin)
+
+#define isNaN(v) (v != v)
+
+@
+\subsection{extern references}
+<<view2d>>=
+extern Display       *dsply;
+extern XFontStruct   *globalFont,*buttonFont,*headerFont,*titleFont,
+                     *graphFont,*unitFont,*serverFont;
+extern XrmDatabase      rDB;
+extern char          scaleXReport[5],scaleYReport[5],deltaXReport[5],
+                     deltaYReport[5];
+extern unsigned long *spadColors;
+extern int           followMouse,viewportKeyNum;
+extern Window        rtWindow,viewman;
+extern GC            globalGC1,globalGC2,anotherGC,globGC,trashGC,
+                     controlMessageGC,graphGC,unitGC;
+extern HashTable     *table;
+extern Colormap      colorMap;
+extern int           Socket,ack;
+extern  GC  processGC;
+extern  viewPoints *viewport;
+extern  controlPanelStruct *control;
+extern  XGCValues gcVals;
+extern  char *s;
+extern  int someInt;
+extern unsigned long foregroundColor, backgroundColor; 
+extern int drawMore;
+extern int spadMode,spadDraw;
+extern jmp_buf jumpFlag;
+extern graphStruct graphArray[maxGraphs]; 
+extern graphStateStruct graphStateArray[maxGraphs],
+                        graphStateBackupArray[maxGraphs];
+extern xPointStruct xPointsArray[maxGraphs];
+extern int pointsON, connectON, splineON, axesON, unitsON, zoomXON, zoomYON;
+extern int transXON, transYON;
+extern char errorStr[80];
+extern int currentGraph; 
+extern int queriedGraph;
+extern int picking,dropping;
+extern char filename[256];
+extern char *xDefault;
+extern int viewAloned;
+extern int mono, totalColors,
+           totalHues, totalSolidShades, totalDitheredAndSolids,totalShades;
+extern float aspectR;
+
+@
+\subsection{forward references}
+<<view2d>>=
 extern int initButtons(buttonStruct * );
 extern void writeControlTitle(void );
 extern void makeMessageFromData(int );
@@ -4026,9 +4136,6 @@ extern void clickedOnGraph(int  , int );
 extern void buttonAction(int );
 extern void processEvents(void);
 extern void clickedOnGraphSelect(int  , int );
-#ifdef _PROCESS2D_C
-static void drawControlPushButton(int  , int );
-#endif
 extern int readViewman(void *  , int );
 extern int spadAction(void);
 extern float absolute(float);
@@ -4038,30 +4145,158 @@ extern void drawTheViewport(int );
 extern viewPoints * makeViewport(char *  , int  , int  , int  , int  , int );
 extern viewPoints * makeView2D(view2DStruct * );
 extern int writeViewport(int );
+extern int PSCreateFile(int , Window , Window , char * );
+extern int GdrawsDrawFrame(int , Window , Window , char * );
+extern int GdrawsSetDimension(Window , Window );
+extern int GDrawImageString(GC , Window , int , int , char * , int , int );
+extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
+extern int GDrawLine(GC , Window , int , int , int , int , int );
+extern int GDrawLines(GC , Window , XPoint * , int , int , int );
+extern int GDrawPoint(Window , GC , int , int , int );
+extern int GDrawString(GC , Window , int , int , char * , int , int );
+extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
+extern int PSGlobalInit(void );
+extern int PSInit(Window , Window );
+extern int PSCreateContext(GC , char * , int , int , int , float , float );
+extern char * PSfindGC(GC );
+extern int GSetForeground(GC , float , int );
+extern int GSetBackground(GC , float , int );
+extern int GSetLineAttributes(GC , int , int , int , int , int );
+extern int PSClose(void );
+extern int centerX(GC , char * , int , int );
+extern int centerY(GC , int );
+extern int PSColorPolygon(float , float , float , XPoint * , int );
+extern int PSColorwOutline(float , float , float , XPoint * , int );
+extern int PSDrawColor(float , float , float , XPoint * , int );
+extern int PSFillPolygon(GC , XPoint * , int );
+extern int PSFillwOutline(GC , XPoint * , int );
+extern HashTable * XCreateAssocTable(int );
+extern void XMakeAssoc(Display * , HashTable * , Window , int * );
+extern int * XLookUpAssoc(Display * , HashTable * , Window );
+extern void XDeleteAssoc(Display * , HashTable * , Window );
+extern int GDrawRectangle(GC , Window , short , short , short , short , int );
+extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
+extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
+extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
+#ifdef _GFUN_C
+static void filecopy(FILE * , FILE * );
+static int TrivEqual(Window , Window );
+static int TrivHashCode(Window , int );
+#endif
 
+@
+\subsection{global variables}
+<<view2d>>=
+Window        rtWindow,viewman;
+Display       *dsply;
+XFontStruct   *globalFont,
+  *buttonFont,
+  *headerFont,
+  *titleFont,
+  *graphFont,
+  *unitFont,
+  *serverFont;
+GC            globalGC1,
+  globalGC2,
+  anotherGC,
+  globGC,
+  trashGC,
+  controlMessageGC,
+  graphGC,
+  unitGC,
+  processGC;
+XGCValues     gcVals;
+HashTable     *table;
+Colormap      colorMap;
 
+Atom wm_delete_window;
 
+XrmDatabase rDB; /* Resource database */
 
 
-#define bColor		98
-#define graphColor	138
+char          scaleXReport[5],
+  scaleYReport[5],
+  deltaXReport[5],
+  deltaYReport[5],
+  *s,
+  errorStr[80],
+  filename[256], /** For writing viewport data out to a file **/
+  *xDefault;     /** used for accessing .XDefaults **/
 
-/*****************************************************
- * int initButtons(buttons)			     *
- *						     *
- * Creates the fields for each button window in the  *
- * two dimensional control panel, and returns the    *
- * number of buttons created.			     *
- *						     *
- *****************************************************/
-
-int 
-initButtons (buttonStruct *buttons)
-{
-  int ii, num = 0;
 
-/********** Scale(Zoom) and Translate Potentiometer Buttons **********/
+unsigned long *spadColors;
+unsigned long foregroundColor, backgroundColor;  
+
+int           followMouse = no, 
+  viewportKeyNum = 0, 
+  scrn, 
+  Socket = 1,
+  ack = 1,
+  someInt,
+  drawMore,
+  spadMode=no, /* yes if receiving Axiom command and calling drawViewport */
+  spadDraw=no, /* yes if drawing viewport because of a Axiom command */
+  pointsON  = yes,  /* these would affect the choices in buttons.c */
+  connectON = yes,
+  splineON  = no,
+  axesON    = yes,
+  unitsON   = no,
+  zoomXON   = yes,
+  zoomYON   = yes,
+  transXON  = yes,
+  transYON  = yes,
+  currentGraph = 0,  /* last graph selected */
+  queriedGraph = 0,  /* current graph queried */
+  picking=0,
+  dropping=0,
+  viewAloned,  /** if not connected to Axiom **/
+  mono, 
+  totalColors, 
+  totalSolid, 
+  totalDithered, 
+  maxGreyShade,
+  totalHues, 
+  totalSolidShades, 
+  totalDitheredAndSolids,
+  totalShades;
+/* totalShades is initially set to totalShadesConst (probably 8).
+   If X cannot allocate 8 shades for each hue, totalShades is 
+   decremented. There is currently only a check for this value
+   to be positive. ---> something to add: change over to monochrome
+   if totalShades=0. Just modify the spadcolors.c file. 
+   spadcolors.c has been modified so that it returns the value for
+   totalShades. Since the return value had previously been unused,
+   a modification in this way ensures continued support of other
+   routines calling this function (e.g. hyperDoc stuff). */
 
+viewPoints    *viewport;
+controlPanelStruct *control;
+jmp_buf jumpFlag;
+graphStruct      graphArray[maxGraphs];
+graphStateStruct graphStateArray[maxGraphs],
+  graphStateBackupArray[maxGraphs];
+xPointStruct     xPointsArray[maxGraphs];
+float aspectR = 1.0;
+
+/* global ps variables */
+int     psInit=no;      /* need to call globalInitPs() each run */
+GCptr   GChead=NULL;    /* ptr to head of ps GC linked list */
+char    *PSfilename;    /* output file name used in user directory */
+char *envAXIOM;    /* environment variable AXIOM or DEVE */
+
+@
+\section{Code}
+\subsection{initButtons}
+Creates the fields for each button window in the
+two dimensional control panel, and returns the
+number of buttons created.
+\index{view2d!initButtons}
+\index{initButtons view2d}
+<<view2d>>=
+<<gfun.c>>
+int initButtons(buttonStruct *buttons) {
+  int ii, num = 0;
+/********** Scale(Zoom) and Translate Potentiometer Buttons **********/
   /* Title:  "Scale" */
   ii = scale2D;
   buttons[ii].buttonX	   = 5;
@@ -4077,7 +4312,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   /* Title:  "Translate" */
   ii = translate2D;
   buttons[ii].buttonX	   = 121;
@@ -4093,9 +4327,7 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   /* Scale potentiometer buttons */
-
   /* Scale along X axis */
   ii = zoom2Dx;
   buttons[ii].buttonX	   = 5;
@@ -4112,8 +4344,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
-
   /* Scale along Y axis */
   ii = zoom2Dy;
   buttons[ii].buttonX	   = 62;
@@ -4130,7 +4360,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   /* Translate along X axis */
   ii = translate2Dx;
   buttons[ii].buttonX	   = 121;
@@ -4147,8 +4376,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
-
   /* Translate along Y axis */
   ii = translate2Dy;
   buttons[ii].buttonX	   = 179;
@@ -4165,8 +4392,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
-
   /* Axes Turned On/Off */
   ii = axesOnOff2D;
   buttons[ii].buttonX	   = 5;
@@ -4185,7 +4410,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   /* Units Turned On/Off */
   ii = unitsOnOff2D;
   buttons[ii].buttonX	   = 100;
@@ -4204,7 +4428,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   /* Generate a Postscript file */
   ii = ps2D;
   buttons[ii].buttonX	   = 195;
@@ -4223,7 +4446,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   /* Bounding Rectangle On/Off */
   ii = spline2D;
   buttons[ii].buttonX	   = 5;
@@ -4242,7 +4464,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   /* Graph points On/Off */
   ii = pointsOnOff;
   buttons[ii].buttonX	   = 75;
@@ -4261,7 +4482,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   /* Graph lines On/Off */
   ii = connectOnOff;
   buttons[ii].buttonX	   = 147;
@@ -4280,7 +4500,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   /* Reset View Position Button */
   ii = reset2D;
   buttons[ii].buttonX	   = 5;
@@ -4299,7 +4518,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   /* Hide Control Panel */
   ii = hideControl2D;
   buttons[ii].buttonX	   = 70;
@@ -4318,7 +4536,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   /* Exits from the viewport running */
   ii = closeAll2D;
   buttons[ii].buttonX	   = 169;
@@ -4337,7 +4554,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   /* Indicates that the graph from a viewport is to be picked up. */
   ii = pick2D;
   buttons[ii].buttonX	   = 190;
@@ -4356,7 +4572,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   /* Indicates that the graph from a viewport is to be dropped into a slot. */
   ii = drop2D;
   buttons[ii].buttonX	   = 190;
@@ -4375,7 +4590,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   /* Indicates that the status of the graphs being displayed in the viewport
      is to be cleared. */
   ii = clear2D;
@@ -4395,7 +4609,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   /* Asks for the scale and translation information for the specified graph. */
   ii = query2D;
   buttons[ii].buttonX	   = 5;
@@ -4414,11 +4627,9 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   /* These buttons indicate the 9 available slot numbers into which
      a 2D graph can be placed, and the status of the graph, i.e. whether
      it is displayed or not. */
-
   ii = graph1;
   buttons[ii].buttonX	   = graphBarLeft;
   buttons[ii].buttonY	   = graphBarTop;
@@ -4434,7 +4645,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   ii = graphSelect1;
   buttons[ii].buttonX	   = graphBarLeft;
   buttons[ii].buttonY	   = graphBarTop + graphBarHeight;
@@ -4450,7 +4660,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   ii = graph2;
   buttons[ii].buttonX	   = graphBarLeft + (graphBarWidth);
   buttons[ii].buttonY	   = graphBarTop;
@@ -4466,7 +4675,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   ii = graphSelect2;
   buttons[ii].buttonX	   = graphBarLeft + (graphBarWidth);
   buttons[ii].buttonY	   = graphBarTop + graphBarHeight;
@@ -4482,7 +4690,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   ii = graph3;
   buttons[ii].buttonX	   = graphBarLeft + 2*(graphBarWidth);
   buttons[ii].buttonY	   = graphBarTop;
@@ -4498,7 +4705,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   ii = graphSelect3;
   buttons[ii].buttonX	   = graphBarLeft + 2*(graphBarWidth);
   buttons[ii].buttonY	   = graphBarTop + graphBarHeight;
@@ -4514,7 +4720,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   ii = graph4;
   buttons[ii].buttonX	   = graphBarLeft + 3*(graphBarWidth);
   buttons[ii].buttonY	   = graphBarTop;
@@ -4530,7 +4735,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   ii = graphSelect4;
   buttons[ii].buttonX	   = graphBarLeft + 3*(graphBarWidth);
   buttons[ii].buttonY	   = graphBarTop + graphBarHeight;
@@ -4546,7 +4750,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   ii = graph5;
   buttons[ii].buttonX	   = graphBarLeft + 4*(graphBarWidth);
   buttons[ii].buttonY	   = graphBarTop;
@@ -4562,7 +4765,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   ii = graphSelect5;
   buttons[ii].buttonX	   = graphBarLeft + 4*(graphBarWidth);
   buttons[ii].buttonY	   = graphBarTop + graphBarHeight;
@@ -4578,7 +4780,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   ii = graph6;
   buttons[ii].buttonX	   = graphBarLeft + 5*(graphBarWidth);
   buttons[ii].buttonY	   = graphBarTop;
@@ -4594,7 +4795,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   ii = graphSelect6;
   buttons[ii].buttonX	   = graphBarLeft + 5*(graphBarWidth);
   buttons[ii].buttonY	   = graphBarTop + graphBarHeight;
@@ -4610,7 +4810,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   ii = graph7;
   buttons[ii].buttonX	   = graphBarLeft + 6*(graphBarWidth);
   buttons[ii].buttonY	   = graphBarTop;
@@ -4626,7 +4825,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   ii = graphSelect7;
   buttons[ii].buttonX	   = graphBarLeft + 6*(graphBarWidth);
   buttons[ii].buttonY	   = graphBarTop + graphBarHeight;
@@ -4642,7 +4840,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   ii = graph8;
   buttons[ii].buttonX	   = graphBarLeft + 7*(graphBarWidth);
   buttons[ii].buttonY	   = graphBarTop;
@@ -4658,7 +4855,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   ii = graphSelect8;
   buttons[ii].buttonX	   = graphBarLeft + 7*(graphBarWidth);
   buttons[ii].buttonY	   = graphBarTop + graphBarHeight;
@@ -4674,7 +4870,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   ii = graph9;
   buttons[ii].buttonX	   = graphBarLeft + 8*(graphBarWidth);
   buttons[ii].buttonY	   = graphBarTop;
@@ -4690,7 +4885,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   ii = graphSelect9;
   buttons[ii].buttonX	   = graphBarLeft + 8*(graphBarWidth);
   buttons[ii].buttonY	   = graphBarTop + graphBarHeight;
@@ -4706,143 +4900,16 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf	   = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf	   = buttons[ii].buttonHeight/2;
   ++num;
-
   return(num);
 }
-@
-\section{control2d.c}
-<<view2d/control2d.c>>=
-#define _CONTROL2D_C
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <X11/X.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-
-<<view2d/header2.h>>
-extern int initButtons(buttonStruct * );
-extern void writeControlTitle(void );
-extern void makeMessageFromData(int );
-extern void writeControlMessage(void );
-extern void drawControlPanel(void );
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void );
-extern void putControlPanelSomewhere(int );
-extern void clearControlMessage(void );
-extern void getGraphFromViewman(int );
-extern void freeGraph(int );
-extern int main(void);
-extern void mergeDatabases(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern void doPick(int  , int );
-extern void doDrop(int  , int );
-extern void clickedOnGraph(int  , int );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern void clickedOnGraphSelect(int  , int );
-#ifdef _PROCESS2D_C
-static void drawControlPushButton(int  , int );
-#endif
-extern int readViewman(void *  , int );
-extern int spadAction(void);
-extern float absolute(float);
-extern void goodbye(int);
-extern void writeTitle(void);
-extern void drawTheViewport(int );
-extern viewPoints * makeViewport(char *  , int  , int  , int  , int  , int );
-extern viewPoints * makeView2D(view2DStruct * );
-extern int writeViewport(int );
-
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-#include "xspadfill.h1"
-#include "util.h1"
-
-
-#define mouseBitmap_width 16
-#define mouseBitmap_height 16
-#define mouseBitmap_x_hot 8
-#define mouseBitmap_y_hot 0
-static char mouseBitmap_bits[] = {
-   0x00, 0x01, 0x00, 0x01, 0x80, 0x02, 0x40, 0x04, 0xc0, 0x06, 0x20, 0x08,
-   0x20, 0x08, 0x30, 0x18, 0x50, 0x14, 0x58, 0x34, 0x90, 0x12, 0x20, 0x08,
-   0xc0, 0x47, 0x00, 0x21, 0x80, 0x10, 0x00, 0x0f};
-#define mouseMask_width 16
-#define mouseMask_height 16
-static char mouseMask_bits[] = {
-   0x00, 0x01, 0x00, 0x01, 0x80, 0x03, 0xc0, 0x07, 0xc0, 0x07, 0xe0, 0x0f,
-   0xe0, 0x0f, 0xf0, 0x1f, 0xf0, 0x1f, 0xf8, 0x3f, 0xf0, 0x1f, 0xe0, 0x0f,
-   0xc0, 0x47, 0x00, 0x21, 0x80, 0x10, 0x00, 0x0f};
-
-/* Defines the pixmap for the arrow displayed in the scale window */
-
-#define scaleArrowN 11
-static XPoint scaleArrow[scaleArrowN] = {
-  {55,14},{64,23},{59,23},
-  {66,45},{79,45},
-  {55,69},
-  {31,45},{44,45},
-  {51,23},{46,23},{55,14} };
-
-/* Defines the pixmap for the arrows displayed in the translate window */
-
-#define translateArrowN 25
-static XPoint translateArrow[translateArrowN] = {
-  {55,2},{60,10},{58,10},{58,37},
-  {85,37},{85,35},{93,40},{85,45},{85,43},{58,43},
-  {58,70},{60,70},{55,78},{50,70},{52,70},{52,43},
-  {25,43}, {25,45}, {17,40},  {25,35}, {25,37}, {52,37},
-  {52,10},{50,10},{55,2} };
-
-/****************************
- * void writeControlTitle() *
- ****************************/
-
-void 
-writeControlTitle(void)
-{
 
+@
+\subsection{writeControlTitle}
+\index{view2d!writeControlTitle}
+\index{writeControlTitle view2d}
+<<view2d>>=
+void writeControlTitle(void) {
   int strlength;
-
   s = viewport->title;
   strlength = strlen(s);
   XClearArea(dsply,control->controlWindow,0,0,controlWidth,potA,False);
@@ -4850,12 +4917,14 @@ writeControlTitle(void)
   GDrawImageString(anotherGC,control->controlWindow,
 		   centerX(anotherGC,s,strlength,controlWidth),
 		   15,s,strlength,Xoption);
-
 } /* writeControlTitle() */
 
-void 
-makeMessageFromData(int whichGraph)
-{
+@
+\subsection{makeMessageFromData}
+\index{view2d!makeMessageFromData}
+\index{makeMessageFromData view2d}
+<<view2d>>=
+void makeMessageFromData(int whichGraph) {
   if (viewport->haveControl) {
     if ((graphStateArray[whichGraph].scaleX) > 99.0) {
       strcpy(scaleXReport,"big");
@@ -4888,41 +4957,35 @@ makeMessageFromData(int whichGraph)
     sprintf(viewport->controlPanel->message,"[%s,%s] >%d< [%s,%s]",
 	    scaleXReport,scaleYReport,whichGraph+1,deltaXReport,deltaYReport);
   }  /* if haveControl */
-
 } /* makeMessageFromData() */
 
-
-void 
-writeControlMessage(void)
-{
+@
+\subsection{writeControlMessage}
+\index{view2d!writeControlMessage}
+\index{writeControlMessage view2d}
+<<view2d>>=
+void writeControlMessage(void) {
   int		     strlength;
   controlPanelStruct *cp;
   XWindowAttributes  cwInfo;
-
   cp = viewport->controlPanel;
   XGetWindowAttributes(dsply,cp->controlWindow,&cwInfo);
   strlength = strlen(cp->message);
-
-
-
   GDrawImageString(controlMessageGC,cp->controlWindow,
 		   centerX(globalGC1,cp->message,strlength,controlWidth),
 		   controlMessageY + globalFont->max_bounds.ascent - 2,
 		   cp->message,strlength,Xoption);
 }
 
-/*********************************/
-/***  void drawControlPanel()  ***/
-/*********************************/
-
-void 
-drawControlPanel(void)
-{
-
+@
+\subsection{drawControlPanel}
+\index{view2d!drawControlPanel}
+\index{drawControlPanel view2d}
+<<view2d>>=
+void drawControlPanel(void) {
   controlPanelStruct *cp;
   int i,strlength;
   char *s;
-
   cp = viewport->controlPanel;
   /* Draw border lines to separate the potentiometer, message, graph select
      and button regions of the control panel. */
@@ -4934,22 +4997,19 @@ drawControlPanel(void)
   GDrawLine(trashGC, cp->controlWindow, 0, messageBot,
 	    controlWidth, messageBot, Xoption);
   GDrawLine(trashGC, cp->controlWindow, 0, 286, controlWidth, 286, Xoption);
-
   /** put the line width as 1 last because used below as well **/
   GSetLineAttributes(trashGC,1,LineSolid,CapButt,JoinMiter,Xoption);
   GDrawRectangle(trashGC,cp->controlWindow,closeLeft,closeTop,
-		 (controlWidth-closeLeft+8),(controlHeight-closeTop+8),Xoption);
-
+	 (controlWidth-closeLeft+8),(controlHeight-closeTop+8),Xoption);
   /* Write potentiometer titles on the control panel. */
   writeControlTitle();
   GSetForeground(globGC,(float)controlPotHeaderColor,Xoption);
   s = "Scale";
   strlength = strlen(s);
   GDrawString(globGC,cp->controlWindow,
-	      centerX(globGC,s,strlength,
-		      cp->buttonQueue[scale2D].buttonWidth) +
-	      cp->buttonQueue[scale2D].buttonX, 31+headerHeight,s,strlength,Xoption);
-
+      centerX(globGC,s,strlength,
+	      cp->buttonQueue[scale2D].buttonWidth) +
+      cp->buttonQueue[scale2D].buttonX, 31+headerHeight,s,strlength,Xoption);
   s = "Translate";
   strlength = strlen(s);
   GDrawString(globGC,cp->controlWindow,
@@ -4957,41 +5017,34 @@ drawControlPanel(void)
 		      cp->buttonQueue[translate2D].buttonWidth) +
 	      cp->buttonQueue[translate2D].buttonX,
 	      31+headerHeight,s,strlen(s),Xoption);
-
   GSetForeground(globGC,(float)controlColorColor,Xoption);
-
   /* Write title of the graph selection window. */
   s = "Graphs";
   strlength = strlen(s);
   GDrawString(globGC,cp->controlWindow,
 	      centerX(globGC,s,strlength,controlWidth),graphHeaderHeight,
 	      s,strlength,Xoption);
-
   /* Write titles on regular buttons and draw pixmaps on potentiometers. */
-
   for (i=0; i<(maxButtons2D); i++) {
     if ((cp->buttonQueue[i]).pot) {
-
       GSetForeground(globalGC1,(float)buttonColor,Xoption);
       GDrawRectangle(globalGC1,cp->controlWindow,
-		     (cp->buttonQueue[i]).buttonX,
-		     (cp->buttonQueue[i]).buttonY,
-		     (cp->buttonQueue[i]).buttonWidth,
-		     (cp->buttonQueue[i]).buttonHeight,Xoption);
-
+	     (cp->buttonQueue[i]).buttonX,
+	     (cp->buttonQueue[i]).buttonY,
+	     (cp->buttonQueue[i]).buttonWidth,
+	     (cp->buttonQueue[i]).buttonHeight,Xoption);
       GSetForeground(trashGC,
-		     (float)monoColor((cp->buttonQueue[i]).textColor),Xoption);
-
+	     (float)monoColor((cp->buttonQueue[i]).textColor),Xoption);
       GDrawLine(globalGC1,cp->controlWindow, /* trashGC, */
-		(cp->buttonQueue[i]).buttonX + (cp->buttonQueue[i]).xHalf,
-		(cp->buttonQueue[i]).buttonY,
-		(cp->buttonQueue[i]).buttonX + (cp->buttonQueue[i]).xHalf,
-		(cp->buttonQueue[i]).buttonY + 2*(cp->buttonQueue[i]).yHalf,Xoption);
+	(cp->buttonQueue[i]).buttonX + (cp->buttonQueue[i]).xHalf,
+	(cp->buttonQueue[i]).buttonY,
+	(cp->buttonQueue[i]).buttonX + (cp->buttonQueue[i]).xHalf,
+	(cp->buttonQueue[i]).buttonY + 2*(cp->buttonQueue[i]).yHalf,Xoption);
       GDrawLine(globalGC1,cp->controlWindow, /* trashGC, */
-		(cp->buttonQueue[i]).buttonX,
-		(cp->buttonQueue[i]).buttonY + (cp->buttonQueue[i]).yHalf,
-		(cp->buttonQueue[i]).buttonX + 2*(cp->buttonQueue[i]).xHalf,
-		(cp->buttonQueue[i]).buttonY + (cp->buttonQueue[i]).yHalf,Xoption);
+	(cp->buttonQueue[i]).buttonX,
+	(cp->buttonQueue[i]).buttonY + (cp->buttonQueue[i]).yHalf,
+	(cp->buttonQueue[i]).buttonX + 2*(cp->buttonQueue[i]).xHalf,
+	(cp->buttonQueue[i]).buttonY + (cp->buttonQueue[i]).yHalf,Xoption);
       switch (i) {
       case scale2D:
 	GDrawLines(trashGC,cp->controlWindow,scaleArrow,
@@ -5003,7 +5056,6 @@ drawControlPanel(void)
 	break;
       } /* switch i */
     } else if (cp->buttonQueue[i].graphNum) {
-
       if (mono) {
 	if (graphStateArray[i-graphStart].showing) {
 	  GSetForeground(graphGC,(float)backgroundColor,Xoption);
@@ -5014,12 +5066,12 @@ drawControlPanel(void)
 	}
 	strlength = strlen((cp->buttonQueue[i]).text);
 	GDrawImageString(graphGC,cp->controlWindow,
-			 (cp->buttonQueue[i]).buttonX +
-			 centerX(graphGC,cp->buttonQueue[i].text,
-				 strlength,(cp->buttonQueue[i]).buttonWidth),
-			 (cp->buttonQueue[i]).buttonY +
-			 centerY(graphGC,(cp->buttonQueue[i]).buttonHeight),
-			 cp->buttonQueue[i].text,strlength,Xoption);
+		 (cp->buttonQueue[i]).buttonX +
+		 centerX(graphGC,cp->buttonQueue[i].text,
+			 strlength,(cp->buttonQueue[i]).buttonWidth),
+		 (cp->buttonQueue[i]).buttonY +
+		 centerY(graphGC,(cp->buttonQueue[i]).buttonHeight),
+		 cp->buttonQueue[i].text,strlength,Xoption);
       } else {
 	if (graphStateArray[i-graphStart].showing)
 	  GSetForeground(graphGC,(float)graphBarShowingColor,Xoption);
@@ -5027,12 +5079,12 @@ drawControlPanel(void)
 	  GSetForeground(graphGC,(float)graphBarHiddenColor,Xoption);
 	strlength = strlen((cp->buttonQueue[i]).text);
 	GDrawString(graphGC,cp->controlWindow,
-		    (cp->buttonQueue[i]).buttonX +
-		    centerX(graphGC,cp->buttonQueue[i].text,
-			    strlength,(cp->buttonQueue[i]).buttonWidth),
-		    (cp->buttonQueue[i]).buttonY +
-		    centerY(graphGC,(cp->buttonQueue[i]).buttonHeight),
-		    cp->buttonQueue[i].text,strlength,Xoption);
+	    (cp->buttonQueue[i]).buttonX +
+	    centerX(graphGC,cp->buttonQueue[i].text,
+		    strlength,(cp->buttonQueue[i]).buttonWidth),
+	    (cp->buttonQueue[i]).buttonY +
+	    centerY(graphGC,(cp->buttonQueue[i]).buttonHeight),
+	    cp->buttonQueue[i].text,strlength,Xoption);
 	}
     } else if (cp->buttonQueue[i].graphSelect) {
       /* The select characters are defined as: "^" for on and "-" for off. */
@@ -5045,16 +5097,15 @@ drawControlPanel(void)
 	strcpy((cp->buttonQueue[i]).text,"-");
       }
        GDrawString(graphGC,cp->controlWindow,
-		 (cp->buttonQueue[i]).buttonX +
-		 centerX(graphGC,cp->buttonQueue[i].text,
-			 strlength,(cp->buttonQueue[i]).buttonWidth),
-		 (cp->buttonQueue[i]).buttonY +
-		 centerY(graphGC,(cp->buttonQueue[i]).buttonHeight),
-		 cp->buttonQueue[i].text,strlength,Xoption);
+	 (cp->buttonQueue[i]).buttonX +
+	 centerX(graphGC,cp->buttonQueue[i].text,
+		 strlength,(cp->buttonQueue[i]).buttonWidth),
+	 (cp->buttonQueue[i]).buttonY +
+	 centerY(graphGC,(cp->buttonQueue[i]).buttonHeight),
+	 cp->buttonQueue[i].text,strlength,Xoption);
     }
     else {  /* a regular button */
       int isOn = 1;
-
       switch(i) {
 	case pointsOnOff:
 	  isOn = pointsON = graphStateArray[0].pointsOn;
@@ -5063,7 +5114,6 @@ drawControlPanel(void)
 	  else
 	    strcpy((cp->buttonQueue[i]).text,"Pts Off");
 	  break;
-
 	case spline2D:
 	  isOn = splineON = graphStateArray[0].splineOn;
 	  if (graphStateArray[0].splineOn)
@@ -5071,7 +5121,6 @@ drawControlPanel(void)
 	  else
 	    strcpy((cp->buttonQueue[i]).text, "Box Off");
 	  break;
-
 	case connectOnOff:
 	  isOn = connectON = graphStateArray[0].connectOn;
 	  if (graphStateArray[0].connectOn)
@@ -5079,7 +5128,6 @@ drawControlPanel(void)
 	  else
 	    strcpy((cp->buttonQueue[i]).text, "Lines Off");
 	  break;
-
 	case axesOnOff2D:
 	  isOn = axesON = graphStateArray[0].axesOn;
 	  if (graphStateArray[0].axesOn)
@@ -5087,7 +5135,6 @@ drawControlPanel(void)
 	  else
 	    strcpy((cp->buttonQueue[i]).text , "Axes Off");
 	  break;
-
 	case unitsOnOff2D:
 	  isOn = unitsON = graphStateArray[0].unitsOn;
 	  if (graphStateArray[0].unitsOn)
@@ -5097,39 +5144,35 @@ drawControlPanel(void)
 	  break;
 	case closeAll2D:
 	  isOn = 0;
-
 	default:
 	  break;
       } /* switch i */
-
       s = (cp->buttonQueue[i]).text;
       strlength = strlen(s);
-
       GDrawPushButton(dsply, globalGC1, trashGC, processGC, cp->controlWindow,
 	  (cp->buttonQueue[i]).buttonX, (cp->buttonQueue[i]).buttonY,
 	  (cp->buttonQueue[i]).buttonWidth, (cp->buttonQueue[i]).buttonHeight,
 	  isOn, s,buttonColor,
 	  monoColor((cp->buttonQueue[i]).textColor), Xoption);
-
     } /* else a regular button */
   } /* for each button */
-
   /* Refresh the latest message */
   makeMessageFromData(0);
   writeControlMessage();
   XFlush(dsply);
-
 }    /*** drawControlPanel ***/
 
-controlXY 
-getControlXY(int whereDoYouWantPanel)
-{
+@
+\subsection{getControlXY}
+\index{view2d!getControlXY}
+\index{getControlXY view2d}
+<<view2d>>=
+controlXY getControlXY(int whereDoYouWantPanel) {
   XWindowAttributes wAttr, wAttrib;
-  controlXY	    cXY;
+  controlXY	    cXY = {0,0};
   int		    tmp=1;
   Window	    rootW, parentW, *childrenWs, tmpW;
   unsigned int	    nChildren;
-
   tmpW = viewport->titleWindow;
   while(tmp) {
     XQueryTree(dsply,tmpW,&rootW,&parentW,&childrenWs,&nChildren);
@@ -5138,7 +5181,6 @@ getControlXY(int whereDoYouWantPanel)
     else tmpW = parentW;
   }
   XGetWindowAttributes(dsply,tmpW,&wAttrib);
-
   XGetWindowAttributes(dsply,viewport->titleWindow,&wAttr);
   if (whereDoYouWantPanel) {
     switch (whereDoYouWantPanel) {
@@ -5178,34 +5220,28 @@ getControlXY(int whereDoYouWantPanel)
     }
   }
   return(cXY);
-
 }
 
-/************************************************/
-/***  controlPanelStruct *makeControlPanel()  ***/
-/************************************************/
-
-controlPanelStruct *
-makeControlPanel(void)
-{
-
+@
+\subsection{makeControlPanel}
+\index{view2d!makeControlPanel}
+\index{makeControlPanel view2d}
+<<view2d>>=
+controlPanelStruct *makeControlPanel(void) {
   Window cw;
   int		       i,num;
   controlPanelStruct   *control;
   buttonStruct	       *buttons;
-  controlXY	       cXY;
+  controlXY	       cXY = {0,0};
   XSetWindowAttributes cwAttrib, controlAttrib;
   XSizeHints	       sizehints;
   Pixmap	       mousebits,mousemask;
   XColor	       foreColor, backColor;
-
   if (!(control = (controlPanelStruct *)malloc(sizeof(controlPanelStruct)))) {
     fprintf(stderr,"Ran out of memory trying to create a control panel.\n");
     exitWithAck(RootWindow(dsply,scrn),Window,-1);
   }
-
   cXY = getControlXY(0);
-
   /* Define and assign a mouse cursor. */
   mousebits = XCreateBitmapFromData(dsply,rtWindow,mouseBitmap_bits,
 				    mouseBitmap_width,mouseBitmap_height);
@@ -5224,29 +5260,23 @@ makeControlPanel(void)
   cwAttrib.cursor = XCreatePixmapCursor(dsply,mousebits,mousemask,
 					&foreColor,&backColor,
 					mouseBitmap_x_hot,mouseBitmap_y_hot);
-
   cw = XCreateWindow(dsply,rtWindow,
 		     cXY.putX,cXY.putY,controlWidth,controlHeight,3,
 		     CopyFromParent,InputOutput,CopyFromParent,
 		     controlCreateMASK,&cwAttrib);
-
   sizehints.flags  = PPosition | PSize;
   sizehints.x	   = cXY.putX;
   sizehints.y	   = cXY.putY;
   sizehints.width  = controlWidth;
   sizehints.height = controlHeight;
-
   /*** the None stands for icon pixmap...change.... ***/
-
   XSetNormalHints(dsply,cw,&sizehints);
   XSetStandardProperties(dsply,cw,"2D Control Panel","2D Control Panel",
 			 None,NULL,0,&sizehints);
-
   control->controlWindow = cw;
   num = initButtons(control->buttonQueue);
   control->numOfButtons = num;
   buttons = control->buttonQueue;
-
   for (i=0; i<num; i++) {
     controlAttrib.event_mask = (control->buttonQueue[i]).mask;
     (control->buttonQueue[i]).self = XCreateWindow(dsply,cw,
@@ -5256,20 +5286,17 @@ makeControlPanel(void)
 				       (control->buttonQueue[i]).buttonHeight,
 				       0,0,InputOnly,CopyFromParent,
 				       buttonCreateMASK,&controlAttrib);
-
     XMakeAssoc(dsply,table,(control->buttonQueue[i]).self,
 	       &((control->buttonQueue[i]).buttonKey));
    /* Use buttonKey instead of i because buttonKey has a permanent address */
     XMapWindow(dsply,(control->buttonQueue[i]).self);
   }
-
 	   /* Create message window */
   control->messageWindow = XCreateWindow(dsply,cw,0,controlMessageY,
 					 controlWidth,controlMessageHeight,
 					 0,0,InputOnly,CopyFromParent,
 					 messageCreateMASK,&cwAttrib);
   XMapWindow(dsply,control->messageWindow);
-
   for (i=0; i<scaleArrowN; i++) {
     scaleArrow[i].x += buttons[scale2D].buttonX;
     scaleArrow[i].y += buttons[scale2D].buttonY;
@@ -5278,43 +5305,30 @@ makeControlPanel(void)
     translateArrow[i].x += buttons[translate2D].buttonX;
     translateArrow[i].y += buttons[translate2D].buttonY;
   }
-
   viewport->justMadeControl = yes;
   return(control);
-
 } /* makeControlPanel() */
 
-
-
-
-
-
-/*****************************************/
-/***  void putControlPanelSomewhere()  ***/
-/*****************************************/
-
-/* This routine puts up the control panel associated with the viewport
-   passed in.  It first tries to put it to the right of the viewport. If
-   there isn't enough room there, it tries the bottom and so on going
-   clockwise. If the viewport is too big and there is no room to put the
-   control panel outside of it, it placed the control panel in the bottom
-   right hand corner of the viewport window. */
-
-void 
-putControlPanelSomewhere(int whereDoesPanelGo)
-{
+@
+\subsection{putControlPanelSomewhere}
+This routine puts up the control panel associated with the viewport
+passed in.  It first tries to put it to the right of the viewport. If
+there isn't enough room there, it tries the bottom and so on going
+clockwise. If the viewport is too big and there is no room to put the
+control panel outside of it, it placed the control panel in the bottom
+right hand corner of the viewport window. 
+\index{view2d!putControlPanelSomewhere}
+\index{putControlPanelSomewhere view2d}
+<<view2d>>=
+void putControlPanelSomewhere(int whereDoesPanelGo) {
   controlPanelStruct *control;
-  controlXY	     whereControl;
-
+  controlXY	     whereControl= {0,0};
   control = viewport->controlPanel;
   whereControl = getControlXY(whereDoesPanelGo);
-
   viewport->haveControl = yes;
-
   XRaiseWindow(dsply,control->controlWindow);
   XMoveWindow(dsply,control->controlWindow,whereControl.putX,
 	      whereControl.putY);
-
   drawControlPanel();
   if (viewport->justMadeControl) {
     XMapWindow(dsply,control->controlWindow);
@@ -5323,141 +5337,28 @@ putControlPanelSomewhere(int whereDoesPanelGo)
   XMapWindow(dsply,control->controlWindow);
 }
 
-
-
-
-
-/************************************/
-/***  void clearControlMessage()  ***/
-/************************************/
-
-void 
-clearControlMessage(void)
-{
-
+@
+\subsection{clearControlMessage}
+\index{view2d!clearControlMessage}
+\index{clearControlMessage view2d}
+<<view2d>>=
+void clearControlMessage(void) {
   strcpy(viewport->controlPanel->message,"");
-  
   XClearArea(dsply,viewport->controlPanel->controlWindow,
 	     0,controlMessageY-2,controlWidth,controlMessageHeight,False);
 }
 
-
-@
-\section{globals2.h}
-<<view2d/globals2.h>>=
-extern int           scrn;
-extern Display       *dsply;
-extern XFontStruct   *globalFont,*buttonFont,*headerFont,*titleFont,
-                     *graphFont,*unitFont,*serverFont;
-extern XrmDatabase      rDB;
-
-extern char          scaleXReport[5],scaleYReport[5],deltaXReport[5],
-                     deltaYReport[5];
-extern unsigned long *spadColors;
-extern int           followMouse,viewportKeyNum;
-extern Window        rtWindow,viewman;
-extern GC            globalGC1,globalGC2,anotherGC,globGC,trashGC,
-                     controlMessageGC,graphGC,unitGC;
-extern HashTable     *table;
-extern Colormap      colorMap;
-extern int           Socket,ack;
-
-extern  GC  processGC;
-extern  viewPoints *viewport;
-extern  controlPanelStruct *control;
-extern  XGCValues gcVals;
-extern  char *s;
-extern  int someInt;
-
-extern unsigned long foregroundColor, backgroundColor; 
-
-extern int drawMore;
-extern int spadMode,spadDraw;
-extern jmp_buf jumpFlag;
-
-extern graphStruct graphArray[maxGraphs]; 
-extern graphStateStruct graphStateArray[maxGraphs],
-                        graphStateBackupArray[maxGraphs];
-extern xPointStruct xPointsArray[maxGraphs];
-
-extern int pointsON, connectON, splineON, axesON, unitsON, zoomXON, zoomYON;
-extern int transXON, transYON;
-
-extern char errorStr[80];
-
-extern int currentGraph; 
-extern int queriedGraph;
-extern int picking,dropping;
-
-extern char filename[256];
-
-extern char *xDefault;
-
-extern int viewAloned;
-
-extern int mono, totalColors,
-           totalHues, totalSolidShades, totalDitheredAndSolids,totalShades;
-
-extern float aspectR;
-
-extern Atom wm_delete_window;
 @
-\section{graph2d.c}
-<<view2d/graph2d.c>>=
-#define _GRAPH2D_C
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-<<view2d/header2.h>>
-
-extern int initButtons(buttonStruct * );
-extern void writeControlTitle(void );
-extern void makeMessageFromData(int );
-extern void writeControlMessage(void );
-extern void drawControlPanel(void );
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void );
-extern void putControlPanelSomewhere(int );
-extern void clearControlMessage(void );
-extern void getGraphFromViewman(int );
-extern void freeGraph(int );
-extern int main(void);
-extern void mergeDatabases(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern void doPick(int  , int );
-extern void doDrop(int  , int );
-extern void clickedOnGraph(int  , int );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern void clickedOnGraphSelect(int  , int );
-#ifdef _PROCESS2D_C
-static void drawControlPushButton(int  , int );
-#endif
-extern int readViewman(void *  , int );
-extern int spadAction(void);
-extern float absolute(float);
-extern void goodbye(int);
-extern void writeTitle(void);
-extern void drawTheViewport(int );
-extern viewPoints * makeViewport(char *  , int  , int  , int  , int  , int );
-extern viewPoints * makeView2D(view2DStruct * );
-extern int writeViewport(int );
-
-#include "util.h1"
-
-
-void 
-getGraphFromViewman(int i)
-{
- /** This routine should be called right after a read of the graph key 
-     was made from the viewport manager (or defined in some other way). **/
-
+\subsection{getGraphFromViewman}
+This routine should be called right after a read of the graph key 
+was made from the viewport manager (or defined in some other way).
+\index{view2d!getGraphFromViewman}
+\index{getGraphFromViewman view2d}
+<<view2d>>=
+void getGraphFromViewman(int i) {
   int j,k,xPointsNeeded;
   pointListStruct *llPtr;
   pointStruct     *p;
-
   readViewman(&(graphArray[i].xmin),floatSize);
   readViewman(&(graphArray[i].xmax),floatSize);
   readViewman(&(graphArray[i].ymin),floatSize);
@@ -5471,18 +5372,18 @@ getGraphFromViewman(int i)
   readViewman(&(graphArray[i].originX),floatSize);
   readViewman(&(graphArray[i].originY),floatSize);
   readViewman(&(graphArray[i].numberOfLists),intSize);
-  
   if (!(llPtr = (pointListStruct *)malloc(graphArray[i].numberOfLists * sizeof(pointListStruct)))) {
     fprintf(stderr,"VIEW2D: Fatal Error>> Ran out of memory trying to receive a graph.\n");
     exitWithAck(RootWindow(dsply,scrn),Window,-1);
   }
   graphArray[i].listOfListsOfPoints = llPtr;
-  
   xPointsNeeded = 0;
   for (j=0; j<graphArray[i].numberOfLists; j++) {
     readViewman(&(llPtr->numberOfPoints),intSize);
-    if (!(p = (pointStruct *)malloc(llPtr->numberOfPoints * sizeof(pointStruct)))) {
-      fprintf(stderr,"VIEW2D: (pointStruct) ran out of memory trying to create a new graph.\n");
+    if (!(p = (pointStruct *)
+           malloc(llPtr->numberOfPoints * sizeof(pointStruct)))) {
+      fprintf(stderr,"VIEW2D: (pointStruct) ran out of memory trying to \n");
+      fprintf(stderr,"create a new graph.\n");
       exitWithAck(RootWindow(dsply,scrn),Window,-1);
     }
     llPtr->listOfPoints = p;             /** point to current point list **/
@@ -5496,11 +5397,9 @@ getGraphFromViewman(int i)
     readViewman(&(llPtr->pointColor),intSize);
     readViewman(&(llPtr->lineColor),intSize);
     readViewman(&(llPtr->pointSize),intSize);
-    
     xPointsNeeded += llPtr->numberOfPoints;
     llPtr++;
   }   /* for j in list of lists of points */
-  
   /* read in graph state for the existing graph (override default values) */
   readViewman(&(graphStateArray[i].scaleX),floatSize);
   readViewman(&(graphStateArray[i].scaleY),floatSize);
@@ -5516,37 +5415,38 @@ getGraphFromViewman(int i)
   readViewman(&(graphStateArray[i].showing),intSize);
   graphStateArray[i].selected = yes;
   graphStateBackupArray[i] = graphStateArray[i];
-
   graphStateArray[i].deltaX = graphStateArray[0].deltaX;
   graphStateArray[i].deltaY = graphStateArray[0].deltaY;
   graphStateArray[i].scaleX = graphStateArray[0].scaleX;
   graphStateArray[i].scaleY = graphStateArray[0].scaleY;
-
   /* allocate memory for xPoints (used in drawViewport) */
-  if (!(xPointsArray[i].xPoint = (XPoint *)malloc(xPointsNeeded * sizeof(XPoint)))) {
-    fprintf(stderr,"VIEW2D: (XPoint) Ran out of memory (malloc) trying to create a new graph.\n");
+  if (!(xPointsArray[i].xPoint = 
+          (XPoint *)malloc(xPointsNeeded * sizeof(XPoint)))) {
+    fprintf(stderr,"VIEW2D: (XPoint) Ran out of memory (malloc) trying \n");
+    fprintf(stderr,"to create a new graph.\n");
     exitWithAck(RootWindow(dsply,scrn),Window,-1);
   }
-  if (!(xPointsArray[i].x10Point = (Vertex *)malloc(xPointsNeeded * sizeof(Vertex)))) {
-    fprintf(stderr,
-            "VIEW2D: (X10Point) Ran out of memory (malloc) trying to create a new graph.\n");
+  if (!(xPointsArray[i].x10Point = 
+          (Vertex *)malloc(xPointsNeeded * sizeof(Vertex)))) {
+    fprintf(stderr,"VIEW2D: (X10Point) Ran out of memory (malloc) trying \n");
+    fprintf(stderr,"to create a new graph.\n");
     exitWithAck(RootWindow(dsply,scrn),Window,-1);
   }
   if (!(xPointsArray[i].arc = (XArc *)malloc(xPointsNeeded * sizeof(XArc)))) {
-    fprintf(stderr,"VIEW2D: (XArc) Ran out of memory (malloc) trying to create a new graph.\n");
+    fprintf(stderr,"VIEW2D: (XArc) Ran out of memory (malloc) trying \n");
+    fprintf(stderr,"to create a new graph.\n");
     exitWithAck(RootWindow(dsply,scrn),Window,-1);
   }
-
 }   /* getGraphFromViewman */
 
-
-
-void 
-freeGraph(int i)
-{
+@
+\subsection{freeGraph}
+\index{view2d!freeGraph}
+\index{freeGraph view2d}
+<<view2d>>=
+void freeGraph(int i) {
   int j;
   pointListStruct *llPtr;
-
   if (graphArray[i].key) {
     graphArray[i].key = 0;   /* 0 means no graph */
     for (j=0,llPtr=graphArray[i].listOfListsOfPoints; 
@@ -5556,470 +5456,14 @@ freeGraph(int i)
     free(xPointsArray[i].xPoint);
   } else {
   }
-
 }
-@
-\section{header2.h}
-<<view2d/header2.h>>=
-#include <X11/Xlib.h>
-#include <X11/Xresource.h>
-#include <setjmp.h>
-
-/* for xdefs */
-#define view2d 
-
-#include "hash.h"
-<<include/nox10.h>>
-<<include/view.h>>
-<<include/view2d.h>>
-<<include/actions.h>>
-<<include/viewcommand.h>>
-<<include/xdefs.h>>
-<<include/override.h>>
-<<include/g.h>>
-
-#define carefullySetFont(gc,font) if (font != serverFont) XSetFont(dsply,gc,font->fid)
-
-#define controlMASK (ButtonPressMask + ExposureMask)
-#define potMASK     (ButtonPressMask + ButtonReleaseMask + ButtonMotionMask + LeaveWindowMask)
-#define buttonMASK  (ButtonPressMask + ButtonReleaseMask + LeaveWindowMask)
-#define colorMASK   (ButtonPressMask + ButtonReleaseMask + LeaveWindowMask)
-
-/* make mouse grab for stationery mouse on a potentiometer slower */
-#define mouseWait 50 
-
-#define controlCreateMASK (CWBackPixel | CWBorderPixel | CWEventMask | CWCursor |CWColormap | CWOverrideRedirect)
-#define buttonCreateMASK    CWEventMask  
-#define messageCreateMASK   0
-#define colormapCreateMASK  CWEventMask
-
-#define controlWidth  236
-#define controlHeight 400
-
-#define closeLeft cp->buttonQueue[closeAll2D].buttonX - 5
-#define closeTop  cp->buttonQueue[closeAll2D].buttonY - 5
-
-#define controlBackground WhitePixel(dsply,scrn)
-#define controlCursorForeground monoColor(4)
-#define controlCursorBackground monoColor(44)
-#define controlTitleColor       monoColor(36)
-#define controlPotHeaderColor   monoColor(52)
-#define controlColorColor       monoColor(13)
-#define controlColorSignColor   monoColor(22)
-
-#define controlMessageHeight globalFont->max_bounds.ascent + globalFont->max_bounds.descent+4
-#define messageBot controlMessageY + controlMessageHeight
-
-#define headerHeight headerFont->max_bounds.ascent
-#define graphHeaderHeight messageBot + headerHeight
-
-#define graphBarTop    graphHeaderHeight + 12
-#define graphBarLeft   66
-#define graphBarWidth  graphFont->max_bounds.width
-#define graphBarHeight graphFont->max_bounds.ascent + graphFont->max_bounds.descent
-
-#define colormapX 10
-#define colormapY 235
-#define colormapW 280
-#define colormapH 60
-
-#define colorWidth   8
-#define colorHeight  12
-  
-#define colorOffset  3
-#define colorOffsetX 24
-#define colorOffsetY 20
-#define colorPointer 18
-
-#define buttonColor monoColor(105) 
-
-#define graphBarDefaultColor    monoColor(15)
-#define graphBarShowingColor    monoColor(15)
-#define graphBarHiddenColor     monoColor(138)
-#define graphBarSelectColor     monoColor(15)
-#define graphBarNotSelectColor  monoColor(138)
-
-#define viewportCreateMASK (CWBackPixel|CWBorderPixel|CWEventMask|CWCursor|CWColormap)
-#define viewportTitleCreateMASK (CWBackPixel|CWBorderPixel|CWCursor|CWColormap|CWEventMask|CWOverrideRedirect)
-
-#define viewportMASK (KeyPressMask + ButtonPressMask + ExposureMask)
-#define titleMASK    ExposureMask
-
-#define lineWidth  1
-#define lineHeight 1
-
-#define titleColor     monoColor(36)
-#define titleHeight    24
-#define appendixHeight 0
-
-#define viewWidth  400
-#define viewHeight 400
-
-#define viewBorderWidth 0
-#define borderWidth     22
-#define borderHeight	45
-
-#define initDeltaX 0.0
-#define initDeltaY 0.0
-#define initScale  1.3
-
-#define minScale  0.01
-#define maxScale  1000.0
-#define maxDelta  1000.0
-
-#define scaleFactor     0.5
-#define translateFactor 10
-
-#define viewCursorForeground monoColor(166)
-#define viewCursorBackground monoColor(5)
-
-#define axisLength 100.0    
-
-#define axesColorDefault  35
-#define labelColor 22
-
-#define meshOutline      monoColor(132)
-#define opaqueOutline    monoColor(53)
-#define opaqueForeground monoColor(236)
-
-#define drawWireFrame 0
-#define drawOpaque    1
-#define drawRendered  2
-
-
-#define numOfColors 240
-
-#define totalHuesConst   27
-#define totalShadesConst 8
-#define hueEnd 360
-#define hueStep hueEnd/totalHuesConst
-
-#define numPlanes 1
-#define numColors 10
-#define startColor 0
-#define endColor   startColor+numColors
-#define maxColors DisplayCells(dsply,scrn)-1
-
-#define colorStep (maxColors+1)/numColors
-
-
-#define physicalWidth  DisplayWidth(dsply,scrn)
-#define physicalHeight DisplayHeight(dsply,scrn)
-#define deep           DisplayPlanes(dsply,scrn)
-
-#define basicScreen 19
-
-#define yes 1
-#define no  0
-
-#define potA  25   /* line dividing potentiometers from stuff above it */
-#define potB 173   /* line dividing potentiometers from title */
-#define butA 260   /* line dividing buttons from stuff above it */
-
-#define controlMessageY     181
-#define controlMessageColor monoColor(29)
-
-#define pi_half         1.570796326794896619231321691639751442099
-#define pi              3.141592653589793238462643383279502884197
-#define three_pi_halves 4.712388980384689857693965074919254326296
-#define two_pi          6.283185307179586476925286766559005768394
-
-#define degrees_in_two_pi 57
-#define d2Pi 57
-
-#define viewBackground 0
-
-#define nbuckets         128
-
-#define anywhere 0
-
-
-#define intSize sizeof(int)
-#define floatSize sizeof(float)
-
-/* type is X, PS,... */
-
-#define drawViewport(type) drawTheViewport(type);
-#define spadDrawViewport() spadMode++; drawTheViewport(X); spadMode--;
-
-@
-\index{struct!buttonStruct}
-\index{buttonStruct struct}
-<<view2d/header2.h>>=
-typedef struct _buttonStruct {
-  int buttonKey, pot, mask, graphNum, graphSelect;
-  short buttonX,buttonY,buttonWidth,buttonHeight,xHalf,yHalf;
-  Window self;
-  char text[40];
-  int textColor, textHue, textShade;
-} buttonStruct;
 
 @
-\index{struct!controlPanelStruct}
-\index{controlPanelStruct struct}
-<<view2d/header2.h>>=
-typedef struct _controlPanelStruct {
-  int                  numOfButtons;
-  Window               controlWindow,messageWindow,colormapWindow;
-  char                 message[40];
-  struct _buttonStruct buttonQueue[maxButtons2D];
-} controlPanelStruct;
-
-@
-\index{struct!mouseCoord}
-\index{mouseCoord struct}
-<<view2d/header2.h>>=
-typedef struct _mouseCoord {
-    float x,y;
-} mouseCoord;
-
-@
-\index{struct!viewPoints}
-\index{viewPoints struct}
-<<view2d/header2.h>>=
-typedef struct _viewPoints {
-  int                 viewportKey;
-  char                title[80];
-  Window              viewWindow,titleWindow;
-  controlPanelStruct  *controlPanel;
-  int                 justMadeControl,haveControl,
-                      axesOn,unitsOn,pointsOn,linesOn,splineOn,closing,
-                      allowDraw;
-  struct _viewPoints  *prevViewport,*nextViewport;
-} viewPoints;
-
-@
-\index{struct!controlXY}
-\index{controlXY struct}
-<<view2d/header2.h>>=
-typedef struct _controlXY {
-  int putX,putY;
-} controlXY;
-
-@
-\index{struct!xPointStruct}
-\index{xPointStruct struct}
-<<view2d/header2.h>>=
-typedef struct _xPointStruct {
-  XPoint *xPoint;
-  Vertex *x10Point;
-  XArc   *arc;
-} xPointStruct;
-
-#define calcUnitX(ii) (vwInfo.width * \
-		       ((graphArray[0].unitX * ii + \
-                     	graphArray[0].originX - graphStateArray[0].centerX) *\
-			graphStateArray[0].scaleX + 0.5))
-#define calcUnitY(ii) (vwInfo.height * aspectR * \
-		       (1 - ((graphArray[0].unitY*aspectR * ii + \
-			      graphArray[0].originY*aspectR - \
-			      graphStateArray[0].centerY) * \
-			     graphStateArray[0].scaleY + 0.5*aspectR )))
-
-#define projX(x,w,i) ((((float)x/w-0.5)/graphStateArray[i].scaleX + \
-		       graphStateArray[i].centerX + 0.5) / 	\
-		      graphArray[i].xNorm + graphArray[i].xmin)
-
-#define projY(y,h,i) (((0.5-(float)y/h*aspectR)/graphStateArray[i].scaleY + \
-		       graphStateArray[i].centerY + 0.5) / 	\
-		      graphArray[i].yNorm + graphArray[i].ymin)
-
-#define isNaN(v) (v != v)
-
-<<view2d/globals2.h>>
-
-@
-\section{main2d.c}
-<<view2d/main2d.c>>=
-#define _MAIN2D_C
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <signal.h>
-
-<<view2d/header2.h>>
-#include "bsdsignal.h"
-<<view2d/globals2.h>>
-#include "bsdsignal.h1"
-extern int initButtons(buttonStruct * );
-extern void writeControlTitle(void );
-extern void makeMessageFromData(int );
-extern void writeControlMessage(void );
-extern void drawControlPanel(void );
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void );
-extern void putControlPanelSomewhere(int );
-extern void clearControlMessage(void );
-extern void getGraphFromViewman(int );
-extern void freeGraph(int );
-extern int main(void);
-extern void mergeDatabases(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern void doPick(int  , int );
-extern void doDrop(int  , int );
-extern void clickedOnGraph(int  , int );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern void clickedOnGraphSelect(int  , int );
-#ifdef _PROCESS2D_C
-static void drawControlPushButton(int  , int );
-#endif
-extern int readViewman(void *  , int );
-extern int spadAction(void);
-extern float absolute(float);
-extern void goodbye(int);
-extern void writeTitle(void);
-extern void drawTheViewport(int );
-extern viewPoints * makeViewport(char *  , int  , int  , int  , int  , int );
-extern viewPoints * makeView2D(view2DStruct * );
-extern int writeViewport(int );
-
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-#include "util.h1"
-#include "xspadfill.h1"
-
-
-/**********************/
-/** global variables **/
-/**********************/
-Window        rtWindow,viewman;
-Display       *dsply;
-XFontStruct   *globalFont,
-  *buttonFont,
-  *headerFont,
-  *titleFont,
-  *graphFont,
-  *unitFont,
-  *serverFont;
-GC            globalGC1,
-  globalGC2,
-  anotherGC,
-  globGC,
-  trashGC,
-  controlMessageGC,
-  graphGC,
-  unitGC,
-  processGC;
-XGCValues     gcVals;
-HashTable     *table;
-Colormap      colorMap;
-
-XrmDatabase rDB; /* Resource database */
-
-
-char          scaleXReport[5],
-  scaleYReport[5],
-  deltaXReport[5],
-  deltaYReport[5],
-  *s,
-  errorStr[80],
-  filename[256], /** For writing viewport data out to a file **/
-  *xDefault;     /** used for accessing .XDefaults **/
-
-
-unsigned long *spadColors;
-unsigned long foregroundColor, backgroundColor;  
-
-int           followMouse = no, 
-  viewportKeyNum = 0, 
-  scrn, 
-  Socket = 1,
-  ack = 1,
-  someInt,
-  drawMore,
-  spadMode=no, /* yes if receiving Axiom command and calling drawViewport */
-  spadDraw=no, /* yes if drawing viewport because of a Axiom command */
-  pointsON  = yes,  /* these would affect the choices in buttons.c */
-  connectON = yes,
-  splineON  = no,
-  axesON    = yes,
-  unitsON   = no,
-  zoomXON   = yes,
-  zoomYON   = yes,
-  transXON  = yes,
-  transYON  = yes,
-  currentGraph = 0,  /* last graph selected */
-  queriedGraph = 0,  /* current graph queried */
-  picking=0,
-  dropping=0,
-  viewAloned,  /** if not connected to Axiom **/
-  mono, 
-  totalColors, 
-  totalSolid, 
-  totalDithered, 
-  maxGreyShade,
-  totalHues, 
-  totalSolidShades, 
-  totalDitheredAndSolids,
-  totalShades;
-/* totalShades is initially set to totalShadesConst (probably 8).
-   If X cannot allocate 8 shades for each hue, totalShades is 
-   decremented. There is currently only a check for this value
-   to be positive. ---> something to add: change over to monochrome
-   if totalShades=0. Just modify the spadcolors.c file. 
-   spadcolors.c has been modified so that it returns the value for
-   totalShades. Since the return value had previously been unused,
-   a modification in this way ensures continued support of other
-   routines calling this function (e.g. hyperDoc stuff). */
-
-viewPoints    *viewport;
-controlPanelStruct *control;
-jmp_buf jumpFlag;
-graphStruct      graphArray[maxGraphs];
-graphStateStruct graphStateArray[maxGraphs],
-  graphStateBackupArray[maxGraphs];
-xPointStruct     xPointsArray[maxGraphs];
-float aspectR = 1.0;
-/* global ps variables */
-int     psInit=no;      /* need to call globalInitPs() each run */
-GCptr   GChead=NULL;    /* ptr to head of ps GC linked list */
-char    *PSfilename,    /* output file name used in user directory */
-  *envAXIOM;    /* used as ps file pathnames */
-
-<<view2d/main2d.c/main>>
-
-void 
-mergeDatabases(void)
-{
+\subsection{mergeDatabases}
+\index{view2d!mergeDatabases}
+\index{mergeDatabases view2d}
+<<view2d>>=
+void mergeDatabases(void) {
   /* using global
      rDB
      dsply
@@ -6029,13 +5473,11 @@ mergeDatabases(void)
   char *filename = &filenamebuf[0];
   char *classname = "Axiom";
   char name[255];
-  
   (void) XrmInitialize();
   (void) strcpy(name, "/usr/lib/X11/app-defaults/");
   (void) strcat(name, classname);
   applicationDB = XrmGetFileDatabase(name);
   (void) XrmMergeDatabases(applicationDB, &rDB);
-  
   if (XResourceManagerString(dsply) != NULL)
     serverDB = XrmGetStringDatabase(XResourceManagerString(dsply));
   else {
@@ -6053,259 +5495,33 @@ mergeDatabases(void)
   }
   else 
     (void) strcpy (filename,getenv ("XENVIRONMENT"));
-  
   homeDB = XrmGetFileDatabase(filename);
   XrmMergeDatabases(homeDB,&rDB);
 }
 
 @
-\section{view2d Makefile}
-<<view2d/Makefile>>=
-BOOK=${SPD}/books/bookvol8.pamphlet
-MIDINT=	${INT}/graph/view2d
-MIDOBJ=	${OBJ}/${SYS}/graph/view2d
-LIB=	${OBJ}/${SYS}/lib
-OUT=	${MNT}/${SYS}/lib
-
-LDFLAGS = ${LDF} ${STATIC} -lX11 -lm ${LDF}
-
-CFLAGS  = ${CCF} -I${SRC}/include
-
-VIEW2D_OBJS= \
- ${MIDOBJ}/buttons2d.o    ${MIDOBJ}/control2d.o ${MIDOBJ}/graph2d.o    \
- ${MIDOBJ}/main2d.o       ${MIDOBJ}/pot2d.o     ${MIDOBJ}/process2d.o  \
- ${MIDOBJ}/spadaction2d.o ${MIDOBJ}/stuff2d.o   ${MIDOBJ}/viewport2d.o \
- ${MIDOBJ}/write2d.o
-
-GDRAW=	${OBJ}/${SYS}/graph/gdraws
-
-GDRAW_OBJS = ${GDRAW}/gfun.o ${OBJ}/${SYS}/lib/hash.o
-
-LIBFILES=${LIB}/bsdsignal.o ${LIB}/util.o       ${LIB}/pixmap.o    \
-         ${LIB}/halloc.o    ${LIB}/spadcolors.o ${LIB}/xspadfill.o \
-         ${LIB}/xdither.o   ${LIB}/xshade.o 
-
-all: ${GDRAW_OBJS} ${LIBFILES} ${OUT}/view2d 
-	@ echo 36 finished bookvol8 view2d
-
-${OUT}/view2d: ${VIEW2D_OBJS} ${GDRAW_OBJS} ${LIBFILES}
-	@ echo 34 linking ${OUT}/view2d
-	@ ${CC} ${VIEW2D_OBJS} ${GDRAW_OBJS} ${LIBFILES} \
-	 -o ${OUT}/view2d $(LDFLAGS) 
-
-${MIDOBJ}/buttons2d.o: ${BOOK}
-	@ echo 2 making ${MIDOBJ}/buttons2d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	      ${TANGLE} -R"view2d/buttons2d.c" ${BOOK} >buttons2d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} -c ${CFLAGS} ${MIDINT}/buttons2d.c )
-
-${MIDOBJ}/control2d.o: ${BOOK}
-	@ echo 5 making ${MIDOBJ}/control2d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	      ${TANGLE} -R"view2d/control2d.c" ${BOOK} >control2d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} -c ${CFLAGS} ${MIDINT}/control2d.c )
-
-${MIDOBJ}/graph2d.o: ${BOOK}
-	@ echo 8 making ${MIDOBJ}/graph2d.o from ${BOOK}
-	@( cd ${MIDINT} ; ${TANGLE} -R"view2d/graph2d.c" ${BOOK} >graph2d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} -c ${CFLAGS} ${MIDINT}/graph2d.c )
-
-${MIDOBJ}/main2d.o: ${BOOK}
-	@ echo 11 making ${MIDOBJ}/main2d.o from ${BOOK}
-	@( cd ${MIDINT} ; ${TANGLE} -R"view2d/main2d.c" ${BOOK} >main2d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} -c ${CFLAGS} ${MIDINT}/main2d.c )
-
-${MIDOBJ}/pot2d.o: ${BOOK}
-	@ echo 14 making ${MIDOBJ}/pot2d.o from ${BOOK}
-	@( cd ${MIDINT} ; ${TANGLE} -R"view2d/pot2d.c" ${BOOK} >pot2d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} -c ${CFLAGS} ${MIDINT}/pot2d.c )
-
-${MIDOBJ}/process2d.o: ${BOOK}
-	@ echo 17 making ${MIDOBJ}/process2d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	      ${TANGLE} -R"view2d/process2d.c" ${BOOK} >process2d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} -c ${CFLAGS} ${MIDINT}/process2d.c )
-
-${MIDOBJ}/spadaction2d.o: ${BOOK}
-	@ echo 20 making ${MIDOBJ}/spadaction2d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	   ${TANGLE} -R"view2d/spadaction2d.c" ${BOOK} >spadaction2d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} -c ${CFLAGS} ${MIDINT}/spadaction2d.c )
-
-${MIDOBJ}/stuff2d.o: ${BOOK}
-	@ echo 26 making ${MIDOBJ}/stuff2d.o from ${BOOK}
-	@( cd ${MIDINT} ; ${TANGLE} -R"view2d/stuff2d.c" ${BOOK} >stuff2d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} -c ${CFLAGS} ${MIDINT}/stuff2d.c )
-
-${MIDOBJ}/viewport2d.o: ${BOOK}
-	@ echo 29 making ${MIDOBJ}/viewport2d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	   ${TANGLE} -R"view2d/viewport2d.c" ${BOOK} >viewport2d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} -c ${CFLAGS} ${MIDINT}/viewport2d.c )
-
-${MIDOBJ}/write2d.o: ${BOOK}
-	@ echo 32 making ${MIDOBJ}/write2d.o from ${BOOK}
-	@( cd ${MIDINT} ; ${TANGLE} -R"view2d/write2d.c" ${BOOK} >write2d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} -c ${CFLAGS} ${MIDINT}/write2d.c )
-
-@
-\section{pot2d.c}
-<<view2d/pot2d.c>>=
-#define _POT2D_C
-
-<<view2d/header2.h>>
-
-extern int initButtons(buttonStruct * );
-extern void writeControlTitle(void );
-extern void makeMessageFromData(int );
-extern void writeControlMessage(void );
-extern void drawControlPanel(void );
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void );
-extern void putControlPanelSomewhere(int );
-extern void clearControlMessage(void );
-extern void getGraphFromViewman(int );
-extern void freeGraph(int );
-extern int main(void);
-extern void mergeDatabases(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern void doPick(int  , int );
-extern void doDrop(int  , int );
-extern void clickedOnGraph(int  , int );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern void clickedOnGraphSelect(int  , int );
-#ifdef _PROCESS2D_C
-static void drawControlPushButton(int  , int );
-#endif
-extern int readViewman(void *  , int );
-extern int spadAction(void);
-extern float absolute(float);
-extern void goodbye(int);
-extern void writeTitle(void);
-extern void drawTheViewport(int );
-extern viewPoints * makeViewport(char *  , int  , int  , int  , int  , int );
-extern viewPoints * makeView2D(view2DStruct * );
-extern int writeViewport(int );
-
-
-mouseCoord 
-getPotValue(short eX,short eY,short xH,short yH)
-{
-
+\subsection{getPotValue}
+\index{view2d!getPotValue}
+\index{getPotValue view2d}
+<<view2d>>=
+mouseCoord getPotValue(short eX,short eY,short xH,short yH) {
   mouseCoord whereMouse;
   float x,y;
-
   x = (float)eX/xH - 1;
   y = -((float)eY/yH -1);
             /* make non-linear potentiometer */
   whereMouse.x = x*x*x; 
   whereMouse.y = y*y*y; 
-
   return(whereMouse);
-
 } /* getPotValue() */
-@
-\section{process2d.c}
-<<view2d/process2d.c>>=
-#define _PROCESS2D_C
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#ifdef RIOSplatform
-#include <sys/select.h>
-#endif
-
-<<view2d/header2.h>>
-
-extern int initButtons(buttonStruct * );
-extern void writeControlTitle(void );
-extern void makeMessageFromData(int );
-extern void writeControlMessage(void );
-extern void drawControlPanel(void );
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void );
-extern void putControlPanelSomewhere(int );
-extern void clearControlMessage(void );
-extern void getGraphFromViewman(int );
-extern void freeGraph(int );
-extern int main(void);
-extern void mergeDatabases(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern void doPick(int  , int );
-extern void doDrop(int  , int );
-extern void clickedOnGraph(int  , int );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern void clickedOnGraphSelect(int  , int );
-#ifdef _PROCESS2D_C
-static void drawControlPushButton(int  , int );
-#endif
-extern int readViewman(void *  , int );
-extern int spadAction(void);
-extern float absolute(float);
-extern void goodbye(int);
-extern void writeTitle(void);
-extern void drawTheViewport(int );
-extern viewPoints * makeViewport(char *  , int  , int  , int  , int  , int );
-extern viewPoints * makeView2D(view2DStruct * );
-extern int writeViewport(int );
 
-#include "util.h1"
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-#include "xspadfill.h1"
-
-
-static int doit=0;  /* globish variable for picking/dropping/clearing - all sorts of
-		2 button sequence events (command & graph #). */
-
-
-void 
-doPick (int i,int bKey)
-{
+@
+\subsection{doPick}
+\index{view2d!doPick}
+\index{doPick view2d}
+<<view2d>>=
+void doPick(int i,int bKey) {
   int vCommand=pick2D;
-  
   picking = no;
   /* reset indicator so that we're not in pick/drop/query mode anymore */
   doit = 0;
@@ -6318,17 +5534,16 @@ doPick (int i,int bKey)
   } else
     sprintf(control->message,"%s","This graph is empty!");
   writeControlMessage();
-  
-  
 }
 
-
-void 
-doDrop (int i,int bKey)
-{
+@
+\subsection{doDrop}
+\index{view2d!doDrop}
+\index{doDrop view2d}
+<<view2d>>=
+void doDrop(int i,int bKey) {
   int vCommand=drop2D;
   int viewGoAhead;
-  
   dropping = no;
   /* reset indicator so that we're not in pick/drop/query mode anymore */
   doit = 0;
@@ -6353,11 +5568,13 @@ doDrop (int i,int bKey)
   }
 }
 
-void 
-clickedOnGraphSelect (int i,int bKey)
-{
+@
+\subsection{clickedOnGraphSelect}
+\index{view2d!clickedOnGraphSelect}
+\index{clickedOnGraphSelect view2d}
+<<view2d>>=
+void clickedOnGraphSelect(int i,int bKey) {
   int strlength;
-  
   switch (doit) {
   case pick2D:
     currentGraph = i;
@@ -6390,7 +5607,6 @@ clickedOnGraphSelect (int i,int bKey)
       GSetForeground(graphGC,(float)foregroundColor,Xoption);
       GSetBackground(graphGC,(float)backgroundColor,Xoption);
     }
-    
     GDrawImageString(graphGC,control->controlWindow,
 		     control->buttonQueue[bKey].buttonX +
 		     centerX(graphGC,
@@ -6405,13 +5621,14 @@ clickedOnGraphSelect (int i,int bKey)
     GDrawLine(trashGC,control->controlWindow,0,286,controlWidth,286,Xoption);
     break;
   } /* switch doit */
-  
 }
 
-
-static void
-drawControlPushButton(int isOn, int index)
-{
+@
+\subsection{drawControlPushButton}
+\index{view2d!drawControlPushButton}
+\index{drawControlPushButton view2d}
+<<view2d>>=
+static void drawControlPushButton(int isOn, int index) {
   GDrawPushButton(dsply, processGC, processGC, processGC,
 		  control->controlWindow,
 		  (control->buttonQueue[index]).buttonX,
@@ -6425,15 +5642,14 @@ drawControlPushButton(int isOn, int index)
   XSync(dsply,False);
 }
 
-
-
-void 
-buttonAction (int bKey)
-{
+@
+\subsection{buttonAction}
+\index{view2d!buttonAction}
+\index{buttonAction view2d}
+<<view2d>>=
+void buttonAction(int bKey) {
   int i;
-  
   switch (bKey) {
-    
   case pick2D:
     if (viewAloned) {
       sprintf(control->message,"%s","Cannot pick without Axiom!");
@@ -6447,7 +5663,6 @@ buttonAction (int bKey)
       XSync(dsply,False);
     }
     break;
-    
   case drop2D:
     if (viewAloned) {
       sprintf(control->message,"%s","Cannot drop without Axiom!");
@@ -6460,28 +5675,21 @@ buttonAction (int bKey)
       XSync(dsply,False);
     }
     break;
-    
   case query2D:
     doit = query2D;
     sprintf(control->message,"%s","Click on the graph to query");
     writeControlMessage();
     XSync(dsply,False);
     break;
-    
-    
   case zoom2Dx:
     if (zoomXON)
-      strcpy((control->buttonQueue[zoom2Dx]).text ,
-	     "X Off");
+      strcpy((control->buttonQueue[zoom2Dx]).text ,"X Off");
     else
-      strcpy((control->buttonQueue[zoom2Dx]).text , 
-	     "X On ");
+      strcpy((control->buttonQueue[zoom2Dx]).text ,"X On ");
     zoomXON = !zoomXON;
-    
     drawControlPushButton(zoomXON, zoom2Dx);
     XSync(dsply,False);
     break;
-    
   case zoom2Dy:
     if (zoomYON) strcpy((control->buttonQueue[zoom2Dy]).text,
 			"Y Off");
@@ -6491,18 +5699,13 @@ buttonAction (int bKey)
     drawControlPushButton(zoomYON, zoom2Dy);
     XSync(dsply,False);
     break;
-    
-    
   case translate2Dx:
-    if (transXON) strcpy((control->buttonQueue[translate2Dx]).text,
-			 "X Off");
-    else strcpy( (control->buttonQueue[translate2Dx]).text,
-		 "X On ");
+    if (transXON) strcpy((control->buttonQueue[translate2Dx]).text,"X Off");
+    else strcpy( (control->buttonQueue[translate2Dx]).text,"X On ");
     transXON = !transXON;
     drawControlPushButton(transXON, translate2Dx);
     XSync(dsply,False);
     break;
-    
   case translate2Dy:
     if (transYON) strcpy((control->buttonQueue[translate2Dy]).text,
 			 "Y Off");
@@ -6512,7 +5715,6 @@ buttonAction (int bKey)
     drawControlPushButton(transYON, translate2Dy);
     XSync(dsply,False);
     break;
-    
   case pointsOnOff:
     if (pointsON) strcpy((control->buttonQueue[pointsOnOff]).text,
 			 "Pts Off");
@@ -6522,76 +5724,59 @@ buttonAction (int bKey)
     for (i=0; i<maxGraphs; i++)
       if (graphStateArray[i].showing && graphStateArray[i].selected)
 	graphStateArray[i].pointsOn = pointsON;
-    
     drawControlPushButton(pointsON, pointsOnOff);
     drawViewport(Xoption);
     break;
-    
   case connectOnOff:
-    if (connectON) strcpy((control->buttonQueue[connectOnOff]).text,
-			  "Lines Off");
-    else strcpy( (control->buttonQueue[connectOnOff]).text,
-		 "Lines On ");
+    if (connectON) 
+      strcpy((control->buttonQueue[connectOnOff]).text,"Lines Off");
+    else 
+      strcpy( (control->buttonQueue[connectOnOff]).text,"Lines On ");
     connectON = !connectON;
     for (i=0; i<maxGraphs; i++)
       if (graphStateArray[i].showing && graphStateArray[i].selected)
 	graphStateArray[i].connectOn = connectON;
-    
     drawControlPushButton(connectON, connectOnOff);
     drawViewport(Xoption);
     break;
-    
   case spline2D:
-    if (splineON) strcpy((control->buttonQueue[spline2D]).text,
-			 "Box Off");
-    else strcpy ((control->buttonQueue[spline2D]).text ,
-		 "Box On ");
+    if (splineON) strcpy((control->buttonQueue[spline2D]).text,"Box Off");
+    else strcpy ((control->buttonQueue[spline2D]).text ,"Box On ");
     splineON = !splineON;
     for (i=0; i<maxGraphs; i++)
       if (graphStateArray[i].showing && graphStateArray[i].selected)
 	graphStateArray[i].splineOn = splineON;
-    
     drawControlPushButton(splineON, spline2D);
     drawViewport(Xoption);
     break;
-    
   case axesOnOff2D:
     if (axesON)
-      strcpy ((control->buttonQueue[axesOnOff2D]).text,
-	      "Axes Off");
+      strcpy ((control->buttonQueue[axesOnOff2D]).text,"Axes Off");
     else
-      strcpy ((control->buttonQueue[axesOnOff2D]).text ,
-	      "Axes On ");
+      strcpy ((control->buttonQueue[axesOnOff2D]).text,"Axes On ");
     axesON = !axesON;
     for (i=0; i<maxGraphs; i++)
       if (graphStateArray[i].showing && graphStateArray[i].selected)
 	graphStateArray[i].axesOn = axesON;
-    
     drawControlPushButton(axesON, axesOnOff2D);
     drawViewport(Xoption);
     break;
-    
   case unitsOnOff2D:
     if (unitsON)
-      strcpy( (control->buttonQueue[unitsOnOff2D]).text,
-	      "Units Off");
+      strcpy( (control->buttonQueue[unitsOnOff2D]).text,"Units Off");
     else
-      strcpy ((control->buttonQueue[unitsOnOff2D]).text,
-	      "Units On ");
+      strcpy ((control->buttonQueue[unitsOnOff2D]).text,"Units On ");
     unitsON = !unitsON;
     for (i=0; i<maxGraphs; i++)
       if (graphStateArray[i].showing && graphStateArray[i].selected)
 	graphStateArray[i].unitsOn = unitsON;
-    
     drawControlPushButton(unitsON, unitsOnOff2D);
     drawViewport(Xoption);
     break;
-    
   case ps2D:
     strcpy(control->message,"Creating postscript now ...");
     writeControlMessage();
     drawControlPushButton(1, ps2D);
-    
     if (PSInit(viewport->viewWindow, viewport->titleWindow) == psError) {
       strcpy(control->message,"Aborted: PSInit error.");
       writeControlMessage();
@@ -6599,9 +5784,7 @@ buttonAction (int bKey)
       XSync(dsply,False);
       return;	/* make new temp name for new file */
     }
-    
     drawViewport(PSoption);	/* draw picture in PS; create ps script file */
-    
     if (PSCreateFile(viewBorderWidth, 
 		     viewport->viewWindow,
 		     viewport->titleWindow, 
@@ -6612,7 +5795,6 @@ buttonAction (int bKey)
       XSync(dsply,False);
       return;
     }
-    
     clearControlMessage();
     strcpy(control->message,PSfilename);
     strcat(control->message," in working dir ");
@@ -6620,7 +5802,6 @@ buttonAction (int bKey)
     drawControlPushButton(0, ps2D);
     XSync(dsply,False);
     break;
-    
   case hideControl2D:
     if (viewport->haveControl) {
       viewport->haveControl = no;
@@ -6628,41 +5809,35 @@ buttonAction (int bKey)
       XSync(dsply,False);
     }
     break;
-    
   case reset2D:
     /* reset view */
     for (i=0; i<maxGraphs; i++)
       if (graphStateArray[i].showing && graphStateArray[i].selected)
 	graphStateArray[i] = graphStateBackupArray[i];
-    
     unitsON = no;
     strcpy( (control->buttonQueue[unitsOnOff2D]).text,s	 = "Units Off");
     for (i=0; i<maxGraphs; i++)
       if (graphStateArray[i].showing && graphStateArray[i].selected)
 	graphStateArray[i].unitsOn = no;
     drawControlPushButton(unitsON, unitsOnOff2D);
-    
     pointsON = yes;
     strcpy ((control->buttonQueue[pointsOnOff]).text ,"Pts On ");
     for (i=0; i<maxGraphs; i++)
       if (graphStateArray[i].showing && graphStateArray[i].selected)
 	graphStateArray[i].pointsOn = yes;
     drawControlPushButton(pointsON, pointsOnOff);
-    
     axesON = yes;
     strcpy ((control->buttonQueue[axesOnOff2D]).text,"Axes On ");
     for (i=0; i<maxGraphs; i++)
       if (graphStateArray[i].showing && graphStateArray[i].selected)
 	graphStateArray[i].axesOn = yes;
     drawControlPushButton(axesON, axesOnOff2D);
-    
     connectON = yes;
     strcpy((control->buttonQueue[connectOnOff]).text,"Lines On ");
     for (i=0; i<maxGraphs; i++)
       if (graphStateArray[i].showing && graphStateArray[i].selected)
 	graphStateArray[i].connectOn = yes;
     drawControlPushButton(connectON, connectOnOff);
-    
     splineON = no;
     strcpy( (control->buttonQueue[connectOnOff]).text ,"Box Off");
     for (i=0; i<maxGraphs; i++)
@@ -6670,9 +5845,7 @@ buttonAction (int bKey)
 	graphStateArray[i].splineOn = splineON;
     drawControlPushButton(splineON, spline2D);
     drawViewport(Xoption);
-    
     break;
-    
   case closeAll2D:
     strcpy(control->message,"       Click again to confirm       ");
     writeControlMessage();
@@ -6680,7 +5853,6 @@ buttonAction (int bKey)
     XSync(dsply,False);
     viewport->closing = yes;
     break;
-    
   case clear2D:
     for (i=0; i<maxGraphs; i++) graphStateArray[i].selected = 1;
     clickedOnGraphSelect(0,graphSelect1);
@@ -6694,7 +5866,6 @@ buttonAction (int bKey)
     clickedOnGraphSelect(8,graphSelect9);
     XSync(dsply,False);
     break;
-    
   case graph1:
   case graph2:
   case graph3:
@@ -6707,7 +5878,6 @@ buttonAction (int bKey)
     clickedOnGraph(bKey-graphStart,bKey);
     XSync(dsply,False);
     break;
-    
   case graphSelect1:
   case graphSelect2:
   case graphSelect3:
@@ -6720,21 +5890,21 @@ buttonAction (int bKey)
     clickedOnGraphSelect(bKey-graphSelectStart,bKey);
     XSync(dsply,False);
     break;
-    
   } /* switch (action) */
 }
 
-/*********************** X Event Processing ***************************/
-void 
-processEvents(void)
-{
-  
+@
+\subsection{processEvents}
+\index{view2d!processEvents}
+\index{processEvents view2d}
+<<view2d>>=
+void processEvents(void) {
   XEvent                  *event,
     tempEvent;
   Window                  whichWindow;
   XWindowAttributes       graphWindowAttrib;
   buttonStruct            *controlButton;
-  mouseCoord              mouseXY;
+  mouseCoord              mouseXY = {0.0,0.0};
   int                     i,
     someInt,
     mouseW4,
@@ -6749,27 +5919,19 @@ processEvents(void)
     len,
     externalControl;
   fd_set                  rd;
-  
-  
   externalControl=0;
   Xcon = ConnectionNumber(dsply);
-  
-  
   if (!(event = (XEvent *)malloc(sizeof(XEvent)))) {
     fprintf(stderr,"Ran out of memory initializing event processing.\n");
     exitWithAck(RootWindow(dsply,scrn),Window,-1);
   }
-  
   controlButton = control->buttonQueue;
-  
   while(1) {
-    
     len=0;
     while(len<=0) {
       FD_ZERO(&rd);
       if (externalControl==0) FD_SET(0, &rd);
       FD_SET(Xcon,&rd);
-      
       if (XEventsQueued(dsply, QueuedAlready)) {
 	len=1;
 	break;
@@ -6791,16 +5953,12 @@ processEvents(void)
 	XNextEvent(dsply,event);
 	gotEvent++;
       }
-      
       if (gotToggle || !followMouse) 
 	checkButton = no;
-      
       if (gotEvent) {
 	whichWindow = ((XButtonEvent *)event)->window;
 	firstTime = no;
-	
 	switch(((XEvent *)event)->type) {
-	  
 	case ClientMessage:
 	  if (event->xclient.data.l[0] == wm_delete_window) {
 	    	  goodbye(-1);
@@ -6859,7 +6017,6 @@ processEvents(void)
 	    break;
 	  }
 	  break;
-	  
 	case MotionNotify:
 	  if (followMouse) {
 	    while (XCheckMaskEvent(dsply,
@@ -6875,7 +6032,6 @@ processEvents(void)
 	    checkButton = yes;
 	  }
 	  break;
-	  
 	case ButtonRelease:
 	  if (followMouse==yes) {
 	    followMouse = no;
@@ -6888,7 +6044,6 @@ processEvents(void)
 	    checkButton = no;
 	  }
 	  break;
-	  
 	case LeaveNotify:
 	  /*
 	    We still follow the mouse when we leave the pots.
@@ -6898,17 +6053,12 @@ processEvents(void)
 		  toggleReady = yes; 
 		  checkButton = no; 
 		  */
-
 	  break;
-	  
 	case ButtonPress:
 	  if (whichWindow == viewport->viewWindow) {
-	    
 	    /* mouse clicked on viewport */
-
 	    switch (((XButtonEvent *)event)->button) {
 	    case Button3:
-
 	      /* print out (x,y) object-space coordinates in message area */
 
 	      XGetWindowAttributes(dsply,whichWindow,&graphWindowAttrib);
@@ -6923,12 +6073,8 @@ processEvents(void)
 	      XFlush(dsply);
 	      break;
 	    default:
-
 	      /* Find where mouse is on the viewport => where to put the CP */
-
-	      XGetWindowAttributes(dsply,
-				   whichWindow,
-				   &graphWindowAttrib);
+	      XGetWindowAttributes(dsply,whichWindow,&graphWindowAttrib);
 	      mouseW4 = graphWindowAttrib.width/4;
 	      if (((XButtonEvent *)event)->x >
 		  (graphWindowAttrib.width - mouseW4))
@@ -6953,22 +6099,17 @@ processEvents(void)
 	      break;
 	    } /* switch on mouse button */
 	  } else if (whichWindow == control->colormapWindow) {
-
 	    /* mouse clicked on colormap */
-
 	    followMouse	= yes;
 	    gotToggle	= no;
 	    checkButton	= yes;
 	    firstTime	= yes;
 	  } else if (whichWindow != control->controlWindow) {
-
 	    /* mouse clicked on control window (not colormap) */
-
 	    if (controlButton->self != whichWindow) {
 	      buttonTablePtr = *((int *)XLookUpAssoc(dsply,table,whichWindow));
 	      controlButton = &(control->buttonQueue[buttonTablePtr]);
 	    }
-	    
 	    if (controlButton->pot) {
 	      /* figure out [x,y] for this button in the range [-1..1,-1..1] */
 	      mouseXY = getPotValue(((XButtonEvent *)event)->x,
@@ -6988,14 +6129,10 @@ processEvents(void)
 	    firstTime   = yes;
 	  }
 	  break;
-	  
 	} /* switch */
 	gotEvent--;
       } /* if gotEvent */
-      
-      
       /* Allow repeat polling when mouse button clicked on a potentiometer. */
-
       if (followMouse && !firstTime && (followMouse++ > mouseWait)) {
 	followMouse = yes;   /* reset for next timing loop */
 	checkButton = yes;
@@ -7011,9 +6148,7 @@ processEvents(void)
 	      ((controlButton->buttonKey < graphStart) &&
 	       (controlButton->buttonKey > (graphSelectStart + maxGraphs))))
 	    doit = 0;
-	  
 	  switch(controlButton->buttonKey) {
-	    
 	  case translate2D:
 	    for (i=0; i<maxGraphs; i++) {
 	      if (graphStateArray[i].showing && graphStateArray[i].selected) {
@@ -7035,7 +6170,6 @@ processEvents(void)
 	    }  /* for graphs */
 	    drawViewport(Xoption);
 	    break;
-	    
 	  case scale2D:
 	    for (i=0; i<maxGraphs; i++) {
 	      if (graphStateArray[i].showing && graphStateArray[i].selected) {
@@ -7071,15 +6205,12 @@ processEvents(void)
   } /* while */
 } /* processEvents() */
 
-
-
-
-
-
-void 
-clickedOnGraph (int i,int bKey)
-{
-  
+@
+\subsection{clickedOnGraph}
+\index{view2d!clickedOnGraph}
+\index{clickedOnGraph view2d}
+<<view2d>>=
+void clickedOnGraph(int i,int bKey) {  
   switch (doit) {
   case pick2D:
     currentGraph = queriedGraph = i;
@@ -7107,15 +6238,15 @@ clickedOnGraph (int i,int bKey)
 	GSetBackground(graphGC,(float)backgroundColor,Xoption);
       }
       GDrawImageString(graphGC,
-		       control->controlWindow,
-		       (control->buttonQueue[bKey]).buttonX +
-		       centerX(graphGC,(control->buttonQueue[bKey]).text,1,
-			       (control->buttonQueue[bKey]).buttonWidth),
-		       (control->buttonQueue[bKey]).buttonY +
-		       centerY(graphGC,(control->buttonQueue[bKey]).buttonHeight),
-		       (control->buttonQueue[bKey]).text,
-		       1,
-		       Xoption);
+	       control->controlWindow,
+	       (control->buttonQueue[bKey]).buttonX +
+	       centerX(graphGC,(control->buttonQueue[bKey]).text,1,
+		       (control->buttonQueue[bKey]).buttonWidth),
+	       (control->buttonQueue[bKey]).buttonY +
+	       centerY(graphGC,(control->buttonQueue[bKey]).buttonHeight),
+	       (control->buttonQueue[bKey]).text,
+	       1,
+	       Xoption);
     } else {
       if (graphStateArray[i].showing)
 	GSetForeground(graphGC,(float)graphBarShowingColor,Xoption);
@@ -7133,100 +6264,37 @@ clickedOnGraph (int i,int bKey)
     drawViewport(Xoption);
     break;
   } /* switch doit */
-  
 }
 
-
-
-
-
-
-
-
-
 @
-\section{spadaction2d.c}
-<<view2d/spadaction2d.c>>=
-#define _SPADACTION2D_C
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-<<view2d/header2.h>>
-
-extern int initButtons(buttonStruct * );
-extern void writeControlTitle(void );
-extern void makeMessageFromData(int );
-extern void writeControlMessage(void );
-extern void drawControlPanel(void );
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void );
-extern void putControlPanelSomewhere(int );
-extern void clearControlMessage(void );
-extern void getGraphFromViewman(int );
-extern void freeGraph(int );
-extern int main(void);
-extern void mergeDatabases(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern void doPick(int  , int );
-extern void doDrop(int  , int );
-extern void clickedOnGraph(int  , int );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern void clickedOnGraphSelect(int  , int );
-#ifdef _PROCESS2D_C
-static void drawControlPushButton(int  , int );
-#endif
-extern int readViewman(void *  , int );
-extern int spadAction(void);
-extern float absolute(float);
-extern void goodbye(int);
-extern void writeTitle(void);
-extern void drawTheViewport(int );
-extern viewPoints * makeViewport(char *  , int  , int  , int  , int  , int );
-extern viewPoints * makeView2D(view2DStruct * );
-extern int writeViewport(int );
-
-#include "util.h1"
-
-
-/******************************
- * int readViewman(info,size) *
- ******************************/
-
-int 
-readViewman(void * info,int size)
-{
+\subsection{readViewman}
+\index{view2d!readViewman}
+\index{readViewman view2d}
+<<view2d>>=
+int readViewman(void * info,int size) {
   int mold = 0;
-
   sprintf(errorStr,"%s %d %s","read of ",size,
 	  " bytes from viewport manager\n");
   mold = check(read(0,info,size));   
   return(mold);
-
 }
 
-/********************
- * int spadAction() *
- ********************/
-extern int viewAloned;
-int 
-spadAction(void)
-{
+@
+\subsection{spadAction}
+\index{view2d!spadAction}
+\index{spadAction view2d}
+<<view2d>>=
+int spadAction(void) {
   int code,viewCommand;
   float f1,f2;
   int i1,i2,i3,viewGoAhead;
   static int ack = 1;
-
   if (viewAloned==yes) {
       close(0);
       return(-1);
       }
   readViewman(&viewCommand,intSize);
-
   switch (viewCommand) {
-
   case hideControl2D:
     readViewman(&i1,intSize);
     if (i1) {                         /* show control panel */
@@ -7239,7 +6307,6 @@ spadAction(void)
       }
     }
     break;
-
   case changeTitle:
     readViewman(&i1,intSize);
     readViewman(viewport->title,i1);
@@ -7249,7 +6316,6 @@ spadAction(void)
     XFlush(dsply);
     spadDraw=no;
     break;
-
   case writeView:
     readViewman(&i1,intSize);
     readViewman(filename,i1);
@@ -7264,16 +6330,13 @@ spadAction(void)
     if (writeViewport(i3) < 0)
       fprintf(stderr,"          Nothing was written\n");
     break;
-
   case closeAll2D:
     code = check(write(Socket,&ack,intSize));
     goodbye(-1);
-
   case ps2D:
     readViewman(&i1,intSize);
     buttonAction(viewCommand);
     break;
-
   case axesOnOff2D:
     readViewman(&i1,intSize);
     i1--;
@@ -7281,7 +6344,6 @@ spadAction(void)
     graphStateArray[i1].axesOn = i2;
     if (graphStateArray[i1].showing) spadDraw=yes;
     break;
-
   case axesColor2D:
     readViewman(&i1,intSize);
     i1--;
@@ -7289,7 +6351,6 @@ spadAction(void)
     graphStateArray[i1].axesColor = i2;
     if (graphStateArray[i1].showing) spadDraw=yes;
     break;
-
   case unitsOnOff2D:
     readViewman(&i1,intSize);
     i1--;
@@ -7297,7 +6358,6 @@ spadAction(void)
     graphStateArray[i1].unitsOn = i2;
     if (graphStateArray[i1].showing) spadDraw=yes;
     break;
-
   case unitsColor2D:
     readViewman(&i1,intSize);
     i1--;
@@ -7305,7 +6365,6 @@ spadAction(void)
     graphStateArray[i1].unitsColor = i2;
     if (graphStateArray[i1].showing) spadDraw=yes;
     break;
-
   case connectOnOff:
     readViewman(&i1,intSize);
     i1--;
@@ -7313,7 +6372,6 @@ spadAction(void)
     graphStateArray[i1].connectOn = i2; 
     if (graphStateArray[i1].showing) spadDraw=yes;
     break;
-
   case pointsOnOff:
     readViewman(&i1,intSize);
     i1--;
@@ -7321,7 +6379,6 @@ spadAction(void)
     graphStateArray[i1].pointsOn = i2;
     if (graphStateArray[i1].showing) spadDraw=yes;
     break;
-
   case spline2D:
     readViewman(&i1,intSize);
     i1--;
@@ -7329,7 +6386,6 @@ spadAction(void)
     graphStateArray[i1].splineOn = i2;
     if (graphStateArray[i1].showing) spadDraw=yes;
     break;
-
   case showing2D:
     readViewman(&i1,intSize);
     i1--;
@@ -7338,7 +6394,6 @@ spadAction(void)
     graphStateArray[i1].showing = !i2;
     clickedOnGraph(i1,i1+graphStart);
     break;
-
   case scale2D:
     readViewman(&i1,intSize);
     i1--;   /* passed index is [1..9] but internal representation is [0..8] */
@@ -7358,8 +6413,6 @@ spadAction(void)
         graphStateArray[i1].scaleY = minScale;
     if (graphStateArray[i1].showing) spadDraw=yes;
     break;   /* scale2D */
-
-
   case translate2D:
     readViewman(&i1,intSize);
     i1--;   /* passed index is [1..9] but internal representation is [0..8] */
@@ -7377,14 +6430,12 @@ spadAction(void)
            graphStateArray[i1].centerY = maxDelta;
     if (graphStateArray[i1].showing) spadDraw=yes;
     break;   /* translate2D */
-
   case moveViewport:
     readViewman(&i1,intSize);
     readViewman(&i2,intSize);
     XMoveWindow(dsply,viewport->titleWindow,i1,i2);
     XSync(dsply,False);
     break;
-
  case resizeViewport:
     readViewman(&i1,intSize);
     readViewman(&i2,intSize);
@@ -7392,7 +6443,6 @@ spadAction(void)
     XResizeWindow(dsply,viewport->viewWindow,i1,i2);
     spadDraw=yes;
     break;
-
   case putGraph:
     readViewman(&i1,intSize);   	/* key of graph to get */
     readViewman(&i2,intSize);   	/* slot to drop graph onto 0..8*/
@@ -7415,114 +6465,24 @@ spadAction(void)
       clickedOnGraphSelect(i2,i2+graphSelectStart);
     }
     break;
-
   case spadPressedAButton:
     readViewman(&i1,intSize);
     buttonAction(i1);
     break;
-
   default:
     return(-1);
   } /* switch */
-
-
   ack++;
   code = check(write(Socket,&ack,intSize));
   return(0);
-
 }
 
 @
-\section{stuff2d.c}
-<<view2d/stuff2d.c>>=
-#define _STUFF2D_C
-
-#include <unistd.h>
-#include <stdlib.h>
-
-<<view2d/header2.h>>
-
-extern int initButtons(buttonStruct * );
-extern void writeControlTitle(void );
-extern void makeMessageFromData(int );
-extern void writeControlMessage(void );
-extern void drawControlPanel(void );
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void );
-extern void putControlPanelSomewhere(int );
-extern void clearControlMessage(void );
-extern void getGraphFromViewman(int );
-extern void freeGraph(int );
-extern int main(void);
-extern void mergeDatabases(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern void doPick(int  , int );
-extern void doDrop(int  , int );
-extern void clickedOnGraph(int  , int );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern void clickedOnGraphSelect(int  , int );
-#ifdef _PROCESS2D_C
-static void drawControlPushButton(int  , int );
-#endif
-extern int readViewman(void *  , int );
-extern int spadAction(void);
-extern float absolute(float);
-extern void goodbye(int);
-extern void writeTitle(void);
-extern void drawTheViewport(int );
-extern viewPoints * makeViewport(char *  , int  , int  , int  , int  , int );
-extern viewPoints * makeView2D(view2DStruct * );
-extern int writeViewport(int );
-
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-#include "util.h1"
-
-
-/**************************/
-/***  float absolute(x) ***/
-/**************************/
-
-float 
-absolute(float x)
-{
+\subsection{absolute}
+\index{view2d!absolute}
+\index{absolute view2d}
+<<view2d>>=
+float absolute(float x) {
   if (x<0.0) {
     return(-x);
   } else {
@@ -7530,22 +6490,17 @@ absolute(float x)
   }
 }
 
-
-
-/************************/
-/***  void goodbye()  ***/
-/************************/
-
-void 
-goodbye(int sig)
-{
+@
+\subsection{goodbye}
+\index{view2d!goodbye}
+\index{goodbye view2d}
+<<view2d>>=
+void goodbye(int sig) {
   int Command,i;
-
 #ifdef DEBUG
   fprintf(stderr,"view2d: Tidying up and exiting\n");
 #endif
   PSClose(); /* free PS file and data structure space */
-
   XFreeGC(dsply,globalGC1);
   XFreeGC(dsply,globalGC2);
   XFreeGC(dsply,globGC);
@@ -7554,148 +6509,32 @@ goodbye(int sig)
   XFreeGC(dsply,controlMessageGC);
   XFreeGC(dsply,graphGC);
   XFreeGC(dsply,unitGC);
-
   XFreeFont(dsply,globalFont);
   XFreeFont(dsply,buttonFont);
   XFreeFont(dsply,headerFont);
   XFreeFont(dsply,titleFont);
   XFreeFont(dsply,graphFont);
   XFreeFont(dsply,unitFont);
-
   XFreeColormap(dsply,colorMap);
-
   /** send off the current graphs to viewport manager **/
-
   Command = viewportClosing;
   check(write(Socket,&Command,intSize));
-
   for (i=0; i<maxGraphs;i++) {
     check(write(Socket,&graphArray[i].key,intSize));
   }
   close(Socket);
   XCloseDisplay(dsply);
   exit(0);
-
 }
 
-
-
-
-
-
 @
-\section{viewport2d.c}
-<<view2d/viewport2d.c>>=
-#define _VIEWPORT2D_C
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <math.h>
-#include <X11/X.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <limits.h>
-
-#define NotPoint	(SHRT_MAX)
-#define eqNANQ(x)	(x == NotPoint)
-
-<<view2d/header2.h>>
-
-extern int initButtons(buttonStruct * );
-extern void writeControlTitle(void );
-extern void makeMessageFromData(int );
-extern void writeControlMessage(void );
-extern void drawControlPanel(void );
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void );
-extern void putControlPanelSomewhere(int );
-extern void clearControlMessage(void );
-extern void getGraphFromViewman(int );
-extern void freeGraph(int );
-extern int main(void);
-extern void mergeDatabases(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern void doPick(int  , int );
-extern void doDrop(int  , int );
-extern void clickedOnGraph(int  , int );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern void clickedOnGraphSelect(int  , int );
-#ifdef _PROCESS2D_C
-static void drawControlPushButton(int  , int );
-#endif
-extern int readViewman(void *  , int );
-extern int spadAction(void);
-extern float absolute(float);
-extern void goodbye(int);
-extern void writeTitle(void);
-extern void drawTheViewport(int );
-extern viewPoints * makeViewport(char *  , int  , int  , int  , int  , int );
-extern viewPoints * makeView2D(view2DStruct * );
-extern int writeViewport(int );
-
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-#include "util.h1"
-#include "xspadfill.h1"
-
-<<include/purty/spadbitmap.bitmap>>
-<<include/purty/spadmask.mask>>
-
-#define rint(z) ((int)(z))
-
-Atom    wm_delete_window;               
-
-
-/*************************** 
- ***  void writeTitle()  *** 
- ***************************/
-
-void 
-writeTitle(void)
-{
-
+\subsection{writeTitle}
+\index{view2d!writeTitle}
+\index{writeTitle view2d}
+<<view2d>>=
+void writeTitle(void) {
   int strlength;
   XWindowAttributes attribInfo;
-  
   XGetWindowAttributes(dsply,viewport->titleWindow,&attribInfo);
   if (mono) GSetForeground(anotherGC,(float)foregroundColor,Xoption);
   else GSetForeground(anotherGC,(float)titleColor,Xoption);
@@ -7704,18 +6543,14 @@ writeTitle(void)
   GDrawImageString(anotherGC,viewport->titleWindow,
               centerX(anotherGC,viewport->title,strlength,attribInfo.width),
               15,viewport->title,strlength,Xoption);
-
 }
 
-
-/********************************/
-/***  void drawTheViewport()  ***/
-/********************************/
-
-void 
-drawTheViewport(int dFlag)
-{
-
+@
+\subsection{drawTheViewport}
+\index{view2d!drawTheViewport}
+\index{drawTheViewport view2d}
+<<view2d>>=
+void drawTheViewport(int dFlag) {
   Window            vw;
   XWindowAttributes vwInfo;
   pointListStruct   *aList;
@@ -7731,35 +6566,25 @@ drawTheViewport(int dFlag)
   int               unitWidth,boxX,boxY,boxW,boxH;
   char              aunit[20];
   XCharStruct       overall;
-
   drawMore = yes;
   vw = viewport->viewWindow;
   XGetWindowAttributes(dsply,vw,&vwInfo);
   aspectR = (float)vwInfo.width/(float)vwInfo.height;
-
   XTextExtents(unitFont,"o",1,&dummyInt,&ascent,&descent,&overall);
   halfheight = (ascent + descent) / 2;
-
   /* Calculate various factors for use in projection. */
   /* Scale the plot, so that the scaling between the axes remains 
      constant and fits within the smaller of the two dimensions. */
-
   charlength = overall.width;
-
   if (dFlag==Xoption) XClearWindow(dsply,vw);
-
   for (i=0; i<maxGraphs; i++) {
-
     if ((graphArray[i].key) && (graphStateArray[i].showing)) {
-
       /* Scale y coordinate dimensions relative to viewport aspect ratio. */
-     
       graphArray[i].yNorm = 1.0/((graphArray[i].ymax-graphArray[i].ymin) *
                                  aspectR);
       graphArray[i].originY = -graphArray[i].ymin*graphArray[i].yNorm 
 	- 0.5/aspectR;
       graphArray[i].unitY = graphArray[i].spadUnitY*graphArray[i].yNorm;
-
       xAxis = rint(vwInfo.width *
 		   ((graphArray[0].originX - graphStateArray[0].centerX) *
 		    graphStateArray[0].scaleX + 0.5));
@@ -7767,13 +6592,11 @@ drawTheViewport(int dFlag)
 		  (1 - ((graphArray[0].originY*aspectR - 
 			 graphStateArray[0].centerY) *
 			graphStateArray[0].scaleY + 0.5*aspectR )));
-
       if (graphStateArray[i].axesOn) {
         if (dFlag==Xoption) /* do only for X, ps uses default of black */
           GSetForeground(globalGC1,
 			 (float)monoColor(graphStateArray[i].axesColor),
 			 dFlag);
-			 
 	if ((yAxis >=0) && (yAxis <= vwInfo.height))
           GDrawLine(globalGC1,vw,
 		    0,yAxis,
@@ -7785,20 +6608,15 @@ drawTheViewport(int dFlag)
 		    xAxis,vwInfo.height,
 		    dFlag);
       }
-        
-
       tempXpt   = anXPoint   = xPointsArray[i].xPoint;
       anX10Point = xPointsArray[i].x10Point;
       anXarc     = xPointsArray[i].arc;
-
       for (j=0,aList=graphArray[i].listOfListsOfPoints;
            (j<graphArray[i].numberOfLists);
            j++, aList++) {
-
         for (k=0,aPoint=aList->listOfPoints;
              (k<aList->numberOfPoints); 
              k++,aPoint++) {
-
           if (graphStateArray[i].scaleX > 99.0)
             graphStateArray[i].scaleX = 99.0;
           if (graphStateArray[i].scaleY > 99.0)
@@ -7943,15 +6761,12 @@ drawTheViewport(int dFlag)
           boxY = vwInfo.height * aspectR *
 	    (1 - ((0.5 - graphStateArray[i].centerY)*
 		  graphStateArray[i].scaleY + 0.5*aspectR));
-
           boxW = graphStateArray[i].scaleX * vwInfo.width + 1;
           boxH = graphStateArray[i].scaleY * vwInfo.height * aspectR + 1;
-
           GDrawRectangle(globalGC1,vw,
 			 boxX,boxY,boxW,boxH,
 			 dFlag);
         }
-
         tempXpt = anXPoint;
       }     /* for a aList in listofListsOfPoints */
       if (graphStateArray[i].unitsOn) {
@@ -7960,14 +6775,11 @@ drawTheViewport(int dFlag)
           GSetForeground(unitGC,
 			 (float)monoColor(graphStateArray[i].unitsColor),
 			 dFlag);
- 
-
         tickStart   = calcUnitX(0);
         oneTickUnit = calcUnitX(1) - tickStart;
-
         /* ticks along the positive X axis */
-
-        unitWidth = 5*overall.width;            /* limit on acceptable separation : 5 chars */
+        /* limit on acceptable separation : 5 chars */
+        unitWidth = 5*overall.width; 
         k = floor(unitWidth/oneTickUnit) +1;    /* get skipping integer */
         for (ii=0, jj = tickStart;
 	     jj < vwInfo.width;
@@ -7976,76 +6788,49 @@ drawTheViewport(int dFlag)
 
 	    /* ticks stuck to viewport*/
 	    GDrawLine(unitGC,vw,
-		      (int)rint(jj),vwInfo.height-8,(int)rint(jj),vwInfo.height-4,
-		      dFlag);
-
+	      (int)rint(jj),vwInfo.height-8,(int)rint(jj),vwInfo.height-4,
+	      dFlag);
 	    sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitX);
 	    strlength=strlen(aunit);
 	    halflength=XTextWidth(unitFont,aunit,strlength)/2;
-
-	    if (dFlag == Xoption) GDrawImageString(unitGC,
-					     vw,
-					     (int)rint(jj) - halflength,
-					     vwInfo.height -8 -descent, 
-					     aunit,
-					     strlength, 
-					     dFlag);
-	    if (dFlag == PSoption) GDrawImageString(unitGC,
-					      vw,
-					      (int)rint(jj) -(strlength*3) ,
-					      vwInfo.height -14, 
-					      aunit,
-					      strlength, 
-					      dFlag); 
+	    if (dFlag == Xoption) 
+              GDrawImageString(unitGC,vw,(int)rint(jj) - halflength,
+                               vwInfo.height-8-descent,aunit,strlength,dFlag);
+	    if (dFlag == PSoption) 
+              GDrawImageString(unitGC,vw,(int)rint(jj) -(strlength*3),
+                               vwInfo.height-14,aunit,strlength,dFlag); 
 	    /* these are "eyeball" parameters for the given PS font */
-              
 	  }
-            
 	}
         /* ticks along the negative X axis */
         for (ii=-k,jj=tickStart - k*oneTickUnit;
 	     jj > 0;
 	     ii=ii-k,jj = jj-k*oneTickUnit) {
 	  if (jj <= vwInfo.width) {
-
 	    /* ticks stuck to viewport*/
-	    GDrawLine(unitGC,vw,
-		      (int)rint(jj),vwInfo.height-8,(int)rint(jj),vwInfo.height-4,
-		      dFlag);
-
+	    GDrawLine(unitGC,vw,(int)rint(jj),vwInfo.height-8,(int)rint(jj),
+                      vwInfo.height-4,dFlag);
 	    sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitX);
 	    strlength=strlen(aunit);
 	    halflength=XTextWidth(unitFont,aunit,strlength)/2;
-
-	    if (dFlag == Xoption) GDrawImageString(unitGC,
-					     vw,
-					     (int)rint(jj) - halflength,
-					     vwInfo.height -8 -descent, 
-					     aunit,
-					     strlength, 
-					     dFlag);
-	    if (dFlag == PSoption) GDrawImageString(unitGC,
-					      vw,
-					      (int)rint(jj) -(strlength*3) ,
-					      vwInfo.height -14, 
-					      aunit,
-					      strlength, 
-					      dFlag);
+	    if (dFlag == Xoption) 
+              GDrawImageString(unitGC,vw,(int)rint(jj) - halflength,
+                               vwInfo.height-8-descent,aunit,strlength,dFlag);
+	    if (dFlag == PSoption) 
+              GDrawImageString(unitGC,vw,(int)rint(jj) -(strlength*3),
+                               vwInfo.height -14,aunit,strlength,dFlag);
 	    /* these are "eyeball" parameters for the given PS font */
 	  }
 	}
-      
         tickStart = calcUnitY(0);
         oneTickUnit = calcUnitY(1) - tickStart;
-     
         /* ticks along the positive Y axis */
-        unitWidth = 2*(ascent+descent);                 /* limit of acceptable separation */
+        unitWidth = 2*(ascent+descent);  /* limit of acceptable separation */
         k = floor(unitWidth/fabs(oneTickUnit)) +1;  /* get skipping integer */
         for (ii=0,jj = tickStart;
 	     jj > 0;
 	     ii=ii+k,jj =jj+k*oneTickUnit ) {
 	  if  (jj < vwInfo.height) {
- 
 	    /* ticks stuck to viewport*/
 	    /* on the right */
 	    /*
@@ -8063,7 +6848,6 @@ drawTheViewport(int dFlag)
 	    XTextExtents(unitFont,aunit,strlength,&dummyInt,
 			 &ascent,&descent,&overall);
 	    halflength=overall.width;           /* let's reuse that variable */
-
 	    if(dFlag == Xoption){
               /* on the right */
 	      /*
@@ -8094,9 +6878,7 @@ drawTheViewport(int dFlag)
 	    }
 	  }
 	}
-
         /* ticks along the negative Y axis */
-    
         for (ii=(-k),jj = tickStart - k*oneTickUnit;
 	     jj < vwInfo.height;
 	     ii=ii-k,jj =jj-k*oneTickUnit) {
@@ -8121,7 +6903,6 @@ drawTheViewport(int dFlag)
 	    XTextExtents(unitFont,aunit,strlength,&dummyInt,
 			 &ascent,&descent,&overall);
 	    halflength=overall.width;           /* let's reuse that variable */
-
 	    if(dFlag == Xoption){
               /* on the right */
 	      /*
@@ -8153,12 +6934,9 @@ drawTheViewport(int dFlag)
 	    }
 	  }
 	}
-      
       }  /* if unitsOn */
     }    /* if graph i exists and is showing */
   }   /* for i in graphs */
-
-
   if (dFlag==Xoption) {
     if (!followMouse) {
       /* no need to do this while autorepeating */
@@ -8167,41 +6945,32 @@ drawTheViewport(int dFlag)
     }
     XFlush(dsply);
   }
-
 }           /* drawViewport() */
 
-
-
-/************************************
- ***  viewPoints *makeViewport()  ***
- ************************************/
-
-viewPoints *
-makeViewport(char *title,int vX,int vY,int vW,int vH,int showCP)
-{
+@
+\subsection{makeViewport}
+\index{view2d!makeViewport}
+\index{makeViewport view2d}
+<<view2d>>=
+viewPoints *makeViewport(char *title,int vX,int vY,int vW,int vH,int showCP) {
   Pixmap               spadbits,spadmask;
   XSetWindowAttributes viewAttrib;
   XSizeHints           titleSizeHints,viewSizeHints;
   Window               viewTitleWindow,viewGraphWindow;
   XColor               foreColor, backColor;
-
 #ifdef DEBUG
   fprintf(stderr,"view2d: About to make a viewport\n");
 #endif
-
   /* Create a viewport */
   if (!(viewport = (viewPoints *)malloc(sizeof(viewPoints)))) {
-    fprintf(stderr,"Ran out of memory (malloc) trying to create a viewport.\n");
-    sleep(5);
-    exitWithAck(RootWindow(dsply,scrn),Window,-1);
+   fprintf(stderr,"Ran out of memory (malloc) trying to create a viewport.\n");
+   sleep(5);
+   exitWithAck(RootWindow(dsply,scrn),Window,-1);
   }
-
 #ifdef DEBUG
   fprintf(stderr,"view2d: Made a viewport\n");
 #endif
-
   strcpy(viewport->title,title); 
-
   viewport->closing      = no;
   viewport->allowDraw    = yes;   /* just draw axes the first time around */
   viewport->axesOn   = axesON;
@@ -8209,7 +6978,6 @@ makeViewport(char *title,int vX,int vY,int vW,int vH,int showCP)
   viewport->pointsOn = pointsON;
   viewport->linesOn  = connectON;
   viewport->splineOn = splineON;
-
   /**** Make the windows for the viewport ****/
   spadbits = XCreateBitmapFromData(dsply,rtWindow,
                                    spadBitmap_bits,
@@ -8221,14 +6989,12 @@ makeViewport(char *title,int vX,int vY,int vW,int vH,int showCP)
   viewAttrib.border_pixel = foregroundColor;
   viewAttrib.override_redirect = overrideManager; 
   viewAttrib.colormap = colorMap;
-
   foreColor.pixel = foregroundColor;
   backColor.pixel = backgroundColor;
   XQueryColor(dsply,colorMap,&foreColor);
   XQueryColor(dsply,colorMap,&backColor);
   viewAttrib.cursor = XCreatePixmapCursor(dsply,spadbits,spadmask,
 		  &foreColor,&backColor,spadBitmap_x_hot,spadBitmap_y_hot);
-
   viewAttrib.event_mask = titleMASK;
   if (vW) {
     titleSizeHints.flags  = PPosition | PSize;
@@ -8241,19 +7007,15 @@ makeViewport(char *title,int vX,int vY,int vW,int vH,int showCP)
     titleSizeHints.width  = viewWidth;
     titleSizeHints.height = viewHeight;
   }
-
   viewTitleWindow = XCreateWindow(dsply,rtWindow,vX,vY,vW,vH,
 				  viewBorderWidth,
 				  CopyFromParent,InputOutput,CopyFromParent,
 				  viewportTitleCreateMASK,&viewAttrib);
-
   wm_delete_window = XInternAtom(dsply, "WM_DELETE_WINDOW", False);
   (void) XSetWMProtocols(dsply, viewTitleWindow, &wm_delete_window, 1);
-
   XSetNormalHints(dsply,viewTitleWindow,&titleSizeHints); 
   XSetStandardProperties(dsply,viewTitleWindow,"Axiom 2D",viewport->title,
 			   None,NULL,0,&titleSizeHints);
-
   viewport->titleWindow = viewTitleWindow;
   viewAttrib.event_mask = viewportMASK; 
   viewSizeHints.flags   = PPosition | PSize;
@@ -8271,138 +7033,39 @@ makeViewport(char *title,int vX,int vY,int vW,int vH,int showCP)
   XSetNormalHints(dsply,viewGraphWindow,&viewSizeHints);
   XSetStandardProperties(dsply,viewGraphWindow,"2D Viewport","2D Viewport",
 			 None,NULL,0,&viewSizeHints); 
-
   viewport->viewWindow = viewGraphWindow;
-
   /*Make the control panel for the viewport. */
   viewport->controlPanel = makeControlPanel();        
   if ((viewport->haveControl = showCP)) putControlPanelSomewhere(anywhere);
-
   XSync(dsply,False); 
   return(viewport);
-
 }
 
-
-/*********************************************
- *****  viewPoints *makeView2D(viewdata)  ****
- *********************************************/
-
-
-viewPoints *
-makeView2D(view2DStruct *viewdata)
-{
+@
+\subsection{makeView2D}
+\index{view2d!makeView2D}
+\index{makeView2D view2d}
+<<view2d>>=
+viewPoints *makeView2D(view2DStruct *viewdata) {
   viewPoints *vPoints;  
-
   vPoints = makeViewport(viewdata->title, viewdata->vX,viewdata->vY,
                          viewdata->vW,viewdata->vH,viewdata->showCP);
-
   vPoints->allowDraw = yes;   /* draw everything from now on */
-
   if (viewdata->showCP) clearControlMessage();
-
   writeTitle(); 
-
   XMapWindow(dsply,vPoints->viewWindow);
   XMapWindow(dsply,vPoints->titleWindow);
   XSync(dsply,0);
-
-  drawViewport(Xoption);      /* draw viewport with X routines (as opposed to PS) */
+  drawViewport(Xoption); /* draw viewport with X routines (as opposed to PS) */
   return(vPoints);
-
 }    /* makeView2D */
 
 @
-\section{write2d.c}
-<<view2d/write2d.c>>=
-#define _WRITE2D_C
-
-#include <stdio.h>
-#include <stdlib.h>
-
-<<view2d/header2.h>>
-<<include/write.h>>
-
-extern int initButtons(buttonStruct * );
-extern void writeControlTitle(void );
-extern void makeMessageFromData(int );
-extern void writeControlMessage(void );
-extern void drawControlPanel(void );
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void );
-extern void putControlPanelSomewhere(int );
-extern void clearControlMessage(void );
-extern void getGraphFromViewman(int );
-extern void freeGraph(int );
-extern int main(void);
-extern void mergeDatabases(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern void doPick(int  , int );
-extern void doDrop(int  , int );
-extern void clickedOnGraph(int  , int );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern void clickedOnGraphSelect(int  , int );
-#ifdef _PROCESS2D_C
-static void drawControlPushButton(int  , int );
-#endif
-extern int readViewman(void *  , int );
-extern int spadAction(void);
-extern float absolute(float);
-extern void goodbye(int);
-extern void writeTitle(void);
-extern void drawTheViewport(int );
-extern viewPoints * makeViewport(char *  , int  , int  , int  , int  , int );
-extern viewPoints * makeView2D(view2DStruct * );
-extern int writeViewport(int );
-
-#include "pixmap.h1"
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-
-
-#define numBits (8*sizeof(int))
-
-int 
-writeViewport(int thingsToWrite)
-{
-
+\subsection{writeViewport}
+\index{view2d!writeViewport}
+\index{writeViewport view2d}
+<<view2d>>=
+int writeViewport(int thingsToWrite) {
   FILE              *viewDataFile;
   char              viewDirName[80],
                     viewBitmapFilename[80],viewDataFilename[80],command[80];
@@ -8410,7 +7073,6 @@ writeViewport(int thingsToWrite)
   pointListStruct   *aList;
   pointStruct       *aPoint;
   XWindowAttributes vwInfo;
-
   XGetWindowAttributes(dsply,viewport->titleWindow,&vwInfo);
   sprintf(viewDirName,"%s%s",filename,".view"); 
   sprintf(command,"%s%s%s","rm -r ",viewDirName," >  /dev/null 2>&1");
@@ -8486,12 +7148,11 @@ writeViewport(int thingsToWrite)
         } /* if */
       } /* for */
     } /* else */
-
            /* write out special files */
     for (ii=1; ii<numBits; ii++) {   /* write.h is one-based */
       if (thingsToWrite & (1<<ii)) {
         switch (ii) {
-        case Pixmap:
+        case aPixmap:
             /*** Create the pixmap (bitmaps need leaf name) ***/
           sprintf(viewBitmapFilename,"%s%s",viewDirName,"/image.xpm");
           XGetWindowAttributes(dsply,viewport->viewWindow,&vwInfo);
@@ -8499,7 +7160,7 @@ writeViewport(int thingsToWrite)
 				   viewport->titleWindow,0,0,vwInfo.width,
 				   vwInfo.height+titleHeight);
           break;
-        case Bitmap:
+        case aBitmap:
             /*** Create the bitmap (bitmaps need leaf name) ***/
           sprintf(viewBitmapFilename,"%s%s",viewDirName,"/image.bm");
           XGetWindowAttributes(dsply,viewport->viewWindow,&vwInfo);
@@ -8507,7 +7168,7 @@ writeViewport(int thingsToWrite)
 				  viewport->titleWindow,vwInfo.width,
 				  vwInfo.height+vwInfo.border_width+20,-1,-1);
           break;
-        case Image:
+        case anImage:
             /*** Create the pixmap (bitmaps need leaf name) ***/
           sprintf(viewBitmapFilename,"%s%s",viewDirName,"/image.xpm");
           XResizeWindow(dsply,viewport->titleWindow,300,300+titleHeight);
@@ -8528,8 +7189,7 @@ writeViewport(int thingsToWrite)
 				  vwInfo.height+vwInfo.border_width+20,-1,-1);
           mono = 0;
           break;
-
-        case Postscript:
+        case aPostscript:
             /*** Create postscript output for viewport (in axiom2d.ps) ***/
          sprintf(PSfilename,"%s%s",viewDirName,"/axiom2d.ps");
          if (PSInit(viewport->viewWindow,viewport->titleWindow) == psError)
@@ -8546,22 +7206,1320 @@ writeViewport(int thingsToWrite)
 
     return(0);
   }    /* else create directory okay */
-
 }
+
+@
+\subsection{main}
+The main function performs the following steps
+\begin{enumerate}
+\item calls XOpenDisplay 
+(See \ref{XOpenDisplay} on page~\pageref{XOpenDisplay}), 
+using the DISPLAY variable from the environment, to choose the display.
+\item uses the DefaultScreen macro 
+(See \ref{DefaultScreen} on page~\pageref{DefaultScreen}), to get the
+user's default screen.
+\item uses the RootWindow macro 
+(See \ref{RootWindow} on page~\pageref{RootWindow}), to get the
+root window on the user's display and screen.
+\item calls XCreateAssocTable to create an association table with
+{\tt nbuckets} which is elsewhere defined to be 128. Note that we
+do not actually use the X10 definition of this function but use our
+own version. See \ref{XCreateAssocTable} on page~\pageref{XCreateAssocTable}.
+This table is used to hold an association between the control panel buttons
+and the window they control.
+\end{enumerate}
+\index{view2d!main}
+\index{main view2d}
+<<view2d>>=
+int main(void) {
+  XGCValues    controlGCVals;
+  int          i,code;
+  view2DStruct viewData;
+  char         property[256];
+  char         *prop = &property[0];
+  char         *str_type[20];
+  XrmValue     value;
+  if ((dsply = XOpenDisplay(getenv("DISPLAY"))) == NULL)
+    fprintf(stderr,"Could not open the display.\n");
+  scrn  = DefaultScreen(dsply);
+  rtWindow  = RootWindow(dsply,scrn);
+  /**** link Xwindows to viewports - X10 feature ****/
+  table        = XCreateAssocTable(nbuckets);  
+  /**** Create Axiom color map ****/
+  totalColors = XInitSpadFill(dsply,scrn,&colorMap,
+                              &totalHues,&totalSolidShades,
+                              &totalDitheredAndSolids,&totalShades);
+  if (totalColors < 0) {
+    fprintf(stderr,">>Error: Could not allocate all the necessary colors.\n");
+    exitWithAck(RootWindow(dsply,scrn),Window,-1);
+  }
+  mergeDatabases();
+  /*** Determine whether monochrome or color is used ***/
+  if (XrmGetResource(rDB,"Axiom.2D.monochrome","",str_type,&value) == True)
+    (void) strncpy(prop,value.addr,(int)value.size);
+  else 
+    (void) strcpy(prop, "off");
+  mono = ((totalSolid == 2) || (strcmp(prop,"on") == 0));
+  if (XrmGetResource(rDB,"Axiom.2D.inverse","",str_type,&value) == True)
+    (void) strncpy(prop,value.addr,(int)value.size);
+  else 
+    (void) strcpy(prop, "off");
+  
+  if (mono) 
+    if (strcmp(prop,"on") == 0) {  	      /* 0 if equal (inverse video) */
+      foregroundColor = WhitePixel(dsply,scrn);
+      backgroundColor = BlackPixel(dsply,scrn);
+    } else {  				      /* off (no inverse video) */
+      foregroundColor = BlackPixel(dsply,scrn);
+      backgroundColor = WhitePixel(dsply,scrn);
+    }
+  else   /* inverse of inverse in color (for some strange reason) */
+    if (strcmp(prop,"on") == 0) {         /* 0 if equal (inverse video) */
+      foregroundColor = WhitePixel(dsply,scrn);
+      backgroundColor = BlackPixel(dsply,scrn);
+    } else {                                  /* off (no inverse video) */
+      foregroundColor = BlackPixel(dsply,scrn);
+      backgroundColor = WhitePixel(dsply,scrn);
+    }
+  /* read default file name for postScript output */
+  if (XrmGetResource(rDB,
+		     "Axiom.2D.postscriptFile",
+		     "",
+		     str_type, &value) == True)
+    (void) strncpy(prop,value.addr,(int)value.size);
+  else 
+    (void) strcpy(prop, "axiom2d.ps");
+  PSfilename = (char *)malloc(strlen(prop)+1);
+  strcpy(PSfilename,prop);
+  /**** Open global fonts ****/
+  serverFont = XQueryFont(dsply,XGContextFromGC(DefaultGC(dsply,scrn)));
+  if (XrmGetResource(rDB,
+		     "Axiom.2D.messageFont",
+		     "Axiom.2D.Font",
+		     str_type, &value) == True)
+    (void) strncpy(prop,value.addr,(int)value.size);
+  else      
+    (void) strcpy(prop,messageFontDefault);  
+  if ((globalFont = XLoadQueryFont(dsply, prop)) == NULL) {
+    fprintf(stderr, 
+	    "Warning:  could not get the %s font for messageFont\n",prop);
+    globalFont = serverFont;
+  }
+  if (XrmGetResource(rDB,
+		     "Axiom.2D.buttonFont",
+		     "Axiom.2D.Font",
+		     str_type, &value) == True)
+    (void) strncpy(prop,value.addr,(int)value.size);
+  else 
+    (void) strcpy(prop,buttonFontDefault);
+  if ((buttonFont = XLoadQueryFont(dsply, prop)) == NULL) {
+    fprintf(stderr, 
+	    "Warning:  could not get the %s font for buttonFont\n",prop);
+    buttonFont = serverFont;
+  }
+  if (XrmGetResource(rDB,
+		     "Axiom.2D.headerFont",
+		     "Axiom.2D.Font",
+		     str_type, &value) == True)
+     (void) strncpy(prop,value.addr,(int)value.size);
+  else
+    (void) strcpy(prop,headerFontDefault);
+  if ((headerFont = XLoadQueryFont(dsply, prop)) == NULL) {
+    fprintf(stderr, 
+	    "Warning:  could not get the %s font for headerFont\n",prop);
+    headerFont = serverFont;
+  }
+  if (XrmGetResource(rDB,
+		     "Axiom.2D.titleFont",
+		     "Axiom.2D.Font",
+		     str_type,&value) == True)
+    (void) strncpy(prop,value.addr,(int)value.size);
+  else 
+    (void) strcpy(prop,titleFontDefault);
+  if ((titleFont = XLoadQueryFont(dsply, prop)) == NULL) {
+    fprintf(stderr, 
+	    "Warning:  could not get the %s font for titleFont\n",prop);
+    titleFont = serverFont;
+  }
+  if (XrmGetResource(rDB,
+		     "Axiom.2D.graphFont",
+		     "Axiom.2D.Font",
+		     str_type,&value) == True)
+    (void) strncpy(prop,value.addr,(int)value.size);
+  else 
+    (void) strcpy(prop,graphFontDefault);
+  if ((graphFont = XLoadQueryFont(dsply, prop)) == NULL) {
+    fprintf(stderr, 
+	    "Warning:  could not get the %s font for graphFont\n",prop);
+    graphFont = serverFont;
+  }
+  if (XrmGetResource(rDB,
+		     "Axiom.2D.unitFont",
+		     "Axiom.2D.Font",
+		     str_type,&value) == True)
+    (void) strncpy(prop,value.addr,(int)value.size);
+  else 
+    (void) strcpy(prop,unitFontDefault);
+  if ((unitFont = XLoadQueryFont(dsply, prop)) == NULL) {
+     fprintf(stderr, 
+	     "Warning:  could not get the %s font for unitFont\n",prop);
+     unitFont = serverFont;
+  }
+
+  /**** Create widely used Graphic Contexts ****/
+  PSGlobalInit();       
+  /* must initiate before using any G/PS functions 
+     need character name: used as postscript GC variable 
+     need to create ps GCs for all GCs used by drawings in viewWindow */
+  /* globalGC1 */
+  controlGCVals.foreground = monoColor(axesColorDefault);
+  controlGCVals.background = backgroundColor;
+  globalGC1 = XCreateGC(dsply,rtWindow,GCForeground | GCBackground ,
+			&controlGCVals);  
+  carefullySetFont(globalGC1,globalFont);
+  /* create the equivalent GCs for ps */
+  PSCreateContext(globalGC1, "globalGC1", psNormalWidth, psButtCap,
+		  psMiterJoin, psWhite, psBlack);
+  /* controlMessageGC */
+  controlGCVals.foreground = controlMessageColor;
+  controlMessageGC = XCreateGC(dsply,rtWindow,GCForeground | GCBackground 
+			       ,&controlGCVals);
+  carefullySetFont(controlMessageGC,globalFont);
+  /* globalGC2 */
+  controlGCVals.foreground = monoColor(labelColor);
+  controlGCVals.background = backgroundColor;
+  globalGC2 = XCreateGC(dsply,rtWindow,GCForeground | GCBackground,
+			&controlGCVals);
+  carefullySetFont(globalGC2,buttonFont);
+  PSCreateContext(globalGC2, "globalGC2", psNormalWidth, psButtCap,
+		  psMiterJoin, psWhite, psBlack);
+  /* trashGC  */
+  trashGC = XCreateGC(dsply,rtWindow,0,&controlGCVals);
+  carefullySetFont(trashGC,buttonFont);
+  PSCreateContext(trashGC, "trashGC", psNormalWidth, psButtCap,
+		  psMiterJoin, psWhite, psBlack);
+  /* globGC */
+  globGC = XCreateGC(dsply,rtWindow,0,&controlGCVals);
+  carefullySetFont(globGC,headerFont);
+  PSCreateContext(globGC, "globGC", psNormalWidth, psButtCap,
+		  psMiterJoin, psWhite, psBlack);
+  /* anotherGC  */
+  controlGCVals.line_width = colorWidth;
+  anotherGC  = XCreateGC(dsply,rtWindow,GCBackground,&controlGCVals);
+  carefullySetFont(anotherGC,titleFont);
+  PSCreateContext(anotherGC, "anotherGC", psNormalWidth, psButtCap,
+		  psMiterJoin, psWhite, psBlack);
+  /* processGC */
+  gcVals.background = backgroundColor;
+  processGC         = XCreateGC(dsply,rtWindow,GCBackground ,&gcVals);
+  carefullySetFont(processGC,buttonFont);
+  /* graphGC */
+  graphGC           = XCreateGC(dsply,rtWindow,GCBackground,&gcVals);
+  carefullySetFont(graphGC,graphFont);
+  PSCreateContext(graphGC, "graphGC", psNormalWidth, psButtCap,
+		  psMiterJoin, psWhite, psBlack);
+  /* unitGC */
+  unitGC            = XCreateGC(dsply,rtWindow,GCBackground ,&gcVals);
+  carefullySetFont(unitGC,unitFont);
+  PSCreateContext(unitGC, "unitGC", psNormalWidth, psButtCap,
+		  psMiterJoin, psWhite, psBlack);
+  /**** Initialize Graph States ****/
+  for (i=0; i<maxGraphs; i++) {
+    graphStateArray[i].scaleX = 0.9;
+    graphStateArray[i].scaleY = 0.9;
+    graphStateArray[i].deltaX = 0.0;
+    graphStateArray[i].deltaY = 0.0;
+    graphStateArray[i].centerX = 0.0;
+    graphStateArray[i].centerY = 0.0;
+    graphStateArray[i].pointsOn  = yes;
+    graphStateArray[i].connectOn = yes;
+    graphStateArray[i].splineOn  = no;
+    graphStateArray[i].axesOn    = yes;
+    graphStateArray[i].unitsOn   = no;
+    graphStateArray[i].showing   = no;
+    graphStateArray[i].selected  = no;
+    graphStateBackupArray[i] = graphStateArray[i];
+  } 
+  /**** Get Data from the Viewport Manager ****/
+  i = 123;
+  code=check(write(Socket,&i,intSize));
+  /* Check if I am getting stuff from Axiom or, if I am viewAlone. */
+  readViewman(&viewAloned,intSize);
+  readViewman(&viewData,sizeof(view2DStruct));
+  readViewman(&i,intSize);
+  if (!(viewData.title = (char *)malloc(i))) {
+    fprintf(stderr,
+	    "ERROR: Ran out of memory trying to receive the title.\n");
+    exitWithAck(RootWindow(dsply,scrn),Window,-1);
+  }
+  readViewman(viewData.title,i);
+  for (i=0; i<maxGraphs; i++) {
+    readViewman(&(graphArray[i].key),intSize);
+    if (graphArray[i].key) {  		/** this graph slot has data **/
+      getGraphFromViewman(i);
+    } /* if graph exists (graphArray[i].key is not zero) */
+  } /* for i in graphs */
+  viewport = makeView2D(&viewData);
+  control = viewport->controlPanel;
+  bsdSignal(SIGTERM,goodbye,DontRestartSystemCalls);
+  /* send acknowledgement to viewport manager */
+  i = 345;
+  check(write(Socket,&(viewport->viewWindow),sizeof(Window)));
+  processEvents();
+  goodbye(-1);
+  return(0);  /* control never reaches here but compiler complains */
+} /* main() */
+
 @
 \chapter{view3d}
 \label{view3d}
-\section{buttons3d.c}
-<<view3d/buttons3d.c>>=
-#define _BUTTONS3D_C
+\section{Constants and Headers}
+\subsection{System includes}
+<<view3d>>=
+#include <limits.h>
+#include <math.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <X11/Xlib.h>
+#include <X11/Xresource.h>
+#include <X11/Xutil.h>
+
+@
+\subsection{Local includes}
+<<view3d>>=
+#include "bsdsignal.h"
+#include "bsdsignal.h1"
+#include "com.h"
+#include "hash.h"
+#include "hash.h1"
+#include "pixmap.h1"
+<<include/view3d.h>>
+#include "spadcolors.h1"
+#include "util.h1"
+#include "xshade.h1"
+#include "xspadfill.h1"
+
+<<include/actions.h>>
+<<include/g.h>>
+<<include/override.h>>
+<<include/view.h>>
+<<include/viewcommand.h>>
+<<include/write.h>>
+<<include/xdefs.h>>
+
+@
+\subsection{defines}
+<<view3d>>=
+#define BH	31  /* button window height */
+#define PH	80  /* potentiometer window height */
+#define XEDGE	5   /* leftmost button starts here */
+
+#define axisLength	1.0   /* use 100.0, if data is not to be normalized */
+
+#define samePoint(a,b) ((refPt3D(viewData,a)->x == refPt3D(viewData,b)->x) &&\
+			(refPt3D(viewData,a)->y == refPt3D(viewData,b)->y) &&\
+			(refPt3D(viewData,a)->z == refPt3D(viewData,b)->z))
+#define MAX_POINT	1000.0
+#define MIN_POINT	-1000.0
 
-<<view3d/header.h>>
-<<view3d/cpanel.h>>
+#define spadBitmap_width 34
+#define spadBitmap_height 20
+#define spadBitmap_x_hot 15
+#define spadBitmap_y_hot 10
+static char spadBitmap_bits[] = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00,
+   0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
+   0xe6, 0xf8, 0x76, 0x00, 0x84, 0x98, 0x44, 0x49, 0x00, 0xc0, 0x98, 0x42,
+   0x49, 0x00, 0xb8, 0x98, 0x42, 0x49, 0x00, 0x84, 0x95, 0x42, 0x49, 0x00,
+   0x44, 0xa5, 0x22, 0x49, 0x00, 0x78, 0x63, 0x1d, 0xdb, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00,
+   0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00};
+
+#define spadMask_width 34
+#define spadMask_height 20
+#define spadMask_x_hot 15
+#define spadMask_y_hot 10
+static char spadMask_bits[] = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
+   0x01, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00,
+   0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x01, 0xfe,
+   0xff, 0xff, 0xff, 0x01, 0xfe, 0xff, 0xff, 0xff, 0x01, 0xfe, 0xff, 0xff,
+   0xff, 0x01, 0xfe, 0xff, 0xff, 0xff, 0x01, 0xfe, 0xff, 0xff, 0xff, 0x01,
+   0xfe, 0xff, 0xff, 0xff, 0x01, 0xfe, 0xff, 0xff, 0xff, 0x01, 0xfc, 0xff,
+   0xff, 0xff, 0x01, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00,
+   0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00};
+
+#define volumeBitmap_width 16
+#define volumeBitmap_height 16
+#define volumeBitmap_x_hot 5
+#define volumeBitmap_y_hot 1
+static char volumeBitmap_bits[] = {
+   0x00, 0x00, 0x60, 0x00, 0x90, 0x00, 0x10, 0x01, 0x10, 0x07, 0x10, 0x09,
+   0x0c, 0x39, 0x1a, 0x51, 0x32, 0x50, 0x22, 0x40, 0x22, 0x40, 0x04, 0x60,
+   0x04, 0x30, 0xf8, 0x1f, 0x04, 0x20, 0xf8, 0x1f};
+#define volumeMask_width 16
+#define volumeMask_height 16
+#define volumeMask_x_hot 5
+#define volumeMask_y_hot 1
+static char volumeMask_bits[] = {
+   0x00, 0x00, 0x60, 0x00, 0xf0, 0x00, 0xf0, 0x01, 0xf0, 0x07, 0xf0, 0x0f,
+   0xfc, 0x3f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfc, 0x7f,
+   0xfc, 0x3f, 0xf8, 0x1f, 0x04, 0x20, 0xf8, 0x1f};
+
+#define mouseBitmap_width 16
+#define mouseBitmap_height 16
+#define mouseBitmap_x_hot 8
+#define mouseBitmap_y_hot 0
+static char mouseBitmap_bits[] = {
+   0x00, 0x01, 0x00, 0x01, 0x80, 0x02, 0x40, 0x04, 0xc0, 0x06, 0x20, 0x08,
+   0x20, 0x08, 0x30, 0x18, 0x50, 0x14, 0x58, 0x34, 0x90, 0x12, 0x20, 0x08,
+   0xc0, 0x47, 0x00, 0x21, 0x80, 0x10, 0x00, 0x0f};
+#define mouseMask_width 16
+#define mouseMask_height 16
+static char mouseMask_bits[] = {
+   0x00, 0x01, 0x00, 0x01, 0x80, 0x03, 0xc0, 0x07, 0xc0, 0x07, 0xe0, 0x0f,
+   0xe0, 0x0f, 0xf0, 0x1f, 0xf0, 0x1f, 0xf8, 0x3f, 0xf0, 0x1f, 0xe0, 0x0f,
+   0xc0, 0x47, 0x00, 0x21, 0x80, 0x10, 0x00, 0x0f};
+
+/* Defines the pixmap for the arrow displayed in the scale window */
+#define zoomArrowN 11
+static XPoint zoomArrow[zoomArrowN] = {
+  {29,14},{38,23},{33,23},
+  {40,45},{53,45},
+  {29,69},
+  {5,45},{18,45},
+  {25,23},{20,23},{29,14} };
+
+/* Defines the pixmap for the arrows displayed in the translate window */
+#define translateArrowN 25
+static XPoint translateArrow[translateArrowN] = {
+  {55,2},{60,10},{58,10},{58,37},
+  {85,37},{85,35},{93,40},{85,45},{85,43},{58,43},
+  {58,70},{60,70},{55,78},{50,70},{52,70},{52,43},
+  {25,43},{25,45},{17,40},{25,35},{25,37},{52,37},
+  {52,10},{50,10},{55,2} };
+
+#define controlMASK		(ButtonPressMask + ButtonReleaseMask + ExposureMask)
+#define potMASK			(ButtonPressMask + ButtonReleaseMask + ButtonMotionMask + LeaveWindowMask)
+#define buttonMASK		(ButtonPressMask + ButtonReleaseMask + ButtonMotionMask + LeaveWindowMask)
+#define colorMASK		(ButtonPressMask + ButtonReleaseMask + ButtonMotionMask + LeaveWindowMask)
+
+
+#define mouseWait		50
+       /* make mouse grab for stationary mouse on a potentiometer slower */
+
+#define controlCreateMASK	CWBackPixel | CWBorderPixel | CWEventMask |CWCursor |CWColormap | CWOverrideRedirect
+#define buttonCreateMASK	CWEventMask  
+#define messageCreateMASK	0
+#define colormapCreateMASK	CWEventMask
+
+#define controlWidth		300
+#define controlHeight		400
+#define quitWidth               63              
+#define quitHeight              107
+#define saveWidth               63
+#define saveHeight              107
+#define borderWidth		22
+#define borderHeight		45
+
+
+#define controlCursorForeground	monoColor(4)
+#define controlCursorBackground	monoColor(54)
+#define controlTitleColor	monoColor(36)
+#define controlPotHeaderColor	monoColor(52)
+#define controlColorColor	monoColor(13)
+#define controlColorSignColor	monoColor(22)
+
+#define headerHeight		headerFont->max_bounds.ascent
+#define controlMessageHeight	globalFont->max_bounds.ascent +globalFont->max_bounds.descent+4
+
+#define potA			25   /* y coordinate of line dividing 
+					potentiometers from stuff above it */
+#define potB			173  /* y coordinate of line dividing 
+					potentiometers from title */
+
+#define cmapA			233  /* y coordinate of line dividing 
+					colormap from stuff above it */
+
+#define butA			((cp->buttonQueue[render]).buttonY - 5)
+
+#define closeL			((cp->buttonQueue[closeAll]).buttonX - 5)
+#define closeA			((cp->buttonQueue[closeAll]).buttonY - 5)
+
+#define controlMessageY		181
+#define controlMessageColor	monoColor(68)
+
+#define offColor	13
+#define onColor		98
+#define	modeColor	44
+
+#define colormapX	        21
+#define colormapY		240
+#define colormapW		290
+#define colormapH		48
+#define colorWidth		8 
+#define colorHeight		8  
+#define colorOffset		3
+#define colorOffsetX		24
+#define colorOffsetY		16
+#define colorPointer		16
+
+#define meshOutline      monoColor(140)
+#define opaqueOutline    monoColor(85)
+#define opaqueForeground backgroundColor
+
+
+#define clipOffset 500
+
+/* recalculation occurs if any of these situations have occured */
+
+#define recalc (rotated || zoomed || translated || !finishedList || \
+		firstTime || switchedPerspective || changedEyeDistance)
+
+
+/*** projection macros if matrices are not used  ***/
+#define projPersp(z) (viewData.eyeDistance / (z+viewData.eyeDistance))
+
+#define proj2PX(x,y)   -(x*cosTheta + y*sinTheta) 
+#define proj2PY(x,y,z) -(y*cosTheta*cosPhi - x*sinTheta*cosPhi + z*sinPhi)
+
+/*** For clipping points ***/
+
+#define behindClipPlane(pz) lessThan(pz,viewData.clipPlane)
+
+#define outsideClippedBoundary(x,y,z) (lessThan(x,viewData.clipXmin) ||    \
+				       greaterThan(x,viewData.clipXmax) || \
+				       lessThan(y,viewData.clipYmin) ||    \
+				       greaterThan(y,viewData.clipYmax) || \
+				       lessThan(z,viewData.clipZmin) ||    \
+				       greaterThan(z,viewData.clipZmax) || \
+				       isNaNPoint(x,y,z))
+#define NotPoint	(SHRT_MAX)
+#define eqNANQ(x)	(x == NotPoint)
+
+#define swap(a,b) {a^=b; b^=a; a^=b;}
+
+#define viewportCreateMASK CWBackPixel | CWBorderPixel | CWEventMask | CWCursor | CWColormap
+#define viewportTitleCreateMASK CWBackPixel | CWBorderPixel | CWCursor | CWColormap | CWEventMask | CWOverrideRedirect
+#define carefullySetFont(gc,font) if (font != serverFont) XSetFont(dsply,gc,font->fid)
+
+#define viewportMASK    (KeyPressMask + ButtonPressMask + ExposureMask)
+#define titleMASK       (ExposureMask)
+
+#define lineWidth       1
+#define lineHeight      1
+
+#define titleColor      monoColor(36)
+#define titleHeight     24
+#define appendixHeight  0
+
+#define viewWidth       400
+#define viewHeight      400
+#define viewYmax        vwInfo.height
+#define viewYmin        vwInfo.y
+#define viewXmax        vwInfo.width
+#define viewXmin        vwInfo.x
+
+#define GC9991 ((GC)9991)
+
+
+/* For smooth shading buffers. Should be screen resolution size, 
+   and one for each of screen width and height may be needed, or
+   it can be changed dynamically if desired. */
+
+#ifdef RIOSplatform
+#define ARRAY_WIDTH      1280 + 1  /* DisplayWidth(dsply,scrn) */
+#define ARRAY_HEIGHT     1024 + 1  /* DisplayHeight(dsply,scrn) */
+#else
+#define ARRAY_WIDTH      1300  /* DisplayWidth(dsply,scrn) */
+#define ARRAY_HEIGHT     1100  /* DisplayHeight(dsply,scrn) */
+#endif
+
+#define viewBorderWidth 0 /* make sure ps.h (postscript header) is the same */
+
+#define initDeltaX      0.0
+#define initDeltaY      0.0
+#define initTheta       pi_half/2.0
+#define initPhi         -pi_half/2.0
+
+#define maxDeltaX       1500.0
+#define maxDeltaY       1500.0
+#define minScale        0.01
+#define maxScale        1000.0
+
+#define rotateFactor    0.2
+#define scaleFactor     0.2
+#define translateFactor 8
+
+#define viewCursorForeground monoColor(166)
+#define viewCursorBackground monoColor(5)
+
+#define axesColor       52
+#define buttonColor     120
+#define labelColor      12
+
+                      /**********************************/
+                      /***        graph stuff         ***/
+                      /**********************************/
+
+#define graphBarLeft    76
+#define graphBarTop     180
+#define graphBarWidth   graphFont->max_bounds.width + 5
+#define graphBarHeight  graphFont->max_bounds.ascent + graphFont->max_bounds.descent
+#define graphBarDefaultColor   monoColor(85)
+#define graphBarShowingColor   monoColor(45)
+#define graphBarHiddenColor    monoColor(146)
+#define graphBarSelectColor    monoColor(45)
+#define graphBarNotSelectColor monoColor(145)
+
+                      /******************************/
+                      /***         colors         ***/
+                      /******************************/
+
+#define totalHuesConst  27
+
+#define hueEnd          360
+#define hueStep         (hueEnd/totalHuesConst)
+
+#define black           BlackPixel(dsply,scrn)
+#define white           WhitePixel(dsply,scrn)
+#define numPlanes       1
+#define numColors       10
+#define startColor      0
+#define endColor        (startColor+numColors)
+#define maxColors       (DisplayCells(dsply,scrn)-1)
+#define maxPlanes       (DefaultVisual((dpy),(scr))->bits_per_rgb)
+
+#define colorStep       ((maxColors+1)/numColors)
+
+                      /**********************************/
+                      /***    Screen and Window Sizes   */
+                      /**********************************/
+
+#define physicalWidth   DisplayWidth(dsply,scrn)
+#define physicalHeight  DisplayHeight(dsply,scrn)
+#define deep            DisplayPlanes(dsply,scrn)
+
+#define basicScreen     19
+
+#define yes             1
+#define no              0
+
+#define pi_half         1.57079632
+#define pi              3.14159265
+#define three_pi_halves 4.71238898
+#define two_pi          6.28318530
+#define pi_sq           9.86960440
+
+#define degrees_in_two_pi 57
+#define d2Pi              57
+
+#define nbuckets         128
+                               
+
+#define anywhere        0
+
+#ifdef DEBUG
+#include "eventnames.h"
+#endif
+
+#define intSize         sizeof(int)
+#define floatSize       sizeof(float)
+
+/* Types so far are X, PS */
+#define drawViewport(type) { drawPreViewport(type); drawTheViewport(type); } 
+#define spadDrawViewport()   spadMode++; drawTheViewport(X); spadMode--;
+
+
+                      /********************************/
+                      /***       lighting panel     ***/
+                      /********************************/
+
+/* These are the lighting panel buttons, they start at 101 
+   (numbers less than 101 are reserved for control panel buttons */
+
+/* From ../include/actions.h */
+
+#define lightingButtonsStart controlButtonsEnd3D  
+
+#define lightMove        (lightingButtonsStart)
+#define lightMoveXY      (lightingButtonsStart+1)
+#define lightMoveZ       (lightingButtonsStart+2)
+#define lightAbort       (lightingButtonsStart+3)
+#define lightReturn      (lightingButtonsStart+4)
+#define lightTranslucent (lightingButtonsStart+5)
+
+#define maxlightingButtons 6
+#define lightingButtonsEnd (lightingButtonsStart + maxlightingButtons)
+
+                      /***********************************/
+                      /***       view volume panel     ***/
+                      /***********************************/
+
+/* These are the volume panel buttons, they start at 200 
+   (numbers less than 101 are reserved for control panel buttons */
+
+#define volumeButtonsStart lightingButtonsEnd
+
+#define volumeReturn    (volumeButtonsStart)
+#define frustrumBut     (volumeButtonsStart+1)
+#define clipXBut        (volumeButtonsStart+2)
+#define clipYBut        (volumeButtonsStart+3)
+#define clipZBut        (volumeButtonsStart+4)
+#define perspectiveBut  (volumeButtonsStart+5)
+#define clipRegionBut   (volumeButtonsStart+6)
+#define clipSurfaceBut  (volumeButtonsStart+7)
+#define volumeAbort     (volumeButtonsStart+8)
+
+#define maxVolumeButtons 9 
+#define volumeButtonsEnd (volumeButtonsStart + maxVolumeButtons)
+
+                       /**** quit panel ****/
+
+#define quitButtonsStart volumeButtonsEnd
+
+#define quitAbort        (quitButtonsStart)
+#define quitReturn       (quitButtonsStart+1)
+#define maxQuitButtons   2
+#define quitButtonsEnd   (quitButtonsStart + maxQuitButtons)
+
+                       /**** save panel ****/
+
+#define saveButtonsStart quitButtonsEnd
+
+#define saveExit         (saveButtonsStart)
+#define pixmap           (saveButtonsStart+1)
+#define ps               (saveButtonsStart+2)
+#define maxSaveButtons   3
+#define saveButtonsEnd   (saveButtonsStart + maxSaveButtons)
+
+                      /******************************************/
+                      /***       buttons to be allocated      ***/
+                      /******************************************/
+
+#define maxButtons3D    saveButtonsEnd
+
+      /******* useful definitions *******/
+
+#define CONTROLpanel 1
+#define LIGHTpanel   2
+#define VOLUMEpanel  3
+#define CONTOURpanel 4
+#define QUITpanel    5
+#define SAVEpanel    6
+
+#define machine0 0.0002
+
+#define lightBitmap_width 16
+#define lightBitmap_height 16
+#define lightBitmap_x_hot 8
+#define lightBitmap_y_hot 0
+static char lightBitmap_bits[] = {
+   0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x04, 0x40, 0xc8, 0x27, 0x20, 0x08,
+   0x10, 0x10, 0x16, 0x10, 0x10, 0xd0, 0x10, 0x10, 0x24, 0x08, 0x42, 0x44,
+   0x40, 0x84, 0x80, 0x02, 0x80, 0x02, 0x00, 0x01};
+#define lightMask_width 16
+#define lightMask_height 16
+#define lightMask_x_hot 8
+#define lightMask_y_hot 0
+static char lightMask_bits[] = {
+   0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x04, 0x40, 0xc8, 0x27, 0x20, 0x08,
+   0x10, 0x11, 0x96, 0x12, 0x90, 0xd2, 0x90, 0x10, 0x24, 0x09, 0x42, 0x45,
+   0x40, 0x85, 0x80, 0x03, 0x80, 0x02, 0x00, 0x01};
+
+#define lightMASK ExposureMask
+#define lightCursorForeground lightingTitleColor
+#define lightCursorBackground foregroundColor
+
+#define lightFontHeight (lightingFont->max_bounds.ascent+lightingFont->max_bounds.descent)
+
+#define lightingAxesColor  monoColor(52)
+#define lightingLabelColor monoColor(12)
+#define lightingBoxColor   monoColor(138)
+#define lightingLightColor monoColor(7)
+#define lightingTitleColor monoColor(69)
+#define lightingButtonColor monoColor(140)
+#define lightingTransColor monoColor(140)
+#define lightingTransArrowColor monoColor(100)
+#define lightingTransLabelColor monoColor(207)
+
+#define lightingAxesSize 175
+#define lightingAxesX	 61
+#define lightingAxesY	 28
+
+#define lightAxesScale 110	/* the extent of the axes in object space */
+#define lightScale 0.63		/* projected scale factor */
+
+#define arrowHead (control->buttonQueue[lightTranslucent].buttonX + 5)
+static viewTriple point0 = {0,0,0};
+
+#define linkThing poly
+
+#define spadActionMode
+#define components
+
+#define inside(A,B) (((XButtonEvent *)event)->x >= A && \
+		     ((XButtonEvent *)event)->x <= B)
+
+#define maxEyeDistance 2000.0
+#define minEyeDistance 200.0
+#define eyeIncrement   25.0
+
+#define clipPlaneMin (-250.0)
+#define clipPlaneMax 250.0
+#define clipPlaneIncrement 10.0
+
+#define quitMASK ExposureMask
+#define quitCursorForeground monoColor(55)
+#define quitCursorBackground monoColor(197)
+#define quitTitleColor monoColor(69)
+#define quitButtonColor monoColor(195)
+#define quitFontHeight (quitFont->max_bounds.ascent+quitFont->max_bounds.descent)
+
+#define saveMASK ExposureMask
+#define saveCursorForeground monoColor(55)
+#define saveCursorBackground monoColor(197)
+#define saveTitleColor monoColor(70)
+#define saveButtonColor monoColor(195)
+#define saveFontHeight (saveFont->max_bounds.ascent+saveFont->max_bounds.descent)
+
+#define SAFE_VALUE 892347
+
+#define precisionFactor 1024
+
+/* depthChecker turns on the extensive depth checking mechanisms
+   for the depth sort algorithm. Without it, the hidden surface
+   removal is just a sort by z which works remarkably well, but,
+   is insufficient and, at times, may end up being incorrect */
+#define depthChecker
+
+#define axesOffset  5
+
+#define eyeDistMessX (frusX(eyeWinX+27))
+#define eyeDistMessY (frusY(eyeWinY-5))
+#define hitherMessX (frusX(hitherWinX+15))
+#define hitherMessY (frusY(hitherWinY))
+
+#define clipXMessX (control->buttonQueue[clipXBut].buttonX + \
+		    control->buttonQueue[clipXBut].xHalf)
+#define clipXMessY (control->buttonQueue[clipXBut].buttonY + 2)
+#define clipYMessX (control->buttonQueue[clipYBut].buttonX + \
+		    control->buttonQueue[clipYBut].buttonWidth-2)
+#define clipYMessY (control->buttonQueue[clipYBut].buttonY + \
+		    control->buttonQueue[clipYBut].yHalf)
+#define clipZMessX (control->buttonQueue[clipZBut].buttonX + \
+		    control->buttonQueue[clipZBut].xHalf+4)
+#define clipZMessY (control->buttonQueue[clipZBut].buttonY + \
+		    control->buttonQueue[clipZBut].yHalf-4)
+
+#define volumeCursorForeground monoColor(68)
+#define volumeCursorBackground monoColor(197)
+
+#define hitherBoxColor	monoColor(141)
+#define hitherBoxTop	(frustrumMidY - 10)
+#define hitherBoxHeight 20
+
+#define clipButtonColor 144
+#define toggleColor 42
+#define arcColor 75
+
+#define arcSize	  6
+#define tinyArc	  5
+#define blank 4
+#define toggleX 190
+#define toggleY 280
+
+#define oldWay
+
+#define frusX(x) (control->buttonQueue[frustrumBut].buttonX + x)
+#define frusY(y) (control->buttonQueue[frustrumBut].buttonY + y)
+
+#define clipMessX 7
+#define clipMessY (control->buttonQueue[clipXBut].buttonY + 15)
+   /* someotherFont holds title font (see main.c) */
+#define clipMessDy (globalFont->max_bounds.ascent/2 + \
+		    globalFont->max_bounds.descent)
+static char *clipMess = "Clip Volume";
+
+#define eyeMess1Dy clipMessDy
+#define eyeMess1X 7
+#define eyeMess1Y (frustrumY + 40 + 3*eyeMess1Dy)
+static char *eyeMess1 = "Eye";
+
+#define eyeMess2X (globalFont->max_bounds.width + 14)
+#define eyeMess2Y (frustrumY + 40)
+#define eyeMess2Dy eyeMess1Dy
+
+#define leftRight
+#define newStuff
+
+   /******* Define's ********/
+      /*** box colors ***/
+#define boxInline	monoColor(140)
+#define boxOutline	monoColor(140)
+#define clipBoxInline	monoColor(148) 
+#define clipBoxOutline	monoColor(148) 
+
+#define lightB		205
+#define lightPotA	(control->buttonQueue[lightMoveZ].buttonY - 15)
+#define lightPotB	(control->buttonQueue[lightMoveZ].buttonY +\
+			 control->buttonQueue[lightMoveZ].buttonHeight + 7)
+#define lightTransL	(control->buttonQueue[lightTranslucent].buttonX - 20)
+
+#define volumeTitleColor monoColor(77)
+#define volumeTitleA	190
+#define volumeTitleB	217
+
+#define volumeMASK	ExposureMask
+
+#define frustrumColor	monoColor(147)
+#define frustrumX	30
+#define frustrumY	20
+#define frustrumLength	100
+#define frustrumMidY	70    /* frustrumY + frustrumLength/2 */
+#define frustrumBotY	(frustrumY + frustrumLength)
+#ifdef  newStuff
+#define frustrumMin	(control->buttonQueue[frustrumBut].xHalf)
+#define frustrumMax	(frustrumMin + \
+			 (control->buttonQueue[frustrumBut].xHalf))
+#endif
+
+#define hitherColor	monoColor(68)   /* clipping plane */
+#define hitherMinX	(frustrumX + 5)
+#define hitherMaxX	(frustrumMin - 30)
+#define hitherWinX	(hitherMinX - 5)
+#define hitherWinY	(frustrumBotY + 10)
+#define hitherWidth	(hitherMaxX - hitherMinX + 10)
+#define hitherHeight	20
+#define hitherBarY	(hitherWinY + 10)   /* hitherWinY + hitherHeight/2 */
+
+#ifdef  newStuff
+#define eyeColor	monoColor(131)
+#define eyeMinX		frustrumMin
+#define eyeMaxX		frustrumMax
+#define eyeWinX		(eyeMinX - 5)
+#define eyeWinY		hitherWinY
+#define eyeWidth	(eyeMaxX - eyeMinX + 10)
+#define eyeHeight	hitherHeight
+#define eyeBarY		hitherBarY
+#endif
+
+#define volumeButtonColor	monoColor(157)
+
+#define frustrumWindowX		30
+#define frustrumWindowY		28
+#define frustrumWindowWidth	(controlWidth - 60)
+#define frustrumWindowHeight	(frustrumBotY + 40)
+
+/**** clip volume ****/
+#define lengthFace	80
+#ifdef  rightLeft
+#define backFaceX	190
+#endif
+#ifdef  leftRight
+#define backFaceX	33
+#endif
+#define backFaceY	255
+#define deltaFace	25
+#define zLength		35.355 /* sqrt(2*deltaFace^2) */
+#ifdef  rightLeft
+#define frontFaceX	(backFaceX - deltaFace)
+#endif
+#ifdef  leftRight
+#define frontFaceX	(backFaceX + deltaFace)
+#endif
+#define frontFaceY	(backFaceY + deltaFace)
+
+
+#define majorAxis	lengthFace    /* size of the potentiometers */
+#define minorAxis	20
+#define midAxis		40
+
+#define clipXButX	backFaceX
+#define clipXButY	(backFaceY-30)
+
+#ifdef  rightLeft
+#define clipYButX	(frontFaceX - minorAxis - 10)
+#endif
+#ifdef  leftRight
+#define clipYButX	(frontFaceX + lengthFace + 10)
+#endif
+#define clipYButY	frontFaceY
+
+#ifdef  rightLeft
+#define clipZButX	clipYButX  /* align left side */
+#endif
+#ifdef  leftRight
+#define clipZButX	(clipYButX+minorAxis-midAxis) /* align right side */
+#endif
+#define clipZButY	clipXButY
+
+#define zFactor		0.6   /* ratio of clipZBut box & actual input area */
+#define minDistXY	0.1   /* min distance between normalized clip faces */
+#define minDistZ	0.06  /* 2/3 of XY */
+
+
+#ifdef  rightLeft
+#define AA		(clipZButX + midAxis)
+#define BB		clipZButY
+#define CC		backFaceX
+#define DD		backFaceY
+#define EE		frontFaceX
+#define FF		frontFaceY
+#define clipZButTopEndX ((AA+BB+CC-DD)/2)
+#define clipZButTopEndY ((AA+BB-CC+DD)/2)
+#define clipZButBotEndX ((AA+BB+EE-FF)/2)
+#define clipZButBotEndY ((AA+BB-EE+FF)/2)
+#endif
+
+#ifdef  leftRight
+#define AA		clipZButX
+#define BB		clipZButY
+#define CC		(backFaceX + majorAxis)
+#define DD		backFaceY
+#define EE		(frontFaceX + majorAxis)
+#define FF		frontFaceY
+
+#define clipZButTopEndX ((AA-BB+CC+DD)/2)
+#define clipZButTopEndY ((BB-AA+CC+DD)/2)
+#define clipZButBotEndX ((AA-BB+EE+FF)/2)
+#define clipZButBotEndY ((BB-AA+EE+FF)/2)
+
+#endif
+
+  /* upper limit as to how many kinds of files could be written (numBits-1) */
+#define numBits (8*sizeof(int))
+#define StellarColors 9
+
+@
+\subsection{static variables}
+\begin{verbatim}
+static char *event_name[] = {
+  "",                        /* 0  */
+  "",                        /* 1  */
+  "KeyPress",                /* 2  */
+  "KeyRelease",              /* 3  */
+  "ButtonPress",             /* 4  */
+  "ButtonRelease",           /* 5  */
+  "MotionNotify",            /* 6  */
+  "EnterNotify",             /* 7  */
+  "LeaveNotify",             /* 8  */
+  "FocusIn",                 /* 9  */
+  "FocusOut",                /* 10 */
+  "KeymapNotify",            /* 11 */
+  "Expose",                  /* 12 */
+  "GraphicsExpose",          /* 13 */
+  "NoExpose",                /* 14 */
+  "VisibilityNotify",        /* 15 */
+  "CreateNotify",            /* 16 */
+  "DestroyNotify",           /* 17 */
+  "UnmapNotify",             /* 18 */
+  "MapNotify",               /* 19 */
+  "MapRequest",              /* 20 */
+  "ReparentNotify",          /* 21 */
+  "ConfigureNotify",         /* 22 */
+  "ConfigureRequest",        /* 23 */
+  "GravityNotify",           /* 24 */
+  "ResizeRequest",           /* 25 */
+  "CirculateNotify",         /* 26 */
+  "CirculateRequest",        /* 27 */
+  "PropertyNotify",          /* 28 */
+  "SelectionClear",          /* 29 */
+  "SelectionRequest",        /* 30 */
+  "SelectionNotify",         /* 31 */
+  "ColormapNotify",          /* 32 */
+  "ClientMessage",           /* 33 */
+  "MappingNotify"            /* 34 */
+  };
+\end{verbatim}
+
+This is a description of script character labels for the x, y, and z axes 
+<<view3d>>=
+static float axes[3][6] = {{-117,0,0,117,0,0},     /* x axis */
+			   {0,-117,0,0,117,0},     /* y axis */
+			   {0,0,-117,0,0,117}};    /* z axis */
+
+/* text labels are currently used */
+static float labels[basicScreen][7] = {
+  {105,0,4,106,0,3,labelColor},     /* script x label - 4 segments */
+  {106,0,3,112,0,10,labelColor},
+  {112,0,10,114,0,9,labelColor},
+  {106,0,10,113,0,3,labelColor},
+  {0,106,9,0,107,10,labelColor},    /* script y label - 7 segments */
+  {0,107,10,0,107,6,labelColor},
+  {0,107,6,0,113,5,labelColor},
+  {0,113,10,0,113,-3,labelColor},
+  {0,113,-3,0,111,-5,labelColor},
+  {0,111,-5,0,110,-1,labelColor},
+  {0,110,-1,0,114,3,labelColor},
+  {0,5,114,0,6,115,labelColor},     /* script z label - 8 segments */
+  {0,6,115,0,11,116,labelColor},
+  {0,11,116,0,12,113,labelColor},
+  {0,12,113,0,10,111,labelColor},
+  {0,10,111,0,11,110,labelColor},
+  {0,11,110,0,11,103,labelColor},
+  {0,11,103,0,9,102,labelColor},
+  {0,9,102,0,9,105,labelColor}};  
+
+@
+\subsection{structs}
+\index{struct!buttonStruct}
+\index{buttonStruct struct}
+<<view3d>>=
+typedef struct _buttonStruct {
+  int           buttonKey, pot, mask;
+  short         buttonX, buttonY, buttonWidth, buttonHeight, xHalf, yHalf;
+  Window        self;
+  char          *text;
+  int           textColor,textHue,textShade;
+} buttonStruct;
+
+@
+\index{struct!controlPanelStruct}
+\index{controlPanelStruct struct}
+<<view3d>>=
+typedef struct _controlPanelStruct {
+  Window        controlWindow, messageWindow, colormapWindow;
+  char          message[40];
+  buttonStruct  buttonQueue[maxButtons3D];
+} controlPanelStruct;
+
+@
+\index{struct!mouseCoord}
+\index{mouseCoord struct}
+<<view3d>>=
+typedef struct _mouseCoord {
+    float       x, y;
+} mouseCoord;
+
+@
+\index{struct!meshStruct}
+\index{meshStruct struct}
+<<view3d>>=
+typedef struct _meshStruct {
+  float         N0[4], N1[4];   /* the fourth element is Zmin */
+} meshStruct;
+
+@
+\index{struct!points3D}
+\index{points3D struct}
+<<view3d>>=
+typedef struct _points3D {
+  float         xmin, xmax,
+                ymin, ymax,
+                xstep, ystep,
+                zmin, zmax,
+                scaleToView;
+  float         *zPoints;
+  int           xnum, ynum,
+                nextRow,
+                style;
+  meshStruct    *normData;   /* list of normals */
+} points3D;
+
+@
+\index{struct!colorBuffer}
+\index{colorBuffer struct}
+<<view3d>>=
+typedef struct _colorBuffer {
+  int      indx;
+  char     axes;
+} colorBuffer;
+
+@
+\index{struct!point}
+\index{point struct}
+<<view3d>>=
+typedef struct _point {
+  float         x, y, z;
+  int           flag;
+} point;
+
+@
+\index{struct!viewPoints}
+\index{viewPoints struct}
+One of the (many) sloppy things that need to be
+cleaned up is the viewPoints structure. a lot of
+stuff in it is used solely for the function of
+two variables stuff. they should be moved to
+the fun2Var substructure.
+<<view3d>>=
+typedef struct _viewPoints {
+  int                 viewportKey;
+  char                title[80];
+  Window              viewWindow, titleWindow;
+  float               deltaX, deltaY,
+                      scale, scaleX, scaleY, scaleZ,
+                      theta, phi,
+                      deltaX0, deltaY0,     /* initial values */
+                      scale0, transX, transY, transZ, thetaObj, phiObj,
+                      theta0, phi0, theta1, phi1, axestheta, axesphi;
+  float               deltaZ, deltaZ0;
+  controlPanelStruct  *controlPanel;
+  int                 axesOn, regionOn, monoOn;
+  int                 zoomXOn, zoomYOn, zoomZOn;
+  int                 originrOn, objectrOn;
+  int                 xyOn, xzOn, yzOn;
+  int                 originFlag;
+  int                 justMadeControl, haveControl,
+                      closing, allowDraw, needNorm;
+  points3D            meshData;
+  float               lightVector[3], translucency;
+  int                 hueOffset, numberOfHues, hueTop, diagonals;
+  struct _viewPoints  *prevViewport, *nextViewport;
+} viewPoints;
+
+@
+\index{struct!controlXY}
+\index{controlXY struct}
+<<view3d>>=
+typedef struct _controlXY {
+  int           putX, putY;
+} controlXY;
 
+@
+\subsection{extern references}
+<<view3d>>=
+extern Display          *dsply;
+extern XFontStruct      *globalFont, *buttonFont, *headerFont, 
+                        *titleFont, *graphFont,
+                        *lightingFont, *volumeFont, *quitFont, *saveFont,
+                        *serverFont;
+extern XrmDatabase      rDB;
+
+extern char             scaleReport[5], deltaXReport[5], deltaYReport[5];
+extern unsigned long    *spadColors;
+extern int              followMouse, gotToggle, viewportKeyNum;
+extern Window           rtWindow, quitWindow, saveWindow;
+extern GC               globalGC1, globalGC2, anotherGC, globGC, trashGC,
+                        componentGC, opaqueGC, renderGC,
+                        controlMessageGC, lightingGC, volumeGC, quitGC, 
+                        saveGC, graphGC;
+extern XSizeHints       viewSizeHints;
+extern HashTable        *table;
+extern Colormap         colorMap;
+extern int              Socket, ack;
+
+extern GC               processGC;
+extern viewPoints       *viewport;
+extern controlPanelStruct *control;
+extern XGCValues        gcVals;
+extern char             *s;
+extern int              someInt;
+
+extern unsigned long    foregroundColor, backgroundColor;
+extern int              mono, totalColors,
+                        totalHues, totalSolidShades, totalSolid,
+                        totalDitheredAndSolids,totalShades;
+
+extern int              drawMore;
+extern int              spadMode,spadDraw;
+extern int              spadSignalReceived;
+extern int              inNextEvent;
+extern jmp_buf          jumpFlag;
+
+extern char             errorStr[80];
+
+extern view3DStruct     viewData;
+
+extern Window           lightingWindow, lightingAxes;
+extern float            lightPointer[3], tempLightPointer[3];
+extern float            lightIntensity, tempLightIntensity;
+extern float            backLightIntensity;
+
+extern char             filename[256];
+
+
+  /** stuff from draw viewport routines */
+extern float            sinTheta, sinPhi, cosTheta, cosPhi,
+                        viewScale, viewScaleX, viewScaleY, viewScaleZ, reScale;
+extern int              xCenter, yCenter;
+extern XWindowAttributes vwInfo;
+extern XWindowAttributes graphWindowAttrib;
+extern XPoint           *quadMesh;
+extern int              *xPts;
+extern XImage           *imageX;
+
+extern float            eyePoint[3];
+
+extern XPoint           polygonMesh[20];
+
+extern int              saveFlag;
+extern int              firstTime, noTrans, startup;
+extern int              redrawView;
+extern int              finishedList, redoSmooth, redoColor, zoomed,
+                        rotated, switchedPerspective, changedEyeDistance,
+                        translated, changedIntensity, movingLight, writeImage,
+                        pixelSetFlag, redoDither, multiColorFlag;
+extern poly             *quickList;
+
+extern int              viewAloned;
+
+extern viewTriple       corners[8], clipCorners[8];
+extern boxSideStruct    box[6], clipBox[6];
+extern int              axesXY[3][4];
+extern float            axesZ[3][2];
+
+extern viewTriple       *splitPoints;
+extern int              resMax;
+
+extern Window           volumeWindow;
+extern int              frustrumVertex;
+extern int              doingPanel;
+extern int              doingVolume;
+extern int              screenX;
+extern float            xClipMinN, xClipMaxN,
+                        yClipMinN, yClipMaxN,
+                        zClipMinN, zClipMaxN,
+                        clipValue;
+
+extern float            pzMin, pzMax;
+
+extern int              maxGreyShade;
+
+extern char             propertyName[];
+extern char             propertyBuffer[];
+
+extern float            transform[4][4], transform1[4][4],
+                        R[4][4], R1[4][4], S[4][4], T[4][4], I[4][4];
+extern float            vxmax,vxmin,vymax,vymin,
+                        wxmax,wxmin,wymax,wymin,wzmax,wzmin;
+
+extern polyList         *scanList[ARRAY_HEIGHT];
+extern int              scanline, polyCount;
+extern float            xleft, xright;
+
+extern colorBuffer      cBuffer[ARRAY_WIDTH];
+extern float            zBuffer[ARRAY_WIDTH];
+
+extern float            zC, dzdx;
+extern float            intersectColor[2], dcolor;
+extern triple           dpt, dnorm;
+
+extern float            Cspec, Cdiff, Camb, coeff, lum, saturation;
+
+extern Pixmap           viewmap;
+extern int              viewmap_valid;
+extern int              smoothHue;
+extern int              smoothConst;
+extern int              smoothError;
+
+@
+\subsection{forward references}
+<<view3d>>=
 extern viewTriple * traverse(int );
 extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
+extern float getRandom(void );
+extern triple normDist(void );
 extern void goodbye(int);
 extern int initButtons(buttonStruct * );
 extern int writeViewport(int );
@@ -8583,6 +8541,7 @@ extern void drawControlPanel(void);
 extern controlXY getControlXY(int );
 extern controlPanelStruct * makeControlPanel(void);
 extern void putControlPanelSomewhere(int );
+
 extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
 extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
 extern void ROTATE(float [4][4]);
@@ -8651,13 +8610,13 @@ extern void calcNormData(void);
 extern viewPoints * make3DComponents(void);
 extern void draw3DComponents(int );
 
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
+extern char getCBufferAxes(int );
+extern void putCBufferAxes(int  , char );
+extern int getCBufferIndx(int );
+extern void putCBufferIndx(int  , int );
+extern void putZBuffer(int  , float );
+extern float getZBuffer(int );
+extern void putImageX(int  , char );
 extern void drawPhongSpan(triple  , float [3] , int );
 extern void scanPhong(int );
 extern void boxTObuffer(void );
@@ -8674,28 +8633,293 @@ extern void drawSavePanel(void);
 extern int main(void);
 extern void mergeDatabases(void);
 
-#define BH	31  /* button window height */
-#define PH	80  /* potentiometer window height */
-#define XEDGE	5   /* leftmost button starts here */
+extern int PSCreateFile(int , Window , Window , char * );
+extern int GdrawsDrawFrame(int , Window , Window , char * );
+extern int GdrawsSetDimension(Window , Window );
+extern int GDrawImageString(GC , Window , int , int , char * , int , int );
+extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
+extern int GDrawLine(GC , Window , int , int , int , int , int );
+extern int GDrawLines(GC , Window , XPoint * , int , int , int );
+extern int GDrawPoint(Window , GC , int , int , int );
+extern int GDrawString(GC , Window , int , int , char * , int , int );
+extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
+extern int PSGlobalInit(void );
+extern int PSInit(Window , Window );
+extern int PSCreateContext(GC , char * , int , int , int , float , float );
+extern char * PSfindGC(GC );
+extern int GSetForeground(GC , float , int );
+extern int GSetBackground(GC , float , int );
+extern int GSetLineAttributes(GC , int , int , int , int , int );
+extern int PSClose(void );
+extern int centerX(GC , char * , int , int );
+extern int centerY(GC , int );
+extern int PSColorPolygon(float , float , float , XPoint * , int );
+extern int PSColorwOutline(float , float , float , XPoint * , int );
+extern int PSDrawColor(float , float , float , XPoint * , int );
+extern int PSFillPolygon(GC , XPoint * , int );
+extern int PSFillwOutline(GC , XPoint * , int );
+extern HashTable * XCreateAssocTable(int );
+extern void XMakeAssoc(Display * , HashTable * , Window , int * );
+extern int * XLookUpAssoc(Display * , HashTable * , Window );
+extern void XDeleteAssoc(Display * , HashTable * , Window );
+extern int GDrawRectangle(GC , Window , short , short , short , short , int );
+extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
+extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
+extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
+#ifdef _GFUN_C
+static void filecopy(FILE * , FILE * );
+static int TrivEqual(Window , Window );
+static int TrivHashCode(Window , int );
+#endif
 
-/*****************************************************
- * int initButtons(buttons)                          *
- *                                                   *
- * Creates the fields for each button window in the  *
- * three dimensional control panel, and returns the  *
- * number of buttons created.                        *
- *                                                   *
- *****************************************************/
-
-int
-initButtons (buttonStruct *buttons)
-{
-  
+@
+\subsection{global variables}
+<<view3d>>=
+float A[4][4];
+int ack=1;
+GC anotherGC;
+float array[4][4];
+int axesXY[3][4];
+float axesZ[3][2];
+
+float B[4][4];
+unsigned long backgroundColor;  
+float backLightIntensity = 1.0;
+boxSideStruct box[6];
+XFontStruct *buttonFont;
+
+float Camb = 0.3;
+colorBuffer cBuffer[ARRAY_WIDTH];
+float Cdiff = 0.4;
+int changedEyeDistance;
+int changedIntensity;
+boxSideStruct clipBox[6];
+viewTriple clipCorners[8];
+float clipValue;              /* mouse input */
+float coeff = 35.0;
+Colormap colorMap;
+GC componentGC;
+controlPanelStruct *control;
+GC controlMessageGC;
+viewTriple corners[8];
+float cosPhi;
+float cosTheta;
+float Cspec = 0.30;
+
+float D[4];
+float dcolor;
+char deltaXReport[5];
+char deltaYReport[5];
+triple dnorm;
+int doingPanel=CONTROLpanel; /* rewrite titles in proper panel */
+int doingVolume;
+triple dpt;
+int drawMore;
+Display *dsply;
+float dzdx;
+
+float E[4][4];
+char *envAXIOM; /* used for ps file paths */
+char errorStr[80];
+static char *eyeMess2 = "Reference";
+float eyePoint[3]; 
+
+float F[4];
+char filename[256]; /* used for writing viewport info out to a file */
+int finishedList=no;
+int firstTime=yes;
+int flatClipBoxX[8];
+int flatClipBoxY[8];
+int followMouse=no;
+unsigned long foregroundColor;
+int frustrumVertex;
+
+GCptr GChead=NULL; /* ptr to head of ps GC linked list */
+XGCValues gcVals;
+XFontStruct *globalFont;
+GC globGC;
+GC globalGC1;
+GC globalGC2;
+int gotToggle = no;
+XFontStruct *graphFont;
+GC graphGC;
+XWindowAttributes graphWindowAttrib;
+
+XFontStruct *headerFont;
+
+float I[4][4];
+XImage *imageX;
+int inNextEvent=no; /* true just before a call to XNextEvent */
+float intersectColor[2];
+
+jmp_buf jumpFlag;
+
+int last_tip_lat_x;
+int last_tip_lat_y;
+int last_tip_long_x;
+int last_tip_long_y;
+Window lightingAxes;
+XFontStruct *lightingFont;
+GC lightingGC;
+Window lightingWindow;
+float lightIntensity=1.0;
+float lightPointer[3];
+float lum;
+
+int maxGreyShade=0;
+int mono;
+int movingLight = no;
+int multiColorFlag = no;
+
+int noTrans = yes;
+
+GC opaqueGC;
+
+int pixelSetFlag = no;
+float point_norm[3];
+int polyCount;
+XPoint polygonMesh[20];
+GC processGC;
+char propertyBuffer[256];
+char propertyName[14];
+char *PSfilename; /* output file name used in user directory */
+int psInit=no; /* need to call globaInitPs() each run */
+pointInfo ptIA;
+pointInfo ptIB;
+pointInfo ptIC;
+float pzMax;
+float pzMin;
+
+XPoint *quadMesh;
+poly *quickList;
+XFontStruct *quitFont;
+GC quitGC;
+Window quitWindow;
+
+float R[4][4];
+float R1[4][4];
+XrmDatabase rDB;
+int redoColor = no;
+int redoDither = no;
+int redoSmooth = no;
+int redrawView = no;   /* set to yes when returning from subpanels */
+GC renderGC;
+int resMax=0;  /* number of points in the split point resevoir */
+float reScale;
+static int rotateX;
+int rotated=yes;
+static int rotateY;
+static int rotateR;
+Window rtWindow;
+
+char *s;
+float S[4][4];
+float saturation = 0.8;
+int saveFlag=no;
+XFontStruct *saveFont;
+GC saveGC;
+Window saveWindow;
+char scaleReport[5];
+int scanline;
+polyList *scanList[ARRAY_HEIGHT];
+int screenX;  /* global point indicating mouse position on frustrum screen */
+int scrn;
+XFontStruct *serverFont;
+float sinPhi;
+float sinTheta;
+int smoothConst = 50;
+int smoothError = no;
+int smoothHue;
+int Socket=1;
+int someInt;  
+unsigned long *spadColors;
+int spadDraw=no; /* yes if drawing viewport for an Axiom command */
+int spadMode=no; /* yes if receiving Axiom command and calling drawViewport */
+/* yes if current state is a result of a signal from Axiom */
+int spadSignalReceived=0;  
+viewTriple *splitPoints;
+int startup = yes;
+int switchedPerspective;
+
+float T[4][4];
+HashTable *table;
+float tempLightIntensity;
+float tempLightPointer[3];
+XFontStruct *titleFont;
+int totalColors;
+int totalDithered;
+int totalDitheredAndSolids;
+int totalHues;
+int totalSolid;
+int totalSolidShades;
+float transform[4][4];
+float transform1[4][4];
+int translated = yes;
+GC trashGC;
+
+@
+totalShades is initially set to totalShadesConst.
+If X cannot allocate 8 shades for each hue, totalShades 
+is decremented. there is currently only a check for
+this value to be positive. --> something to add: change over 
+to monochrome if totalShades=0. just modify the spadcolors.c
+file. spadcolors.c has been modified so that it returns the
+value for totalShades. since the return value had previously
+been unused, a modification in this way ensures continued
+support of other routines calling this function (e.g. hypertex stuff).
+<<view3d>>=
+int totalShades;
+
+int viewAloned; /** if not connected to Axiom **/
+view3DStruct viewData;
+Pixmap viewmap;
+int viewmap_valid = 0;
+viewPoints *viewport;
+int viewportKeyNum=0;
+float viewScale;
+float viewScaleX;
+float viewScaleY;
+float viewScaleZ;
+XSizeHints viewSizeHints;
+XFontStruct *volumeFont;
+GC volumeGC;
+Window volumeWindow;
+XWindowAttributes vwInfo;
+
+Atom wm_delete_window;
+int writeImage = no;
+
+int xCenter;
+float xClipMaxN; /* normalized values for clip volume */
+float xClipMinN; /* normalized values for clip volume */
+float xleft = (float)0;
+int *xPts;  /* pointer to projected points (x followed by y) */
+float xright = (float)ARRAY_WIDTH;
+
+int yCenter;
+float yClipMaxN; /* normalized values for clip volume */
+float yClipMinN; /* normalized values for clip volume */
+
+float zBuffer[ARRAY_WIDTH];
+float zC;
+float zClipMaxN; /* normalized values for clip volume */
+float zClipMinN; /* normalized values for clip volume */
+int zoomed=yes;
+
+@
+\section{Code}
+\subsection{initButtons}
+Creates the fields for each button window in the
+three dimensional control panel, and returns the
+number of buttons created.
+\index{view3d!initButtons}
+\index{initButtons view3d}
+<<view3d>>=
+<<gfun.c>>
+int initButtons(buttonStruct *buttons) {  
   int PBY = 297; /* panel button Y coordinate at which buttons appear */
   int ii, num = 0;
-  
   /* Rotate, Zoom, and Translate Potentiometer Buttons */
-  
   /* Title:  "Rotate" */
   ii = rotate;
   buttons[ii].buttonX       = XEDGE;    buttons[ii].buttonY         = 85;
@@ -8707,7 +8931,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf         = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf         = buttons[ii].buttonHeight/2;
   ++num;
-  
   /* Title:  "Scale" */
   ii = zoom;
   buttons[ii].buttonX         = 121;  buttons[ii].buttonY           = 85;
@@ -8719,8 +8942,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf           = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf           = buttons[ii].buttonHeight/2;
   ++num;
-  
-  
   /* Title:  "Translate" */
   ii = translate;
   buttons[ii].buttonX         = 185;  buttons[ii].buttonY      = 85;
@@ -8732,14 +8953,11 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf           = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf           = buttons[ii].buttonHeight/2;
   ++num;
-  
   /* All the rest of the buttons are regular, toggle only buttons and
      have the potentiometer variable set to "no". */
-  
   /* First Row of Buttons */
   /* The four rendering mode buttons:  
      wireframe, hiddenline solid, hiddenline shaded and smooth shaded **/
-
   /* Wirefram mesh */
   ii = transparent;
   buttons[ii].buttonX         = XEDGE;   buttons[ii].buttonY       = PBY;
@@ -8752,7 +8970,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf           = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf           = buttons[ii].buttonHeight/2;
   ++num;
-  
   /* Hidden surface mesh */
   ii = opaqueMesh;
   buttons[ii].buttonX         = 55;  buttons[ii].buttonY      = PBY;
@@ -8765,7 +8982,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf           = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf           = buttons[ii].buttonHeight/2;
   ++num;
-  
   /* Lambertian polygon fill with phong illumination model */
   ii = render;
   buttons[ii].buttonX       = 113;  buttons[ii].buttonY         = PBY;
@@ -8778,7 +8994,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf         = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf         = buttons[ii].buttonHeight/2;
   ++num;  
-  
   /* Phong smooth shading and illumination */
   ii = smooth;
   buttons[ii].buttonX       = 171;  buttons[ii].buttonY         = PBY;
@@ -8791,7 +9006,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf         = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf         = buttons[ii].buttonHeight/2;
   ++num;  
-  
   /* Reset View Position Button */
   ii = resetView;
   buttons[ii].buttonX       = 240;    buttons[ii].buttonY       = PBY;
@@ -8804,13 +9018,9 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf         = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf         = buttons[ii].buttonHeight/2;
   ++num;
-  
-  
   /* Second Row of Buttons */
-
   /* update y displacement of buttons row */
   PBY=PBY+BH+3;  
-  
   /* Bounding Region On/Off */
   ii = region3D;
   buttons[ii].buttonX     = XEDGE;    buttons[ii].buttonY       = PBY;
@@ -8823,7 +9033,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf       = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf       = buttons[ii].buttonHeight/2;
   ++num;
-  
   /* Axes Turned On/Off */
   ii = axesOnOff;
   buttons[ii].buttonX     = 68;    buttons[ii].buttonY      = PBY;
@@ -8836,7 +9045,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf       = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf       = buttons[ii].buttonHeight/2;
   ++num;
-  
   /* Outline polygons with black lines in render mode */
   ii = outlineOnOff;
   buttons[ii].buttonX     = 122;   buttons[ii].buttonY       = PBY;
@@ -8849,7 +9057,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf       = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf       = buttons[ii].buttonHeight/2;
   ++num;
-  
   /* Display as if a 1-bit plane image */
   ii = bwColor;
   buttons[ii].buttonX      = 197; buttons[ii].buttonY      = PBY;
@@ -8862,7 +9069,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf        = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf        = buttons[ii].buttonHeight/2;
   ++num;
-  
   /* Hide Control Panel */
   ii = hideControl;
   buttons[ii].buttonX      = 240;   buttons[ii].buttonY       = PBY;
@@ -8875,13 +9081,9 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf        = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf        = buttons[ii].buttonHeight/2;
   ++num;
-  
-  
   /* Third Row of Buttons */
-
   /* update y displacement of buttons row */
   PBY=PBY+BH+3;  
-  
   /* Shows Lighting Control Panel */
   ii = lighting;
   buttons[ii].buttonX     = XEDGE;   buttons[ii].buttonY       = PBY;
@@ -8894,7 +9096,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf       = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf       = buttons[ii].buttonHeight/2;
   ++num;
-  
   /* Shows View Volume Control Panel */
   ii = viewVolume;
   buttons[ii].buttonX     = 75;    buttons[ii].buttonY       = PBY;
@@ -8907,7 +9108,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf       = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf       = buttons[ii].buttonHeight/2;
   ++num;
-  
   /* Shows Save Panel */
   ii = saveit;
   buttons[ii].buttonX      = 180;  buttons[ii].buttonY       = PBY;
@@ -8920,7 +9120,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf        = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf        = buttons[ii].buttonHeight/2;
   ++num;
-  
   /* Exits from the viewport running */
   ii = closeAll;
   buttons[ii].buttonX     = 240;  buttons[ii].buttonY       = PBY;
@@ -8933,12 +9132,9 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf       = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf       = buttons[ii].buttonHeight/2;
   ++num;
-  
   /* Buttons to control potentiometers */
   /* These buttons appear above the potentiometer windows which they affect. */
-
   /* Rotate potentiometer buttons */
-  
   /* Rotate about the origin indicated by the axes */
   /* Red is off, Green is on */
   ii = originr;
@@ -8952,7 +9148,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf           = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf           = buttons[ii].buttonHeight/2;
   ++num;
-  
   /* Rotate about the objects center of volume */
   /* Red is off, Green is on */
   ii = objectr;
@@ -8966,9 +9161,7 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf           = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf           = buttons[ii].buttonHeight/2;
   ++num;
-  
   /* Scale potentiometer buttons */
-  
   /* Scale along X axis:  Red is off, Green is on */
   ii = zoomx;
   buttons[ii].buttonX         = 121;  buttons[ii].buttonY           = 55;
@@ -8981,7 +9174,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf           = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf           = buttons[ii].buttonHeight/2;
   ++num;
-  
   /* Scale along Y axis:  Red is off, Green is on */
   ii = zoomy;
   buttons[ii].buttonX         = 141;  buttons[ii].buttonY           = 55;
@@ -8994,7 +9186,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf           = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf           = buttons[ii].buttonHeight/2;
   ++num;
-  
   /* Zoom along Z axis:  Red is off, Green is on */
   ii = zoomz;
   buttons[ii].buttonX         = 161;  buttons[ii].buttonY           = 55;
@@ -9007,9 +9198,7 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf           = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf           = buttons[ii].buttonHeight/2;
   ++num;
-  
   /* Translate potentiometer buttons */
-  
   /* Indicates an orthographic projection of the xy-plane,
      translation is in x and y coordinates */ 
   ii = xy;
@@ -9023,7 +9212,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf      = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf      = buttons[ii].buttonHeight/2;
   ++num;
-  
   /* Indicates an orthographic projection of the xz-plane,
      translation is in x and z coordinates */ 
   ii = xz;
@@ -9037,7 +9225,6 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf      = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf      = buttons[ii].buttonHeight/2;
   ++num;
-  
   /* Indicates an orthographic projection of the yz-plane,
      translation is in y and z coordinates */ 
   ii = yz;
@@ -9051,192 +9238,20 @@ initButtons (buttonStruct *buttons)
   buttons[ii].xHalf      = buttons[ii].buttonWidth/2;
   buttons[ii].yHalf      = buttons[ii].buttonHeight/2;
   ++num;
-  
   return(num);
-  
 } /* initButtons() */
 
 @
-\section{closeview3d.c}
-<<view3d/closeview3d.c>>=
-#define _CLOSEVIEW3D_C
-
-#include <stdlib.h>
-<<view3d/header.h>>
-
-#include "util.h1"
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-
-
-/*****************************************************
- * int closeViewport()                               *
- *                                                   *
- * This closes all of the windows created for the    *
- * control panel window and the viewport window of   *
- * the current graph being displayed.                *
- * It does not currently return a specified value.   * 
- *                                                   *
- *****************************************************/
-
-void
-closeViewport (void)
-{
+\subsection{closeViewport}
+This closes all of the windows created for the
+control panel window and the viewport window of
+the current graph being displayed.
+It does not currently return a specified value.
+\index{view3d!closeViewport}
+\index{closeViewport view3d}
+<<view3d>>=
+void closeViewport(void) {
   int i;
-
   /* First, unlink viewport from global list of viewports */
   if (viewport->prevViewport) {    /* if there is a viewport before it */
     (viewport->prevViewport)->nextViewport = viewport->nextViewport;
@@ -9246,228 +9261,44 @@ closeViewport (void)
   if (viewport->nextViewport) {    /* if there is a viewport following it */
     (viewport->nextViewport)->prevViewport = viewport->prevViewport;
   }
-
   /* Free up the control panel button windows */
   for (i=0; i<maxButtons3D; i++) {
     XDeleteAssoc(dsply,table,(control->buttonQueue[i]).self);
   }
-  
   /* Free up the control panel window */
   XDestroyWindow(dsply,control->controlWindow);
   free(control);
-  
   /* Free up the viewport window */
-
   XDestroyWindow(dsply,viewport->viewWindow);
   XDestroyWindow(dsply,viewport->titleWindow);
   free(viewport);
-  
   XFlush(dsply);
-  
 } /* closeViewport() */
 
 @
-\section{component3d.c}
-<<view3d/component3d.c>>=
-#define _COMPONENT3D_C
-
-<<view3d/header.h>>
-<<view3d/draw.h>>
-
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-#include "util.h1"
-#include "xspadfill.h1"
-
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-#define axisLength	1.0   /* use 100.0, if data is not to be normalized */
-
-#define samePoint(a,b) ((refPt3D(viewData,a)->x == refPt3D(viewData,b)->x) &&\
-			(refPt3D(viewData,a)->y == refPt3D(viewData,b)->y) &&\
-			(refPt3D(viewData,a)->z == refPt3D(viewData,b)->z))
-#define MAX_POINT	1000.0
-#define MIN_POINT	-1000.0
-
-
-void 
-scaleComponents (void)
-{
-  
+\subsection{scaleComponents}
+\index{view3d!scaleComponents}
+\index{scaleComponents view3d}
+<<view3d>>=
+void scaleComponents(void) {
   double xRange,yRange,zRange;
   int i;
   viewTriple *aPoint;
-  
   /* Temporary range limits until the three dimensional clipping
      package is fully functional */
-  
   if (viewData.xmin < MIN_POINT) viewData.xmin = MIN_POINT;
   if (viewData.xmax > MAX_POINT) viewData.xmax = MAX_POINT;
   if (viewData.ymin < MIN_POINT) viewData.ymin = MIN_POINT;
   if (viewData.ymax > MAX_POINT) viewData.ymax = MAX_POINT;
   if (viewData.zmin < MIN_POINT) viewData.zmin = MIN_POINT;
   if (viewData.zmax > MAX_POINT) viewData.zmax = MAX_POINT;
-  
   xRange = viewData.xmax - viewData.xmin;
   yRange = viewData.ymax - viewData.ymin;
   zRange = viewData.zmax - viewData.zmin;
-  
   /* We scale down, normalize the data, if it is coming from Axiom
      (handled by viewman).  If the data is coming from a file (handled by
      viewalone) then it should already been scaled down. 
      */
-  
   /* Find the coordinate axis with the larges range of data and scale
      the others relative to it. 
      */
@@ -9497,7 +9328,6 @@ scaleComponents (void)
 	viewData.scaleToView = axisLength/(absolute(viewData.zmin));
     }
   }
-  
   /* We now normalize all the points in this program. The information
      needed to link the normalized set of points back to the real object
      space scale created in Axiom is held in viewData.scaleToView. */
@@ -9513,29 +9343,24 @@ scaleComponents (void)
   viewData.clipYmax = viewData.ymax;
   viewData.clipZmin = viewData.zmin;
   viewData.clipZmax = viewData.zmax;
-  
   for (i=0, aPoint=viewData.points; i<viewData.numOfPoints; i++,aPoint++) {
     aPoint->x *= viewData.scaleToView;
     aPoint->y *= viewData.scaleToView;
     aPoint->z *= viewData.scaleToView;
   }
-  
 } /* scaleComponents() */
 
-
-/*
- void makeTriangle(a,b,c)   
- Given three indices to three points, a triangular polygon is created 
- and inserted into the polygon list of viewData. If two or more of the 
- points are coincidental, no polygon is created since that would be a 
- degenerate (collapsed) polygon.
- */
-
-void
-makeTriangle (int a, int b, int c)
-{
+@
+\subsection{makeTriangle}
+Given three indices to three points, a triangular polygon is created 
+and inserted into the polygon list of viewData. If two or more of the 
+points are coincidental, no polygon is created since that would be a 
+degenerate (collapsed) polygon.
+\index{view3d!makeTriangle}
+\index{makeTriangle view3d}
+<<view3d>>=
+void makeTriangle(int a, int b, int c) {
   poly *aPoly;
-  
   if (!(samePoint(a,b) || samePoint(b,c) || samePoint(c,a))) {
     /* create triangle only if the three vertex points are distinct */
     aPoly = (poly *)saymem("component.c",1,sizeof(poly));
@@ -9551,38 +9376,30 @@ makeTriangle (int a, int b, int c)
     aPoly->next = viewData.polygons;
     viewData.polygons = aPoly;
   } /* if all points are unique */
-  
 } /* makeTriangle() */
 
-
-
-
-/*
-  void triangulate()
- 
-  Only if there is more than one list do we triangulate; a single list 
-  is used for either a space curve or simply a point.  Actually, in that 
-  case, we now make "flat" *polygons, flagged by the primitiveType field 
-  (pointComponent, etc. in tube.h).  We need to examine two lists at a time
-  (and if the structure is closed, the last and first as well). For every 
-  three points in the two lists, alternating between one in one and two in
-  the other, we construct triangles. If one list is shorter, then its last 
-  point becomes the vertex for the remaining pairs of points from the other
-  list.  It turns out that any distribution of points in the two lists 
-  (preserving cyclic order) will produce the same desired polygon.
-  */
-
-void
-triangulate (void)
-{
-  
+@
+\subsection{triangulate}
+Only if there is more than one list do we triangulate; a single list 
+is used for either a space curve or simply a point.  Actually, in that 
+case, we now make "flat" *polygons, flagged by the primitiveType field 
+(pointComponent, etc. in tube.h).  We need to examine two lists at a time
+(and if the structure is closed, the last and first as well). For every 
+three points in the two lists, alternating between one in one and two in
+the other, we construct triangles. If one list is shorter, then its last 
+point becomes the vertex for the remaining pairs of points from the other
+list.  It turns out that any distribution of points in the two lists 
+(preserving cyclic order) will produce the same desired polygon.
+\index{view3d!triangulate}
+\index{triangulate view3d}
+<<view3d>>=
+void triangulate(void) {
   int u,l;
   int uBound,lBound;
   int i,j,k;
   LLPoint *anLLPoint;
   LPoint *list1,*list2;
   poly *aPoly;
-  
   anLLPoint = viewData.lllp.llp;
   for (i=0; i<viewData.lllp.numOfComponents; i++,anLLPoint++) {
     if (anLLPoint->numOfLists > 1) {
@@ -9660,14 +9477,14 @@ triangulate (void)
       } /* point, line, polygon, surface components are taken care of above */
     } /* else anLLPoint->numOfLists <= 1 */
   } /* for LLPoints in LLLPoints (i) */
-  
 } /* triangulate */
 
-
-
-void
-readComponentsFromViewman (void)
-{
+@
+\subsection{readComponentsFromViewman}
+\index{view3d!readComponentsFromViewman}
+\index{readComponentsFromViewman view3d}
+<<view3d>>=
+void readComponentsFromViewman(void) {
   int i,j,k;
   LLPoint *anLLPoint;
   LPoint *anLPoint;
@@ -9675,9 +9492,7 @@ readComponentsFromViewman (void)
   /* maxLength holds the max(llp,lp) figure regarding how large to
      make the array of XPoints, i.e. quadMesh, for use in calling XDraw(). */
   int maxLength=0;
-  
   int *anIndex;
-  
   readViewman(&(viewData.numOfPoints),intSize);
   aPoint = viewData.points =
     (viewTriple *)saymem("component.c",viewData.numOfPoints,
@@ -9692,7 +9507,6 @@ readComponentsFromViewman (void)
       fprintf(stderr,"%g\n", aPoint->z);
 #endif
   }
-  
   readViewman(&(viewData.lllp.numOfComponents),intSize);
   anLLPoint = viewData.lllp.llp =
     (LLPoint *)saymem("component.c, i",viewData.lllp.numOfComponents,
@@ -9721,30 +9535,25 @@ readComponentsFromViewman (void)
       }
     } /* for LPoints in LLPoints (j) */
   } /* for LLPoints in LLLPoints (i) */
-  
   quadMesh = (XPoint *)saymem("component.c",maxLength+2,sizeof(XPoint));
-  
 } /* readComponentsFromViewman() */
 
-
-
-/*
-  void calcNormData()	    *
-  Calculates the surface normals for the polygons that make up the tube.
-  Also finds the fourth coefficient to the plane equation:
+@
+\subsection{calcNormData}
+Calculates the surface normals for the polygons that make up the tube.
+Also finds the fourth coefficient to the plane equation:
+\[
   Ax + By + Cz + D = 0  
-  A,B, and C are in the normal N[3] and D is the planeConst.
-  Figures out the color as well (from the average of the points) and 
-  resets the moved flag    
-  */
-
-void
-calcNormData (void)
-{
-  
+\]
+$A$, $B$, and $C$ are in the normal $N[3]$ and $D$ is the planeConst.
+Figures out the color as well (from the average of the points) and 
+resets the moved flag    
+\index{view3d!calcNormData}
+\index{calcNormData view3d}
+<<view3d>>=
+void calcNormData(void) {  
   poly *aPoly;
   int *index;
-  
   for (aPoly = viewData.polygons; aPoly != NIL(poly); aPoly = aPoly->next) {
     index = aPoly->indexPtr;
     switch (aPoly->primitiveType) {
@@ -9769,7 +9578,6 @@ calcNormData (void)
 		    refPt3D(viewData,*(index+2))->x,
 		    refPt3D(viewData,*(index+2))->y,
 		    refPt3D(viewData,*(index+2))->z, 0.0, 1.0, aPoly->N);
-      
       /* calculate the constant term, D,  for the plane equation */
       aPoly->planeConst =
 	-(aPoly->N[0] * refPt3D(viewData,*index)->x +
@@ -9782,38 +9590,30 @@ calcNormData (void)
       break;
     } /* switch */
   }
-  
 }  /* calcNormData() */
 
-
-
-/*
-  viewPoints *make3DComponents()
-
-  Read in all the 3D data from the viewport manager and construct the 
-  model of it. The model is based upon a list of lists of lists of points. 
-  Each top level list makes a component in 3-space. The interpretation 
-  really begins at the level below that, where the list of lists of 
-  points is. For 3D explicit equations of two variables, the closed 
-  boolean for this level is False and the closed boolean for each sublist 
-  is False as well. For 3D parameterized curves of one variable, the 
-  closed boolean for this level is defined by the user from Axiom , 
-  (which defaults to False) and the closed boolean for each sublist is True.
-  */
-
-viewPoints *
-make3DComponents (void)
-{
+@
+\subsection{make3DComponents}
+Read in all the 3D data from the viewport manager and construct the 
+model of it. The model is based upon a list of lists of lists of points. 
+Each top level list makes a component in 3-space. The interpretation 
+really begins at the level below that, where the list of lists of 
+points is. For 3D explicit equations of two variables, the closed 
+boolean for this level is False and the closed boolean for each sublist 
+is False as well. For 3D parameterized curves of one variable, the 
+closed boolean for this level is defined by the user from Axiom , 
+(which defaults to False) and the closed boolean for each sublist is True.
+\index{view3d!make3DComponents}
+\index{make3DComponents view3d}
+<<view3d>>=
+viewPoints *make3DComponents(void) {
   viewPoints *graphData;
-
   readComponentsFromViewman();
-
   /* The initial boundaries for the clipping region are set to those
      of the boundaries of the data region. */
   viewData.clipXmin = viewData.xmin;  viewData.clipXmax = viewData.xmax;
   viewData.clipYmin = viewData.ymin;  viewData.clipYmax = viewData.ymax;
   viewData.clipZmin = viewData.zmin;  viewData.clipZmax = viewData.zmax;
-  
   /* normalize the data coordinates */
   if (viewData.scaleDown) scaleComponents();
   viewData.numPolygons = 0;
@@ -9823,9 +9623,7 @@ make3DComponents (void)
   triangulate();
   /* calculate the plane equations for all the polygons */
   calcNormData();
-  
   graphData = makeViewport();
-  
   imageX = XCreateImage(/* display */        dsply,
 			/* visual */         DefaultVisual(dsply,scrn),
 			/* depth */          DefaultDepth(dsply,scrn),
@@ -9837,7 +9635,6 @@ make3DComponents (void)
 			/* bitmap_pad */     32,
 			/* bytes_per_line */ 0);
   imageX->data = NIL(char);
-  
   /* windowing displaying */
   writeTitle();
   postMakeViewport();
@@ -9846,19 +9643,15 @@ make3DComponents (void)
   XMapWindow(dsply, graphData->viewWindow);
   XMapWindow(dsply, graphData->titleWindow);
   XFlush(dsply);
-  
   return(graphData);
-  
 } /* make3DComponents */
 
-
-
-
-
-void
-draw3DComponents (int dFlag)
-{
-  
+@
+\subsection{draw3DComponents}
+\index{view3d!draw3DComponents}
+\index{draw3DComponents view3d}
+<<view3d>>=
+void draw3DComponents(int dFlag) {
   int	     i, j, k, hue, x1, y1, x2, y2;
   LLPoint    *anLLPoint;
   LPoint     *anLPoint;
@@ -9869,12 +9662,10 @@ draw3DComponents (int dFlag)
   viewTriple *aLPt;
   XPoint     line[2];
   RGB	     col_rgb;
-  
   calcEyePoint();
   while ((XPending(dsply) > 0) && (scanline > 0))
     XNextEvent(dsply,&peekEvent);
   switch (viewData.style) {
-    
   case transparent:
     GSetLineAttributes(componentGC,0,LineSolid,CapButt,JoinMiter,dFlag);
     if (dFlag==Xoption) {
@@ -9887,38 +9678,38 @@ draw3DComponents (int dFlag)
     }
     /* no need to check "keep drawing" for ps */
     if (dFlag == Xoption) drawMore = keepDrawingViewport();
-    
-    /*
-      This is where we interpret the list of lists of lists of points struct.
-      We want to extract the following forms of data:
-      - individual points (drawn as filled points)
-      - lines (space curves)
-      - defined polygon primitives
-      - surfaces
-      the last one is the one that will replace the function of 2 variables,
-      tubes as well as 3D parameterized functions of 2 variables.
-      Since there could be many other ways of constructing L L L Pts - much
-      more than could be usefully interpreted - any other formats are
-      currently not allowed. When they are, this comment should be updated
-      appropriately.
-
-      ************************************************************************
-      
-      Traverse each component.
-      We decide here, before we begin traversing the
-      component what we want to interpret it as.
-      Here's the convention used to figure that out:
-      - points:	#anLLPoint->numOfLists was 1
-      #anLPoint->numOfPoints is 1
-      - lines:	#anLLPoint->numOfLists was 1
-      #anLPoint->numOfPoints > 1
-      - polygons: #anLLPoint->numOfLists was 2
-      #anLPoint->numOfPoints is 1
-      - surface:	#anLLPoint->numOfLists was some m>1
-      #anLPoint->numOfPoints all point lists are the same.
+@
+This is where we interpret the list of lists of lists of points struct.
+We want to extract the following forms of data:
+\begin{itemize}
+\item individual points (drawn as filled points)
+\item lines (space curves)
+\item defined polygon primitives
+\item surfaces
+\end{itemize}
+the last one is the one that will replace the function of 2 variables,
+tubes as well as 3D parameterized functions of 2 variables.
+Since there could be many other ways of constructing 
+{\tt List List List Points} - much
+more than could be usefully interpreted - any other formats are
+currently not allowed. When they are, this comment should be updated
+appropriately.
       
-      */
-
+Traverse each component.
+We decide here, before we begin traversing the
+component what we want to interpret it as.
+Here's the convention used to figure that out:
+\begin{itemize}
+\item points: \#anLLPoint$\rightarrow$numOfLists was 1\\
+\#anLPoint$\rightarrow$numOfPoints is 1
+\item lines: \#anLLPoint$\rightarrow$ numOfLists was 1\\
+\#anLPoint$\rightarrow$numOfPoints > 1
+\item polygons: \#anLLPoint$\rightarrow$numOfLists was 2\\
+\#anLPoint$\rightarrow$numOfPoints is 1
+\item surface: \#anLLPoint$\rightarrow$numOfLists was some $m>1$\\
+\#anLPoint$\rightarrow$numOfPoints all point lists are the same.
+\end{itemize}
+<<view3d>>=
     anLLPoint = viewData.lllp.llp;
     for (i=0; i<viewData.lllp.numOfComponents; i++,anLLPoint++) {
       /* initially, component type is unknown */
@@ -9934,11 +9725,8 @@ draw3DComponents (int dFlag)
       /* Check for corrupt data and NaN data is made in Axiom . */
       if (componentType == stillDontKnow)
 	componentType = surfaceComponent;
-      
       anLPoint = anLLPoint->lp;
-      
       switch (componentType) {
-	
       case pointComponent:
 	/* anLLPoint->numOfLists == anLLPoint->lp->numOfPoints == 1 here */
 	aLPt = refPt3D(viewData,*(anLPoint->indices));
@@ -9954,7 +9742,6 @@ draw3DComponents (int dFlag)
 	GFillArc(componentGC,viewport->viewWindow,quadMesh->x,quadMesh->y,
 		 viewData.pointSize,viewData.pointSize,0,360*64,dFlag);
 	break;
-	
       case lineComponent:
 	/* anLLPoint->numOfLists == 1 here */
 	anIndex = anLPoint->indices;
@@ -10026,7 +9813,6 @@ draw3DComponents (int dFlag)
 	  }
 	}
 	break;
-	
       case polygonComponent:
 	/* first pt of polygon is a single list */
 	project(refPt3D(viewData,*(anLPoint->indices)),quadMesh,0);
@@ -10097,7 +9883,6 @@ draw3DComponents (int dFlag)
 	}
 	/* close a polygon */
 	break;
-	
       case surfaceComponent:
 	if (dFlag==Xoption) {
 	  if (mono || viewport->monoOn)
@@ -10108,7 +9893,6 @@ draw3DComponents (int dFlag)
 	else {
 	  GSetForeground(componentGC, psBlack, dFlag);
 	}
-	
 	/* traverse down one direction first (all points 
 	   in a list at a time) */
 	for (j=0; drawMore && j<anLLPoint->numOfLists; j++,anLPoint++) {
@@ -10129,7 +9913,6 @@ draw3DComponents (int dFlag)
 	      }
 	      clip_a = clip_i + 1;
 	    }
-	    
 	    drawMore = keepDrawingViewport();
 	  } /* for points in LPoints (k) */
 	  if (drawMore) {
@@ -10158,7 +9941,6 @@ draw3DComponents (int dFlag)
 	    }
 	  } /* drawMore */
 	} /* for LPoints in LLPoints (j) */
-	
 	/* now traverse down the list in the other direction
 	   (one point from each list at a time) */
 	for (j=0; drawMore && j<anLLPoint->lp->numOfPoints; j++) {
@@ -10180,7 +9962,6 @@ draw3DComponents (int dFlag)
 	    }
 	    drawMore = keepDrawingViewport();
 	  } /* for points in LPoints (k) */
-	  
 	  if (drawMore) {
 	    /* if drawMore is true, then the above loop terminated with
 	       clip_i incremented properly */
@@ -10211,7 +9992,6 @@ draw3DComponents (int dFlag)
       } /* switch componentType */
     } /* for LLPoints in LLLPoints (i) */
     break;
-    
   case opaqueMesh:
     if (dFlag==Xoption) {
       GSetForeground(globGC, (float)opaqueForeground, dFlag);
@@ -10224,7 +10004,6 @@ draw3DComponents (int dFlag)
     GSetLineAttributes(opaqueGC,0,LineSolid,CapButt,JoinRound,dFlag);
     drawPolygons(dFlag);
     break;
-    
   case render:
     if (viewData.outlineRenderOn) {
       GSetLineAttributes(renderGC,0,LineSolid,CapButt,JoinRound,dFlag);
@@ -10233,1947 +10012,23 @@ draw3DComponents (int dFlag)
     }
     drawPolygons(dFlag);
     break;
-    
   case smooth:
     drawPhong(dFlag);
     break;
-    
   } /* switch on style */
-  
 } /* draw3DComponents() */
 
 @
-\section{contour3d.c.out}
-<<view3d/contour3d.c.out>>=
-  /***********************************************************************
-    contour.c
-    
-    begun 19 September 1992, Jim Wen
-   ***********************************************************************/
-
-<<view3d/header.h>>
-<<view3d/draw.h>>
-
-#define segmentDEBUG_X
-
-#define contourDEBUG_X
-#define use_min
-#define realloc_bug_fixed_NOT
-
-  /*=====================================================================*
-    Static variables
-   *=====================================================================*/
-int noo=0;
-poly   		       *contour_poly_list;
-poly     	       *active_list_first, *active_list_last, *active_list_current;
-segment_list_struct    *tmp_segment_list;
-
-  /*=====================================================================*
-    macro definitions
-   *=====================================================================*/
-#define foreach_poly(p)       for ((p)=contour_poly_list; p != NIL(poly); p=p->next)
-#define foreach_active(p,f,l) if (f != NIL(poly)) for (p=f; p!=l; p=(p)->next)
-#define in_range(x,a,b)	      ( ((x>=a) && (x<b)) || ((x<a) && (x>=b)) )
-#define poly_in_plane(p,z)    ( (p->contour_min==z) && (p->contour_max==z) )
-
-			       
-
-  /*=====================================================================*
-    local function declarations
-   *=====================================================================*/
-int 		 contour_compare(poly *p1, poly *p2);
-void 		 add_segment(segment_list_struct * seg_list, int index,
-                   segment_struct * seg);
-segment_struct  *make_the_segment(viewTriple * pt1, viewTriple * pt2);
-viewTriple 	*mkpoint(viewTriple * vt1, viewTriple * vt2,
-                   CONTOUR_float z_val);
-CONTOUR_float    get_t_from_pts(CONTOUR_float z_min, CONTOUR_float  z_max,
-                   CONTOUR_float z_val);
-void 		 make_active_list(poly *da_list, CONTOUR_float z_min,
-                   CONTOUR_float z_max, poly ** af, poly ** al, poly ** ac);
-int 		 maintain_active_list(poly ** af, poly ** al, poly ** ac,
-                   CONTOUR_float z_max, CONTOUR_float z_min);
-void             contour_minMaxPolygons(poly * aPoly);
-
-  /*=====================================================================*
-    contour_compare()
-    
-    The compare function passed to msort. 
-   *=====================================================================*/
-int
-contour_compare(poly *p1, poly *p2)
-{
-
-#ifdef use_min
-  if (p1->contour_min < p2->contour_min) return(-1);
-  else if (p1->contour_min == p2->contour_min) return(0);
-  else return(1);
-#else
-  if (p1->contour_max > p2->contour_max) return(-1);
-  else if (p1->contour_max == p2->contour_max) return(0);
-  else return(1);
-#endif /* use_min */
-}  /* contour_compare() */
-
-  /*=====================================================================*
-    do_contour_map()
-   *=====================================================================*/
-int
-do_contour_map(void)
-{
-
-  poly *pp;
-  poly *ap;
-  CONTOUR_float z_now;
-  int got_more;
-  int *anIndex;
-  viewTriple *aPt, *daPt, *one_point;
-  int jj, segment_index;
-  int got_one_intersection;
-  int done;
-  segment_list_struct *sl;
-#ifdef contour_object_rotate
-  float rotMat[4][4];
-  float transformed_zmax, transformed_zmin;
-#endif
-#ifdef conDEBUG
-  segment_struct *seg;
-#endif
-
-        /*---------------------------------------------------*
-	  the flag "did_contour" should be set to "no" whenever
-	  the user modifies one of the parameters
-         *---------------------------------------------------*/
-#ifdef contourDEBUG_x
-  fprintf(stderr,"Contour is %s\n",(did_contour)?"yes":"no");
-#endif
-  if (did_contour) return 1;
-  did_contour = yes;
-
-#ifdef contour_object_rotate
-        /*---------------------------------------------------*
-	  transform all the points for arbitrary plane
-	  slicing.  this includes all the viewTriples
-	  being referenced as well as the boundaries
-	  in viewData (to get contour_min, contour_max).
-         *---------------------------------------------------*/
-#ifdef oldie
-  rot_theta = 0;
-  rot_phi   = pi/2;
-#endif
-
-  sinTheta  = sin(-rot_theta);
-  cosTheta  = cos(-rot_theta);
-  sinPhi    = sin(rot_phi);
-  cosPhi    = cos(rot_phi);
-  ROTATE1(rotMat);
-
-        /*---------------------------------------------------*
-	  transform all the points.
-	  the zmin and zmax values need to be recalculated
-	  now that the object has been transformed.  note
-	  that transforming the z extreme points will not
-	  work correctly (i know, i've tried it).
-         *---------------------------------------------------*/
-    {
-      int i,j,k;
-      LLPoint *anLLPoint;
-      LPoint *anLPoint;
-      int *anIndex;
-      viewTriple *daPoint;
-      float v_in[4], v_out[4];
-      int first_time = yes;
-
-      anLLPoint = viewData.lllp.llp;
-      for (i=0; i<viewData.lllp.numOfComponents; i++,anLLPoint++) {
-	anLPoint = anLLPoint->lp;
-	for (j=0; j<anLLPoint->numOfLists; j++,anLPoint++) {
-	  anIndex = anLPoint->indices;
-	  for (k=0; k<anLPoint->numOfPoints; k++,anIndex++) {
-	    daPoint = refPt3D(viewData, *anIndex);
-        /*---------------------------------------------------*
-	  inefficient code so that the vector package could
-	  be used to see if things work;
-	  should change viewTriple's <x,y,z> to an array(?)
-         *---------------------------------------------------*/
-	    v_in[0] = daPoint->x;  v_in[1] = daPoint->y;  
-	    v_in[2] = daPoint->z;  v_in[3] = 1.0;
-	    vectorMatrix4(v_in, rotMat, v_out);
-	    daPoint->contour_x = v_out[0];  
-	    daPoint->contour_y = v_out[1];
-	    daPoint->contour_z = v_out[2];
-	    if (first_time) {
-	      first_time = no;
-	      transformed_zmin = transformed_zmax = v_out[2];
-	    } else {
-	      if (v_out[2] < transformed_zmin)
-	        transformed_zmin = v_out[2];
-	      else if (v_out[2] > transformed_zmax) 
-	        transformed_zmax = v_out[2];
-	    }
-	  } /* for points in LPoints (k) */
-	} /* for LPoints in LLPoints (j) */
-      } /* for LLPoints in LLLPoints (i) */
-
-    }
-
-#endif
-
-
-        /*---------------------------------------------------*
-	  set up the step size - it should be user adjustable
-	  and include all the slices possible.
-	  max_cuts is #slices seen
-	  z_step is #slices made
-	  cuts_used is #slices actually displayed
-         *---------------------------------------------------*/
-  z_step = (transformed_zmax - transformed_zmin)/max_cuts;
-#ifdef oldie
-  cuts_used = max_cuts;
-#endif
-
-        /*---------------------------------------------------*
-	  calculate the bounds of the polygons - the 
-	  contour_minMaxPolygons routine looks at the
-	  contour points rather than the object or 
-	  projected points
-         *---------------------------------------------------*/
-  contour_poly_list = copyPolygons(viewData.polygons);
-  contour_minMaxPolygons(contour_poly_list);
-
-        /*---------------------------------------------------*
-	  sort the polygons by the zmax value
-	  (or whatever transformed value, in general)
-         *---------------------------------------------------*/
-  contour_poly_list = msort(contour_poly_list, 0, 
-			    viewData.numPolygons, contour_compare);
-
-        /*---------------------------------------------------*
-	  having figured out how many cuts we need (should
-	  be a one time overhead so the following stuff
-	  should be in the initialization routine), we
-	  allocate an array of segment lists and initialize
-	  them (this part can stay here).
-         *---------------------------------------------------*/
-#ifdef oldie
-  segment_list = saymem("contour.c: segment_list", 
-			max_cuts, sizeof(segment_list_struct));
-#else
-        /*---------------------------------------------------*
-	  if the append flag is set, then we want to add 
-	  the new segment stuff onto the end of the old
-	  stuff (to build up a model of the surface).
-	  tmp_segment_list is use to keep track of the
-	  head of the new list while the routine goes
-	  through its paces.
-         *---------------------------------------------------*/
-  if (contour_append_lists_flag) {
-    noo = 0;
-#ifdef segmentDEBUG
-    fprintf(stderr,"======= series %d ========\n",noo);
-    fprintf(stderr,"     ---> before: sl->num=%d [%x]\n",
-	    segment_list->num, segment_list);
-#endif
-
-#ifdef realloc_bug_fixed
-    realloc(segment_list, (cuts_used + max_cuts) * sizeof(segment_list_struct));
-    tmp_segment_list = segment_list;
-    segment_list += cuts_used;  /* shift to end of list */
-    cuts_used += max_cuts;      /* size of new list */
-
-#ifdef segmentDEBUG
-    fprintf(stderr,"> %d cuts => seg at %x [old=%x]\n",
-  	  cuts_used, segment_list, tmp_segment_list);
-    fprintf(stderr,"        sl->num=%d, tsl->num=%d\n",
-	    segment_list->num, tmp_segment_list->num);
-#endif
-
-#else /* DONT_WORK */
-
-        /*---------------------------------------------------*
-	  Because realloc doesn't seem to work properly,
-	  we need to do this by hand
-         *---------------------------------------------------*/
-        /*---------------------------------------------------*
-	  allocate new space
-         *---------------------------------------------------*/
-  tmp_segment_list = saymem("contour.c: segment_list, append",
-			    cuts_used + max_cuts,
-			    sizeof(segment_list_struct));
-
-        /*---------------------------------------------------*
-	  copy over old data (1..cuts_used)
-         *---------------------------------------------------*/
-  {
-    segment_list_struct *tsl;
-
-    for (segment_index=0, sl=segment_list, tsl=tmp_segment_list; 
-	 segment_index<cuts_used; 
-	 segment_index++, sl++, tsl++) {
-      tsl->num = sl->num;
-      tsl->max_num = sl->max_num;
-      tsl->num_segs = sl->num_segs;
-      tsl->segments = sl->segments;
-    }
-  }
-
-        /*---------------------------------------------------*
-	  free the old stuff
-         *---------------------------------------------------*/
-/*  free(segment_list); */
-
-        /*---------------------------------------------------*
-	  now set segment_list to point to the point
-	  where tmp_segment_list stops - there ought
-	  to me max_cuts storage spaces left.
-         *---------------------------------------------------*/
-  segment_list = tmp_segment_list + cuts_used;
-
-        /*---------------------------------------------------*
-	  update cuts_used to have everything for a possible
-	  next iteration
-         *---------------------------------------------------*/
-  cuts_used += max_cuts;
-
-#endif /* realloc_BUG */
-
-
-  } else {
-    if (contour_allocated) {
-/*      free(segment_list); */
-    } else {
-      contour_allocated = yes;
-    }
-    noo = 0;
-    segment_list = saymem("contour.c: segment_list", 
-			  max_cuts, sizeof(segment_list_struct));
-    cuts_used = max_cuts;
-#ifdef segmentDEBUG
-    fprintf(stderr,"======= series %d ========\n",noo);
-    fprintf(stderr,"%d cuts => seg at %x\n",cuts_used, segment_list);
-#endif
-  }
-#endif
-
-  for (segment_index=0, sl=segment_list; 
-       segment_index<max_cuts; 
-       segment_index++, sl++) {
-    sl->num = ++noo;
-    sl->max_num = max_cuts;
-#ifdef segmentDEBUG
-    fprintf(stderr,"Made segment list %d  [%x]\n",noo,sl);
-/*    fprintf(stderr,"       ...(tsl->num=%d [%x]\n",
-	    tmp_segment_list->num, tmp_segment_list); */
-#endif
-    sl->num_segs = 0;
-    sl->segments = NIL(segment_struct);
-  }
-        /*---------------------------------------------------*
-	  create an "active_list" of polygons such that 
-	  this slice step intersects all and only those
-	  polygons in the active list.
-         *---------------------------------------------------*/
-  make_active_list(contour_poly_list,
-#ifdef use_min
-		   transformed_zmin, transformed_zmin+z_step,
-#else
-		   transformed_zmax, transformed_zmax-z_step,
-#endif
-		   &active_list_first, &active_list_last, &active_list_current);
-
-        /*---------------------------------------------------*
-	  iterate from zmax down to zmin with z_step increments
-         *---------------------------------------------------*/
-  segment_index = 0;
-#ifdef use_min
-  for (z_now=transformed_zmin; z_now<transformed_zmax; /* see below for incr*/) {
-#else
-  for (z_now=transformed_zmax; z_now>transformed_zmin; /* see below for incr*/) {
-#endif
-        /*---------------------------------------------------*
-	  for each of the polygons on the active list, 
-	  intersect each of line equation for the sides	
-	  with the plane equation for the plane at z_now.
-	  one of the following may occur:
-	     no intersections: haha - can't happen coz active
-	    one intersection : at the point, create point line
-	    two intersections: create line connecting points
-	    lies in the plane: create three segments
-	  note that this is a fairly inefficient approach but
-	  i'm just throwing this stuff together in an afternoon
-	  to see how it looks
-         *---------------------------------------------------*/
-    foreach_active(ap, active_list_first, active_list_last) {
-
-        /*---------------------------------------------------*
-	  do line-plane equation for each side of the 
-	  polygon
-	  for now - just 3+ sided polygons (no degenerates)
-         *---------------------------------------------------*/
-
-      if (ap->numpts >= 3) {
-	if (poly_in_plane(ap, z_now)) {
-        /*---------------------------------------------------*
-	  re-create all the segments of the polygon
-         *---------------------------------------------------*/
-	  daPt = refPt3D(viewData, *(ap->indexPtr + (ap->numpts - 1)));
-	  for (jj=0, anIndex=ap->indexPtr; jj<ap->numpts; jj++, anIndex++) {
-	    aPt = refPt3D(viewData, *anIndex);
-	    add_segment(segment_list, segment_index, 
-			make_the_segment(aPt, daPt));
-	    daPt = aPt;
-	  }
-	} else {
-        /*---------------------------------------------------*
-	  find the line that defines the intersection of 
-	  the polygon with the z-plane
-         *---------------------------------------------------*/
-	  got_one_intersection = no;
-	  done = no;
-	  daPt = refPt3D(viewData, *(ap->indexPtr + (ap->numpts - 1)));
-	  for (jj=0, anIndex=ap->indexPtr; 
-	       !done && jj<ap->numpts; 
-	       jj++, anIndex++) {
-	    aPt = refPt3D(viewData, *anIndex);
-	    if (in_range(z_now, aPt->contour_z, daPt->contour_z)) {
-	      if (got_one_intersection) {
-		add_segment(segment_list, segment_index,
-			    make_the_segment(one_point, 
-					     mkpoint(aPt, daPt, z_now)));
-		done = yes;
-	      } else {
-		one_point = mkpoint(aPt, daPt, z_now);
-		got_one_intersection = yes;
-	      }
-	    } 
-	    daPt = aPt;
-	  }  /* for */
-	}  /* else not lie in plane */
-
-      }
-    }  /* foreach_active(ap) */
-
-        /*---------------------------------------------------*
-	  maintain/update the active list, pruning off things
-	  the fall off the top (beyond z_now - z_step) and
-===>	  adding on things to the bottom that now fall into   
-	  the range [z_now ---> z_now-z_step].
-         *---------------------------------------------------*/
-    segment_index++;
-#ifdef use_min
-    z_now += z_step;
-    got_more = maintain_active_list(&active_list_first, 
-				    &active_list_last, 
-				    &active_list_current,
-				    z_now + z_step, 
-				    z_now);
-#else
-    z_now -= z_step;
-    got_more = maintain_active_list(&active_list_first, 
-				    &active_list_last, 
-				    &active_list_current,
-				    z_now, 
-				    z_now - z_step);
-#endif
-  }  /* for z_now from zmax to zmin */
-
-        /*---------------------------------------------------*
-	  if the segment lists have been appended, reset
-	  the global segment lists pointer to the top of
-	  the lists
-         *---------------------------------------------------*/
-  if (contour_append_lists_flag) {
-    segment_list = tmp_segment_list;
-#ifdef segmentDEBUG
-#ifdef oldie
-    fprintf(stderr,"    setting seg to old=%x\n", segment_list);
-    fprintf(stderr,"        num is %d\n",segment_list->num);
-#endif
-  {
-
-    for (segment_index=0, sl=segment_list; 
-	 segment_index<cuts_used; 
-	 segment_index++, sl++) {
-      fprintf(stderr,"   sl->num = %d\n",sl->num);
-    }
-  }
-
-#endif
-  }
-
-}  /* do_contour_map() */
-
-
-  /*=====================================================================*
-    make_active_list(da_list, z_min, z_max, af, al, ac)
-   *=====================================================================*/
-void 
-make_active_list(poly *da_list, CONTOUR_float z_min, CONTOUR_float z_max,
-                 poly ** af, poly ** al, poly ** ac)
-{
-
-  poly *tmp_p;
-
-        /*---------------------------------------------------*
-	  the first active polygon is the first one in the
-	  given, sorted list.  note that if it doesn't fall
-===>	  inside the z_max --> z_min range, af is set to NIL.
-         *---------------------------------------------------*/
-#ifdef use_min
-  if (da_list->contour_min > z_max) {
-#else
-  if (da_list->contour_max < z_min) {
-#endif
-    *af = NIL(poly);
-    return;
-  } else {
-    *af = da_list;
-  }
-
-        /*---------------------------------------------------*
-	  the current active polygon is set to "af" at this
-	  point but it could be the case that it is set to	
-	  "al" if, for example, the current span of z-values
-	  has no polygons - af is set to NIL, and the next
-	  time we look we start at ac=af.
-         *---------------------------------------------------*/
-  *ac = *af;
-
-        /*---------------------------------------------------*
-	  the last active polygon is the polygon right before
-===>	  the first one whose zmax is too small to make the
-	  list 
-         *---------------------------------------------------*/
-  *al = da_list;	
-  tmp_p = da_list->next;
-  for (; tmp_p != NIL(poly); tmp_p = tmp_p->next) {
-#ifdef use_min
-    if (tmp_p->contour_min > z_max) return;
-#else
-    if (tmp_p->contour_max < z_min) return;
-#endif
-    *al = tmp_p;
-  }
-  
-}  /* make_active_list() */
-
-
-  /*=====================================================================*
-    maintain_active_list(af, al, ac, z_max, z_min)
-   *=====================================================================*/
-int 
-maintain_active_list(poly ** af, poly ** al, poly ** ac,
-                     CONTOUR_float z_max, CONTOUR_float z_min)
-{
-
-  poly *tmp_p;
-
-        /*---------------------------------------------------*
-	  first, get the lower boundary to be within range,
-	  pruning elements from the head of the list
-         *---------------------------------------------------*/
-  *af = *ac;
-#ifdef use_min
-  while ((*af) && (*af)->contour_max < z_min) {
-#else
-  while ((*af) && (*af)->contour_min > z_max) {
-#endif
-    *af = (*af)->next;
-  }
-
-        /*---------------------------------------------------*
-	  check to see if the upper boundary is still in
-	  range
-         *---------------------------------------------------*/
-#ifdef use_min
-  if ((*af) == NIL(poly) || ((*af)->contour_min > z_max)) {
-#else
-  if ((*af) == NIL(poly) || ((*af)->contour_max < z_min)) {
-#endif
-    /*   --- nope, it wasn't ---   */
-    *ac = *af;
-    *af = NIL(poly);
-    return(0);
-  }
-
-        /*---------------------------------------------------*
-	  upper boundary is okay...see if we need to add to
-	  the list on the lower bound side
-         *---------------------------------------------------*/
-  tmp_p = (*al)->next;
-  for (; tmp_p != NIL(poly); tmp_p = tmp_p->next) {
-#ifdef use_min
-    if (tmp_p->contour_min > z_max) return;
-#else
-    if (tmp_p->contour_max < z_min) return;
-#endif
-    *al = tmp_p;
-  }
-
-  return(1);
-
-}  /* maintain_active_list() */
-
-
-  /*=====================================================================*
-    add_segment(seg_list, index, seg)
-   *=====================================================================*/
-void
-add_segment(segment_list_struct * seg_list, int index, segment_struct * seg)
-{
-
-  segment_list_struct *sl;
-
-  sl = seg_list + index;
-
-  seg->next = sl->segments;
-  sl->segments = seg;
-  sl->num_segs++;
-
-}  /* add_segment() */
-
-
-  /*=====================================================================*
-    make_the_segment(pt1, pt2)
-   *=====================================================================*/
-segment_struct *
-make_the_segment(viewTriple * pt1, viewTriple * pt2)
-{
-  segment_struct *seg;
-  
-  seg = (segment_struct *)saymem("contour.c: segment",1,sizeof(segment_struct));
-  seg->point1 = pt1;
-  seg->point2 = pt2;
-
-  return(seg);
-
-}  /* make_the_segment() */
-
-
-  /*=====================================================================*
-    viewTriple *mkpoint(vt1, vt2, z_val)
-   *=====================================================================*/
-viewTriple *
-mkpoint(viewTriple * vt1, viewTriple * vt2, CONTOUR_float z_val)
-{
-
-  viewTriple *vt;
-  CONTOUR_float t;
-
-  vt = (viewTriple *)saymem("contour.c: viewTriple",1,sizeof(viewTriple));
-  
-  t = get_t_from_pts(vt1->contour_z, vt2->contour_z, z_val);
-
-#ifdef waitaminute
-  vt->x = vt1->contour_x + (vt2->contour_x - vt1->contour_x) * t;
-  vt->y = vt1->contour_y + (vt2->contour_y - vt1->contour_y) * t;
-  vt->z = z_val;
-#else
-  vt->x = vt1->x + (vt2->x - vt1->x) * t;
-  vt->y = vt1->y + (vt2->y - vt1->y) * t;
-  vt->z = vt1->z + (vt2->z - vt1->z) * t;
-#endif
-
-  vt->contour_x = vt1->contour_x + (vt2->contour_x - vt1->contour_x) * t;
-  vt->contour_y = vt1->contour_y + (vt2->contour_y - vt1->contour_y) * t;
-  vt->contour_z = z_val;
-
-  return(vt);
-
-}  /* mkpoint() */
-
-
-
-  /*=====================================================================*
-    get_t_from_pts(z_min, z_max, z_val)
-   *=====================================================================*/
-CONTOUR_float
-get_t_from_pts(CONTOUR_float z_min, CONTOUR_float  z_max, CONTOUR_float z_val)
-{
-  CONTOUR_float t;
-
-  if (z_min == z_max) return 0;
-  
-  t = (z_val - z_min)/(z_max - z_min);
-
-  return(t);
-}  /* get_t_from_pts() */
-
-
-void
-contour_minMaxPolygons(poly * aPoly)
-{
-
-  int *anIndex;
-  int i;
-
-
-  for (; aPoly != NIL(poly); aPoly = aPoly->next) {
-    anIndex = aPoly->indexPtr;
-    aPoly->contour_min = aPoly->contour_max = 
-      refPt3D(viewData,*anIndex)->contour_z;
-    for (i=1,anIndex++; i<aPoly->numpts; i++,anIndex++) {
-      if (refPt3D(viewData,*anIndex)->contour_z < aPoly->contour_min)
-        aPoly->contour_min = refPt3D(viewData,*anIndex)->contour_z;
-      else if (refPt3D(viewData,*anIndex)->contour_z > aPoly->contour_max)
-        aPoly->contour_max = refPt3D(viewData,*anIndex)->contour_z;
-    }
-  }
-
-
-}  /* contour_minMaxPolygons */
-@
-\section{contour.h}
-<<view3d/contour.h>>=
-  /***********************************************************************
-    contour.h
-   ***********************************************************************/
-#define segDEBUG
-
-/* #define contour -100*/
-
-#define CONTOUR_float double
-#define ACTIVE_poly_struct poly
-
-#define line_crosses_plane(z_min, z_max, z_val) \
-  ((z_min < z_val) && (z_max >= z_val))
-
-#ifdef oldie
-@
-\index{struct!active\_poly\_struct}
-\index{active\_poly\_struct struct}
-<<view3d/contour.h>>=
-typedef struct _active_poly_struct {
-  struct _active_poly_struct *next;
-  int num;
-  struct _poly *polygon;
-} active_poly_struct;
-#endif
-
-@
-\index{struct!segment\_struct}
-\index{segment\_struct struct}
-<<view3d/contour.h>>=
-typedef struct _segment_struct {
-  struct _segment_struct *next;
-  struct _viewTriple     *point1, *point2;
-} segment_struct;
-
-@
-\index{struct!segment\_list\_struct}
-\index{segment\_list\_struct struct}
-<<view3d/contour.h>>=
-typedef struct _segment_list_struct {
-  int		  num_segs;
-  segment_struct *segments;
-  int num, max_num;  /* num=slice num, max_num=#slices for this contour */
-} segment_list_struct;
-
-  /*=====================================================================*
-    Macro Definitions
-   *=====================================================================*/
-#define foreach_slice(index, slice, slice_list, max_slices) 	\
-  for (index=0;							\
-       (index<max_slices) && (int)(slice=(slice_list+index)); 	\
-       index++)
-#define foreach_segment(seg, slice, fl)				\
-  for (seg=slice->segments; (fl) && (seg != NIL(segment_struct)); seg=seg->next)
-
-#define foreach_segment_old(idx, s, sl, max, fl) \
-  for (idx=0; idx<max; idx++) 					\
-    for (s=(sl+idx)->segments; (fl) && (s != NIL(segment_struct)); s=s->next)
-
-  /*---------------------------------------------------------------------*
-    interface stuff
-   *---------------------------------------------------------------------*/
-#ifdef oldie
-#define contourCursorForeground moColor(red1, light)
-#define contourCursorBackground moColor(green0, normal)
-#else
-#define contourCursorForeground monoColor(68)
-#define contourCursorBackground monoColor(197)
-#endif
-
-#define contourMASK	ExposureMask
-
-#define contourPlaneTextCOLOR 28
-
-        /*---------------------------------------------------*
-	  title, dividing lines & stuff
-         *---------------------------------------------------*/
-#define contourTitleColor moColor(blue0, normal)
-#define contourTitleA	190
-#define contourTitleB	217
-
-#define dotSize 8
-#define dotExt  12
-#define dotColor moColor(red2, pastel)
-
-        /*---------------------------------------------------*
-	  Button Positions & Dimensions
-         *---------------------------------------------------*/
-#define contourPlaneXY_X 150
-#define contourPlaneXY_Y 250
-#define contourPlaneXZ_X 190
-#define contourPlaneXZ_Y 250
-#define contourPlaneYZ_X 230
-#define contourPlaneYZ_Y 250
-#define contourLittleButt_W 20
-#define contourLittleButt_H 20
-
-#define contourFlatView_X 120
-#define contourFlatView_Y 290
-#define contourAppendSegs_X 120
-#define contourAppendSegs_Y 320
-#ifdef oldie
-#define contourBigButt_W  170 
-#define contourBigButt_H   20 
-#else
-#define contourBigButt_W  10 
-#define contourBigButt_H  10 
-#endif
-        /*---------------------------------------------------*
-	  Line & button colors
-         *---------------------------------------------------*/
-#define abort_FG      moColor(red1, pastel)
-#define return_FG     moColor(green2, pastel)
-#define littleButt_FG moColor(yellow0, pastel)
-#define bigButt_FG    moColor(orange1, pastel)
-
-        /*---------------------------------------------------*
-	  longitude part
-         *---------------------------------------------------*/
-#define contourLongitude_X  10
-#define contourLongitude_Y  55
-#define contourLongitude_W  135
-#define contourLongitude_H  120
-
-#define long_FG        moColor(green1, normal)
-#define long_corner_X  36
-#define long_corner_Y  72
-#define long_RADIUS    40
-#define long_W         (long_RADIUS<<1)
-#define long_H         (long_RADIUS<<1)
-
-#define long_center_X  (long_corner_X + long_RADIUS)
-#define long_center_Y  (long_corner_Y + long_RADIUS)
-
-#define long_str_X 15
-#define long_str_Y 48
-
-        /*---------------------------------------------------*
-	  latitude part
-         *---------------------------------------------------*/
-#define contourLatitude_X   160
-#define contourLatitude_Y   55
-#define contourLatitude_W   135
-#define contourLatitude_H   120
-
-#define lat_FG        moColor(green1, normal)
-#define lat_corner_X  130
-#define lat_corner_Y  85
-#define lat_RADIUS    60
-#define lat_W         (lat_RADIUS<<1)
-#define lat_H         (lat_RADIUS<<1)
-#define lat_quad_X    (lat_corner_X + lat_RADIUS)
-#define lat_quad_Y    (lat_corner_Y + lat_RADIUS)
-
-#define lat_str_X 176
-#define lat_str_Y 48
-
-        /*---------------------------------------------------*
-	  slice part
-         *---------------------------------------------------*/
-#define contourSliceNum_X   10
-#define contourSliceNum_Y   245
-#define contourSliceNum_W   90
-#define contourSliceNum_H   115
-
-#define slice_FG        moColor(red1, normal)
-
-#define slice_str_X 20
-#define slice_str_Y 240
-#define slicer_image_X 50
-#define slicer_image_Y 253
-
-#define MAX_SLICES 100
-
-@
-\section{contour\_panel3d.c.out}
-<<view3d/contour\_panel3d.c.out>>=
-  /***********************************************************************
-    contour_panel.c
-
-    begun 25 November 1992, Jim Wen
-   ***********************************************************************/
-
-<<view3d/header.h>>
-<<view3d/cpanel.h>>
-<<view3d/draw.h>>
-<<include/purty/volume.bitmap>>
-<<include/purty/volume.mask>>
-#define slicer_width 50
-#define haha_X
-#ifdef haha
-#define slicer_height 120
-#else
-#define slicer_height 100
-#endif
-static char slicer_bits[] = {
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
-   0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0xc0, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x1f, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x80, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0xfc, 0xff, 0xff, 0x3f, 0x00, 0x00  ,0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0xf0, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00,
-
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x03, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x0f,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00 
-
-#ifdef haha
-				,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-#endif
-};
-
-#define use_fat
-
-#define gStuff_NOT
-
-#define contourWinDEBUG
-#define drawDEBUG
-#define contourDEBUG
-
-#define stickColor moColor(orange2, pastel)
-
-  /*=====================================================================*
-    Static Variables
-   *=====================================================================*/
-XImage slicer_image_stuff, *slicer_image = &slicer_image_stuff;
-int last_tip_long_x, last_tip_long_y;
-int last_tip_lat_x, last_tip_lat_y;
-
-  /*=====================================================================*
-    Local Functions
-   *=====================================================================*/
-int initContourButtons(void);
-
-  /*---------------------------------------------------------------------*
-    makeContourPanel()
-   *---------------------------------------------------------------------*/
-int
-makeContourPanel(void)
-{
-
-  int i;
-  XSetWindowAttributes cwAttrib, controlAttrib;
-  XSizeHints sizehint;
-  Pixmap contourbits, contourmask, slicer_pixmap;
-  XColor foreColor, backColor;
-  
-  contourbits = XCreateBitmapFromData(dsply,rtWindow,volumeBitmap_bits,
-				     volumeBitmap_width,volumeBitmap_height);
-  contourmask = XCreateBitmapFromData(dsply,rtWindow,volumeMask_bits,
-				     volumeMask_width,volumeMask_height);
-  cwAttrib.background_pixel = backgroundColor;
-  cwAttrib.border_pixel = foregroundColor;
-  cwAttrib.event_mask = contourMASK;
-  cwAttrib.colormap = colorMap;
-  cwAttrib.override_redirect = overrideManager;
-  foreColor.pixel = contourCursorForeground;
-  XQueryColor(dsply,colorMap,&foreColor);
-  backColor.pixel = contourCursorBackground;
-  XQueryColor(dsply,colorMap,&backColor);
-  cwAttrib.cursor = XCreatePixmapCursor(dsply,contourbits,contourmask,
-                                        &foreColor,&backColor,
-                                        volumeBitmap_x_hot,
-					volumeBitmap_y_hot);
-
-#define slicer_pixmap_FG moColor(yellow1,normal)
-#define slicer_pixmap_BG backgroundColor
-  slicer_pixmap = XCreatePixmapFromBitmapData(dsply, control->controlWindow,
-					      slicer_bits, slicer_width, slicer_height,
-					      slicer_pixmap_FG, slicer_pixmap_BG, 
-					      DefaultDepthOfScreen
-					      (DefaultScreenOfDisplay(dsply)));
-  slicer_image = XGetImage(dsply, slicer_pixmap, 0, 0, slicer_width, slicer_height,
-			  AllPlanes, ZPixmap);
-
-
-  contourWindow = XCreateWindow(dsply,control->controlWindow,
-			       -3,-3,controlWidth,controlHeight,3,
-			       CopyFromParent,InputOutput,CopyFromParent,
-			       controlCreateMASK,&cwAttrib); 
-
-  sizehint.flags  = USPosition | USSize;
-  sizehint.x      = 0;
-  sizehint.y      = 0;
-  sizehint.width  = controlWidth;
-  sizehint.height = controlHeight;
-          /*** the None stands for icon pixmap ***/
-  XSetNormalHints(dsply,contourWindow,&sizehint);
-  XSetStandardProperties(dsply,contourWindow,"Control Panel 3D",
-			 "Contour Slicing",None,NULL,0,&sizehint);
-
-      /*** volume frustrum window ***/
-
-    /*** do contour buttons ***/
-  initContourButtons(control->buttonQueue);
-  for (i=contourButtonsStart; i<(contourButtonsEnd); i++) {          
-    controlAttrib.event_mask = (control->buttonQueue[i]).mask;
-    (control->buttonQueue[i]).self = 
-    		XCreateWindow(dsply,contourWindow,
-                              (control->buttonQueue[i]).buttonX,
-                              (control->buttonQueue[i]).buttonY,
-                              (control->buttonQueue[i]).buttonWidth,
-                              (control->buttonQueue[i]).buttonHeight,
-                              0,0,InputOnly,CopyFromParent,
-                              buttonCreateMASK,&controlAttrib);
-    XMakeAssoc(dsply,table,(control->buttonQueue[i]).self,
-               &((control->buttonQueue[i]).buttonKey));
-    XMapWindow(dsply,(control->buttonQueue[i]).self);
-  }
-
-}  /* makeContourPanel() */
-
-
-int
-initContourButtons(buttonStruct * contourButtons)
-{
-
-  int ii, num = 0;
-
-  ii = contourReturn;
-  contourButtons[ii].buttonX      = 154;
-  contourButtons[ii].buttonY      = 370;
-  contourButtons[ii].buttonWidth  = 110;
-  contourButtons[ii].buttonHeight = 24;
-  contourButtons[ii].buttonKey    = ii;
-  contourButtons[ii].pot          = no;
-  contourButtons[ii].mask         = buttonMASK;
-  contourButtons[ii].text         = "Return";
-  contourButtons[ii].textColor    = return_FG;
-  contourButtons[ii].xHalf        = contourButtons[ii].buttonWidth/2;
-  contourButtons[ii].yHalf        = contourButtons[ii].buttonHeight/2;
-  ++num;
-
-  ii = contourXY;
-  contourButtons[ii].buttonX      = contourPlaneXY_X;
-  contourButtons[ii].buttonY      = contourPlaneXY_Y;
-  contourButtons[ii].buttonWidth  = contourLittleButt_W;
-  contourButtons[ii].buttonHeight = contourLittleButt_H;
-  contourButtons[ii].buttonKey    = ii;
-  contourButtons[ii].pot          = no;
-  contourButtons[ii].mask         = buttonMASK;
-  contourButtons[ii].text         = "XY";
-  contourButtons[ii].textColor    = littleButt_FG;
-  contourButtons[ii].xHalf        = contourButtons[ii].buttonWidth/2;
-  contourButtons[ii].yHalf        = contourButtons[ii].buttonHeight/2;
-  ++num;
-
-  ii = contourXZ;
-  contourButtons[ii].buttonX      = contourPlaneXZ_X;
-  contourButtons[ii].buttonY      = contourPlaneXZ_Y;
-  contourButtons[ii].buttonWidth  = contourLittleButt_W;
-  contourButtons[ii].buttonHeight = contourLittleButt_H;
-  contourButtons[ii].buttonKey    = ii;
-  contourButtons[ii].pot          = no;
-  contourButtons[ii].mask         = buttonMASK;
-  contourButtons[ii].text         = "XZ";
-  contourButtons[ii].textColor    = littleButt_FG;
-  contourButtons[ii].xHalf        = contourButtons[ii].buttonWidth/2;
-  contourButtons[ii].yHalf        = contourButtons[ii].buttonHeight/2;
-  ++num;
-
-  ii = contourYZ;
-  contourButtons[ii].buttonX      = contourPlaneYZ_X;
-  contourButtons[ii].buttonY      = contourPlaneYZ_Y;
-  contourButtons[ii].buttonWidth  = contourLittleButt_W;
-  contourButtons[ii].buttonHeight = contourLittleButt_H;
-  contourButtons[ii].buttonKey    = ii;
-  contourButtons[ii].pot          = no;
-  contourButtons[ii].mask         = buttonMASK;
-  contourButtons[ii].text         = "YZ";
-  contourButtons[ii].textColor    = littleButt_FG;
-  contourButtons[ii].xHalf        = contourButtons[ii].buttonWidth/2;
-  contourButtons[ii].yHalf        = contourButtons[ii].buttonHeight/2;
-  ++num;
-
-  ii = contourFlatView;
-  contourButtons[ii].buttonX      = contourFlatView_X;
-  contourButtons[ii].buttonY      = contourFlatView_Y;
-  contourButtons[ii].buttonWidth  = contourBigButt_W;
-  contourButtons[ii].buttonHeight = contourBigButt_H;
-  contourButtons[ii].buttonKey    = ii;
-  contourButtons[ii].pot          = no;
-  contourButtons[ii].mask         = potMASK;
-  contourButtons[ii].text         = "Flat View Upon Return";
-  contourButtons[ii].textColor    = bigButt_FG;
-  contourButtons[ii].xHalf        = contourButtons[ii].buttonWidth/2;
-  contourButtons[ii].yHalf        = contourButtons[ii].buttonHeight/2;
-  ++num;
-
-  ii = contourAppendSegs;
-  contourButtons[ii].buttonX      = contourAppendSegs_X;
-  contourButtons[ii].buttonY      = contourAppendSegs_Y;
-  contourButtons[ii].buttonWidth  = contourBigButt_W;
-  contourButtons[ii].buttonHeight = contourBigButt_H;
-  contourButtons[ii].buttonKey    = ii;
-  contourButtons[ii].pot          = no;
-  contourButtons[ii].mask         = potMASK;
-  contourButtons[ii].text         = "Append Contours";
-  contourButtons[ii].textColor    = bigButt_FG;
-  contourButtons[ii].xHalf        = contourButtons[ii].buttonWidth/2;
-  contourButtons[ii].yHalf        = contourButtons[ii].buttonHeight/2;
-  ++num;
-
-  ii = contourLongitude;
-  contourButtons[ii].buttonX      = contourLongitude_X;
-  contourButtons[ii].buttonY      = contourLongitude_Y;
-  contourButtons[ii].buttonWidth  = contourLongitude_W;
-  contourButtons[ii].buttonHeight = contourLongitude_H;
-  contourButtons[ii].buttonKey    = ii;
-  contourButtons[ii].pot          = yes;
-  contourButtons[ii].mask         = potMASK;
-  contourButtons[ii].text         = "XZ";
-  contourButtons[ii].textColor    = long_FG;
-  contourButtons[ii].xHalf        = contourButtons[ii].buttonWidth/2;
-  contourButtons[ii].yHalf        = contourButtons[ii].buttonHeight/2;
-  ++num;
-
-  ii = contourLatitude;
-  contourButtons[ii].buttonX      = contourLatitude_X;
-  contourButtons[ii].buttonY      = contourLatitude_Y;
-  contourButtons[ii].buttonWidth  = contourLatitude_W;
-  contourButtons[ii].buttonHeight = contourLatitude_H;
-  contourButtons[ii].buttonKey    = ii;
-  contourButtons[ii].pot          = yes;
-  contourButtons[ii].mask         = potMASK;
-  contourButtons[ii].text         = "XZ";
-  contourButtons[ii].textColor    = lat_FG;
-  contourButtons[ii].xHalf        = contourButtons[ii].buttonWidth/2;
-  contourButtons[ii].yHalf        = contourButtons[ii].buttonHeight/2;
-  ++num;
-
-  ii = contourSliceNum;
-  contourButtons[ii].buttonX      = contourSliceNum_X;
-  contourButtons[ii].buttonY      = contourSliceNum_Y;
-  contourButtons[ii].buttonWidth  = contourSliceNum_W;
-  contourButtons[ii].buttonHeight = contourSliceNum_H;
-  contourButtons[ii].buttonKey    = ii;
-  contourButtons[ii].pot          = yes;
-  contourButtons[ii].mask         = potMASK;
-  contourButtons[ii].text         = "XZ";
-  contourButtons[ii].textColor    = slice_FG;
-  contourButtons[ii].xHalf        = contourButtons[ii].buttonWidth/2;
-  contourButtons[ii].yHalf        = contourButtons[ii].buttonHeight/2;
-  ++num;
-
-  ii = contourAbort;
-  contourButtons[ii].buttonX      = 36;
-  contourButtons[ii].buttonY      = 370;
-  contourButtons[ii].buttonWidth  = 110;
-  contourButtons[ii].buttonHeight = 24;
-  contourButtons[ii].buttonKey    = ii;
-  contourButtons[ii].pot          = no;
-  contourButtons[ii].mask         = buttonMASK;
-  contourButtons[ii].text         = "Abort";
-  contourButtons[ii].textColor    = abort_FG;
-  contourButtons[ii].xHalf        = contourButtons[ii].buttonWidth/2;
-  contourButtons[ii].yHalf        = contourButtons[ii].buttonHeight/2;
-  ++num;
-
-
-  return(num);
-
-}  /* initContourButtons() */
-
-
-void
-drawContourPanel(void)
-{
-
-  int i,strlength;
-
-        /*---------------------------------------------------*
-	  Set the function to copy for first painting
-         *---------------------------------------------------*/
-  XSetFunction(dsply, contourGC, GXcopy);
-
-            /* Draw some lines for the contour panel, break up da space */
-  GSetForeground(contourGC /* ZZZ */,(float)foregroundColor,X);
-  GSetLineAttributes(contourGC /* ZZZ */,3,LineSolid,CapButt,JoinMiter,X);
-  GDrawLine(contourGC /* ZZZ */, contourWindow, 0, potA, controlWidth, potA, X);
-
-
-  GSetLineAttributes(contourGC /* ZZZ */,2,LineSolid,CapButt,JoinMiter,X);
-  GDrawLine(contourGC /* ZZZ */, contourWindow, 0, contourTitleA, controlWidth, 
-	    contourTitleA, X); 
-  GDrawLine(contourGC /* ZZZ */, contourWindow, 0, contourTitleB, controlWidth,
-	    contourTitleB, X); 
-
-  writeControlTitle(contourWindow);
-  s = "Contour Slicing Panel";
-  strlength = strlen(s);
-  GSetForeground(anotherGC,(float)contourTitleColor,X);
-  GDrawString(anotherGC,contourWindow,
-              centerX(anotherGC,s,strlength,controlWidth),
-	      contourTitleA+18,s,strlength,X);
-
-  for (i=contourButtonsStart; i<(contourButtonsEnd); i++) { 
-        /*---------------------------------------------------*
-	  NOTE: different from other control panels in that
-	        the "monoColor" is defined in the button
-		and "moColor" is used there
-         *---------------------------------------------------*/
-    GSetForeground(contourGC /* ZZZ */,
-#ifdef oldie
-		   (float)monoColor((control->buttonQueue[i]).textColor),X);
-#else
-		   (float)((control->buttonQueue[i]).textColor),X);
-#endif
-    switch (i) {
-
-    case contourFlatView:
-    case contourAppendSegs:
-      GSetForeground(contourGC,
-		     (float)((control->buttonQueue[i]).textColor),X);
-      GDrawRectangle(contourGC,contourWindow,
-		     (control->buttonQueue[i]).buttonX,
-		     (control->buttonQueue[i]).buttonY,
-		     (control->buttonQueue[i]).buttonWidth,
-		     (control->buttonQueue[i]).buttonHeight,X);
-      GDrawString(contourGC,contourWindow,
-		  (control->buttonQueue[i]).buttonX + 
-		  (control->buttonQueue[i]).buttonWidth + 4,
-		  (control->buttonQueue[i]).buttonY +
-		  centerY(contourGC,(control->buttonQueue[i]).buttonHeight),
-		  (control->buttonQueue[i]).text,
-		  strlen(control->buttonQueue[i].text),X);
-      if (i==contourFlatView && contour_flat_view_flag)
-      GDrawString(contourGC,contourWindow,
-		  (control->buttonQueue[i]).buttonX +
-		  centerX(contourGC,"x",1,
-			  (control->buttonQueue[i]).buttonWidth),
-		  (control->buttonQueue[i]).buttonY +
-		  centerY(contourGC,(control->buttonQueue[i]).buttonHeight),
-		  "x",1,X);
-      else if (i==contourAppendSegs && contour_append_lists_flag)
-      GDrawString(contourGC,contourWindow,
-		  (control->buttonQueue[i]).buttonX +
-		  centerX(contourGC,"x",1,
-			  (control->buttonQueue[i]).buttonWidth),
-		  (control->buttonQueue[i]).buttonY +
-		  centerY(contourGC,(control->buttonQueue[i]).buttonHeight),
-		  "x",1,X);
-      break;
-
-    case contourLongitude:
-      GDrawRectangle(contourGC /* ZZZ */,contourWindow,
-                     (control->buttonQueue[i]).buttonX,
-		     (control->buttonQueue[i]).buttonY,
-                     (control->buttonQueue[i]).buttonWidth,
-		     (control->buttonQueue[i]).buttonHeight,X);
-      draw_contour_longitude();
-      break;
-
-    case contourLatitude:
-#ifdef oldie
-      GDrawRectangle(contourGC /* ZZZ */,contourWindow,
-                     (control->buttonQueue[i]).buttonX,
-		     (control->buttonQueue[i]).buttonY,
-                     (control->buttonQueue[i]).buttonWidth,
-		     (control->buttonQueue[i]).buttonHeight,X);
-#else
-      XDrawRectangle(dsply,contourWindow, contourGC /* ZZZ */,
-                     (control->buttonQueue[i]).buttonX,
-		     (control->buttonQueue[i]).buttonY,
-                     (control->buttonQueue[i]).buttonWidth,
-		     (control->buttonQueue[i]).buttonHeight);
-#endif
-      draw_contour_latitude();
-      break;
-
-    case contourSliceNum:
-      GDrawRectangle(contourGC /* ZZZ */,contourWindow,
-                     (control->buttonQueue[i]).buttonX,
-		     (control->buttonQueue[i]).buttonY,
-                     (control->buttonQueue[i]).buttonWidth,
-		     (control->buttonQueue[i]).buttonHeight,X);
-      draw_contour_slicing();
-      break;
-
-    default:
-      GDrawRectangle(contourGC /* ZZZ */,contourWindow,
-                     (control->buttonQueue[i]).buttonX,
-		     (control->buttonQueue[i]).buttonY,
-                     (control->buttonQueue[i]).buttonWidth,
-		     (control->buttonQueue[i]).buttonHeight,X);
-      s = (control->buttonQueue[i]).text;
-      strlength = strlen(s);
-      GSetForeground(contourGC /* ZZZ */,
-#ifdef oldie
-		     (float)monoColor((control->buttonQueue[i]).textColor),X);
-#else
-		     (float)((control->buttonQueue[i]).textColor),X);
-#endif
-      GDrawString(trashGC /* ZZZ */,contourWindow,
-		  (control->buttonQueue[i]).buttonX +
-		  centerX(processGC,s,strlength,
-			  (control->buttonQueue[i]).buttonWidth),
-		  (control->buttonQueue[i]).buttonY +
-		  centerY(processGC,(control->buttonQueue[i]).buttonHeight),
-		  s,strlen(s),X);
-      break;
-    }  /* switch on i */
-  }  /* for contour buttons */
-
-        /*---------------------------------------------------*
-	  Set the function to XOR for updating
-         *---------------------------------------------------*/
-  XSetFunction(dsply, contourGC, GXxor);
-  update_contour_longitude();  /* to get the xor stuff going */
-  update_contour_latitude();    /* to get the xor stuff going */
-
-}  /* drawContourPanel() */
-
-
-  /*---------------------------------------------------------------------*
-    draw_contour_longitude()
-   *---------------------------------------------------------------------*/
-void
-draw_contour_longitude(void)
-{
-
-  int tip_x, tip_y;
-  char stringo[20];
-
-
-        /*---------------------------------------------------*
-	  print out the longitude in degrees
-         *---------------------------------------------------*/
-  sprintf(stringo,"Longitude: %d",(int)(rot_theta * DEGREES));
-  XClearArea(dsply, contourWindow, long_str_X, long_str_Y - 12,
-	     long_W + 50, 18, False);
-  XDrawString(dsply, contourWindow, anotherGC,
-	      long_str_X, long_str_Y,
-	      stringo, strlen(stringo));
-
-        /*---------------------------------------------------*
-	  draw the background artwork
-         *---------------------------------------------------*/
-  XClearArea(dsply, contourWindow,
-	     contourLongitude_X, contourLongitude_Y,
-	     contourLongitude_W, contourLongitude_H,
-	     False);
-#ifdef use_fat
-  XSetForeground(dsply, contourGC /* ZZZ */, long_FG);
-  XDrawArc(dsply, contourWindow, contourGC /* ZZZ */,
-	   long_corner_X, long_corner_Y,
-	   long_W, long_H,
-	   0, 360*64);
-#else
-  XSetForeground(dsply, contourGC, long_FG);
-  XSetForeground(dsply, trashGC, long_FG);
-  XDrawArc(dsply, contourWindow, trashGC /* ZZZ */,
-	   long_corner_X, long_corner_Y,
-	   long_W, long_H,
-	   0, 360*64);
-#endif
-
-        /*---------------------------------------------------*
-	  some spokes to make it look purty
-         *---------------------------------------------------*/
-  {
-    float a, xp, yp;
-    for (a=0; a<pi; a+=pi/8) {
-      xp = long_RADIUS*cos(a);
-      yp = long_RADIUS*sin(a);
-      XDrawLine(dsply, contourWindow, 
-#ifdef use_fat
-		contourGC,
-#else
-		trashGC,
-#endif
-		(int)(xp + long_center_X), (int)(yp + long_center_Y),
-		(int)(-xp + long_center_X), (int)(-yp + long_center_Y));
-    }
-  }
-
-        /*---------------------------------------------------*
-	  calculate and draw the longitudal pointer
-         *---------------------------------------------------*/
-  XSetFunction(dsply, contourGC, GXxor);
-  tip_x = (int)(cos(rot_theta) * (long_RADIUS + dotExt)) + long_center_X;
-  tip_y = (int)(-sin(rot_theta) * (long_RADIUS + dotExt)) + long_center_Y;
-  last_tip_long_x = tip_x;
-  last_tip_long_y = tip_y;
-  GSetForeground(contourGC,(float)stickColor,X);
-  GDrawLine(contourGC /* ZZZ */, contourWindow,
-	    long_center_X, long_center_Y,
-	    tip_x, tip_y, X);
-  GSetForeground(contourGC,(float)dotColor,X);
-  XFillArc(dsply, contourWindow, contourGC /* ZZZ */,
-	   tip_x - (dotSize>>1), tip_y - (dotSize>>1),
-	   dotSize, dotSize,
-	   0, 360*64);
-  XSetFunction(dsply, contourGC, GXcopy);
-
-}  /* draw_contour_longitude() */
-
-
-  /*---------------------------------------------------------------------*
-    draw_contour_latitude()
-   *---------------------------------------------------------------------*/
-void
-draw_contour_latitude(void)
-{
-
-  int tip_x, tip_y;
-  char stringo[20];
-
-        /*---------------------------------------------------*
-	  print out the latitude in degrees
-         *---------------------------------------------------*/
-  sprintf(stringo,"Latitude: %d",(int)(rot_phi * DEGREES));
-  XClearArea(dsply, contourWindow, lat_str_X, lat_str_Y - 12,
-	     lat_W, 18, False);
-  XDrawString(dsply, contourWindow, anotherGC,
-	      lat_str_X, lat_str_Y,
-	      stringo, strlen(stringo));
-
-        /*---------------------------------------------------*
-	  draw the background superduper work of art
-         *---------------------------------------------------*/
-  XClearArea(dsply, contourWindow,
-	     contourLatitude_X, contourLatitude_Y,
-	     contourLatitude_W, contourLatitude_H,
-	     False);
-  XSetForeground(dsply, contourGC /* ZZZ */, lat_FG);
-  XDrawArc(dsply, contourWindow, contourGC /* ZZZ */,
-	   lat_corner_X, lat_corner_Y,
-	   lat_W, lat_H,
-	   0, 90*64);
-  XDrawLine(dsply, contourWindow, contourGC,
-	    lat_quad_X, lat_quad_Y,
-	    lat_quad_X, lat_quad_Y - lat_RADIUS);
-  XDrawLine(dsply, contourWindow, contourGC,
-	    lat_quad_X, lat_quad_Y,
-	    lat_quad_X + lat_RADIUS, lat_quad_Y);
-
-        /*---------------------------------------------------*
-	  purty leettle tabs
-         *---------------------------------------------------*/
-  {
-    float a, xp, yp;
-    for (a=0; a<pi_half; a+=pi/16) {
-      xp = cos(a);
-      yp = -sin(a);
-      XDrawLine(dsply, contourWindow, contourGC,
-		(int)((lat_RADIUS-3) * xp + lat_quad_X),
-		(int)((lat_RADIUS-3) * yp + lat_quad_Y),
-		(int)((lat_RADIUS+3) * xp + lat_quad_X),
-		(int)((lat_RADIUS+3) * yp + lat_quad_Y));
-    }
-  }
-
-        /*---------------------------------------------------*
-	  calculate and draw the latitudal pointer
-         *---------------------------------------------------*/
-  XSetFunction(dsply, contourGC, GXxor);
-  tip_x = (int)(sin(rot_phi) * (lat_RADIUS + dotExt)) + lat_quad_X;
-  tip_y = (int)(-cos(rot_phi) * (lat_RADIUS + dotExt)) + lat_quad_Y;
-  last_tip_lat_x = tip_x;
-  last_tip_lat_y = tip_y;
-  GSetForeground(contourGC,(float)stickColor,X);
-  GDrawLine(contourGC /* ZZZ */, contourWindow,
-	    lat_quad_X, lat_quad_Y,
-	    tip_x, tip_y, X);
-  XSetForeground(dsply, contourGC, dotColor);
-  XFillArc(dsply, contourWindow, contourGC /* ZZZ */,
-	   tip_x - (dotSize>>1), tip_y - (dotSize>>1),
-	   dotSize, dotSize,
-	   0, 360*64);
-  XSetFunction(dsply, contourGC, GXcopy);
-
-}  /* draw_contour_latitude() */
-
-
-
-  /*---------------------------------------------------------------------*
-    draw_contour_slicing()
-   *---------------------------------------------------------------------*/
-void
-draw_contour_slicing(void)
-{
-
-  int tip_y, cut_spacing;
-#ifdef oldie
-  XDrawString(dsply, contourWindow, anotherGC,
-	      slice_str_X, slice_str_Y,
-	      "Slicer", 6);
-#else
-  char stringo[20];
-
-  sprintf(stringo,"Cuts: %d",max_cuts);
-  XClearArea(dsply, contourWindow, 
-	     slice_str_X, 
-	     slice_str_Y - 12,
-	     contourSliceNum_W, 16, False);
-  XDrawString(dsply, contourWindow, anotherGC,
-	      slice_str_X, slice_str_Y,
-	      stringo, strlen(stringo));
-#endif
-
-        /*---------------------------------------------------*
-	  put up the piece de resistance
-         *---------------------------------------------------*/
-  XClearArea(dsply, contourWindow,
-	     contourSliceNum_X, contourSliceNum_Y,
-	     contourSliceNum_W, contourSliceNum_H,
-	     False);
-  XPutImage(dsply, contourWindow, contourGC,
-	    slicer_image,
-	    0, 0, 
-	    slicer_image_X,
-	    slicer_image_Y,
-	    slicer_width, slicer_height);
-
-        /*---------------------------------------------------*
-	  draw the number of slices
-         *---------------------------------------------------*/
-#define cuts_X (contourSliceNum_X + 15)
-#define cuts_Y (contourSliceNum_Y + 15)
-#define cuts_W 20
-#define cuts_H 85
-
-  XSetLineAttributes(dsply, trashGC, 1, LineSolid, CapButt, JoinMiter);
-  XClearArea(dsply, contourWindow,
-	     cuts_X, cuts_Y, cuts_W, cuts_H, False);
-#ifdef oldie
-  cut_spacing = ( -(max_cuts - 1) + MAX_SLICES ) * cuts_H / MAX_SLICES;
-#else
-  {
-    float tmp;
-    tmp = (float)(-(max_cuts - 1) + MAX_SLICES) / MAX_SLICES;
-    cut_spacing = tmp*tmp * cuts_H;
-    if (cut_spacing < 1) cut_spacing = 1;
-    else if (cut_spacing > cuts_H) cut_spacing = cuts_H;
-  }
-#endif
-
-  XSetForeground(dsply, trashGC, moColor(violet0, pastel));
-  for (tip_y=cuts_Y+cuts_H; tip_y>=cuts_Y; tip_y-=cut_spacing) {
-    XDrawLine(dsply, contourWindow, trashGC,
-	      cuts_X, tip_y,
-	      cuts_X + cuts_W, tip_y);
-  }
-
-#define slide_Y (contourSliceNum_Y + 30)
-#define slide_H 55
-  {
-    float where;
-    int here;
-    where = (float)max_cuts/MAX_SLICES;  /* [0..1] */
-    here = where * slide_H + slide_Y;
-    XSetForeground(dsply, contourGC, moColor(red1, normal));
-    XDrawLine(dsply, contourWindow, contourGC,
-	      cuts_X + 45, here,
-	      cuts_X + 55, here);
-  }
-
-}  /* draw_contour_slicing() */
-
-
-  /*---------------------------------------------------------------------*
-    update_contour_longitude()
-
-    To be called for all subsequent updates after the contour window has 
-    been mapped and drawn.
-   *---------------------------------------------------------------------*/
-void
-update_contour_longitude(void)
-{
-
-  int tip_x, tip_y;
-  char stringo[20];
-
-        /*---------------------------------------------------*
-	  print out the longitude in degrees
-         *---------------------------------------------------*/
-  sprintf(stringo,"Longitude: %d",(int)(rot_theta * DEGREES));
-  XClearArea(dsply, contourWindow, long_str_X, long_str_Y - 12,
-	     long_W + 50, 18, False);
-  XDrawString(dsply, contourWindow, anotherGC,
-	      long_str_X, long_str_Y,
-	      stringo, strlen(stringo));
-
-
-        /*---------------------------------------------------*
-	  calculate and draw the longitudal pointer
-         *---------------------------------------------------*/
-  GSetForeground(contourGC,(float)stickColor,X);
-  GDrawLine(contourGC /* ZZZ */, contourWindow,
-	    long_center_X, long_center_Y,
-	    last_tip_long_x, last_tip_long_y, X);
-  GSetForeground(contourGC,(float)dotColor,X);
-  XFillArc(dsply, contourWindow, contourGC /* ZZZ */,
-	   last_tip_long_x - (dotSize>>1), last_tip_long_y - (dotSize>>1),
-	   dotSize, dotSize,
-	   0, 360*64);
-  tip_x = (int)(cos(rot_theta) * (long_RADIUS + dotExt)) + long_center_X;
-  tip_y = (int)(-sin(rot_theta) * (long_RADIUS + dotExt)) + long_center_Y;
-  last_tip_long_x = tip_x;
-  last_tip_long_y = tip_y;
-  GSetForeground(contourGC,(float)stickColor,X);
-  GDrawLine(contourGC /* ZZZ */, contourWindow,
-	    long_center_X, long_center_Y,
-	    tip_x, tip_y, X);
-  GSetForeground(contourGC,(float)dotColor,X);
-  XFillArc(dsply, contourWindow, contourGC /* ZZZ */,
-	   tip_x - (dotSize>>1), tip_y - (dotSize>>1),
-	   dotSize, dotSize,
-	   0, 360*64);
-
-}  /* update_contour_longitude() */
-
-
-  /*---------------------------------------------------------------------*
-    update_contour_latitude()
-
-    To be called for all subsequent updates after the contour window has 
-    been mapped and drawn.
-   *---------------------------------------------------------------------*/
-void
-update_contour_latitude(void)
-{
-
-  int tip_x, tip_y;
-  char stringo[20];
-
-        /*---------------------------------------------------*
-	  print out the latitude in degrees
-         *---------------------------------------------------*/
-  sprintf(stringo,"Latitude: %d",(int)(rot_phi * DEGREES));
-  XClearArea(dsply, contourWindow, lat_str_X, lat_str_Y - 12,
-	     lat_W, 18, False);
-  XDrawString(dsply, contourWindow, anotherGC,
-	      lat_str_X, lat_str_Y,
-	      stringo, strlen(stringo));
-
-        /*---------------------------------------------------*
-	  calculate and draw the latitudal pointer
-         *---------------------------------------------------*/
-  GSetForeground(contourGC,(float)stickColor,X);
-  GDrawLine(contourGC /* ZZZ */, contourWindow,
-	    lat_quad_X, lat_quad_Y,
-	    last_tip_lat_x, last_tip_lat_y, X);
-  XSetForeground(dsply, contourGC, dotColor);
-  XFillArc(dsply, contourWindow, contourGC /* ZZZ */,
-	   last_tip_lat_x - (dotSize>>1), 
-	   last_tip_lat_y - (dotSize>>1),
-	   dotSize, dotSize,
-	   0, 360*64);
-  tip_x = (int)(sin(rot_phi) * (lat_RADIUS + dotExt)) + lat_quad_X;
-  tip_y = (int)(-cos(rot_phi) * (lat_RADIUS + dotExt)) + lat_quad_Y;
-  last_tip_lat_x = tip_x;
-  last_tip_lat_y = tip_y;
-  GSetForeground(contourGC,(float)stickColor,X);
-  GDrawLine(contourGC /* ZZZ */, contourWindow,
-	    lat_quad_X, lat_quad_Y,
-	    tip_x, tip_y, X);
-  XSetForeground(dsply, contourGC, dotColor);
-  XFillArc(dsply, contourWindow, contourGC /* ZZZ */,
-	   tip_x - (dotSize>>1), tip_y - (dotSize>>1),
-	   dotSize, dotSize,
-	   0, 360*64);
-
-}  /* update_contour_latitude() */
-@
-\section{control3d.c}
-<<view3d/control3d.c>>=
-#define _CONTROL3D_C
-#include <string.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#define mouseBitmap_width 16
-#define mouseBitmap_height 16
-#define mouseBitmap_x_hot 8
-#define mouseBitmap_y_hot 0
-static char mouseBitmap_bits[] = {
-   0x00, 0x01, 0x00, 0x01, 0x80, 0x02, 0x40, 0x04, 0xc0, 0x06, 0x20, 0x08,
-   0x20, 0x08, 0x30, 0x18, 0x50, 0x14, 0x58, 0x34, 0x90, 0x12, 0x20, 0x08,
-   0xc0, 0x47, 0x00, 0x21, 0x80, 0x10, 0x00, 0x0f};
-#define mouseMask_width 16
-#define mouseMask_height 16
-static char mouseMask_bits[] = {
-   0x00, 0x01, 0x00, 0x01, 0x80, 0x03, 0xc0, 0x07, 0xc0, 0x07, 0xe0, 0x0f,
-   0xe0, 0x0f, 0xf0, 0x1f, 0xf0, 0x1f, 0xf8, 0x3f, 0xf0, 0x1f, 0xe0, 0x0f,
-   0xc0, 0x47, 0x00, 0x21, 0x80, 0x10, 0x00, 0x0f};
-
-<<view3d/header.h>>
-<<view3d/cpanel.h>>
-
-#include "util.h1"
-#include "xshade.h1"
-#include "xspadfill.h1"
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-/* Defines the pixmap for the arrow displayed in the scale window */
-#define zoomArrowN 11
-static XPoint zoomArrow[zoomArrowN] = {
-  {29,14},{38,23},{33,23},
-  {40,45},{53,45},
-  {29,69},
-  {5,45},{18,45},
-  {25,23},{20,23},{29,14} };
-
-/* Defines the pixmap for the arrows displayed in the translate window */
-#define translateArrowN 25
-static XPoint translateArrow[translateArrowN] = {
-  {55,2},{60,10},{58,10},{58,37},
-  {85,37},{85,35},{93,40},{85,45},{85,43},{58,43},
-  {58,70},{60,70},{55,78},{50,70},{52,70},{52,43},
-  {25,43},{25,45},{17,40},{25,35},{25,37},{52,37},
-  {52,10},{50,10},{55,2} };
-
-static int rotateX, rotateY, rotateR;
-
-/*
-  void drawColorMap () 
-  */
-
-void
-drawColorMap (void)
-{
-  
+\subsection{drawColorMap}
+\index{view3d!drawColorMap}
+\index{drawColorMap view3d}
+<<view3d>>=
+void drawColorMap (void) {  
   controlPanelStruct *cp;
   int i,shadeWidth;
-  
   /* Draw the color map window */
-  
   cp = viewport->controlPanel;
-  
   XClearArea(dsply,cp->controlWindow,5,colormapY,colormapW,colormapH,False);
-  
   /* if window is grayscale, show the grayscale colormap */
   if (mono || (viewport->monoOn)) {
     shadeWidth = 230/maxGreyShade;
@@ -12200,10 +10055,8 @@ drawColorMap (void)
 		colormapX + i*colorWidth + colorOffsetX,
 		colormapY + colorOffsetY + colorHeight,Xoption);
     }
-
     if (viewport->hueTop > totalHues-1) viewport->hueTop = totalHues-1;
     if (viewport->hueOffset > totalHues-1) viewport->hueOffset = totalHues-1;
-
     GSetForeground(globGC, (float)monoColor(7), Xoption);
     /* Bottom (zmin) color indicator */
     GDrawLine(globGC,cp->controlWindow,
@@ -12211,14 +10064,12 @@ drawColorMap (void)
 	      colormapY + colorOffsetY+colorHeight,
 	      colormapX + viewport->hueOffset * colorWidth + colorOffsetX,
 	      colormapY + colorOffsetY+colorHeight+colorPointer,Xoption);
-
     /* Top (zmax) color indicator */
     GDrawLine(globGC,cp->controlWindow,
 	      colormapX + viewport->hueTop * colorWidth+colorOffsetX,
 	      colormapY + colorOffsetY,
 	      colormapX + viewport->hueTop * colorWidth+colorOffsetX,
 	      colormapY + colorOffsetY-colorPointer,Xoption);
-
     /* Connect the bottom and top color indicator bars */
     GSetForeground(globGC, (float)monoColor(0), Xoption);
     GDrawLine(globGC,cp->controlWindow,
@@ -12228,44 +10079,32 @@ drawColorMap (void)
 	      colormapY + colorOffsetY,Xoption);
   }
   XSync(dsply,0);
-
 }  /* drawColorMap() */
 
-
-/*******************************
- * void writeControlTitle(w)   *
- *			       *
- * We need the window argument *
- * here because there are      *
- * multiple control panels in  *
- * 3D.			       *
- *******************************/
-
-void
-writeControlTitle (Window w)
-{
+@
+\subsection{writeControlTitle}
+We need the window argument here because there are multiple control 
+panels in 3D.
+\index{view3d!writeControlTitle}
+\index{writeControlTitle view3d}
+<<view3d>>=
+void writeControlTitle(Window w) {
   int strlength;
-
   s = viewport->title;
   strlength = strlen(s);
   XClearArea(dsply,w,0,0,controlWidth,potA,False);
-
   GSetForeground(anotherGC,(float)controlTitleColor,Xoption);
   GDrawString(anotherGC,w,centerX(anotherGC,s,strlength,controlWidth),
 	      15,s,strlength,Xoption);
-
 }  /* writeControlTitle() */
 
-
-/************************************/
-/***  void clearControlMessage()  ***/
-/************************************/
-
-void
-clearControlMessage (void)
-{
+@
+\subsection{clearControlMessage}
+\index{view3d!clearControlMessage}
+\index{clearControlMessage view3d}
+<<view3d>>=
+void clearControlMessage(void) {
   int strlength;
-
   strcpy(viewport->controlPanel->message,"                                ");
   strlength = strlen(viewport->controlPanel->message);
   GDrawImageString(globalGC1,viewport->controlPanel->controlWindow,
@@ -12273,20 +10112,16 @@ clearControlMessage (void)
 			   strlength,controlWidth),
 		   controlMessageY + globalFont->max_bounds.ascent + 8,
 		   viewport->controlPanel->message,strlength,Xoption);
-
 }
 
-/************************************/
-/***  void writeControlMessage()  ***/
-/************************************/
-
-void
-writeControlMessage (void)
-{
-
+@
+\subsection{writeControlMessage}
+\index{view3d!writeControlMessage}
+\index{writeControlMessage view3d}
+<<view3d>>=
+void writeControlMessage(void) { 
   int strlength;
   controlPanelStruct *cp;
-
   cp = viewport->controlPanel;
   strlength = strlen(cp->message);
   XClearArea(dsply,cp->controlWindow,
@@ -12297,74 +10132,54 @@ writeControlMessage (void)
 		   centerX(globalGC1,cp->message,strlength,controlWidth),
 		   controlMessageY + globalFont->max_bounds.ascent + 8,
 		   cp->message,strlength,Xoption);
-
   XFlush(dsply);
-
 }
 
-/*********************************/
-/***  void drawControlPanel()  ***/
-/*********************************/
-
-void
-drawControlPanel(void )
-{
-
+@
+\subsection{drawControlPanel}
+\index{view3d!drawControlPanel}
+\index{drawControlPanel view3d}
+<<view3d>>=
+void drawControlPanel(void) {
   int			offShade=14;
   controlPanelStruct	*cp;
   int			i, strlength;
   char			*s;
-
   cp = viewport->controlPanel;
-
   GSetForeground(trashGC, (float)foregroundColor, Xoption);
-
   /* Draw border lines to separate the potentiometer, message, colormap and
      button regions of the control panel. */
   GSetLineAttributes(trashGC, 2, LineSolid, CapButt, JoinMiter, Xoption);
-
   /* Draw a horizontal white line below the potentiometer area. */
-  GDrawLine(trashGC, cp->controlWindow, 0, potB-1, controlWidth, potB-1, Xoption);
-
+  GDrawLine(trashGC,cp->controlWindow,0,potB-1,controlWidth,potB-1,Xoption);
   /* Draw a horizontal white line above the rendering mode buttons. */
   GDrawLine(trashGC, cp->controlWindow, 0, butA, controlWidth, butA, Xoption);
-
   /* Draw a horizontal white line above the color mapping area. */
-  GDrawLine(trashGC, cp->controlWindow, 0, cmapA, controlWidth, cmapA, Xoption);
-
+  GDrawLine(trashGC,cp->controlWindow,0, cmapA, controlWidth, cmapA, Xoption);
   GSetLineAttributes(trashGC, 3, LineSolid, CapButt, JoinMiter, Xoption);
   /* Draw a horizontal white line above the potentiometer area. */
   GDrawLine(trashGC, cp->controlWindow, 0, potA, controlWidth, potA, Xoption);
-
   /* Set the line width as 1 here because it is used below as well. */
   GSetLineAttributes(trashGC, 1, LineSolid, CapButt, JoinMiter, Xoption);
-
   /* Draw inner white lines around quit, hide panel, and reset buttons. */
-  GDrawLine(trashGC, cp->controlWindow, closeL, butA, closeL, butA+110, Xoption);
-
+  GDrawLine(trashGC,cp->controlWindow,closeL,butA, closeL, butA+110, Xoption);
   /* Write potentiometer titles on the control panel. */
-
   writeControlTitle(cp->controlWindow);
   GSetForeground(globGC, (float)controlPotHeaderColor, Xoption);
-
   s	= "Rotate";
   GDrawString(globGC,cp->controlWindow,35,31+headerHeight,s,strlen(s),Xoption);
   s	= "Translate";
-  GDrawString(globGC,cp->controlWindow,202,31+headerHeight,s,strlen(s),Xoption);
+  GDrawString(globGC,cp->controlWindow,202,31+headerHeight,s,
+              strlen(s),Xoption);
   s	= "Scale";
-  GDrawString(globGC,cp->controlWindow,126,31+headerHeight,s,strlen(s),Xoption);
-
+  GDrawString(globGC,cp->controlWindow,126,31+headerHeight,s,
+              strlen(s),Xoption);
   GSetForeground(globGC, (float)controlColorColor, Xoption);
-
   /* Write labels on regular buttons, draw pixmaps on the potentiometers. */
-
   GSetForeground(globalGC1, (float)monoColor(buttonColor), Xoption);
-
   for (i=controlButtonsStart3D; i<(controlButtonsEnd3D); i++) {
     /* special cases depending on initial conditions */
-
     /* check if axes are set on or off */
-
     if (((cp->buttonQueue[i]).buttonKey == axesOnOff) &&
 	  (viewport->axesOn)) {
       (cp->buttonQueue[i]).textColor = onColor;
@@ -12396,7 +10211,8 @@ drawControlPanel(void )
 	  s = (control->buttonQueue[axesOnOff]).text;
 	  strlength = strlen(s);
 	  GSetForeground(processGC,
-	    (float)monoColor((control->buttonQueue[axesOnOff]).textColor),Xoption);
+	    (float)monoColor((control->buttonQueue[axesOnOff]).textColor),
+            Xoption);
 	  GDrawImageString(processGC,control->controlWindow,
 			   (control->buttonQueue[axesOnOff]).buttonX +
 			   centerX(processGC,s,strlength,
@@ -12408,9 +10224,7 @@ drawControlPanel(void )
 	} /* if mono */
       }
     } /* if axes */
-
     /* check if bounding region is set on or off */
-
     if (((cp->buttonQueue[i]).buttonKey == region3D) &&
 	  (viewport->regionOn)) {
       (cp->buttonQueue[i]).textColor = onColor;
@@ -12442,7 +10256,8 @@ drawControlPanel(void )
 	  s = (control->buttonQueue[region3D]).text;
 	  strlength = strlen(s);
 	  GSetForeground(processGC,
-	    (float)monoColor((control->buttonQueue[region3D]).textColor),Xoption);
+	    (float)monoColor((control->buttonQueue[region3D]).textColor),
+            Xoption);
 	  GDrawImageString(processGC,control->controlWindow,
 			   (control->buttonQueue[region3D]).buttonX +
 			   centerX(processGC,s,strlength,
@@ -12454,9 +10269,7 @@ drawControlPanel(void )
 	} /* if mono */
       }
     } /* if bounding region */
-
     /* check if black and white is set on or off */
-
     if (((cp->buttonQueue[i]).buttonKey == bwColor) && (mono)) {
       (cp->buttonQueue[i]).text = " ";
       XChangeShade(dsply,offShade);
@@ -12470,7 +10283,6 @@ drawControlPanel(void )
 	(cp->buttonQueue[i]).textColor = onColor;
 	s = (control->buttonQueue[bwColor]).text;
 	strlength = strlen(s);
-
 	GSetForeground(processGC,
 	  (float)monoColor((control->buttonQueue[bwColor]).textColor),Xoption);
 	GDrawImageString(processGC,control->controlWindow,
@@ -12482,13 +10294,14 @@ drawControlPanel(void )
 				 (control->buttonQueue[bwColor]).buttonHeight),
 			 s,strlength,Xoption);
       } else {
-	if (((cp->buttonQueue[i]).buttonKey == bwColor) && (!viewport->monoOn)) {
+	if (((cp->buttonQueue[i]).buttonKey == bwColor) && 
+             (!viewport->monoOn)) {
 	  (cp->buttonQueue[i]).textColor = offColor;
 	  s = (control->buttonQueue[bwColor]).text;
 	  strlength = strlen(s);
-
 	  GSetForeground(processGC,
-	    (float)monoColor((control->buttonQueue[bwColor]).textColor),Xoption);
+	    (float)monoColor((control->buttonQueue[bwColor]).textColor),
+            Xoption);
 	  GDrawImageString(processGC,control->controlWindow,
 			   (control->buttonQueue[bwColor]).buttonX +
 			   centerX(processGC,s,strlength,
@@ -12500,9 +10313,7 @@ drawControlPanel(void )
 	}
       }
     } /* if black and white */
-
     /* check if object rotation is set on or off */
-
     if (((cp->buttonQueue[i]).buttonKey == objectr) &&
 	      (viewport->objectrOn)) {
 	(control->buttonQueue[objectr]).textColor = onColor;
@@ -12538,7 +10349,8 @@ drawControlPanel(void )
 			 (control->buttonQueue[objectr]).buttonWidth,
 			 (control->buttonQueue[objectr]).buttonHeight,Xoption);
 	  GSetForeground(processGC,
-	    (float)monoColor((control->buttonQueue[objectr]).textColor),Xoption);
+	    (float)monoColor((control->buttonQueue[objectr]).textColor),
+            Xoption);
 	  GDrawImageString(processGC,control->controlWindow,
 		   (control->buttonQueue[objectr]).buttonX +
 		   centerX(processGC,(control->buttonQueue[objectr]).text,
@@ -12548,13 +10360,12 @@ drawControlPanel(void )
 			   centerY(processGC,
 			   (control->buttonQueue[objectr]).buttonHeight),
 			   (control->buttonQueue[objectr]).text,
-			   strlen((control->buttonQueue[objectr]).text),Xoption);
+			   strlen((control->buttonQueue[objectr]).text),
+                           Xoption);
 	}
       } /* else not object rotation */
     } /* if object rotation */
-
     /* check if origin rotation is set on or off */
-
     if (((cp->buttonQueue[i]).buttonKey == originr) &&
 	      (viewport->originrOn)) {
 	(control->buttonQueue[originr]).textColor = onColor;
@@ -12591,7 +10402,8 @@ drawControlPanel(void )
 			 (control->buttonQueue[originr]).buttonHeight,Xoption);
 
 	  GSetForeground(processGC,
-		(float)monoColor((control->buttonQueue[originr]).textColor),Xoption);
+		(float)monoColor((control->buttonQueue[originr]).textColor),
+                Xoption);
 	  GDrawImageString(processGC,control->controlWindow,
 		   (control->buttonQueue[originr]).buttonX +
 		   centerX(processGC,(control->buttonQueue[originr]).text,
@@ -12601,13 +10413,12 @@ drawControlPanel(void )
 			   centerY(processGC,
 			   (control->buttonQueue[originr]).buttonHeight),
 			   (control->buttonQueue[originr]).text,
-			   strlen((control->buttonQueue[originr]).text),Xoption);
+			   strlen((control->buttonQueue[originr]).text),
+                           Xoption);
 	}
       } /* else not origin rotation */
     } /* if origin rotation */
-
     /* check if zoom X is set on or off */
-
     if (((cp->buttonQueue[i]).buttonKey == zoomx) &&
 	      (viewport->zoomXOn)) {
 	(control->buttonQueue[zoomx]).textColor = onColor;
@@ -12644,7 +10455,8 @@ drawControlPanel(void )
 			 (control->buttonQueue[zoomx]).buttonHeight,Xoption);
 
 	  GSetForeground(processGC,
-		(float)monoColor((control->buttonQueue[zoomx]).textColor),Xoption);
+		(float)monoColor((control->buttonQueue[zoomx]).textColor),
+                Xoption);
 	  GDrawImageString(processGC,control->controlWindow,
 		   (control->buttonQueue[zoomx]).buttonX +
 		   centerX(processGC,(control->buttonQueue[zoomx]).text,
@@ -12658,9 +10470,7 @@ drawControlPanel(void )
 	}
       } /* else not zoom X */
     } /* if zoom X */
-
     /* check if zoom Y is set on or off */
-
     if (((cp->buttonQueue[i]).buttonKey == zoomy) &&
 	      (viewport->zoomYOn)) {
 	(control->buttonQueue[zoomy]).textColor = onColor;
@@ -12697,7 +10507,8 @@ drawControlPanel(void )
 			 (control->buttonQueue[zoomy]).buttonHeight,Xoption);
 
 	  GSetForeground(processGC,
-		(float)monoColor((control->buttonQueue[zoomy]).textColor),Xoption);
+		(float)monoColor((control->buttonQueue[zoomy]).textColor),
+                Xoption);
 	  GDrawImageString(processGC,control->controlWindow,
 		   (control->buttonQueue[zoomy]).buttonX +
 		   centerX(processGC,(control->buttonQueue[zoomy]).text,
@@ -12711,9 +10522,7 @@ drawControlPanel(void )
 	}
       } /* else not zoom Y */
     } /* if zoom Y */
-
     /* check if zoom Z is set on or off */
-
     if (((cp->buttonQueue[i]).buttonKey == zoomz) &&
 	      (viewport->zoomZOn)) {
 	(control->buttonQueue[zoomz]).textColor = onColor;
@@ -12750,7 +10559,8 @@ drawControlPanel(void )
 			 (control->buttonQueue[zoomz]).buttonHeight,Xoption);
 
 	  GSetForeground(processGC,
-		(float)monoColor((control->buttonQueue[zoomz]).textColor),Xoption);
+		(float)monoColor((control->buttonQueue[zoomz]).textColor),
+                Xoption);
 	  GDrawImageString(processGC,control->controlWindow,
 		   (control->buttonQueue[zoomz]).buttonX +
 		   centerX(processGC,(control->buttonQueue[zoomz]).text,
@@ -12764,9 +10574,7 @@ drawControlPanel(void )
 	}
       } /* else not zoom Y */
     } /* if zoom Y */
-
     /* check if outline is set on or off */
-
     if (((cp->buttonQueue[i]).buttonKey == outlineOnOff) &&
 	  (viewData.outlineRenderOn)) {
       (cp->buttonQueue[i]).textColor = onColor;
@@ -12785,7 +10593,8 @@ drawControlPanel(void )
 	  strlength = strlen(s);
 
 	  GSetForeground(processGC,
-	   (float)monoColor((control->buttonQueue[outlineOnOff]).textColor),Xoption);
+	   (float)monoColor((control->buttonQueue[outlineOnOff]).textColor),
+           Xoption);
 	  GDrawImageString(processGC,control->controlWindow,
 			   (control->buttonQueue[outlineOnOff]).buttonX +
 			   centerX(processGC,s,strlength,
@@ -12797,14 +10606,11 @@ drawControlPanel(void )
 	} /* if mono */
       } /* outline off */
     } /* outline on */
-
     /* Draw the button window border */
-
     GDraw3DButtonOut(globalGC1,cp->controlWindow,
 		   (cp->buttonQueue[i]).buttonX, (cp->buttonQueue[i]).buttonY,
 		   (cp->buttonQueue[i]).buttonWidth,
 		   (cp->buttonQueue[i]).buttonHeight,Xoption);
-
     GSetForeground(trashGC,
 		   (float)monoColor((cp->buttonQueue[i]).textColor), Xoption);
     switch (i) {
@@ -12812,17 +10618,14 @@ drawControlPanel(void )
       GDrawArc(trashGC, cp->controlWindow,
 	       rotateX, rotateY, rotateR, rotateR, 0, 360*64, Xoption);
       break;
-
     case zoom:
       GDrawLines(trashGC, cp->controlWindow, zoomArrow, zoomArrowN,
 		 CoordModeOrigin, Xoption);
       break;
-
     case translate:
       GDrawLines(trashGC, cp->controlWindow, translateArrow,
 		 translateArrowN, CoordModeOrigin, Xoption);
       break;
-
     default:
       s = (cp->buttonQueue[i]).text;
       strlength = strlen(s);
@@ -12832,62 +10635,50 @@ drawControlPanel(void )
 			  (cp->buttonQueue[i]).buttonWidth),
 		  (cp->buttonQueue[i]).buttonY +
 		  centerY(processGC,
-			  (cp->buttonQueue[i]).buttonHeight),s,strlen(s),Xoption);
+			  (cp->buttonQueue[i]).buttonHeight),s,strlen(s),
+                          Xoption);
       break;
     };
-
     if ((cp->buttonQueue[i]).pot) {
       /* draw horizontal and vertical centerlines */
-
       GDrawLine(globalGC1,cp->controlWindow,
 		(cp->buttonQueue[i]).buttonX + (cp->buttonQueue[i]).xHalf,
 		(cp->buttonQueue[i]).buttonY,
 		(cp->buttonQueue[i]).buttonX + (cp->buttonQueue[i]).xHalf,
-		(cp->buttonQueue[i]).buttonY + 2*(cp->buttonQueue[i]).yHalf,Xoption);
-
+		(cp->buttonQueue[i]).buttonY + 2*(cp->buttonQueue[i]).yHalf,
+                Xoption);
       GDrawLine(globalGC1,cp->controlWindow,
 		(cp->buttonQueue[i]).buttonX,
 		(cp->buttonQueue[i]).buttonY + (cp->buttonQueue[i]).yHalf,
 		(cp->buttonQueue[i]).buttonX + 2*(cp->buttonQueue[i]).xHalf,
-		(cp->buttonQueue[i]).buttonY + (cp->buttonQueue[i]).yHalf,Xoption);
+		(cp->buttonQueue[i]).buttonY + (cp->buttonQueue[i]).yHalf,
+                Xoption);
     }
   }
-
   /* refresh the latest message */
   clearControlMessage();
   strcpy(control->message,viewport->title);
   writeControlMessage();
-
  /* Draw the color map window */
   cp = viewport->controlPanel;
   drawColorMap();
   XFlush(dsply);
-
 }  /* drawControlPanel() */
 
-
-/*****************************
- *  void getControlXY()	     *
- *			     *
- * Determines the x and y    *
- * coordinate where the	     *
- * control panel is to be    *
- * placed, based upon where  *
- * the mouse button was	     *
- * pressed within the graph  *
- * viewport window.	     *
- *****************************/
-
-controlXY
-getControlXY (int whereDoYouWantPanel)
-{
-
+@
+\subsection{getControlXY}
+Determines the x and y coordinate where the control panel is to be
+placed, based upon where the mouse button was pressed within the graph
+viewport window.
+\index{view3d!getControlXY}
+\index{getControlXY view3d}
+<<view3d>>=
+controlXY getControlXY(int whereDoYouWantPanel) {
   XWindowAttributes wAttrib;
-  controlXY	    cXY;
+  controlXY	    cXY = {0,0};
   int		    viewX, viewY, viewW, viewH, tmp=1;
   Window	    rootW, parentW, *childrenWs, tmpW;
   unsigned int	    nChildren;
-
   tmpW = viewport->titleWindow;
   while(tmp) {
     XQueryTree(dsply,tmpW,&rootW,&parentW,&childrenWs,&nChildren);
@@ -12899,12 +10690,10 @@ getControlXY (int whereDoYouWantPanel)
     }
   }
   XGetWindowAttributes(dsply,tmpW,&wAttrib);
-
   viewX = wAttrib.x;
   viewY = wAttrib.y;
   viewW = wAttrib.width;
   viewH = wAttrib.height;
-
   if (whereDoYouWantPanel) {
     switch (whereDoYouWantPanel) {
     case 1: /* right */
@@ -12944,37 +10733,29 @@ getControlXY (int whereDoYouWantPanel)
   if (cXY.putX < 0) cXY.putX = 0;
   if (cXY.putY < 0) cXY.putY = 0;
   return(cXY);
-
 }
 
-
-
-/************************************************/
-/***  controlPanelStruct *makeControlPanel()  ***/
-/************************************************/
-
-controlPanelStruct *
-makeControlPanel (void)
-{
-
+@
+\subsection{makeControlPanel}
+\index{view3d!makeControlPanel}
+\index{makeControlPanel view3d}
+<<view3d>>=
+controlPanelStruct *makeControlPanel(void) { 
   Window		cw;
   int			i, num;
   controlPanelStruct	*control;
   buttonStruct		*buttons;
-  controlXY		cXY;
+  controlXY		cXY = {0,0};
   XSetWindowAttributes	cwAttrib, controlAttrib;
   XSizeHints		sizehint;
   Pixmap		mousebits, mousemask;
   XColor		foreColor, backColor;
-
   if (!(control = (controlPanelStruct *)saymem("control.c",1,
 			sizeof(controlPanelStruct)))) {
     fprintf(stderr,"Ran out of memory trying to create control panel.\n");
     exitWithAck(RootWindow(dsply,scrn),Window,-1);
   }
-
   cXY = getControlXY(0);
-
   mousebits = XCreateBitmapFromData(dsply,rtWindow, mouseBitmap_bits,
 				    mouseBitmap_width, mouseBitmap_height);
   mousemask = XCreateBitmapFromData(dsply,rtWindow, mouseMask_bits,
@@ -12995,7 +10776,6 @@ makeControlPanel (void)
 		     cXY.putX,cXY.putY,controlWidth,controlHeight,3,
 		     CopyFromParent,InputOutput,CopyFromParent,
 		     controlCreateMASK,&cwAttrib);
-
   sizehint.flags  = PPosition | PSize;
   sizehint.x	  = cXY.putX;
   sizehint.y	  = cXY.putY;
@@ -13005,10 +10785,8 @@ makeControlPanel (void)
   XSetNormalHints(dsply,cw,&sizehint);
   XSetStandardProperties(dsply,cw,"3D Control Panel","3D Control Panel",
 			 None,NULL,0,&sizehint);
-
   /* Define and assign a mouse cursor */
   control->controlWindow = cw;
-
   num = initButtons(control->buttonQueue);
   buttons = control->buttonQueue;
   for (i=controlButtonsStart3D; i<(controlButtonsEnd3D); i++) {
@@ -13023,12 +10801,8 @@ makeControlPanel (void)
     XMakeAssoc(dsply,table,(control->buttonQueue[i]).self,
 	       &((control->buttonQueue[i]).buttonKey));
     /* use buttonKey and not i because buttonKey has a permanent address */
-
     XMapWindow(dsply,(control->buttonQueue[i]).self);
-
   } /* for each button */
-
-
   /* Set up the potentiometer pixmaps. */
   for (i=0; i<zoomArrowN; i++) {
     zoomArrow[i].x += buttons[zoom].buttonX;
@@ -13038,13 +10812,10 @@ makeControlPanel (void)
     translateArrow[i].x += buttons[translate].buttonX;
     translateArrow[i].y += buttons[translate].buttonY;
   }
-
   rotateX = control->buttonQueue[rotate].buttonX+17;
   rotateY = control->buttonQueue[rotate].buttonY+2;
   rotateR = control->buttonQueue[rotate].buttonHeight-4;
-
   strcpy(control->message,"                                ");
-
   /* Create the color mapping window */
   controlAttrib.event_mask   = colorMASK;
   control->colormapWindow = XCreateWindow(dsply,cw, colorWidth,colormapY,
@@ -13053,43 +10824,28 @@ makeControlPanel (void)
 			      &controlAttrib);
   XMapWindow(dsply,control->colormapWindow);
   viewport->justMadeControl = yes;
-
   return(control);
-
 } /* makeControlPanel() */
 
-
-
-
-/******************************************
- *  void putControlPanelSomewhere()	  *
- * This routine puts up the control panel *
- * associated with the viewport passed	  *
- * in.	It first tries to put it to the	  *
- * right of the viewport.  If there isn't *
- * enough room, it tries the bottom and	  *
- * so on going clockwise. If the viewport *
- * is too big and there is no room to put *
- * the control panel outside of it, the	  *
- * control panel is placed on the bottom  *
- * right hand corner of the viewport.	  *
- *****************************************/
-
-void
-putControlPanelSomewhere (int whereDoesPanelGo)
-{
+@
+\subsection{putControlPanelSomewhere}
+This routine puts up the control panel associated with the viewport passed
+in. It first tries to put it to the right of the viewport.  If there isn't
+enough room, it tries the bottom and so on going clockwise. If the viewport
+is too big and there is no room to put the control panel outside of it, the
+control panel is placed on the bottom right hand corner of the viewport.
+\index{view3d!putControlPanelSomewhere}
+\index{putControlPanelSomewhere view3d}
+<<view3d>>=
+void putControlPanelSomewhere(int whereDoesPanelGo) {
   controlPanelStruct *control;
-  controlXY	     whereControl;
-
+  controlXY	     whereControl = {0,0};
   control      = viewport->controlPanel;
   whereControl = getControlXY(whereDoesPanelGo);
-
   viewport->haveControl = yes;
-
   XRaiseWindow(dsply,control->controlWindow);
   XMoveWindow(dsply, control->controlWindow,
 	      whereControl.putX, whereControl.putY);
-
   drawControlPanel();
   XSync(dsply,0);
   if (viewport->justMadeControl) {
@@ -13098,836 +10854,36 @@ putControlPanelSomewhere (int whereDoesPanelGo)
   }
   XMapWindow(dsply,control->controlWindow);
   XFlush(dsply);
-
 }
 
-
-
-@
-\section{cpanel.h}
-<<view3d/cpanel.h>>=
-/* 
-to be included in control.c for drawing the colormap and
-process.c for getting the mouse input
- */
-
-#define controlMASK		(ButtonPressMask + ButtonReleaseMask + ExposureMask)
-#define potMASK			(ButtonPressMask + ButtonReleaseMask + ButtonMotionMask + LeaveWindowMask)
-#define buttonMASK		(ButtonPressMask + ButtonReleaseMask + ButtonMotionMask + LeaveWindowMask)
-#define colorMASK		(ButtonPressMask + ButtonReleaseMask + ButtonMotionMask + LeaveWindowMask)
-
-
-#define mouseWait		50
-       /* make mouse grab for stationary mouse on a potentiometer slower */
-
-#define controlCreateMASK	CWBackPixel | CWBorderPixel | CWEventMask |CWCursor |CWColormap | CWOverrideRedirect
-#define buttonCreateMASK	CWEventMask  
-#define messageCreateMASK	0
-#define colormapCreateMASK	CWEventMask
-
-#define controlWidth		300
-#define controlHeight		400
-#define quitWidth               63              
-#define quitHeight              107
-#define saveWidth               63
-#define saveHeight              107
-#define borderWidth		22
-#define borderHeight		45
-
-
-#define controlCursorForeground	monoColor(4)
-#define controlCursorBackground	monoColor(54)
-#define controlTitleColor	monoColor(36)
-#define controlPotHeaderColor	monoColor(52)
-#define controlColorColor	monoColor(13)
-#define controlColorSignColor	monoColor(22)
-
-#define headerHeight		headerFont->max_bounds.ascent
-#define controlMessageHeight	globalFont->max_bounds.ascent +globalFont->max_bounds.descent+4
-
-#define potA			25   /* y coordinate of line dividing 
-					potentiometers from stuff above it */
-#define potB			173  /* y coordinate of line dividing 
-					potentiometers from title */
-
-#define cmapA			233  /* y coordinate of line dividing 
-					colormap from stuff above it */
-
-#define butA			((cp->buttonQueue[render]).buttonY - 5)
-
-#define closeL			((cp->buttonQueue[closeAll]).buttonX - 5)
-#define closeA			((cp->buttonQueue[closeAll]).buttonY - 5)
-
-#define controlMessageY		181
-#define controlMessageColor	monoColor(68)
-
-#define offColor	13
-#define onColor		98
-#define	modeColor	44
-
-#define colormapX	        21
-#define colormapY		240
-#define colormapW		290
-#define colormapH		48
-#define colorWidth		8 
-#define colorHeight		8  
-#define colorOffset		3
-#define colorOffsetX		24
-#define colorOffsetY		16
-#define colorPointer		16
-@
-\section{draw.h}
-<<view3d/draw.h>>=
-#define meshOutline      monoColor(140)
-#define opaqueOutline    monoColor(85)
-#define opaqueForeground backgroundColor
-
-
-#define clipOffset 500
-
-/* recalculation occurs if any of these situations have occured */
-
-#define recalc (rotated || zoomed || translated || !finishedList || \
-		firstTime || switchedPerspective || changedEyeDistance)
-
-
-/*** projection macros if matrices are not used  ***/
-#define projPersp(z) (viewData.eyeDistance / (z+viewData.eyeDistance))
-
-#define proj2PX(x,y)   -(x*cosTheta + y*sinTheta) 
-#define proj2PY(x,y,z) -(y*cosTheta*cosPhi - x*sinTheta*cosPhi + z*sinPhi)
-
-/*** For clipping points ***/
-
-#define behindClipPlane(pz) lessThan(pz,viewData.clipPlane)
-
-#define outsideClippedBoundary(x,y,z) (lessThan(x,viewData.clipXmin) ||    \
-				       greaterThan(x,viewData.clipXmax) || \
-				       lessThan(y,viewData.clipYmin) ||    \
-				       greaterThan(y,viewData.clipYmax) || \
-				       lessThan(z,viewData.clipZmin) ||    \
-				       greaterThan(z,viewData.clipZmax) || \
-				       isNaNPoint(x,y,z))
-#include <limits.h>
-
-#define NotPoint	(SHRT_MAX)
-#define eqNANQ(x)	(x == NotPoint)
-
-
-
-/* Tests for NaN clipping should be added in here. */
-
-
-@
-\section{eventnames.h}
-<<view3d/eventnames.h>>=
-static char *event_name[] = {
-  "",                        /* 0  */
-  "",                        /* 1  */
-  "KeyPress",                /* 2  */
-  "KeyRelease",              /* 3  */
-  "ButtonPress",             /* 4  */
-  "ButtonRelease",           /* 5  */
-  "MotionNotify",            /* 6  */
-  "EnterNotify",             /* 7  */
-  "LeaveNotify",             /* 8  */
-  "FocusIn",                 /* 9  */
-  "FocusOut",                /* 10 */
-  "KeymapNotify",            /* 11 */
-  "Expose",                  /* 12 */
-  "GraphicsExpose",          /* 13 */
-  "NoExpose",                /* 14 */
-  "VisibilityNotify",        /* 15 */
-  "CreateNotify",            /* 16 */
-  "DestroyNotify",           /* 17 */
-  "UnmapNotify",             /* 18 */
-  "MapNotify",               /* 19 */
-  "MapRequest",              /* 20 */
-  "ReparentNotify",          /* 21 */
-  "ConfigureNotify",         /* 22 */
-  "ConfigureRequest",        /* 23 */
-  "GravityNotify",           /* 24 */
-  "ResizeRequest",           /* 25 */
-  "CirculateNotify",         /* 26 */
-  "CirculateRequest",        /* 27 */
-  "PropertyNotify",          /* 28 */
-  "SelectionClear",          /* 29 */
-  "SelectionRequest",        /* 30 */
-  "SelectionNotify",         /* 31 */
-  "ColormapNotify",          /* 32 */
-  "ClientMessage",           /* 33 */
-  "MappingNotify"            /* 34 */
-  };
-@
-\section{globals.h}
-<<view3d/globals.h>>=
-extern int              scrn;
-extern Display          *dsply;
-extern XFontStruct      *globalFont, *buttonFont, *headerFont, 
-                        *titleFont, *graphFont,
-                        *lightingFont, *volumeFont, *quitFont, *saveFont,
-                        *serverFont;
-extern XrmDatabase      rDB;
-
-extern char             scaleReport[5], deltaXReport[5], deltaYReport[5];
-extern unsigned long    *spadColors;
-extern int              followMouse, gotToggle, viewportKeyNum;
-extern Window           rtWindow, quitWindow, saveWindow;
-extern GC               globalGC1, globalGC2, anotherGC, globGC, trashGC,
-                        componentGC, opaqueGC, renderGC,
-                        controlMessageGC, lightingGC, volumeGC, quitGC, 
-                        saveGC, graphGC;
-extern XSizeHints       viewSizeHints;
-extern HashTable        *table;
-extern Colormap         colorMap;
-extern int              Socket, ack;
-
-extern GC               processGC;
-extern viewPoints       *viewport;
-extern controlPanelStruct *control;
-extern XGCValues        gcVals;
-extern char             *s;
-extern int              someInt;
-
-extern unsigned long    foregroundColor, backgroundColor;
-extern int              mono, totalColors,
-                        totalHues, totalSolidShades, totalSolid,
-                        totalDitheredAndSolids,totalShades;
-
-extern int              drawMore;
-extern int              spadMode,spadDraw;
-extern int              spadSignalReceived;
-extern int              inNextEvent;
-extern jmp_buf          jumpFlag;
-
-extern char             errorStr[80];
-
-extern view3DStruct     viewData;
-
-extern Window           lightingWindow, lightingAxes;
-extern float            lightPointer[3], tempLightPointer[3];
-extern float            lightIntensity, tempLightIntensity;
-extern float            backLightIntensity;
-
-extern char             filename[256];
-
-
-  /** stuff from draw viewport routines */
-extern float            sinTheta, sinPhi, cosTheta, cosPhi,
-                        viewScale, viewScaleX, viewScaleY, viewScaleZ, reScale;
-extern int              xCenter, yCenter;
-extern XWindowAttributes vwInfo;
-extern XWindowAttributes graphWindowAttrib;
-extern XPoint           *quadMesh;
-extern int              *xPts;
-extern XImage           *imageX;
-
-extern float            eyePoint[3];
-
-extern XPoint           polygonMesh[20];
-
-extern int              saveFlag;
-extern int              firstTime, noTrans, startup;
-extern int              redrawView;
-extern int              finishedList, redoSmooth, redoColor, zoomed,
-                        rotated, switchedPerspective, changedEyeDistance,
-                        translated, changedIntensity, movingLight, writeImage,
-                        pixelSetFlag, redoDither, multiColorFlag;
-extern poly             *quickList;
-
-extern int              viewAloned;
-
-extern viewTriple       corners[8], clipCorners[8];
-extern boxSideStruct    box[6], clipBox[6];
-extern int              axesXY[3][4];
-extern float            axesZ[3][2];
-
-extern viewTriple       *splitPoints;
-extern int              resMax;
-
-extern Window           volumeWindow;
-extern int              frustrumVertex;
-extern int              doingPanel;
-extern int              doingVolume;
-extern int              screenX;
-extern float            xClipMinN, xClipMaxN,
-                        yClipMinN, yClipMaxN,
-                        zClipMinN, zClipMaxN,
-                        clipValue;
-
-extern float            pzMin, pzMax;
-
-extern int              maxGreyShade;
-
-extern char             propertyName[];
-extern char             propertyBuffer[];
-
-extern float            transform[4][4], transform1[4][4],
-                        R[4][4], R1[4][4], S[4][4], T[4][4], I[4][4];
-extern float            vxmax,vxmin,vymax,vymin,
-                        wxmax,wxmin,wymax,wymin,wzmax,wzmin;
-
-extern polyList         *scanList[ARRAY_HEIGHT];
-extern int              scanline, polyCount;
-extern float            xleft, xright;
-
-extern colorBuffer      cBuffer[ARRAY_WIDTH];
-extern float            zBuffer[ARRAY_WIDTH];
-
-extern float            zC, dzdx;
-extern float            intersectColor[2], dcolor;
-extern triple           dpt, dnorm;
-
-extern float            Cspec, Cdiff, Camb, coeff, lum, saturation;
-
-extern Pixmap           viewmap;
-extern int              viewmap_valid;
-extern int              smoothHue;
-extern int              smoothConst;
-extern int              smoothError;
-
-extern char             *PSfilename;  /* output file name in user directory */
-extern char             *envAXIOM;    /* used for ps file paths */
-
-extern Atom wm_delete_window;
-
-@
-\section{header.h}
-<<view3d/header.h>>=
-#define view3D 
-#include <X11/Xlib.h>
-#include <X11/Xresource.h>
-#include <X11/Xutil.h>
-#include <setjmp.h>
-#include "hash.h"
-<<include/view.h>>
-<<include/view3d.h>>
-<<include/actions.h>>
-<<include/viewcommand.h>>
-<<include/xdefs.h>>
-<<include/override.h>>
-<<include/g.h>>
-
-#define swap(a,b) {a^=b; b^=a; a^=b;}
-
-                      /**********************************/
-                      /***         axes stuff         ***/
-                      /**********************************/
-
-#define viewportCreateMASK CWBackPixel | CWBorderPixel | CWEventMask | CWCursor | CWColormap
-#define viewportTitleCreateMASK CWBackPixel | CWBorderPixel | CWCursor | CWColormap | CWEventMask | CWOverrideRedirect
-#define carefullySetFont(gc,font) if (font != serverFont) XSetFont(dsply,gc,font->fid)
-
-#define viewportMASK    (KeyPressMask + ButtonPressMask + ExposureMask)
-#define titleMASK       (ExposureMask)
-
-#define lineWidth       1
-#define lineHeight      1
-
-#define titleColor      monoColor(36)
-#define titleHeight     24
-#define appendixHeight  0
-
-#define viewWidth       400
-#define viewHeight      400
-#define viewYmax        vwInfo.height
-#define viewYmin        vwInfo.y
-#define viewXmax        vwInfo.width
-#define viewXmin        vwInfo.x
-
-#define GC9991 ((GC)9991)
-
-
-/* For smooth shading buffers. Should be screen resolution size, 
-   and one for each of screen width and height may be needed, or
-   it can be changed dynamically if desired. */
-
-#ifdef RIOSplatform
-#define ARRAY_WIDTH      1280 + 1  /* DisplayWidth(dsply,scrn) */
-#define ARRAY_HEIGHT     1024 + 1  /* DisplayHeight(dsply,scrn) */
-#else
-#define ARRAY_WIDTH      1300  /* DisplayWidth(dsply,scrn) */
-#define ARRAY_HEIGHT     1100  /* DisplayHeight(dsply,scrn) */
-#endif
-
-#define viewBorderWidth 0 /* make sure ps.h (postscript header) is the same */
-
-#define initDeltaX      0.0
-#define initDeltaY      0.0
-#define initTheta       pi_half/2.0
-#define initPhi         -pi_half/2.0
-
-#define maxDeltaX       1500.0
-#define maxDeltaY       1500.0
-#define minScale        0.01
-#define maxScale        1000.0
-
-#define rotateFactor    0.2
-#define scaleFactor     0.2
-#define translateFactor 8
-
-#define viewCursorForeground monoColor(166)
-#define viewCursorBackground monoColor(5)
-
-#define axesColor       52
-#define buttonColor     120
-#define labelColor      12
-
-                      /**********************************/
-                      /***        graph stuff         ***/
-                      /**********************************/
-
-#define graphBarLeft    76
-#define graphBarTop     180
-#define graphBarWidth   graphFont->max_bounds.width + 5
-#define graphBarHeight  graphFont->max_bounds.ascent + graphFont->max_bounds.descent
-#define graphBarDefaultColor   monoColor(85)
-#define graphBarShowingColor   monoColor(45)
-#define graphBarHiddenColor    monoColor(146)
-#define graphBarSelectColor    monoColor(45)
-#define graphBarNotSelectColor monoColor(145)
-
-                      /******************************/
-                      /***         colors         ***/
-                      /******************************/
-
-#define totalHuesConst  27
-
-#define hueEnd          360
-#define hueStep         (hueEnd/totalHuesConst)
-
-#define black           BlackPixel(dsply,scrn)
-#define white           WhitePixel(dsply,scrn)
-#define numPlanes       1
-#define numColors       10
-#define startColor      0
-#define endColor        (startColor+numColors)
-#define maxColors       (DisplayCells(dsply,scrn)-1)
-#define maxPlanes       (DefaultVisual((dpy),(scr))->bits_per_rgb)
-
-#define colorStep       ((maxColors+1)/numColors)
-
-                      /**********************************/
-                      /***    Screen and Window Sizes   */
-                      /**********************************/
-
-#define physicalWidth   DisplayWidth(dsply,scrn)
-#define physicalHeight  DisplayHeight(dsply,scrn)
-#define deep            DisplayPlanes(dsply,scrn)
-
-#define basicScreen     19
-
-#define yes             1
-#define no              0
-
-#define pi_half         1.57079632
-#define pi              3.14159265
-#define three_pi_halves 4.71238898
-#define two_pi          6.28318530
-#define pi_sq           9.86960440
-
-#define degrees_in_two_pi 57
-#define d2Pi              57
-
-#define nbuckets         128
-                               
-
-#define anywhere        0
-
-#ifdef DEBUG
-#include "eventnames.h"
-#endif
-
-#define intSize         sizeof(int)
-#define floatSize       sizeof(float)
-
-/* Types so far are X, PS */
-#define drawViewport(type) { drawPreViewport(type); drawTheViewport(type); } 
-#define spadDrawViewport()   spadMode++; drawTheViewport(X); spadMode--;
-
-
-                      /********************************/
-                      /***       lighting panel     ***/
-                      /********************************/
-
-/* These are the lighting panel buttons, they start at 101 
-   (numbers less than 101 are reserved for control panel buttons */
-
-/* From ../include/actions.h */
-
-#define lightingButtonsStart controlButtonsEnd3D  
-
-#define lightMove        (lightingButtonsStart)
-#define lightMoveXY      (lightingButtonsStart+1)
-#define lightMoveZ       (lightingButtonsStart+2)
-#define lightAbort       (lightingButtonsStart+3)
-#define lightReturn      (lightingButtonsStart+4)
-#define lightTranslucent (lightingButtonsStart+5)
-
-#define maxlightingButtons 6
-#define lightingButtonsEnd (lightingButtonsStart + maxlightingButtons)
-
-                      /***********************************/
-                      /***       view volume panel     ***/
-                      /***********************************/
-
-/* These are the volume panel buttons, they start at 200 
-   (numbers less than 101 are reserved for control panel buttons */
-
-#define volumeButtonsStart lightingButtonsEnd
-
-#define volumeReturn    (volumeButtonsStart)
-#define frustrumBut     (volumeButtonsStart+1)
-#define clipXBut        (volumeButtonsStart+2)
-#define clipYBut        (volumeButtonsStart+3)
-#define clipZBut        (volumeButtonsStart+4)
-#define perspectiveBut  (volumeButtonsStart+5)
-#define clipRegionBut   (volumeButtonsStart+6)
-#define clipSurfaceBut  (volumeButtonsStart+7)
-#define volumeAbort     (volumeButtonsStart+8)
-
-#define maxVolumeButtons 9 
-#define volumeButtonsEnd (volumeButtonsStart + maxVolumeButtons)
-
-                       /**** quit panel ****/
-
-#define quitButtonsStart volumeButtonsEnd
-
-#define quitAbort        (quitButtonsStart)
-#define quitReturn       (quitButtonsStart+1)
-#define maxQuitButtons   2
-#define quitButtonsEnd   (quitButtonsStart + maxQuitButtons)
-
-                       /**** save panel ****/
-
-#define saveButtonsStart quitButtonsEnd
-
-#define saveExit         (saveButtonsStart)
-#define pixmap           (saveButtonsStart+1)
-#define ps               (saveButtonsStart+2)
-#define maxSaveButtons   3
-#define saveButtonsEnd   (saveButtonsStart + maxSaveButtons)
-
-                      /******************************************/
-                      /***       buttons to be allocated      ***/
-                      /******************************************/
-
-#define maxButtons3D    saveButtonsEnd
-
-
-      /************************ Type Declarations *************************/
-
-                      /**********************************/
-                      /***        control stuff       ***/
-                      /**********************************/
-
-@
-\index{struct!buttonStruct}
-\index{buttonStruct struct}
-<<view3d/header.h>>=
-typedef struct _buttonStruct {
-  int           buttonKey, pot, mask;
-  short         buttonX, buttonY, buttonWidth, buttonHeight, xHalf, yHalf;
-  Window        self;
-  char          *text;
-  int           textColor,textHue,textShade;
-} buttonStruct;
-
-@
-\index{struct!controlPanelStruct}
-\index{controlPanelStruct struct}
-<<view3d/header.h>>=
-typedef struct _controlPanelStruct {
-  Window        controlWindow, messageWindow, colormapWindow;
-  char          message[40];
-  buttonStruct  buttonQueue[maxButtons3D];
-} controlPanelStruct;
-
-@
-\index{struct!mouseCoord}
-\index{mouseCoord struct}
-<<view3d/header.h>>=
-typedef struct _mouseCoord {
-    float       x, y;
-} mouseCoord;
-
-  
-                      /**********************************/
-                      /***         mesh stuff         ***/
-                      /**********************************/
-
-@
-\index{struct!meshStruct}
-\index{meshStruct struct}
-<<view3d/header.h>>=
-typedef struct _meshStruct {
-  float         N0[4], N1[4];   /* the fourth element is Zmin */
-} meshStruct;
-
-@
-\index{struct!points3D}
-\index{points3D struct}
-<<view3d/header.h>>=
-typedef struct _points3D {
-  float         xmin, xmax,
-                ymin, ymax,
-                xstep, ystep,
-                zmin, zmax,
-                scaleToView;
-  float         *zPoints;
-  int           xnum, ynum,
-                nextRow,
-                style;
-  meshStruct    *normData;   /* list of normals */
-} points3D;
-
 @
-\index{struct!colorBuffer}
-\index{colorBuffer struct}
-<<view3d/header.h>>=
-typedef struct _colorBuffer {
-  int      indx;
-  char     axes;
-} colorBuffer;
-
-
-                      /**********************************/
-                      /***         axes stuff         ***/
-                      /**********************************/
-
-@
-\index{struct!point}
-\index{point struct}
-<<view3d/header.h>>=
-typedef struct _point {
-  float         x, y, z;
-  int           flag;
-} point;
-
-@
-\index{struct!viewPoints}
-\index{viewPoints struct}
-One of the (many) sloppy things that need to be
-cleaned up is the viewPoints structure. a lot of
-stuff in it is used solely for the function of
-two variables stuff. they should be moved to
-the fun2Var substructure.
-<<view3d/header.h>>=
-typedef struct _viewPoints {
-  int                 viewportKey;
-  char                title[80];
-  Window              viewWindow, titleWindow;
-  float               deltaX, deltaY,
-                      scale, scaleX, scaleY, scaleZ,
-                      theta, phi,
-                      deltaX0, deltaY0,     /* initial values */
-                      scale0, transX, transY, transZ, thetaObj, phiObj,
-                      theta0, phi0, theta1, phi1, axestheta, axesphi;
-  float               deltaZ, deltaZ0;
-  controlPanelStruct  *controlPanel;
-  int                 axesOn, regionOn, monoOn;
-  int                 zoomXOn, zoomYOn, zoomZOn;
-  int                 originrOn, objectrOn;
-  int                 xyOn, xzOn, yzOn;
-  int                 originFlag;
-  int                 justMadeControl, haveControl,
-                      closing, allowDraw, needNorm;
-  points3D            meshData;
-  float               lightVector[3], translucency;
-  int                 hueOffset, numberOfHues, hueTop, diagonals;
-  struct _viewPoints  *prevViewport, *nextViewport;
-} viewPoints;
-
-@
-\index{struct!controlXY}
-\index{controlXY struct}
-<<view3d/header.h>>=
-typedef struct _controlXY {
-  int           putX, putY;
-} controlXY;
-
-
-      /******* useful definitions *******/
-
-#define CONTROLpanel 1
-#define LIGHTpanel   2
-#define VOLUMEpanel  3
-#define CONTOURpanel 4
-#define QUITpanel    5
-#define SAVEpanel    6
-
-#define machine0 0.0002
-
-<<view3d/globals.h>>
-
-@
-\section{illuminate3d.c}
-<<view3d/illuminate3d.c>>=
-#define _ILLUMINATE3D_C
-
-#include <math.h>
-
-<<view3d/header.h>>
-<<view3d/draw.h>>
-
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-/***********************
- * void phong(pt,N)    *
- *                     *
- * a general routine   *
- * for determining the *
- * intensity values at *
- * a particular point  *
- * using the Phong     *
- * illumination model  *
- * with Phong shading  *
- ***********************/
-
-float 
-phong(triple pt,float N[3])
-{
+\subsection{phong}
+A general routine for determining the intensity values at
+a particular point using the Phong illumination model with Phong shading
+\index{view3d!phong}
+\index{phong view3d}
+<<view3d>>=
+float phong(triple pt,float N[3]) {
   float     dotLN, dotHN, H[3], E[3], P[3], NM[3], L[3];
   float     color, diffuse, specular;
-
   diffuse = 0.0;  specular = 0.0;
-
   /* renormalize average normal vector for the point */
   normalizeVector(N);
   /* temporary norm, in case the sign is switched */
   NM[0] = N[0];  NM[1] = N[1];  NM[2] = N[2];
-
   P[0] = pt.x;  P[1] = pt.y;  P[2] = pt.z;
   normalizeVector(P);
-
   /* vector from infinite light source */
   L[0] = viewport->lightVector[0];
   L[1] = viewport->lightVector[1];
   L[2] = viewport->lightVector[2];
   normalizeVector(L);
-
   /* vector from point to observers eye */
   normalizeVector(eyePoint);
   E[0] = 8.0*eyePoint[0] - P[0];
   E[1] = 8.0*eyePoint[1] - P[1];
   E[2] = 8.0*eyePoint[2] - P[2];
   normalizeVector(E);
-
   /*  light returned even if normal faces away from light source */
   dotLN = L[0]*NM[0] + L[1]*NM[1] + L[2]*NM[2];
   if (dotLN < 0.0) dotLN = -dotLN;
@@ -13942,32 +10898,32 @@ phong(triple pt,float N[3])
     if (dotHN < 0.0) dotHN = -dotHN;
     specular = pow((double)dotHN,coeff)*lightIntensity;
   } 
-
   /* return intensity value from 0.0 to 1.0 */
   color = Camb + diffuse*Cdiff + specular*Cspec;
-
   if (color > 1.0) color = 1.0;
   if (color < 0.0) color = 0.0;
-
   return(color);
 }
 
-int 
-hueValue(float val)
-{
+@
+\subsection{hueValue}
+\index{view3d!hueValue}
+\index{hueValue view3d}
+<<view3d>>=
+int hueValue(float val) {
   int hue;
-    	
   hue = floor(absolute(val) * viewport->numberOfHues) + viewport->hueOffset;
   if (hue > 26) hue = 26;
-
   return hue;
 }
 
-int 
-getHue(float val)
-{
+@
+\subsection{getHue}
+\index{view3d!getHue}
+\index{getHue view3d}
+<<view3d>>=
+int getHue(float val) {
   int hue;
-    	
   hue = hueValue(val);
   if (hue < 11)
     hue *= 6;
@@ -13976,17 +10932,16 @@ getHue(float val)
       hue = hue*20 - 140;
     else 
       hue = hue*12 - 12;
-
   return hue;
 }
 
-/**** Conversion functions for different color models ****/
-
-float 
-Value(float n1, float n2, float hue)
-{
+@
+\subsection{Value}
+\index{view3d!Value}
+\index{Value view3d}
+<<view3d>>=
+float Value(float n1, float n2, float hue) {
   float v;
-
   if (hue > 360.0) hue -= 360.0;
   if (hue < 0.0) hue += 360.0;
   if (hue < 60.0) {
@@ -14005,13 +10960,14 @@ Value(float n1, float n2, float hue)
   return(v);
 }
 
-
-RGB
-hlsTOrgb(float h,float l,float s)
-{
+@
+\subsection{hlsTOrgb}
+\index{view3d!hlsTOrgb}
+\index{hlsTOrgb view3d}
+<<view3d>>=
+RGB hlsTOrgb(float h,float l,float s) {
   RGB rgb;
   float m1, m2;
-
   if (l <= 0.5) { 
     m2 = l*(1.0+s); 
   }
@@ -14022,154 +10978,19 @@ hlsTOrgb(float h,float l,float s)
   rgb.r = Value(m1,m2,h+120.0);
   rgb.g = Value(m1,m2,h);
   rgb.b = Value(m1,m2,h-120.0);
-
   return(rgb);
 }
 
-
-
-
-
-
 @
-\section{lightbut3d.c}
-<<view3d/lightbut3d.c>>=
-#define _LIGHTBUT3D_C
-
-<<view3d/header.h>>
-<<view3d/cpanel.h>>
-
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-/*****************************************************
- * int initLightButtons (lightButtons)               *
- *                                                   *
- * Creates the fields for each button window in the  *
- * three dimensional lighting subpanel, and returns  *
- * the number of buttons created.                    *
- *                                                   *
- *****************************************************/
-
-int 
-initLightButtons (buttonStruct *lightButtons)
-{
+\subsection{initLightButtons}
+Creates the fields for each button window in the three dimensional 
+lighting subpanel, and returns the number of buttons created.
+\index{view3d!initLightButtons}
+\index{initLightButtons view3d}
+<<view3d>>=
+int initLightButtons(buttonStruct *lightButtons) {
   int ii;
   int num = 0;
-
   /* Not functional -- can be used to allow light window as a potentiometer */
   ii = lightMove;
   lightButtons[ii].buttonX      = 63;
@@ -14183,7 +11004,6 @@ initLightButtons (buttonStruct *lightButtons)
   lightButtons[ii].xHalf        = lightButtons[ii].buttonWidth/2;
   lightButtons[ii].yHalf        = lightButtons[ii].buttonHeight/2;
   ++num;
-
   /* Change x and y coordinate of light source */
   ii = lightMoveXY;
   lightButtons[ii].buttonX      = 20;
@@ -14197,7 +11017,6 @@ initLightButtons (buttonStruct *lightButtons)
   lightButtons[ii].xHalf        = lightButtons[ii].buttonWidth/2;
   lightButtons[ii].yHalf        = lightButtons[ii].buttonHeight/2;
   ++num;
-  
   /* Change z coordinate of light source */
   ii = lightMoveZ;
   lightButtons[ii].buttonX      = 149;
@@ -14211,7 +11030,6 @@ initLightButtons (buttonStruct *lightButtons)
   lightButtons[ii].xHalf        = lightButtons[ii].buttonWidth/2;
   lightButtons[ii].yHalf        = lightButtons[ii].buttonHeight/2;
   ++num;
-  
   /* Change intensity of light source */
   ii = lightTranslucent;
   lightButtons[ii].buttonX      = 250;
@@ -14225,7 +11043,6 @@ initLightButtons (buttonStruct *lightButtons)
   lightButtons[ii].xHalf        = lightButtons[ii].buttonWidth/2;
   lightButtons[ii].yHalf        = lightButtons[ii].buttonHeight/2;
   ++num;
-
   /* Leave lighting window without updating changes made. */
   ii = lightAbort;
   lightButtons[ii].buttonX      = 36;
@@ -14240,7 +11057,6 @@ initLightButtons (buttonStruct *lightButtons)
   lightButtons[ii].xHalf        = lightButtons[ii].buttonWidth/2;
   lightButtons[ii].yHalf        = lightButtons[ii].buttonHeight/2;
   ++num;
-
   /* Leave lighting window and update changes made. */
   ii = lightReturn;
   lightButtons[ii].buttonX      = 154;
@@ -14255,240 +11071,20 @@ initLightButtons (buttonStruct *lightButtons)
   lightButtons[ii].xHalf        = lightButtons[ii].buttonWidth/2;
   lightButtons[ii].yHalf        = lightButtons[ii].buttonHeight/2;
   ++num;
-
   return(num);
 }
 
-
 @
-\section{lighting3d.c}
-<<view3d/lighting3d.c>>=
-#define _LIGHTING3D_C
-
-#include <math.h>
-#include <string.h>
-
-#define lightBitmap_width 16
-#define lightBitmap_height 16
-#define lightBitmap_x_hot 8
-#define lightBitmap_y_hot 0
-static char lightBitmap_bits[] = {
-   0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x04, 0x40, 0xc8, 0x27, 0x20, 0x08,
-   0x10, 0x10, 0x16, 0x10, 0x10, 0xd0, 0x10, 0x10, 0x24, 0x08, 0x42, 0x44,
-   0x40, 0x84, 0x80, 0x02, 0x80, 0x02, 0x00, 0x01};
-#define lightMask_width 16
-#define lightMask_height 16
-#define lightMask_x_hot 8
-#define lightMask_y_hot 0
-static char lightMask_bits[] = {
-   0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x04, 0x40, 0xc8, 0x27, 0x20, 0x08,
-   0x10, 0x11, 0x96, 0x12, 0x90, 0xd2, 0x90, 0x10, 0x24, 0x09, 0x42, 0x45,
-   0x40, 0x85, 0x80, 0x03, 0x80, 0x02, 0x00, 0x01};
-
-
-<<view3d/header.h>>
-<<view3d/static.h>>
-<<view3d/draw.h>>
-<<view3d/cpanel.h>>
-<<view3d/volume.h>>
-
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-#include "xspadfill.h1"
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-#define lightMASK ExposureMask
-#define lightCursorForeground lightingTitleColor
-#define lightCursorBackground foregroundColor
-
-#define lightFontHeight (lightingFont->max_bounds.ascent+lightingFont->max_bounds.descent)
-
-#define lightingAxesColor  monoColor(52)
-#define lightingLabelColor monoColor(12)
-#define lightingBoxColor   monoColor(138)
-#define lightingLightColor monoColor(7)
-#define lightingTitleColor monoColor(69)
-#define lightingButtonColor monoColor(140)
-#define lightingTransColor monoColor(140)
-#define lightingTransArrowColor monoColor(100)
-#define lightingTransLabelColor monoColor(207)
-
-#define lightingAxesSize 175
-#define lightingAxesX	 61
-#define lightingAxesY	 28
-
-#define lightAxesScale 110	/* the extent of the axes in object space */
-#define lightScale 0.63		/* projected scale factor */
-
-#define arrowHead (control->buttonQueue[lightTranslucent].buttonX + 5)
-static viewTriple point0 = {0,0,0};
-
-
-/***************************
- * int makeLightingPanel() *
- ***************************/
-
-int
-makeLightingPanel(void)
-{
-
+\subsection{makeLightingPanel}
+\index{view3d!makeLightingPanel}
+\index{makeLightingPanel view3d}
+<<view3d>>=
+int makeLightingPanel(void) {
   int i;
   XSetWindowAttributes cwAttrib, controlAttrib;
   XSizeHints sizehint;
   Pixmap lightbits,lightmask;
   XColor foreColor, backColor;
-
   lightbits = XCreateBitmapFromData(dsply,rtWindow, lightBitmap_bits,
 				    lightBitmap_width,lightBitmap_height);
   lightmask = XCreateBitmapFromData(dsply,rtWindow, lightMask_bits,
@@ -14509,7 +11105,6 @@ makeLightingPanel(void)
 				 -3,-3,controlWidth,controlHeight,3,
 				 CopyFromParent,InputOutput,CopyFromParent,
 				 controlCreateMASK,&cwAttrib);
-
   sizehint.flags  = USPosition | USSize;
   sizehint.x	  = 0;
   sizehint.y	  = 0;
@@ -14519,7 +11114,6 @@ makeLightingPanel(void)
   XSetNormalHints(dsply,lightingWindow,&sizehint);
   XSetStandardProperties(dsply,lightingWindow,"Lighting Panel 3D",
 			 "Lighting Panel",None,NULL,0,&sizehint);
-
       /*** lighting axes window ***/
   cwAttrib.event_mask = 0;
   lightingAxes = XCreateWindow(dsply,lightingWindow,
@@ -14538,7 +11132,6 @@ makeLightingPanel(void)
   XSetStandardProperties(dsply,lightingAxes,"Lighting Axes","Lighting Axes",
 			 None,NULL,0,&sizehint);
   XMapWindow(dsply,lightingAxes);
-
     /*** draw lighting buttons ***/
   initLightButtons(control->buttonQueue);
   for (i=(lightingButtonsStart + 1); i<(lightingButtonsEnd); i++) {
@@ -14555,41 +11148,33 @@ makeLightingPanel(void)
 	       &((control->buttonQueue[i]).buttonKey));
     XMapWindow(dsply,(control->buttonQueue[i]).self);
   }
-
      /* assign global direction variables for light projections */
   sinTheta  = sin(-viewport->theta);
   cosTheta  = cos(-viewport->theta);
   sinPhi    = sin(viewport->phi);
   cosPhi    = cos(viewport->phi);
-
   return(0);
-
 }  /* makeLightingPanel() */
 
-/***************************
- * void drawLightingAxes() *
- ***************************/
-
-void 
-drawLightingAxes(void)
-{
-
+@
+\subsection{drawLightingAxes}
+\index{view3d!drawLightingAxes}
+\index{drawLightingAxes view3d}
+<<view3d>>=
+void drawLightingAxes(void) {
   XWindowAttributes laInfo;
   int i,xCenter,yCenter;
   float Px0,Py0;
   int vPx0,vPy0,vPx1,vPy1;
   viewTriple pointX,pointY,pointXY,pointXYZ;
-
   XGetWindowAttributes(dsply,lightingAxes,&laInfo);
   XClearWindow(dsply,lightingAxes);
   xCenter = laInfo.width / 2;
   yCenter = laInfo.height / 2;
-
   sinTheta = sin(-viewport->theta);
   cosTheta = cos(-viewport->theta);
   sinPhi   = sin(viewport->phi);
   cosPhi   = cos(viewport->phi);
-
   GSetForeground(lightingGC,(float)monoColor(buttonColor),Xoption);
   for (i=0; i < 3; i++) {
     Px0 = proj2PX(axes[i][0],axes[i][1]);
@@ -14602,7 +11187,6 @@ drawLightingAxes(void)
     vPy1 = laInfo.height - (Py0 * lightScale + yCenter);
     GDrawLine(lightingGC,lightingAxes,vPx0,vPy0,vPx1,vPy1,Xoption);
   }
-
   GSetForeground(lightingGC,(float)lightingLabelColor,Xoption);
   for (i=0; i < basicScreen; i++) {
     Px0 = proj2PX(labels[i][0],labels[i][1]);
@@ -14615,68 +11199,54 @@ drawLightingAxes(void)
     vPy1 = laInfo.height - (Py0 * lightScale + yCenter);
     GDrawLine(lightingGC,lightingAxes,vPx0,vPy0,vPx1,vPy1,Xoption);
   }
-
   GSetForeground(lightingGC,(float)lightingBoxColor,Xoption);
   pointX.x = tempLightPointer[0] * lightAxesScale;
   pointX.y = 0;
   pointX.z = 0;
-
   pointY.x = 0;
   pointY.y = tempLightPointer[1] * lightAxesScale;
   pointY.z = 0;
-
   pointXY.x = tempLightPointer[0] * lightAxesScale;
   pointXY.y = tempLightPointer[1] * lightAxesScale;
   pointXY.z = 0;
-
   pointXYZ.x = tempLightPointer[0] * lightAxesScale;
   pointXYZ.y = tempLightPointer[1] * lightAxesScale;
   pointXYZ.z = tempLightPointer[2] * lightAxesScale;
-
   Px0 = proj2PX(pointXY.x,pointXY.y);
   Py0 = proj2PY(pointXY.x,pointXY.y,pointXY.z);
   vPx0 =		   Px0 * lightScale + xCenter;
   vPy0 = laInfo.height - (Py0 * lightScale + yCenter);
-
   Px0 = proj2PX(pointX.x,pointX.y);
   Py0 = proj2PY(pointX.x,pointX.y,pointX.z);
   vPx1 =		   Px0 * lightScale + xCenter;
   vPy1 = laInfo.height - (Py0 * lightScale + yCenter);
   GDrawLine(lightingGC,lightingAxes,vPx0,vPy0,vPx1,vPy1,Xoption);
-
   Px0 = proj2PX(pointY.x,pointY.y);
   Py0 = proj2PY(pointY.x,pointY.y,pointY.z);
   vPx1 =		   Px0 * lightScale + xCenter;
   vPy1 = laInfo.height - (Py0 * lightScale + yCenter);
   GDrawLine(lightingGC,lightingAxes,vPx0,vPy0,vPx1,vPy1,Xoption);
-
   Px0 = proj2PX(pointXYZ.x,pointXYZ.y);
   Py0 = proj2PY(pointXYZ.x,pointXYZ.y,pointXYZ.z);
   vPx1 =		   Px0 * lightScale + xCenter;
   vPy1 = laInfo.height - (Py0 * lightScale + yCenter);
   GDrawLine(lightingGC,lightingAxes,vPx0,vPy0,vPx1,vPy1,Xoption);
-
   GSetForeground(lightingGC,(float)lightingLightColor,Xoption);
   Px0 = proj2PX(point0.x,point0.y);
   Py0 = proj2PY(point0.x,point0.y,point0.z);
   vPx0 =		   Px0 * lightScale + xCenter;
   vPy0 = laInfo.height - (Py0 * lightScale + yCenter);
   GDrawLine(lightingGC,lightingAxes,vPx0,vPy0,vPx1,vPy1,Xoption);
-
 }   /* drawLightingAxes */
 
-
-/******************************
- * void drawLightTransArrow() *
- ******************************/
-
-void 
-drawLightTransArrow(void)
-{
-
+@
+\subsection{drawLightTransArrow}
+\index{view3d!drawLightTransArrow}
+\index{drawLightTransArrow view3d}
+<<view3d>>=
+void drawLightTransArrow(void) {
   int i;
   float f;
-
   /*** Draw the intensity potentiometer window. ***/
   XClearArea(dsply,lightingWindow,
 	     (control->buttonQueue[lightTranslucent]).buttonX,
@@ -14728,10 +11298,8 @@ drawLightTransArrow(void)
 	    (control->buttonQueue[lightTranslucent]).buttonWidth * 3/10,
 	    (control->buttonQueue[lightTranslucent]).buttonY +
 	    (control->buttonQueue[lightTranslucent]).buttonHeight,Xoption);
-
   /*** Draw the intensity selection arrow ***/
   GSetForeground(lightingGC,(float)lightingTransArrowColor,Xoption);
-
   f = (control->buttonQueue[lightTranslucent].buttonY +
        control->buttonQueue[lightTranslucent].buttonHeight) -
        (tempLightIntensity *
@@ -14743,30 +11311,21 @@ drawLightTransArrow(void)
 	    arrowHead + 22, i - 2, Xoption);
   GDrawLine(lightingGC, lightingWindow, arrowHead + 22, i - 2,
 	    arrowHead + 10, i, Xoption);
-
 }  /* drawLightTransArrow() */
 
-
-
-
-
-/****************************
- * void drawLightingPanel() *
- ****************************/
-
-void
-drawLightingPanel(void)
-{
-
+@
+\subsection{drawLightingPanel}
+\index{view3d!drawLightingPanel}
+\index{drawLightingPanel view3d}
+<<view3d>>=
+void drawLightingPanel(void) {
   char *s;
   int i,strlength;
-
   /* Draw border lines to separate the lighting window, potentiometers,
      and button regions of the lightng subpanel. */
   GSetForeground(trashGC,(float)foregroundColor,Xoption);
   GSetLineAttributes(trashGC,3,LineSolid,CapButt,JoinMiter,Xoption);
   GDrawLine(trashGC, lightingWindow, 0,	 potA, controlWidth, potA, Xoption);
-
   GSetLineAttributes(trashGC,2,LineSolid,CapButt,JoinMiter,Xoption);
   GDrawLine(trashGC, lightingWindow, 0, lightB, controlWidth, lightB, Xoption);
   GDrawLine(trashGC, lightingWindow, 0, lightPotA, controlWidth,
@@ -14775,7 +11334,6 @@ drawLightingPanel(void)
 	    lightPotB, Xoption);
   GDrawLine(trashGC, lightingWindow, lightTransL, lightPotA,
 	    lightTransL, lightPotB, Xoption);
-
   writeControlTitle(lightingWindow);
   s = "Lighting Control Panel";
   strlength = strlen(s);
@@ -14783,7 +11341,6 @@ drawLightingPanel(void)
   GDrawString(anotherGC, lightingWindow,
 	      centerX(anotherGC, s, strlength, controlWidth),
 	      lightB+18, s, strlength, Xoption);
-
   for (i=lightingButtonsStart; i<(lightingButtonsEnd); i++) {
     switch (i) {
     case lightMove:
@@ -14876,7 +11433,8 @@ drawLightingPanel(void)
       s = (control->buttonQueue[i]).text;
       strlength = strlen(s);
       GSetForeground(trashGC,
-		     (float)monoColor((control->buttonQueue[i]).textColor),Xoption);
+		     (float)monoColor((control->buttonQueue[i]).textColor),
+                     Xoption);
       GDrawString(trashGC, lightingWindow,
 		  (control->buttonQueue[i]).buttonX +
 		  centerX(processGC,s,strlength,
@@ -14886,7 +11444,6 @@ drawLightingPanel(void)
 		  s,strlen(s),Xoption);
     }  /* switch */
   }  /* for i in control->buttonQueue */
-
   GSetForeground(lightingGC,(float)monoColor(labelColor),Xoption);
   GDrawString(lightingGC,lightingWindow,
 	      control->buttonQueue[lightMoveXY].buttonX +
@@ -14904,7 +11461,6 @@ drawLightingPanel(void)
 	      control->buttonQueue[lightMoveZ].xHalf - 2,
 	      control->buttonQueue[lightMoveZ].buttonY - 4,
 	      "z",1,Xoption);
-
   /** Draw the title for the intensity potentiometer. */
   GSetForeground(lightingGC,(float)lightingTransColor,Xoption);
 
@@ -14963,742 +11519,36 @@ drawLightingPanel(void)
 	      "y",1,Xoption);
   drawLightingAxes();
   drawLightTransArrow();
-
 }  /* drawLightingPanel */
 
-
-
-
-
 @
-\section{main3d.c}
-<<view3d/main3d.c>>=
-#define _MAIN3D_C
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <signal.h>
-
-<<view3d/header.h>>
-<<view3d/cpanel.h>>
-<<view3d/process.h>>
-#include "bsdsignal.h"
-
-#include "bsdsignal.h1"
-#include "util.h1"
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-#include "xspadfill.h1"
-#include "xshade.h1"
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-                                 /**********************/
-                                 /** global variables **/
-                                 /**********************/
-
-unsigned long * spadColors;
-Display         *dsply;
-int             scrn;
-XFontStruct     *globalFont, *buttonFont, *headerFont, *titleFont, *graphFont,
-                *lightingFont, *volumeFont, *quitFont, *saveFont,*serverFont;
-char            scaleReport[5];
-char            deltaXReport[5], deltaYReport[5];
-int             followMouse=no,
-                viewportKeyNum=0;
-Window          rtWindow;
-GC              globalGC1, globalGC2, anotherGC, globGC, trashGC,
-                controlMessageGC, lightingGC, volumeGC, quitGC, 
-                saveGC, graphGC, componentGC, opaqueGC, renderGC;
-XSizeHints      viewSizeHints;
-HashTable       *table;
-Colormap        colorMap;
-int             Socket=1, ack=1;
-
-GC              processGC;
-viewPoints      *viewport;
-controlPanelStruct      *control;
-XGCValues       gcVals;
-char            *s;
-int             someInt;  
-
-/* check /usr/include/X11 for current implementation of
-   pixels (e.g. BlackPixel()) */
-unsigned long   foregroundColor, backgroundColor;  
-
-           /** totalShades is initially set to totalShadesConst.
-               If X cannot allocate 8 shades for each hue, total-
-               Shades is decremented. there is currently only a check for
-               this value to be positive. --> something to add: change over 
-               to monochrome if totalShades=0. just modify the spadcolors.c
-               file. spadcolors.c has been modified so that it returns the
-               value for totalShades. since the return value had previously
-               been unused, a modification in this way ensures continued
-               support of other routines calling this function (e.g.
-               hypertex stuff). **/
-
-int             mono, totalColors, totalSolid, totalDithered, totalHues, 
-                totalSolidShades, totalDitheredAndSolids,totalShades;
-
-int             drawMore;
-
-int             spadMode=no,            /* yes if receiving Axiom command and
-                                           calling drawViewport */
-                spadDraw=no;            /* yes if drawing viewport for 
-                                           an Axiom command */
-int             spadSignalReceived=0;  /* yes if current state is a result of
-                                           a signal from Axiom */
-int             inNextEvent=no;         /* true just before a call to
-					   XNextEvent */
-jmp_buf         jumpFlag;
-
-char            errorStr[80];
-
-view3DStruct    viewData;
-
-Window          quitWindow, saveWindow;
-
-                /** variables below assume only one viewport per process **/
-
-Window          lightingWindow, lightingAxes;
-float           lightPointer[3], tempLightPointer[3];
-                
-int             axesXY[3][4];
-float           axesZ[3][2];
-
-float           lightIntensity=1.0, tempLightIntensity;
-float           backLightIntensity = 1.0;
-
-                /** used for writing viewport info out to a file **/
-char            filename[256];
-
-
-                /** used for draw viewport routines */
-float           sinTheta, sinPhi, cosTheta, cosPhi, viewScale, 
-                viewScaleX, viewScaleY, viewScaleZ, reScale;
-int             xCenter, yCenter;
-
-XWindowAttributes       vwInfo;
-XWindowAttributes	graphWindowAttrib;
-
-XPoint          *quadMesh;
-XImage          *imageX;
-int             *xPts;   /* pointer to projected points (x followed by y) */
-float           transform[4][4], transform1[4][4],
-                R[4][4], R1[4][4], S[4][4], T[4][4], I[4][4];
-float           A[4][4], B[4][4], D[4], E[4][4], F[4], array[4][4];
-                
-
-int             scanline, polyCount;
-polyList        *scanList[ARRAY_HEIGHT];
-float           xleft = (float)0 ,xright = (float)ARRAY_WIDTH;
-
-colorBuffer      cBuffer[ARRAY_WIDTH];
-float            zBuffer[ARRAY_WIDTH];
-
-float           zC, dzdx, lum, point_norm[3];
-float           intersectColor[2], dcolor;
-triple          dpt, dnorm;
-
-                /** eyePoint **/
-float           eyePoint[3];
-
-                /** tube stuff **/
-XPoint          polygonMesh[20];
-
-                /* bypass the hidden surface algorithm if no rotations, etc */
-int             saveFlag=no;
-int             firstTime=yes, noTrans = yes, startup = yes;
-int             redrawView = no;   /* set to yes when returning from
-				      subpanels */
-int             redoColor = no, pixelSetFlag = no, redoDither = no;
-int             redoSmooth = no, multiColorFlag = no;
-
-/* In order to set recalc to true (see draw.h) */
-int             finishedList=no, zoomed=yes, translated = yes,
-                changedIntensity, movingLight = no, writeImage = no,
-                rotated=yes, switchedPerspective, changedEyeDistance,
-                gotToggle = no;
-poly            *quickList;
-
-                /** if not connected to Axiom **/
-int             viewAloned;
-
-                /** for drawing the box **/
-viewTriple      corners[8], clipCorners[8];
-boxSideStruct   box[6], clipBox[6];
-
-                /** for freeing up points created frrom split polygons **/
-viewTriple      *splitPoints;
-int             resMax=0;  /* number of points in the split point resevoir */
-
-                /** view volume stuff **/
-Window          volumeWindow;
-int             frustrumVertex;
-int             doingPanel=CONTROLpanel; /* rewrite titles in proper panel */
-int             doingVolume;
-
-int             screenX;  /* global floating point indicating mouse position
-			     on frustrum screen */
-float           xClipMinN, xClipMaxN,   /* normalized values for
-					   clip volume */
-                yClipMinN, yClipMaxN,
-                zClipMinN, zClipMaxN,
-                clipValue;              /* mouse input */
-float           pzMin, pzMax;   /* for a given (theta,phi): calculated in
-                                   drawViewport(), used in drawFrustrum() */
-
-                /** B/W shades **/
-int             maxGreyShade=0;
-                /** events from the viewport manager **/
-char            propertyName[14];
-char            propertyBuffer[256];
-
-                /* global ps variables */
-int             psInit=no;      /* need to call globaInitPs() each run */
-GCptr           GChead=NULL;    /* ptr to head of ps GC linked list */
-char            *PSfilename;    /* output file name used in user directory */
-char            *envAXIOM;      /* used for ps file paths */
-
-               /** Resource database **/
-XrmDatabase rDB;
-
-               /** variables used for smooth shading **/
-int    smoothError = no;
-Pixmap viewmap;
-int    viewmap_valid = 0;
-float  Cspec = 0.30;
-float  Cdiff = 0.4;
-float  Camb = 0.3;
-float  coeff = 35.0;
-float  saturation = 0.8;
-int    smoothHue;
-int    smoothConst = 50;
-
-
-
-int 
-the_handler(Display *display,XErrorEvent *event) 
-{
+\subsection{theHandler}
+\index{view3d!theHandler}
+\index{theHandler view3d}
+<<view3d>>=
+int theHandler(Display *display,XErrorEvent *event) {
   char buffer[512];
   XGetErrorText(display,event->error_code,buffer,511);
   fprintf(stderr,"%s\n",buffer);
   return(0);
 }
 
-int
-main(void) 
-{
-
-  XGCValues     controlGCVals;
-  int           i, code;
-
-  char property[256];
-  char *prop = &property[0];
-  char *str_type[20];
-  XrmValue value;
-
-
-  /**** Global inits ****/
-  splitPoints = NIL(viewTriple);
-
-  /**** Set up display ****/
-  if ((dsply = XOpenDisplay(getenv("DISPLAY"))) == NULL)
-    {fprintf(stderr,"Could not open display.\n");exit (-1);}
-  scrn = DefaultScreen(dsply);
-  rtWindow = RootWindow(dsply,scrn);
-  XSetErrorHandler(the_handler);
-  /*   XSynchronize(dsply,False); */
-
-  /**** link Xwindows to viewports - X10 feature ****/
-  table = XCreateAssocTable(nbuckets);  
-
-  /**** Create Axiom color map ****/
-  totalShades = 0;
-  totalColors = XInitSpadFill(dsply,scrn,&colorMap,
-                              &totalHues,&totalSolidShades,
-                              &totalDitheredAndSolids,&totalShades);
-  if (totalColors < 0) {
-    fprintf(stderr,"ERROR: Could not allocate all the necessary colors.\n");
-    exitWithAck(RootWindow(dsply,scrn),Window,-1);
-  }
-
-  
-  mergeDatabases();
-
-  /*** Determine whether monochrome or color is used ***/
-  if (XrmGetResource(rDB,"Axiom.3D.monochrome","",str_type,&value) == True){
-     (void) strncpy(prop,value.addr,(int)value.size);
-     }
-  else {
-     (void) strcpy(prop, "off");
-     }
-
-
-  mono = ((totalSolid == 2) || (strcmp(prop,"on") == 0));
-  if (mono) maxGreyShade=XInitShades(dsply,scrn) ;
-
-  if (XrmGetResource(rDB,"Axiom.3D.inverse","",str_type,&value) == True){
-     (void) strncpy(prop,value.addr,(int)value.size);
-     }
-  else {
-     (void) strcpy(prop, "off");
-     }
-
-  if (mono) {
-    if (strcmp(prop,"on") == 0) {  /* 0 if equal - inverse video */
-      foregroundColor = white;
-      backgroundColor = black;
-    } else {  /* off - no inverse video */
-      foregroundColor = black;
-      backgroundColor = white;
-    }
-  } else {  /* inverse of inverse in color (for some strange reason) */
-    if (strcmp(prop,"on") == 0) {  /* 0 if equal - inverse video */
-      foregroundColor = white;
-      backgroundColor = black;
-    } else {  /* off - no inverse video */
-      foregroundColor = black;
-      backgroundColor = white;
-    }
-  }
-
-  /* read default file name for postScript output */
-  if (XrmGetResource(rDB,"Axiom.3D.postscriptFile","",str_type,&value) == True){
-     (void) strncpy(prop,value.addr,(int)value.size);
-     }
-  else {
-     (void) strcpy(prop, "axiom3d.ps");
-     }
-  PSfilename = (char *)malloc(strlen(prop)+1);
-  strcpy(PSfilename,prop);
-
-  XSync(dsply,0);
-
-  /**** Open global fonts ****/
-   serverFont = XQueryFont(dsply,XGContextFromGC(DefaultGC(dsply,scrn)));
-
-  if (XrmGetResource(rDB,"Axiom.3D.messageFont","Axiom.3D.Font",str_type,&value) == True){
-     (void) strncpy(prop,value.addr,(int)value.size);
-     }
-  else {
-     (void) strcpy(prop,messageFontDefault);
-     }
-  if ((globalFont = XLoadQueryFont(dsply, prop)) == NULL) {
-     fprintf(stderr, "Warning:  could not get the %s font for messageFont\n",prop);
-     globalFont = serverFont;
-  }
-
-  if (XrmGetResource(rDB,"Axiom.3D.buttonFont","Axiom.3D.Font",str_type,&value) == True){
-     (void) strncpy(prop,value.addr,(int)value.size);
-     }
-  else {
-     (void) strcpy(prop,buttonFontDefault);
-     }
-  if ((buttonFont = XLoadQueryFont(dsply, prop)) == NULL) {
-     fprintf(stderr, "Warning:  could not get the %s font for buttonFont\n",prop);
-     buttonFont = serverFont;
-  }
-
-  if (XrmGetResource(rDB,"Axiom.3D.headerFont","Axiom.3D.Font",str_type,&value) == True){
-     (void) strncpy(prop,value.addr,(int)value.size);
-     }
-  else {
-     (void) strcpy(prop,headerFontDefault);
-     }
-  if ((headerFont = XLoadQueryFont(dsply, prop)) == NULL) {
-     fprintf(stderr, "Warning:  could not get the %s font for headerFont\n",prop);
-     headerFont = serverFont;
-  }
-
-  if (XrmGetResource(rDB,"Axiom.3D.titleFont","Axiom.3D.Font",str_type,&value) == True){
-     (void) strncpy(prop,value.addr,(int)value.size);
-     }
-  else {
-     (void) strcpy(prop,titleFontDefault);
-     }
-  if ((titleFont = XLoadQueryFont(dsply, prop)) == NULL) {
-     fprintf(stderr, "Warning:  could not get the %s font for titleFont\n",prop);
-     titleFont = serverFont;
-  }
-
-  if (XrmGetResource(rDB,"Axiom.3D.lightingFont","Axiom.3D.Font",str_type,&value) == True){
-     (void) strncpy(prop,value.addr,(int)value.size);
-     }
-  else {
-     (void) strcpy(prop,lightingFontDefault);
-     }
-  if ((lightingFont = XLoadQueryFont(dsply, prop)) == NULL) {
-     fprintf(stderr, "Warning:  could not get the %s font for lightingFont\n",prop);
-     lightingFont = serverFont;
-  }
-
-  if (XrmGetResource(rDB,"Axiom.3D.volumeFont","Axiom.3D.Font",str_type,&value) == True){
-     (void) strncpy(prop,value.addr,(int)value.size);
-     }
-  else {
-     (void) strcpy(prop,volumeFontDefault);
-     }
-  if ((volumeFont = XLoadQueryFont(dsply, prop)) == NULL) {
-     fprintf(stderr, "Warning:  could not get the %s font for volumeFont\n",prop);
-     volumeFont = serverFont;
-
-  }
- /**** Create widely used Graphic Contexts ****/
-
-
-  PSGlobalInit();
-  /* must initiate before using any G/PS functions */
-  /* need character name: used as postscript GC variable */
-  /* need to create ps GCs for all GCs used by drawing in viewWindow */
-
-                     /* globalGC1 */
-  controlGCVals.foreground  = monoColor(axesColor);
-  controlGCVals.background  = backgroundColor;
-  globalGC1  = XCreateGC(dsply,rtWindow,GCForeground |
-                         GCBackground ,&controlGCVals);
-  carefullySetFont(globalGC1,globalFont);
-  PSCreateContext(globalGC1, "globalGC1", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-
-                     /* controlMessageGC */
-  controlGCVals.foreground  = controlMessageColor;
-  controlGCVals.background  = backgroundColor;
-  controlMessageGC      = XCreateGC(dsply,rtWindow,GCForeground |
-				    GCBackground ,&controlGCVals);
-  carefullySetFont(controlMessageGC,globalFont);
-
-                     /* globalGC2 */
-  controlGCVals.foreground = monoColor(labelColor);
-  globalGC2 = XCreateGC(dsply,rtWindow,GCForeground,&controlGCVals);
-  carefullySetFont(globalGC2,buttonFont);
-  PSCreateContext(globalGC2, "globalGC2", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-
-                     /* trashGC */
-  controlGCVals.function = GXcopy; 
-  trashGC  = XCreateGC(dsply,rtWindow,0 ,&controlGCVals);
-  carefullySetFont(trashGC,buttonFont);
-  PSCreateContext(trashGC, "trashGC", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-
-                    /* componentGC */
-  componentGC  = XCreateGC(dsply,rtWindow,0 ,&controlGCVals);
-  carefullySetFont(componentGC,buttonFont);
-  PSCreateContext(componentGC, "componentGC", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-
-                   /* opaqueGC */
-  opaqueGC  = XCreateGC(dsply,rtWindow,0 ,&controlGCVals);
-  carefullySetFont(opaqueGC,buttonFont);
-  PSCreateContext(opaqueGC, "opaqueGC", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-
-                   /* renderGC */
-  renderGC  = XCreateGC(dsply,rtWindow,0,&controlGCVals);
-  carefullySetFont(renderGC,buttonFont);
-  PSCreateContext(renderGC, "renderGC", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-
-                  /* globGC */
-  globGC = XCreateGC(dsply,rtWindow,0,&controlGCVals);
-  carefullySetFont(globGC,headerFont);
-  PSCreateContext(globGC, "globGC", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-
-                /* anotherGC */
-  controlGCVals.line_width = colorWidth;
-  anotherGC  = XCreateGC(dsply,rtWindow,GCBackground | GCLineWidth |
-                         GCFunction ,&controlGCVals);  
-  carefullySetFont(anotherGC,titleFont);
-  PSCreateContext(anotherGC, "anotherGC", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-
-  /* also create one for rendering (grayscale only for now) */
-  /* assign arbitrary number to renderGC as 9991 - see header.h */
-  PSCreateContext(GC9991, "renderGC", psNormalWidth, psButtCap,
-		  psRoundJoin, psWhite, psBlack );
-
-
-              /* processGC */
-  gcVals.background  = backgroundColor;
-  processGC = XCreateGC(dsply,rtWindow,GCBackground |
-			GCFillStyle,&gcVals);
-  carefullySetFont(processGC,buttonFont);
-
-              /* lightingGC */
-  controlGCVals.foreground = monoColor(axesColor);
-  controlGCVals.background = backgroundColor;
-  lightingGC  = XCreateGC(dsply,rtWindow,GCForeground | GCBackground
-			  ,&controlGCVals);
-  carefullySetFont(lightingGC,lightingFont);
-
-
-             /* volumeGC */
-  volumeGC = XCreateGC(dsply,rtWindow,GCForeground | GCBackground 
-		       ,&controlGCVals);
-  carefullySetFont(volumeGC,volumeFont);
-
-              /* quitGC */
-  quitGC  = XCreateGC(dsply,rtWindow,GCForeground | GCBackground 
-		      ,&controlGCVals);
-  carefullySetFont(quitGC,buttonFont);
-
-              /* saveGC */
-  saveGC  = XCreateGC(dsply,rtWindow,GCForeground | GCBackground 
-		      ,&controlGCVals);
-  carefullySetFont(saveGC,buttonFont);
-
-
-              /* graphGC */
-  graphGC  = XCreateGC(dsply,rtWindow,GCForeground | GCBackground 
-		       ,&controlGCVals);
-  carefullySetFont(graphGC,buttonFont);
-
-  /**** Get Data from the Viewport Manager ****/
-
-  i    = 123;   /* Used in viewman, what is this for? */
-  code = check(write(Socket,&i,intSize));
-
-  /* Check if I am getting stuff from Axiom or, if I am viewalone. */
-  readViewman(&viewAloned,intSize);
-  readViewman(&viewData,sizeof(view3DStruct));
-  readViewman(&i,intSize);
-
-  if (!(viewData.title = (char *)saymem("main.c",i,sizeof(char)))) {
-    fprintf(stderr,"VIEW3D: Fatal Error>> Ran out of memory trying to receive\
-                         the title.\n");
-    exitWithAck(RootWindow(dsply,scrn),Window,-1);
-  }
-  readViewman(viewData.title,i);
-
-  readViewman(&(viewData.lightVec[0]),floatSize);
-  readViewman(&(viewData.lightVec[1]),floatSize);
-  readViewman(&(viewData.lightVec[2]),floatSize);
-
-  viewData.scaleDown = yes;
-
-  switch (viewData.typeOf3D) {
-
-  /* Currently, the view3DType information doesn't get sent from
-     Axiom - all surfaces are alike regardless of how they
-     were created. We may revert back to receiving this information
-     in case we want to take advantage of certain properties of
-     certain surfaces (e.g. z=f(x,y)). */
-
-        case view3DType:
-        case viewTubeType:
-                viewport = make3DComponents();
-                viewData.box = no;
-                viewData.pointSize = 3;
-                break;
-  }; /* switch typeOf3D */
-
-
-  /*************************************************
-   ** Do some temporary assignments that would    **
-   ** later be coded in the makeViewport routines **
-   ** when the corresponding code has been put    **
-   ** into the viewalone, viewman and spad files. **
-   *************************************************/
-
-  viewData.distortX     = viewData.distortY = viewData.distortZ = 1;
-  viewData.clipPlane    = clipPlaneMin;
-  viewData.clipStuff    = yes;
-
-  xClipMinN = yClipMinN = zClipMinN = 0.0;
-  xClipMaxN = yClipMaxN = zClipMaxN = 1.0;
-
-  control = viewport->controlPanel;
-
-  bsdSignal(SIGTERM,goodbye,DontRestartSystemCalls);
-  bsdSignal(SIGSEGV,goodbye,DontRestartSystemCalls);
-
-  /** send acknowledgement to viewport manager**/
-  i = 345;
-
-  sprintf(errorStr,"sending window info to viewport manager");
-  check(write(Socket,&(viewport->viewWindow),sizeof(Window))); 
-
-  viewmap = XCreatePixmap(dsply,viewport->viewWindow,
-			  vwInfo.width,vwInfo.height,
-			  DisplayPlanes(dsply,scrn));
-  viewmap_valid = 1;
-
-  processEvents();
-
-  goodbye(-1);
-  return(0); /* control never gets here but compiler complains */
-}     /* main() */
-     
-
-
-void
-mergeDatabases(void)
-{
+@
+\subsection{mergeDatabases}
+\index{view3d!mergeDatabases}
+\index{mergeDatabases view3d}
+<<view3d>>=
+void mergeDatabases(void) {
   XrmDatabase homeDB,serverDB,applicationDB;
   char filenamebuf[1024];
   char *filename = &filenamebuf[0];
   char *classname = "Axiom";
   char name[255];
-
   (void) XrmInitialize();
   (void) strcpy(name, "/usr/lib/X11/app-defaults/");
   (void) strcat(name, classname);
   applicationDB = XrmGetFileDatabase(name);
   (void) XrmMergeDatabases(applicationDB, &rDB);
-
   if (XResourceManagerString(dsply) != NULL){
     serverDB = XrmGetStringDatabase(XResourceManagerString(dsply));
   }
@@ -15713,9 +11563,7 @@ mergeDatabases(void)
     (void) strcpy(filename,getenv("HOME"));
     (void) strcat(filename,"/.Xdefaults-");
     len = strlen(filename);
-
     (void) gethostname(filename+len,1024-len);
-
   }
   else {
     (void) strcpy (filename,getenv ("XENVIRONMENT"));
@@ -15725,340 +11573,20 @@ mergeDatabases(void)
 }
 
 @
-\section{Makefile}
-<<view3d/Makefile>>=
-BOOK=${SPD}/books/bookvol8.pamphlet
-MIDINT=	${INT}/graph/view3d
-MIDOBJ= ${OBJ}/${SYS}/graph/view3d
-OUT=	${MNT}/${SYS}/lib
-DOC=    ${MNT}/${SYS}/doc/src/graph
-
-LIB=    ${OBJ}/${SYS}/lib
-GDRAW=  ${OBJ}/${SYS}/graph/gdraws
-
-CFLAGS  = ${CCF} -I${SRC}/include
-LDFLAGS =  ${LDF} ${STATIC} -lX11 -lm 
-
-OBJS = \
- ${MIDOBJ}/buttons3d.o    ${MIDOBJ}/closeview3d.o  ${MIDOBJ}/component3d.o   \
- ${MIDOBJ}/control3d.o    ${MIDOBJ}/illuminate3d.o ${MIDOBJ}/lightbut3d.o    \
- ${MIDOBJ}/lighting3d.o   ${MIDOBJ}/main3d.o       ${MIDOBJ}/mesh3d.o        \
- ${MIDOBJ}/msort3d.o      ${MIDOBJ}/pot3d.o        ${MIDOBJ}/process3d.o     \
- ${MIDOBJ}/project3d.o    ${MIDOBJ}/quitbut3d.o    ${MIDOBJ}/quit3d.o        \
- ${MIDOBJ}/save3d.o       ${MIDOBJ}/savebut3d.o    ${MIDOBJ}/smoothshade3d.o \
- ${MIDOBJ}/spadaction3d.o ${MIDOBJ}/stuff3d.o      ${MIDOBJ}/surface3d.o     \
- ${MIDOBJ}/transform3d.o  ${MIDOBJ}/viewport3d.o   ${MIDOBJ}/volume3d.o      \
- ${MIDOBJ}/write3d.o
-
-GDRAW_OBJS  = ${GDRAW}/gfun.o ${OBJ}/${SYS}/lib/hash.o
-
-all: ${OUT}/view3d 
-	@echo 78 finished view3d from bookvol8
-
-${OUT}/view3d: ${OBJS} ${GDRAW_OBJS} ${LIB}/bsdsignal.o ${LIB}/util.o \
-               ${LIB}/xshade.o ${LIB}/halloc.o ${LIB}/pixmap.o \
-               ${LIB}/spadcolors.o ${LIB}/xspadfill.o ${LIB}/xdither.o 
-	@ echo 76 linking ${OUT}/view3d $(LDFLAGS)
-	@ ${CC} ${OBJS} ${GDRAW_OBJS} ${LIB}/bsdsignal.o \
-	${LIB}/util.o  ${LIB}/xshade.o ${LIB}/halloc.o \
-	${LIB}/pixmap.o ${LIB}/spadcolors.o ${LIB}/xspadfill.o \
-	${LIB}/xdither.o -o ${OUT}/view3d $(LDFLAGS) -lXpm
-
-${MIDOBJ}/buttons3d.o: ${BOOK}
-	@ echo 2 making ${MIDOBJ}/buttons3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	      ${TANGLE} -R"view3d/buttons3d.c" ${BOOK} >buttons3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/buttons3d.c )
-
-${MIDOBJ}/closeview3d.o: ${BOOK}
-	@ echo 5 making ${MIDOBJ}/closeview3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	    ${TANGLE} -R"view3d/closeview3d.c" ${BOOK} >closeview3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/closeview3d.c )
-
-${MIDOBJ}/component3d.o: ${BOOK}
-	@ echo 8 making ${MIDOBJ}/component3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	    ${TANGLE} -R"view3d/component3d.c" ${BOOK} >component3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/component3d.c )
-
-${MIDOBJ}/control3d.o: ${BOOK}
-	@ echo 11 making ${MIDOBJ}/control3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	      ${TANGLE} -R"view3d/control3d.c" ${BOOK} >control3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/control3d.c )
-
-${MIDOBJ}/illuminate3d.o: ${BOOK}
-	@ echo 14 making ${MIDOBJ}/illuminate3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	   ${TANGLE} -R"view3d/illuminate3d.c" ${BOOK} >illuminate3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/illuminate3d.c )
-
-${MIDOBJ}/lightbut3d.o: ${BOOK}
-	@ echo 17 making ${MIDOBJ}/lightbut3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	     ${TANGLE} -R"view3d/lightbut3d.c" ${BOOK} >lightbut3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/lightbut3d.c )
-
-${MIDOBJ}/lighting3d.o: ${BOOK}
-	@ echo 20 making ${MIDOBJ}/lighting3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	     ${TANGLE} -R"view3d/lighting3d.c" ${BOOK} >lighting3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/lighting3d.c )
-
-${MIDOBJ}/main3d.o: ${BOOK}
-	@ echo 23 making ${MIDOBJ}/main3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	         ${TANGLE} -R"view3d/main3d.c" ${BOOK} >main3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/main3d.c )
-
-${MIDOBJ}/mesh3d.o: ${BOOK}
-	@ echo 26 making ${MIDOBJ}/mesh3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	         ${TANGLE} -R"view3d/mesh3d.c" ${BOOK} >mesh3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/mesh3d.c )
-
-${MIDOBJ}/msort3d.o: ${BOOK}
-	@ echo 29 making ${MIDOBJ}/msort3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	        ${TANGLE} -R"view3d/msort3d.c" ${BOOK} >msort3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/msort3d.c )
-
-${MIDOBJ}/pot3d.o: ${BOOK}
-	@ echo 32 making ${MIDOBJ}/pot3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	          ${TANGLE} -R"view3d/pot3d.c" ${BOOK} >pot3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/pot3d.c )
-
-${MIDOBJ}/process3d.o: ${BOOK}
-	@ echo 35 making ${MIDOBJ}/process3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	      ${TANGLE} -R"view3d/process3d.c" ${BOOK} >process3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/process3d.c )
-
-${MIDOBJ}/project3d.o: ${BOOK}
-	@ echo 38 making ${MIDOBJ}/project3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	      ${TANGLE} -R"view3d/project3d.c" ${BOOK} >project3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/project3d.c )
-
-${MIDOBJ}/quitbut3d.o: ${BOOK}
-	@ echo 41 making ${MIDOBJ}/quitbut3d.o from ${MIDINT}/quitbut3d.c
-	@( cd ${MIDINT} ; \
-	      ${TANGLE} -R"view3d/quitbut3d.c" ${BOOK} >quitbut3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/quitbut3d.c )
-
-${MIDOBJ}/quit3d.o: ${BOOK}
-	@ echo 44 making ${MIDOBJ}/quit3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	         ${TANGLE} -R"view3d/quit3d.c" ${BOOK} >quit3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/quit3d.c )
-
-${MIDOBJ}/save3d.o: ${BOOK}
-	@ echo 47 making ${MIDOBJ}/savebut3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	         ${TANGLE} -R"view3d/save3d.c" ${BOOK} >save3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/save3d.c )
-
-${MIDOBJ}/savebut3d.o: ${BOOK}
-	@ echo 50 making ${MIDOBJ}/savebutbut3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	      ${TANGLE} -R"view3d/savebut3d.c" ${BOOK} >savebut3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/savebut3d.c )
-
-${MIDOBJ}/smoothshade3d.o: ${BOOK}
-	@ echo 53 making ${MIDOBJ}/smoothShadebut3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	  ${TANGLE} -R"view3d/smoothshade3d.c" ${BOOK} >smoothshade3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/smoothshade3d.c )
-
-${MIDOBJ}/spadaction3d.o: ${BOOK}
-	@ echo 56 making ${MIDOBJ}/spadActionbut3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	   ${TANGLE} -R"view3d/spadaction3d.c" ${BOOK} >spadaction3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/spadaction3d.c )
-
-${MIDOBJ}/stuff3d.o: ${BOOK}
-	@ echo 59 making ${MIDOBJ}/stuffbut3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	        ${TANGLE} -R"view3d/stuff3d.c" ${BOOK} >stuff3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/stuff3d.c )
-
-${MIDOBJ}/surface3d.o: ${BOOK}
-	@ echo 62 making ${MIDOBJ}/surfacebut3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	      ${TANGLE} -R"view3d/surface3d.c" ${BOOK} >surface3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/surface3d.c )
-
-${MIDOBJ}/transform3d.o: ${BOOK}
-	@ echo 65 making ${MIDOBJ}/transformbut3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	    ${TANGLE} -R"view3d/transform3d.c" ${BOOK} >transform3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/transform3d.c )
-
-${MIDOBJ}/viewport3d.o: ${BOOK}
-	@ echo 68 making ${MIDOBJ}/viewportbut3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	     ${TANGLE} -R"view3d/viewport3d.c" ${BOOK} >viewport3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/viewport3d.c )
-
-${MIDOBJ}/volume3d.o: ${BOOK}
-	@ echo 71 making ${MIDOBJ}/volumebut3d.o from ${BOOK}
-	@( cd ${MIDINT} ; \
-	       ${TANGLE} -R"view3d/volume3d.c" ${BOOK} >volume3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/volume3d.c )
-
-${MIDOBJ}/write3d.o: ${BOOK}
-	@ echo 74 making ${MIDOBJ}/writebut3d.o from ${BOOK}
-	@( cd ${MIDINT} ; ${TANGLE} -R"view3d/write3d.c" ${BOOK} >write3d.c )
-	@ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/write3d.c )
-
-@
-\section{mesh3d.c}
-<<view3d/mesh3d.c>>=
-#define _MESH3D_C
-#include <math.h>
-
-<<view3d/header.h>>
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-/***************************************************************************
- *** void getMeshNormal(x0,y0,z0,x1,y1,z1,x2,y2,z2,zMin,zRange,Normal);  ***
- ***************************************************************************/
-
-void 
-getMeshNormal(float x0,float y0,float z0,float x1,float y1,float z1,
-      float x2,float y2,float z2,float zMin,float zRange,float Normal[3])
-{
-  float Ax,Ay,Az,Bx,By,Bz,
-        UnitFactor;
-
+\subsection{getMeshNormal}
+\index{view3d!getMeshNormal}
+\index{getMeshNormal view3d}
+<<view3d>>=
+void getMeshNormal(float x0,float y0,float z0,float x1,float y1,float z1,
+      float x2,float y2,float z2,float zMin,float zRange,float Normal[3]) {
+  float Ax,Ay,Az,Bx,By,Bz, UnitFactor;
   Ax = x0-x1;  Ay = y0-y1;  Az = z0-z1;
   Bx = x2-x1;  By = y2-y1;  Bz = z2-z1;
-
   /* compute cross product */
-
   Normal[0] = (Ay*Bz - Az*By);
   Normal[1] = (Az*Bx - Ax*Bz);
   Normal[2] = (Ax*By - Ay*Bx);
-
   /* normalize normal vector */
-
   UnitFactor = sqrt(Normal[0]*Normal[0] +
 		    Normal[1]*Normal[1] +
 		    Normal[2]*Normal[2]);
@@ -16071,21 +11599,16 @@ getMeshNormal(float x0,float y0,float z0,float x1,float y1,float z1,
     Normal[1] = 0.0;
     Normal[2] = 0.0;
   }
-
 } /* getMeshNormal() */
 
-
-/***********************************
- ****  void normalizeVector(v)  ****
- ***********************************/
-
-void 
-normalizeVector(float *v)
-{
+@
+\subsection{normalizeVector}
+\index{view3d!normalizeVector}
+\index{normalizeVector view3d}
+<<view3d>>=
+void normalizeVector(float *v) {
    /* v should be a triple (ignoring the rest of the array if necessary) */
-
   float UnitFactor;
-
   UnitFactor = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
   if (UnitFactor != 0.0) {
     v[0] /= UnitFactor;
@@ -16094,211 +11617,66 @@ normalizeVector(float *v)
   } else {
     v[0] = v[1] = v[2] = 0.0;
   }
-
 } /* normalizeVector() */
 
-
-/************************************
- ****  void dotProduct(a,b,size) ****
- ************************************/
-
-float 
-dotProduct(float * a,float *b,int size)
-{
+@
+\subsection{dotProduct}
+\index{view3d!dotProduct}
+\index{dotProduct view3d}
+<<view3d>>=
+float dotProduct(float * a,float *b,int size) {
   int i;
   float f=0;
-
   for (i=0; i<size; i++)
     f += (a[i]*b[i]);
   return(f);
-
 } /* dotProduct() */
 
 @
-\section{msort3d.c}
-<<view3d/msort3d.c>>=
-#define _MSORT3D_C
-
-/*****************************************************
- * Mergesort routine                                 *
- *                                                   *
- * This file depends on the file msort.h. There, a   *
- * data type called linkElement is defined. It is    *
- * used here and is the main structure being sorted  *
- * here. You can sort any linked structure, under    *
- * any name - so long as it has a next field (see    *
- * below). The define statement, below, renames      *
- * linkElement to linkThing. All you need to do      *
- * is change the define statement to rename          *
- * your structure to linkThing. The first argument   *
- * you pass to the sort routine is a pointer to      *
- * the unsorted list. The function returns with      *
- * that same pointer pointing to a sorted list.      *
- *                                                   *
- *  Usage:                                           *
- *    linkElement *msort(p,min,max,compare)          *
- *      linkElement *L;                              *
- *      int min,max;                                 *
- *      int (*compare)();                            *
- *                                                   *
- *    e.g.                                           *
- *      msort(L,0,N,compare);                        *
- *                                                   *
- *    where                                          *
- *      L is the list of things to be sorted,        *
- *        it is expected to be a linked list         *
- *        where the following element is pointed     *
- *        to by a field called "next"                *
- *      0 is the index of the first element          *
- *        (since this routine is called recursively, *
- *        this field is kept for clarity; it will    *
- *        always be zero at top level)               *
- *      N the number of elements in the list         * 
- *        minus one                                  *
- *      compare(X,Y) is a comparison function that   *
- *        returns a -1 if X is less than Y           *
- *                   0 if X is the same as Y         *
- *               and 1 if X is greater than Y        *
- *                                                   *
- *****************************************************/
-
-
-<<view3d/header.h>>
-
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-
-#define   linkThing poly
-
-
-
-/**********************
- * merge(p,q,compare) *
- **********************/
+This file depends on the file msort.h. There, a data type called linkElement 
+is defined. It is used here and is the main structure being sorted here. 
+You can sort any linked structure, under any name - so long as it has a 
+next field (see below). The define statement, below, renames linkElement 
+to linkThing. All you need to do is change the define statement to rename
+your structure to linkThing. The first argument you pass to the sort routine 
+is a pointer to the unsorted list. The function returns with that same 
+pointer pointing to a sorted list. 
+\begin{verbatim}
+  Usage:                                           
+    linkElement *msort(p,min,max,compare)          
+      linkElement *L;                              
+      int min,max;                                 
+      int (*compare)();                            
+                                                   
+    e.g.                                           
+      msort(L,0,N,compare);                        
+                                                   
+    where                                          
+      L is the list of things to be sorted,        
+        it is expected to be a linked list         
+        where the following element is pointed     
+        to by a field called "next"                
+      0 is the index of the first element          
+        (since this routine is called recursively, 
+        this field is kept for clarity; it will    
+        always be zero at top level)               
+      N the number of elements in the list         *
+        minus one                                  
+      compare(X,Y) is a comparison function that   
+        returns a -1 if X is less than Y           
+                   0 if X is the same as Y         
+               and 1 if X is greater than Y        
+\end{verbatim}
 
-linkThing *
-merge(linkThing *p, linkThing *q,int (*compare)(linkThing *, linkThing *))
-{
+\subsection{merge}
+\index{view3d!merge}
+\index{merge view3d}
+<<view3d>>=
+linkThing *merge(linkThing *p, linkThing *q,
+                 int (*compare)(linkThing *, linkThing *)) {
   linkThing *returnVal,*current,*pN,*qN;
-
   /* return if only one item - take out when insert sort implemented */
   if (!p) return(q); else if (!q) return(p);
-
     /* set up the head of the list (first element) */
   if (compare(p,q) <= 0) {
     returnVal = current = p;
@@ -16309,7 +11687,6 @@ merge(linkThing *p, linkThing *q,int (*compare)(linkThing *, linkThing *))
     pN = p;
     qN = q->next;
   }
-
     /* merge the two lists */
   while ((pN != NULL) && (qN != NULL)) {
     if (compare(pN,qN) <= 0) {   /* pN <= qN */
@@ -16322,28 +11699,22 @@ merge(linkThing *p, linkThing *q,int (*compare)(linkThing *, linkThing *))
       qN = qN->next;
     }
   }
-
     /* tag on the tail end */
   if (pN == NULL) current->next = qN;
   else current->next = pN;
-
   return(returnVal);
-
 } /* merge() */
 
-
-
-/*********************************
- * msort: the top level function *
- *********************************/
-
-linkThing *
-msort(linkThing *p,int min,int max,int (*compare)(linkThing *, linkThing *))
-{
+@
+\subsection{msort}
+\index{view3d!msort}
+\index{msort view3d}
+<<view3d>>=
+linkThing *msort(linkThing *p,int min,int max,
+                 int (*compare)(linkThing *, linkThing *)) {
   int mid;
   int i;
   linkThing *q,*temp,*xxx;
-
   if (min == max) return p;
   else {
     mid = (min + max - 1)/2;
@@ -16353,151 +11724,20 @@ msort(linkThing *p,int min,int max,int (*compare)(linkThing *, linkThing *))
     q->next = 0;
     xxx = merge(msort(p,min,mid,compare),
 		msort(temp,mid+1,max,compare), compare);
-
     return(xxx); 
   }
-
 } /* msort() */
 
-
-
 @
-\section{pot3d.c}
-<<view3d/pot3d.c>>=
-#define _POT3D_C
-
-<<view3d/header.h>>
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-/****************************/
-/***  void getPotValue()  ***/
-/****************************/
-
-mouseCoord 
-getPotValue(short eX,short eY,short xH,short yH)
-{
-
+\subsection{getPotValue}
+\index{view3d!getPotValue}
+\index{getPotValue view3d}
+<<view3d>>=
+mouseCoord getPotValue(short eX,short eY,short xH,short yH) {
   mouseCoord whereMouse;
   float x,y;
-
   x = (float)eX/xH - 1;
   y = -((float)eY/yH -1);
-
   /* make non-linear potentiometer */
   whereMouse.x = x*x*x; 
   whereMouse.y = y*y*y; 
@@ -16505,237 +11745,38 @@ getPotValue(short eX,short eY,short xH,short yH)
   if (whereMouse.y > 1.0)  whereMouse.y = 1.0;
   if (whereMouse.x < -1.0) whereMouse.x = -1.0;
   if (whereMouse.y < -1.0) whereMouse.y = -1.0;
-
   return(whereMouse);
-
 } /* getPotValue() */
 
-
-
-/**********************************/
-/***  void getLinearPotValue()  ***/
-/**********************************/
-
-mouseCoord 
-getLinearPotValue(short eX,short eY,short xH,short yH)
-{
-
+@
+\subsection{getLinearPotValue}
+\index{view3d!getLinearPotValue}
+\index{getLinearPotValue view3d}
+<<view3d>>=
+mouseCoord getLinearPotValue(short eX,short eY,short xH,short yH) {
   mouseCoord whereMouse;
-
   whereMouse.x = (float)eX/xH - 1;
   whereMouse.y = -((float)eY/yH -1);
-
   return(whereMouse);
-
 } /* getLinearPotValue() */
 
-
 @
-\section{process3d.c}
-<<view3d/process3d.c>>=
-#define _PROCESS3D_C
-
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/time.h>
-
-
-<<view3d/header.h>>
-<<view3d/cpanel.h>>
-<<view3d/volume.h>>
-#define spadActionMode
-/* define spadEventMode */
-#define components
-<<view3d/process.h>>
-<<view3d/draw.h>>
-#include "com.h"
-
-
-#include "util.h1"
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-#include "pixmap.h1"
-#include "xshade.h1"
-#include "xspadfill.h1"
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-#define inside(A,B) (((XButtonEvent *)event)->x >= A && \
-		     ((XButtonEvent *)event)->x <= B)
-
-
-void
-buttonAction (int bKey)
-{
-
+\subsection{buttonAction}
+\index{view3d!buttonAction}
+\index{buttonAction view3d}
+<<view3d>>=
+void buttonAction(int bKey) {
   char *s1, *s2;
   int strL, strL1, strL2, offShade=14;
-
   /* Button colors which are offColor, RED, are turned off, and those which
      are onColor, GREEN, indicate the mode is in effect. */
-
   switch (bKey) {
-
   case hideControl:
     if (viewport->haveControl) {
       viewport->haveControl = no;
       XUnmapWindow(dsply,control->controlWindow);
     }
     break;
-
   case region3D:
     clearControlMessage();
     strcpy(control->message,viewport->title);
@@ -16777,12 +11818,11 @@ buttonAction (int bKey)
 		       (control->buttonQueue[region3D]).buttonHeight,Xoption);
       }
     }
-
     s = (control->buttonQueue[region3D]).text;
     strL = strlen(s);
-
     GSetForeground(processGC,
-	   (float)monoColor((control->buttonQueue[region3D]).textColor),Xoption);
+	   (float)monoColor((control->buttonQueue[region3D]).textColor),
+           Xoption);
     GDrawImageString(processGC,control->controlWindow,
 		     (control->buttonQueue[region3D]).buttonX +
 		     centerX(processGC,s,strL,
@@ -16794,9 +11834,6 @@ buttonAction (int bKey)
     redoSmooth = yes;
     drawViewport(Xoption);
     break;
-
-
-
   case bwColor:
     clearControlMessage();
     strcpy(control->message,viewport->title);
@@ -16828,12 +11865,11 @@ buttonAction (int bKey)
 		       (control->buttonQueue[bwColor]).buttonWidth,
 		       (control->buttonQueue[bwColor]).buttonHeight,Xoption);
       }
-
       s = (control->buttonQueue[bwColor]).text;
       strL = strlen(s);
-
       GSetForeground(processGC,
-	     (float)monoColor((control->buttonQueue[bwColor]).textColor),Xoption);
+	     (float)monoColor((control->buttonQueue[bwColor]).textColor),
+             Xoption);
       GDrawImageString(processGC,control->controlWindow,
 		       (control->buttonQueue[bwColor]).buttonX +
 		       centerX(processGC,s,strL,
@@ -16848,9 +11884,6 @@ buttonAction (int bKey)
       drawViewport(Xoption);
     }
     break;
-
-
-
   case outlineOnOff:
     clearControlMessage();
     strcpy(control->message,viewport->title);
@@ -16870,7 +11903,8 @@ buttonAction (int bKey)
 		       (control->buttonQueue[outlineOnOff]).buttonX,
 		       (control->buttonQueue[outlineOnOff]).buttonY,
 		       (control->buttonQueue[outlineOnOff]).buttonWidth,
-		       (control->buttonQueue[outlineOnOff]).buttonHeight,Xoption);
+		       (control->buttonQueue[outlineOnOff]).buttonHeight,
+                       Xoption);
       }
     } else {
       viewData.outlineRenderOn = 1;
@@ -16887,14 +11921,15 @@ buttonAction (int bKey)
 		       (control->buttonQueue[outlineOnOff]).buttonX,
 		       (control->buttonQueue[outlineOnOff]).buttonY,
 		       (control->buttonQueue[outlineOnOff]).buttonWidth,
-		       (control->buttonQueue[outlineOnOff]).buttonHeight,Xoption);
+		       (control->buttonQueue[outlineOnOff]).buttonHeight,
+                       Xoption);
       }
     }
     s = (control->buttonQueue[outlineOnOff]).text;
     strL = strlen(s);
-
     GSetForeground(processGC,
-	   (float)monoColor((control->buttonQueue[outlineOnOff]).textColor),Xoption);
+	   (float)monoColor((control->buttonQueue[outlineOnOff]).textColor),
+           Xoption);
     GDrawImageString(processGC,control->controlWindow,
 		     (control->buttonQueue[outlineOnOff]).buttonX +
 		     centerX(processGC,s,strL,
@@ -16907,8 +11942,6 @@ buttonAction (int bKey)
       drawViewport(Xoption);
     }
     break;
-
-
   case lighting:
     if (saveFlag) {
       doingPanel = CONTROLpanel;
@@ -16921,8 +11954,6 @@ buttonAction (int bKey)
     tempLightIntensity = lightIntensity;
     XMapWindow(dsply,lightingWindow);
     break;
-
-
   case viewVolume:
     if (saveFlag) {
       doingPanel = CONTROLpanel;
@@ -16933,23 +11964,17 @@ buttonAction (int bKey)
     redrawView = yes;
     drawViewport(Xoption);	/* draw it with doingVolume set to yes */
     break;
-
-
   case volumeReturn:
     doingPanel = CONTROLpanel;
     redoSmooth = yes;
     redrawView = yes;
     XUnmapWindow(dsply,volumeWindow);
     break;
-
-
   case volumeAbort:
     doingPanel = CONTROLpanel;
     redrawView = yes;
     XUnmapWindow(dsply,volumeWindow);
     break;
-
-
   case lightReturn:
     doingPanel = CONTROLpanel;
     viewport->lightVector[0] = lightPointer[0] = tempLightPointer[0];
@@ -16961,15 +11986,11 @@ buttonAction (int bKey)
     if (movingLight || changedIntensity) redoSmooth = yes;
     XUnmapWindow(dsply,lightingWindow);
     break;
-
-
   case lightAbort:
     movingLight = no;  changedIntensity = no;
     doingPanel = CONTROLpanel;
     XUnmapWindow(dsply,lightingWindow);
     break;
-
-
   case resetView:
     clearControlMessage();
     strcpy(control->message,viewport->title);
@@ -16991,7 +12012,8 @@ buttonAction (int bKey)
     viewport->deltaY	   = viewport->deltaZ0;
     viewport->scale	   = viewport->scale0;
     viewport->scaleX	   = viewport->scaleY = viewport->scaleZ = 1.0;
-    if (!equal(viewport->theta,viewport->theta0) || !equal(viewport->phi,viewport->phi0))
+    if (!equal(viewport->theta,viewport->theta0) || 
+        !equal(viewport->phi,viewport->phi0))
       rotated = yes;
     viewport->theta = viewport->axestheta = viewport->theta0 = viewData.theta;
     viewport->phi   = viewport->axesphi	  = viewport->phi0   = viewData.phi;
@@ -17002,8 +12024,6 @@ buttonAction (int bKey)
     if (viewport->haveControl) drawControlPanel();
     writeTitle();
     break;
-
-
   case axesOnOff:
     clearControlMessage();
     strcpy(control->message,viewport->title);
@@ -17043,12 +12063,11 @@ buttonAction (int bKey)
 		       (control->buttonQueue[axesOnOff]).buttonHeight,Xoption);
       }
     }
-
     s = (control->buttonQueue[axesOnOff]).text;
     strL = strlen(s);
-
     GSetForeground(processGC,
-	   (float)monoColor((control->buttonQueue[axesOnOff]).textColor),Xoption);
+	   (float)monoColor((control->buttonQueue[axesOnOff]).textColor),
+           Xoption);
     GDrawImageString(processGC,control->controlWindow,
 		     (control->buttonQueue[axesOnOff]).buttonX +
 		     centerX(processGC,s,strL,
@@ -17063,8 +12082,6 @@ buttonAction (int bKey)
     }
     drawViewport(Xoption);
     break;
-
-
   case zoomx:
     if (viewport->zoomXOn) {
       viewport->zoomXOn = no;
@@ -17101,10 +12118,8 @@ buttonAction (int bKey)
 		       (control->buttonQueue[zoomx]).buttonHeight,Xoption);
       }
     }
-
     s = (control->buttonQueue[zoomx]).text;
     strL = strlen(s);
-
     GSetForeground(processGC,
 	   (float)monoColor((control->buttonQueue[zoomx]).textColor),Xoption);
     GDrawImageString(processGC,control->controlWindow,
@@ -17119,8 +12134,6 @@ buttonAction (int bKey)
     strcpy(control->message,viewport->title);
     writeControlMessage();
     break;
-
-
   case zoomy:
     if (viewport->zoomYOn) {
       viewport->zoomYOn = no;
@@ -17157,10 +12170,8 @@ buttonAction (int bKey)
 		       (control->buttonQueue[zoomy]).buttonHeight,Xoption);
       }
     }
-
     s = (control->buttonQueue[zoomy]).text;
     strL = strlen(s);
-
     GSetForeground(processGC,
 	   (float)monoColor((control->buttonQueue[zoomy]).textColor),Xoption);
     GDrawImageString(processGC,control->controlWindow,
@@ -17175,8 +12186,6 @@ buttonAction (int bKey)
     strcpy(control->message,viewport->title);
     writeControlMessage();
     break;
-
-
   case zoomz:
     if (viewport->zoomZOn) {
       viewport->zoomZOn = no;
@@ -17213,10 +12222,8 @@ buttonAction (int bKey)
 		       (control->buttonQueue[zoomz]).buttonHeight,Xoption);
       }
     }
-
     s = (control->buttonQueue[zoomz]).text;
     strL = strlen(s);
-
     GSetForeground(processGC,
 	   (float)monoColor((control->buttonQueue[zoomz]).textColor),Xoption);
     GDrawImageString(processGC,control->controlWindow,
@@ -17231,8 +12238,6 @@ buttonAction (int bKey)
     strcpy(control->message,viewport->title);
     writeControlMessage();
     break;
-
-
   case originr:
     viewport->originrOn = yes;
     (control->buttonQueue[originr]).textColor = onColor;
@@ -17269,9 +12274,9 @@ buttonAction (int bKey)
     strL1 = strlen(s1);
     s2 = (control->buttonQueue[originr]).text;
     strL2 = strlen(s2);
-
     GSetForeground(processGC,
-	   (float)monoColor((control->buttonQueue[objectr]).textColor),Xoption);
+	   (float)monoColor((control->buttonQueue[objectr]).textColor),
+           Xoption);
     GDrawImageString(processGC,control->controlWindow,
 		     (control->buttonQueue[objectr]).buttonX +
 		     centerX(processGC,s1,strL1,
@@ -17280,9 +12285,9 @@ buttonAction (int bKey)
 		     centerY(processGC,
 			     (control->buttonQueue[objectr]).buttonHeight),
 		     s1,strL1,Xoption);
-
     GSetForeground(processGC,
-	   (float)monoColor((control->buttonQueue[originr]).textColor),Xoption);
+	   (float)monoColor((control->buttonQueue[originr]).textColor),
+           Xoption);
     GDrawImageString(processGC,control->controlWindow,
 		     (control->buttonQueue[originr]).buttonX +
 		     centerX(processGC,s2,strL2,
@@ -17295,15 +12300,11 @@ buttonAction (int bKey)
     strcpy(control->message,viewport->title);
     writeControlMessage();
     break;
-
-
-
   case objectr:
     viewport->objectrOn = yes;
     (control->buttonQueue[objectr]).textColor = onColor;
     viewport->originrOn = no;
     (control->buttonQueue[originr]).textColor = offColor;
-
     viewport->originFlag = no;
     if (mono) {
       XChangeShade(dsply,offShade);
@@ -17337,7 +12338,8 @@ buttonAction (int bKey)
     strL2 = strlen(s2);
 
     GSetForeground(processGC,
-	   (float)monoColor((control->buttonQueue[objectr]).textColor),Xoption);
+	   (float)monoColor((control->buttonQueue[objectr]).textColor),
+           Xoption);
     GDrawImageString(processGC,control->controlWindow,
 		     (control->buttonQueue[objectr]).buttonX +
 		     centerX(processGC,s1,strL1,
@@ -17346,9 +12348,9 @@ buttonAction (int bKey)
 		     centerY(processGC,
 			     (control->buttonQueue[objectr]).buttonHeight),
 		     s1,strL1,Xoption);
-
     GSetForeground(processGC,
-	   (float)monoColor((control->buttonQueue[originr]).textColor),Xoption);
+	   (float)monoColor((control->buttonQueue[originr]).textColor),
+           Xoption);
     GDrawImageString(processGC,control->controlWindow,
 		     (control->buttonQueue[originr]).buttonX +
 		     centerX(processGC,s2,strL2,
@@ -17361,9 +12363,6 @@ buttonAction (int bKey)
     strcpy(control->message,viewport->title);
     writeControlMessage();
     break;
-
-
-
   case ps:
     strcpy(control->message,"   Creating postscript file ...   ");
     writeControlMessage();
@@ -17372,7 +12371,6 @@ buttonAction (int bKey)
       writeControlMessage();
       return;	/* make new tmpnam for new file */
     }
-
     redoSmooth = yes;
     drawViewport(PSoption);	/* draw picture in PS; create ps script file */
 
@@ -17382,15 +12380,11 @@ buttonAction (int bKey)
       writeControlMessage();
       return;
     }
-
     clearControlMessage();
     strcpy(control->message,PSfilename);
     strcat(control->message," in working dir ");
     writeControlMessage();
     break;
-
-
-
   case pixmap:
     strcpy(control->message,"   Creating axiom3D.xpm now ...   ");
     writeControlMessage();
@@ -17402,9 +12396,6 @@ buttonAction (int bKey)
     strcpy(control->message,"   axiom3D.xpm in working dir     ");
     writeControlMessage();
     break;
-
-
-
   case transparent:
   case opaqueMesh:
   case render:
@@ -17415,8 +12406,6 @@ buttonAction (int bKey)
     viewData.style = bKey;
     drawViewport(Xoption);  /* draw picture in viewWindow with X routines */
     break;
-
-
   case closeAll:
     clearControlMessage();
     strcpy(control->message,viewport->title);
@@ -17425,19 +12414,13 @@ buttonAction (int bKey)
     viewport->closing = yes;
     XMapWindow(dsply,quitWindow);
     break;
-
-
   case quitReturn:
     XUnmapWindow(dsply,quitWindow);
     break;
-
-
   case quitAbort:
     doingPanel = CONTROLpanel;
     XUnmapWindow(dsply,quitWindow);
     break;
-
-
   case saveit:
     clearControlMessage();
     strcpy(control->message,viewport->title);
@@ -17446,15 +12429,11 @@ buttonAction (int bKey)
     doingPanel = SAVEpanel;
     XMapWindow(dsply,saveWindow);
     break;
-
-
   case saveExit:
     saveFlag = no;
     doingPanel = CONTROLpanel;
     XUnmapWindow(dsply,saveWindow);
     break;
-
-
   case xy:
     viewport->theta = pi;
     viewport->phi   = 0.0;
@@ -17465,8 +12444,6 @@ buttonAction (int bKey)
     viewport->xyOn = yes;
     drawViewport(Xoption);
     break;
-
-
   case xz:
     viewport->theta = pi;
     viewport->phi   = -pi_half;
@@ -17477,8 +12454,6 @@ buttonAction (int bKey)
     viewport->xzOn = yes;
     drawViewport(Xoption);
     break;
-
-
   case yz:
     viewport->theta = pi_half;
     viewport->phi   = -pi_half;
@@ -17489,26 +12464,24 @@ buttonAction (int bKey)
     viewport->yzOn = yes;
     drawViewport(Xoption);
     break;
-
-
   default:
     fprintf(stderr,"Received a non-functioning button request: %d \n",bKey);
     break;
   } /* switch (action) */
-
 } /* processEvents() */
 
-
-
-/************************** X Event Processing *****************************/
-void 
-processEvents(void)
-{
-
+@
+\subsection{processEvents}
+X Event Processing
+\index{view3d!processEvents}
+\index{processEvents view3d}
+<<view3d>>=
+void processEvents(void) {
   XEvent		*event, tempEvent;
   Window		whichWindow;
   buttonStruct		*controlButton;
-  mouseCoord		mouseXY, linearMouseXY;
+  mouseCoord		mouseXY = {0.0,0.0};
+  mouseCoord		linearMouseXY= {0.0,0.0};
   int			someInt, mouseW4, mouseH4;
   int			toggleReady =yes;
   int                   checkButton = no;
@@ -17523,24 +12496,18 @@ processEvents(void)
   Window		dummy;
   int                   Xcon,externalControl,len;
   fd_set                rd;
-
   externalControl = 0;
   Xcon = ConnectionNumber(dsply);
-
   /** assign lightPointer for light panel **/
   lightPointer[0] = tempLightPointer[0] = viewport->lightVector[0];
   lightPointer[1] = tempLightPointer[1] = viewport->lightVector[1];
   lightPointer[2] = tempLightPointer[2] = viewport->lightVector[2];
-
   if (!(event = (XEvent *)saymem("process.c",1,sizeof(XEvent)))) {
     fprintf(stderr,"Ran out of memory initializing event processing.\n");
     exitWithAck(RootWindow(dsply,scrn),Window,-1);
   }
-
   controlButton = 0;
-
   while(1) {
-
     /* Store old viewport window size attributes for resizing comparison. */
     XGetWindowAttributes(dsply,viewport->titleWindow,&graphWindowAttrib);
     tempTW = graphWindowAttrib.width;
@@ -17548,11 +12515,9 @@ processEvents(void)
     XGetWindowAttributes(dsply,viewport->viewWindow,&graphWindowAttrib);
     tempVW = graphWindowAttrib.width;
     tempVH = graphWindowAttrib.height;
-
     /* Get the next X event. The check for pending events is so that
        a held down mouse button is interpreted as an event
        even if nothing is pending. */
-
     len=0;
     while(len<=0) {
       FD_ZERO(&rd);
@@ -17568,7 +12533,6 @@ processEvents(void)
       else 
 	len=1;
     }
-    
     if (FD_ISSET(Xcon,&rd)|| 
 	XEventsQueued(dsply, QueuedAfterFlush) || 
 	followMouse) {
@@ -17581,10 +12545,8 @@ processEvents(void)
 	XNextEvent(dsply,event);
 	gotEvent++;
       }
-      
       if (gotToggle || !followMouse) 
 	checkButton = no;
-      
       if (gotEvent) {
 	whichWindow = ((XButtonEvent *)event)->window;
 	first_time = no;
@@ -17693,12 +12655,9 @@ processEvents(void)
 	  } else {
 	    fprintf(stderr,"Not a valid window.\n");
 	  }
-	  
 	  XFlush(dsply);
 	  while(XCheckTypedWindowEvent(dsply, whichWindow, Expose, &tempEvent));
 	  break;
-	  
-	  
 	case MotionNotify:
 	  exposeView = no;
 	  if (followMouse) {
@@ -17723,12 +12682,10 @@ processEvents(void)
 	    }
 	  }
 	  break;
-	  
 	case ButtonRelease:
 	  exposeView = followMouse = no;
 	  toggleReady = yes;  gotToggle = yes;
 	  break;
-	  
 	case LeaveNotify:
 	  XQueryPointer(dsply,rtWindow,&dummy,&dummy,&px,&py,&lx,&ly,&lbuttons);
 	  if ( (controlButton) &&
@@ -17748,7 +12705,6 @@ processEvents(void)
 	  toggleReady = yes;
 	  checkButton = exposeView = no;
 	  break;
-	  
 	case ButtonPress:
 	  exposeView = no;  changingColor = no;
 	  if (whichWindow == viewport->viewWindow) {
@@ -17796,23 +12752,20 @@ processEvents(void)
 	      gotToggle = no;
 	    } else {
 	      followMouse = no;
-	      gotToggle = yes;   /* auto-repeat of toggle buttons not allowed */
+	      gotToggle = yes;   /*auto-repeat of toggle buttons not allowed*/
 	      if (toggleReady) toggleReady = no;
 	    }
 	    checkButton = yes;
 	    first_time  = yes;
 	  }
 	  break;
-	  
 	default:
 	  toggleReady = gotToggle = yes;
 	  exposeView = changingColor = checkButton = followMouse = no;
 	  break;
-	  
 	} /* switch */
 	gotEvent--;
       }  /* if gotEvent */
-      
       /* Allow a pressed mouse button on a potentiometer to poll repeatedly. */
       if (followMouse && !first_time && (followMouse++ > mouseWait)) {
 	/* reset for next timing loop */
@@ -17873,10 +12826,8 @@ processEvents(void)
 	  clearControlMessage();
 	  /* reset all the things that might affect a recalculation for
 	     redrawing removing hidden surfaces */
-	  
 	  /* determine what type of button has been pressed */
 	  switch(controlButton->buttonKey) {
-	    
 	    /*** Potentiometers ***/
 	  case rotate:
 	    if (!((viewport->originrOn) && (viewport->objectrOn))) {
@@ -17937,7 +12888,6 @@ processEvents(void)
 	      drawViewport(Xoption);
 	    }
 	    break;
-	    
 	  case zoom:
 	    /* if uniform scaling */
 	    if ((viewport->zoomXOn) &&
@@ -17966,22 +12916,23 @@ processEvents(void)
 		(viewport->zoomZOn))
 	      drawViewport(Xoption);
 	    break;
-	    
 	  case translate:
 	    viewport->deltaX += mouseXY.x * translateFactor;
 	    viewport->deltaY += mouseXY.y * translateFactor;
-	    if (viewport->deltaX > maxDeltaX) viewport->deltaX = maxDeltaX;
-	    else if (viewport->deltaX < -maxDeltaX) viewport->deltaX = -maxDeltaX;
-	    
-	    if (viewport->deltaY > maxDeltaY) viewport->deltaY = maxDeltaY;
-	    else if (viewport->deltaY < -maxDeltaY) viewport->deltaY = -maxDeltaY;
+	    if (viewport->deltaX > maxDeltaX) 
+                   viewport->deltaX = maxDeltaX;
+	    else if (viewport->deltaX < -maxDeltaX) 
+                   viewport->deltaX = -maxDeltaX;
+	    if (viewport->deltaY > maxDeltaY) 
+                   viewport->deltaY = maxDeltaY;
+	    else if (viewport->deltaY < -maxDeltaY) 
+                   viewport->deltaY = -maxDeltaY;
 	    translated = yes;
 	    clearControlMessage();
 	    strcpy(control->message,viewport->title);
 	    writeControlMessage();
 	    drawViewport(Xoption);
 	    break;
-	    
 	    /*** Lighting panel ***/
 	  case lightMoveXY:
 	    tempLightPointer[0] = linearMouseXY.x;
@@ -17993,7 +12944,6 @@ processEvents(void)
 	    movingLight = yes;
 	    drawLightingAxes();
 	    break;
-	    
 	  case lightMoveZ:
 	    tempLightPointer[2] = linearMouseXY.y;
 	    /* linearMouse => no checking necessary */
@@ -18002,7 +12952,6 @@ processEvents(void)
 	    movingLight = yes;
 	    drawLightingAxes();
 	    break;
-	    
 	    /* changes the light intensity */
 	  case lightTranslucent:
 	    tempLightIntensity = (linearMouseXY.y+1)/2;
@@ -18011,7 +12960,6 @@ processEvents(void)
 	    changedIntensity = yes;
 	    drawLightTransArrow();
 	    break;
-	    
 	    /*** volume panel ***/
 	  case frustrumBut:
 	    screenX = ((XButtonEvent *)event)->x;
@@ -18044,7 +12992,6 @@ processEvents(void)
 	      doingPanel = VOLUMEpanel;
 	    }
 	    break;
-	    
 	  case clipXBut:  /* this is a horizontal button */
 	    clipValue = linearMouseXY.x * 0.5 + 0.5;   /* normalize to 0..1 */
 	    if (lessThan(clipValue,0.0)) clipValue = 0.0;
@@ -18079,7 +13026,6 @@ processEvents(void)
 	      }
 	    }
 	    break;
-	    
 	  case clipYBut:  /* this is a vertical button */
 	    /* normalize to 0..1, bottom up */
 	    clipValue = 1 - (linearMouseXY.y * 0.5 + 0.5);
@@ -18115,7 +13061,6 @@ processEvents(void)
 	      }
 	    }
 	    break;
-	    
 	  case clipZBut:  /* this is a diagonally aligned button! */
 	    /* f1 is the distance from the center of the button along
 	       the diagonal line with a slope of -1. If f1 is negative,
@@ -18165,12 +13110,12 @@ processEvents(void)
 	      }
 	    }	/* if lessThan(x,y) */
 	    break;
-	    
 	  case perspectiveBut:
 	    if ((viewData.perspective = !viewData.perspective)) {
 	      switchedPerspective = yes;
 	      GSetForeground(volumeGC,
-			     (float)monoColor((control->buttonQueue[perspectiveBut]).textColor),Xoption);
+            (float)monoColor((control->buttonQueue[perspectiveBut]).textColor),
+                  Xoption);
 	      GDrawString(volumeGC,volumeWindow,
 			  controlButton->buttonX +
 			  centerX(volumeGC,"x",1,controlButton->buttonWidth),
@@ -18191,7 +13136,8 @@ processEvents(void)
 	  case clipRegionBut:
 	    if ((viewData.clipbox = !viewData.clipbox)) {
 	      GSetForeground(volumeGC,
-			     (float)monoColor((control->buttonQueue[clipRegionBut]).textColor),Xoption);
+             (float)monoColor((control->buttonQueue[clipRegionBut]).textColor),
+                            Xoption);
 	      GDrawString(volumeGC,volumeWindow,
 			  controlButton->buttonX +
 			  centerX(volumeGC,"x",1,controlButton->buttonWidth),
@@ -18209,11 +13155,11 @@ processEvents(void)
 	    
 	    drawViewport(Xoption);
 	    break;
-	    
 	  case clipSurfaceBut:
 	    if ((viewData.clipStuff = !viewData.clipStuff)) {
 	      GSetForeground(volumeGC,
-			     (float)monoColor((control->buttonQueue[clipSurfaceBut]).textColor),Xoption);
+            (float)monoColor((control->buttonQueue[clipSurfaceBut]).textColor),
+                             Xoption);
 	      GDrawString(volumeGC,volumeWindow,
 			  controlButton->buttonX +
 			  centerX(volumeGC,"x",1,controlButton->buttonWidth),
@@ -18233,7 +13179,6 @@ processEvents(void)
 	  default:
 	    buttonAction(controlButton->buttonKey);
 	  } /* switch on buttonKey */
-	  
 	}  /* else - not closing */
       }	  /* if checkButton */
     } /* if FD_ISSET(Xcon,.. */
@@ -18244,258 +13189,89 @@ processEvents(void)
   } 	  /* for (until closed) */
 }	  /* processEvents() */
 
-
-
 @
-\section{process.h}
-<<view3d/process.h>>=
-#define maxEyeDistance 2000.0
-#define minEyeDistance 200.0
-#define eyeIncrement   25.0
-
-#define clipPlaneMin (-250.0)
-#define clipPlaneMax 250.0
-#define clipPlaneIncrement 10.0
-@
-\section{project3d.c}
-<<view3d/project3d.c>>=
-#define _PROJECT3D_C
-#include <string.h>
-
-<<view3d/header.h>>
-<<view3d/draw.h>>
-#define spadActionMode
-/* define spadEventMode */
-#define components
-
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-/*******************************************
- * void project(aViewTriple,someXpoints,i) *
- *                                         *
- *  orthogonal projection for a point      *
- *  setting the ith Xpoint as well         *
- *******************************************/
-
-void 
-project(viewTriple * aViewTriple,XPoint *someXpoints,int i)
-{
+\subsection{project}
+Orthogonal projection for a point setting the ith Xpoint as well.
+\index{view3d!project}
+\index{project view3d}
+<<view3d>>=
+void project(viewTriple * aViewTriple,XPoint *someXpoints,int i) {
   float Vtmp[4], V[4], V1[4];
-
   V[0] = aViewTriple->x;  V[1] = aViewTriple->y;  
   V[2] = aViewTriple->z;  V[3] = 1.0;
-
   if (isNaNPoint(V[0], V[1], V[2])) {
     (someXpoints+i)->x = aViewTriple->px = NotPoint;
     (someXpoints+i)->y = aViewTriple->py = NotPoint;
     return;
   }
-
   V[0] -= viewport->transX; V[1] -= viewport->transY;
   V[2] -= viewport->transZ;
   vectorMatrix4(V,R1,Vtmp);
-
   matrixMultiply4x4(S,R,transform);
   vectorMatrix4(Vtmp,transform,V1);
-
   aViewTriple->wx = V1[0]; aViewTriple->wy = V1[1];
   aViewTriple->wz = V1[2];
-
   V1[0] *= reScale;  V1[1] *= reScale;  V1[2] *= reScale;
-
   aViewTriple->pz = V1[2];
   if (viewData.perspective) {
     V1[0] *= projPersp(aViewTriple->pz);
     V1[1] *= projPersp(aViewTriple->pz);
   }
-
   matrixMultiply4x4(I,T,transform);
   vectorMatrix4(V1,transform,V);    
   V[0] = V[0]*viewScale + xCenter;
   V[1] = vwInfo.height - (V[1]*viewScale + yCenter);
-
   (someXpoints+i)->x = aViewTriple->px = V[0];
   (someXpoints+i)->y = aViewTriple->py = V[1];
 }
 
-
-/***************************************************
- * void projectAPoint(aViewTriple)                 *
- *                                                 *
- *  orthogonal projection for a point. sort of     *
- *  like the above, but no Xpoint assignment       *
- ***************************************************/
-
-void 
-projectAPoint(viewTriple *aViewTriple)
-{
+@
+\subsection{projectAPoint}
+Orthogonal projection for a point. sort of like the above, 
+but no Xpoint assignment.
+\index{view3d!projectAPoint}
+\index{projectAPoint view3d}
+<<view3d>>=
+void projectAPoint(viewTriple *aViewTriple) {
   float Vtmp[4], V[4], V1[4];
- 
   V[0] = aViewTriple->x;  V[1] = aViewTriple->y;  
   V[2] = aViewTriple->z;  V[3] = 1.0;
-
   if (isNaNPoint(V[0], V[1], V[2])) {
     aViewTriple->px = NotPoint;
     aViewTriple->py = NotPoint;
     return;
   }
-
   V[0] -= viewport->transX; V[1] -= viewport->transY;
   V[2] -= viewport->transZ;
   vectorMatrix4(V,R1,Vtmp);
-
   matrixMultiply4x4(S,R,transform);
   vectorMatrix4(Vtmp,transform,V1);
-
   aViewTriple->wx = V1[0]; aViewTriple->wy = V1[1];
   aViewTriple->wz = V1[2];
-
   V1[0] *= reScale;  V1[1] *= reScale;  V1[2] *= reScale;
-
   aViewTriple->pz = V1[2];
   if (viewData.perspective) {
     V1[0] *= projPersp(aViewTriple->pz);
     V1[1] *= projPersp(aViewTriple->pz);
   }
-
   matrixMultiply4x4(I,T,transform);
   vectorMatrix4(V1,transform,V);    
   V[0] = V[0]*viewScale + xCenter;
   V[1] = vwInfo.height - (V[1]*viewScale + yCenter);
-
   aViewTriple->px = V[0];
   aViewTriple->py = V[1];
 }
 
-
-/***************************
- * void projectAllPoints() *
- ***************************/
-
-void 
-projectAllPoints(void)
-{
-
+@
+\subsection{projectAllPoints}
+\index{view3d!projectAllPoints}
+\index{projectAllPoints view3d}
+<<view3d>>=
+void projectAllPoints(void) {
   int i,j,k;
   LLPoint *anLLPoint;
   LPoint *anLPoint;
   int *anIndex;
-
   anLLPoint = viewData.lllp.llp;
   for (i=0; i<viewData.lllp.numOfComponents; i++,anLLPoint++) {
     anLPoint = anLLPoint->lp;
@@ -18506,28 +13282,18 @@ projectAllPoints(void)
       } /* for points in LPoints (k) */
     } /* for LPoints in LLPoints (j) */
   } /* for LLPoints in LLLPoints (i) */
-
 } /* projectAllPoints() */
 
-
-/*******************************
- * void projectAllPolys(pList) *
- *                             *
- * orthogonal projection of    *
- * all the polygons in a given *
- * list in one go. pz holds    *
- * the projected depth info    *
- * for hidden surface removal. *
- * Polygons totally outside of *
- * the window dimensions after *
- * projection are discarded    *
- * from the list.              *
- *******************************/
-
-void 
-projectAllPolys (poly *pList)
-{
-
+@
+\subsection{projectAllPolys}
+Orthogonal projection of all the polygons in a given list in one
+go. pz holds the projected depth info for hidden surface removal. 
+Polygons totally outside of the window dimensions after projection 
+are discarded from the list.
+\index{view3d!projectAllPolys}
+\index{projectAllPolys view3d}
+<<view3d>>=
+void projectAllPolys(poly *pList) {
   int i,clipped,clippedPz;
   float x0=0.0;
   float y0=0.0;
@@ -18537,10 +13303,8 @@ projectAllPolys (poly *pList)
   float yB=0.0;
   int *anIndex;
   viewTriple *aPt;
-
   strcpy(control->message,"         Projecting Polygons        ");
   writeControlMessage();
-
   projectAllPoints();
   for (;pList != NIL(poly);pList=pList->next) {
       /* totalClip==yes => partialClip==yes (of course) */
@@ -18556,7 +13320,6 @@ projectAllPolys (poly *pList)
       clippedPz = behindClipPlane(aPt->pz);
       pList->totalClipPz = pList->totalClipPz && clippedPz;
       pList->partialClipPz = pList->partialClipPz || clippedPz;
-      
         /* stuff for figuring out normalFacingOut, after the loop */
       if (!i) {
         x0 = aPt->px; y0 = aPt->py;
@@ -18580,29 +13343,19 @@ projectAllPolys (poly *pList)
     if ((x0 = xA*yB - yA*xB) > machine0) pList->normalFacingOut = 1;
     else if (x0 < machine0) pList->normalFacingOut = -1;
     else pList->normalFacingOut = 0;
-
   }
   strcpy(control->message,viewport->title);
   writeControlMessage();
-  
 }   /* projectAllPolys */
 
-
-
-/*******************************
- * void projectAPoly(p)        *
- *                             *
- * orthogonal projection of    *
- * all a polygon. pz holds     *
- * the projected depth info    *
- * for hidden surface removal  *
- *******************************/
-
-
-void 
-projectAPoly (poly *p)
-{
-
+@
+\subsection{projectAPoly}
+Orthogonal projection of all a polygon. pz holds the projected depth info
+for hidden surface removal.
+\index{view3d!projectAPoly}
+\index{projectAPoly view3d}
+<<view3d>>=
+void projectAPoly(poly *p) {
   int i,clipped,clippedPz;
   float Vtmp[4],V[4],V1[4];
   float x0=0.0;
@@ -18611,10 +13364,8 @@ projectAPoly (poly *p)
   float yA=0.0;
   float xB=0.0;
   float yB=0.0;
-
   int *anIndex;
   viewTriple *aPt;
-
 /*  totalClip==yes => partialClip==yes */
   p->totalClipPz = yes; /*  start with 1, AND all points with Pz<0 */
   p->partialClipPz = no;  /* start with 0, OR any points with Pz<0 */
@@ -18623,38 +13374,29 @@ projectAPoly (poly *p)
   for (i=0,anIndex=p->indexPtr; i<p->numpts; i++,anIndex++) {
     aPt  = refPt3D(viewData,*anIndex);
     V[0] = aPt->x;  V[1] = aPt->y;  V[2] = aPt->z;  V[3] = 1.0;
-
     V[0] -= viewport->transX; V[1] -= viewport->transY;
     V[2] -= viewport->transZ;
     vectorMatrix4(V,R1,Vtmp);
-
     matrixMultiply4x4(S,R,transform);
     vectorMatrix4(Vtmp,transform,V1);
-
     aPt->wx = V1[0];  aPt->wy = V1[1];  aPt->wz = V1[2];
-
     V1[0] *= reScale;  V1[1] *= reScale;  V1[2] *= reScale;
-
     aPt->pz = V1[2];
     if (viewData.perspective) {
       V1[0] *= projPersp(V1[2]);
       V1[1] *= projPersp(V1[2]);
     }
-
     matrixMultiply4x4(I,T,transform);
     vectorMatrix4(V1,transform,V);    
     V[0] = V[0]*viewScale + xCenter;
     V[1] = vwInfo.height - (V[1]*viewScale + yCenter);
-
     aPt->px = V[0];  aPt->py = V[1];
-    
     clipped = outsideClippedBoundary(aPt->x, aPt->y, aPt->z);
     p->totalClip = p->totalClip && clipped;
     p->partialClip = p->partialClip || clipped;
     clippedPz = behindClipPlane(aPt->pz);
     p->totalClipPz = p->totalClipPz && clippedPz;
     p->partialClipPz = p->partialClipPz || clippedPz;
-    
     /* stuff for figuring out normalFacingOut, after the loop */
     if (!i) {
       x0 = aPt->px; y0 = aPt->py;
@@ -18665,264 +13407,64 @@ projectAPoly (poly *p)
       xB = aPt->px - x0; yB = aPt->py - y0;
     }
   }
-
   if ((x0 = xA*yB - yA*xB) > machine0) p->normalFacingOut = 1;
   else if (x0 < machine0) p->normalFacingOut = -1;
   else p->normalFacingOut = 0;
-  
 }  /*  projectAPoly */
 
-
-
-/**********************************
- * void projectStuff(x,y,z,px,py) *
- *                                *
- * sort of like the project stuff *
- * in tube.c but used exclusively *
- * for the functions of two       *
- * variables. probably will need  *
- * to be changed later to be more *
- * general (i.e. have everybody   *
- * use the viewTriple point       *
- * structure).                    *
- **********************************/
-
-void 
-projectStuff(float x,float y,float z,int *px,int *py,float *Pz)
-{
+@
+\subsection{projectStuff}
+Sort of like the project stuff in tube.c but used exclusively for the
+functions of two variables. probably will need to be changed later to
+be more general (i.e. have everybody use the viewTriple point structure).
+\index{view3d!projectStuff}
+\index{projectStuff view3d}
+<<view3d>>=
+void projectStuff(float x,float y,float z,int *px,int *py,float *Pz) {
   float tempx,tempy,tempz,temps,V[4],V1[4],stuffScale=100.0;
-
   tempx = viewport->scaleX;
   tempy = viewport->scaleY;
   tempz = viewport->scaleZ;
   temps = viewScale;
-
   if (viewport->scaleX > 5.0) viewport->scaleX = 5.0;
   if (viewport->scaleY > 5.0) viewport->scaleY = 5.0;
   if (viewport->scaleZ > 3.0) viewport->scaleZ = 3.0;
   if (viewScale > 5.0) viewScale = 5.0;
-
   V[0] = x;  V[1] = y;  
   V[2] = z;  V[3] = 1.0;
-
   V[0] -= viewport->transX*stuffScale;
   V[1] -= viewport->transY*stuffScale;
   V[2] -= viewport->transZ*stuffScale;
-
   matrixMultiply4x4(S,R,transform); 
   vectorMatrix4(V,transform,V1);   
   *Pz = V1[2];
-
   if (viewData.perspective) {
     V1[0] *= projPersp(V1[2]);
     V1[1] *= projPersp(V1[2]);
   }
-
   matrixMultiply4x4(I,T,transform);
   vectorMatrix4(V1,transform,V);    
-
   V[0] = V[0]*viewScale + xCenter;
   V[1] = vwInfo.height - (V[1]*viewScale + yCenter);
-
   *px = V[0];
   *py = V[1];
-
   viewport->scaleX = tempx;
   viewport->scaleY = tempy;
   viewport->scaleZ = tempz;
   viewScale = temps;
 }
-@
-\section{quit3d.c}
-<<view3d/quit3d.c>>=
-#define _QUIT3D_C
-
-#include <string.h>
-<<view3d/header.h>>
-<<view3d/cpanel.h>>
-<<view3d/volume.h>>
-<<include/purty/volume.bitmap>>
-<<include/purty/volume.mask>>
-
-#include "util.h1"
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-#include "xspadfill.h1"
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-#define quitMASK ExposureMask
-#define quitCursorForeground monoColor(55)
-#define quitCursorBackground monoColor(197)
-#define quitTitleColor monoColor(69)
-#define quitButtonColor monoColor(195)
-#define quitFontHeight (quitFont->max_bounds.ascent+quitFont->max_bounds.descent)
-
-
-/***************************
- * int makeQuitPanel() *
- ***************************/
-
-int
-makeQuitPanel(void)
-{
 
+@
+\subsection{makeQuitPanel}
+\index{view3d!makeQuitPanel}
+\index{makeQuitPanel view3d}
+<<view3d>>=
+int makeQuitPanel(void) {
   int i;
   XSetWindowAttributes quitter,QuitterAttrib;
   XSizeHints sizeh;
   Pixmap quitbits, quitmask;
   XColor quitterColor,qColor;
-
   quitbits = XCreateBitmapFromData(dsply,rtWindow, volumeBitmap_bits,
 				   volumeBitmap_width,volumeBitmap_height);
   quitmask = XCreateBitmapFromData(dsply,rtWindow,volumeMask_bits,
@@ -18940,21 +13482,18 @@ makeQuitPanel(void)
 				       &quitterColor,&qColor,
 				       volumeBitmap_x_hot,volumeBitmap_y_hot);
   quitWindow = XCreateWindow(dsply,control->controlWindow,
-			     controlWidth-quitWidth-2,controlHeight-quitHeight-2,
-                             quitWidth-2,quitHeight-2,2,
-			     CopyFromParent,InputOutput,CopyFromParent,
-			     controlCreateMASK,&quitter);
-
+		     controlWidth-quitWidth-2,controlHeight-quitHeight-2,
+                     quitWidth-2,quitHeight-2,2,
+                     CopyFromParent,InputOutput,CopyFromParent,
+                     controlCreateMASK,&quitter);
   sizeh.flags  = USPosition | USSize;
   sizeh.x      = 0;
   sizeh.y      = 0;
   sizeh.width  = quitWidth-2;
   sizeh.height = quitHeight-2;
-
   XSetNormalHints(dsply,quitWindow,&sizeh);
   XSetStandardProperties(dsply,quitWindow,"Quit Panel","Quit Panel",
 			 None,NULL,0,&sizeh);
-
   /*** do quit buttons ***/
   initQuitButtons(control->buttonQueue);
   for (i=quitButtonsStart; i<(quitButtonsEnd); i++) {
@@ -18971,29 +13510,23 @@ makeQuitPanel(void)
 	       &((control->buttonQueue[i]).buttonKey));
     XMapWindow(dsply,(control->buttonQueue[i]).self);
   }
-
   return(0);
-
 }  /* makeQuitPanel() */
 
-
-/****************************
- * void drawQuitPanel() *
- ****************************/
-
-void
-drawQuitPanel(void)
-{
-
+@
+\subsection{drawQuitPanel}
+\index{view3d!drawQuitPanel}
+\index{drawQuitPanel view3d}
+<<view3d>>=
+void drawQuitPanel(void) {
   char *s;
   int i,strlength;
-
   s = "Really?";
   strlength = strlen(s);
   GSetForeground(anotherGC,(float)quitTitleColor,Xoption);
   GDrawString(anotherGC,quitWindow,
-	      centerX(anotherGC,s,strlength,quitWidth),centerY(anotherGC,39),s,strlength,Xoption);
-
+              centerX(anotherGC,s,strlength,quitWidth),
+              centerY(anotherGC,39),s,strlength,Xoption);
   GSetForeground(anotherGC,(float)quitButtonColor,Xoption);
   for (i=quitButtonsStart; i<(quitButtonsEnd); i++) {
       GDraw3DButtonOut(quitGC,quitWindow,
@@ -19004,7 +13537,8 @@ drawQuitPanel(void)
       s = (control->buttonQueue[i]).text;
       strlength = strlen(s);
       GSetForeground(trashGC,
-		     (float)monoColor((control->buttonQueue[i]).textColor),Xoption);
+		     (float)monoColor((control->buttonQueue[i]).textColor),
+                     Xoption);
       GDrawString(trashGC,quitWindow,
 		  (control->buttonQueue[i]).buttonX +
 		  centerX(processGC,s,strlength,
@@ -19013,141 +13547,16 @@ drawQuitPanel(void)
 		  centerY(processGC,(control->buttonQueue[i]).buttonHeight),
 		  s,strlen(s),Xoption);
   }  /* for i in control->buttonQueue */
-
 }  /* drawQuitPanel */
-@
-\section{quitbut3d.c}
-<<view3d/quitbut3d.c>>=
-#define _QUITBUT3D_C
 
-<<view3d/header.h>>
-<<view3d/cpanel.h>>
-
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-
-
-int 
-initQuitButtons (buttonStruct *quitButtons)
-{
+@
+\subsection{initQuitButtons}
+\index{view3d!initQuitButtons}
+\index{initQuitButtons view3d}
+<<view3d>>=
+int initQuitButtons(buttonStruct *quitButtons) {
   int ii;
   int num = 0;
-
   ii = quitAbort;
   quitButtons[ii].buttonX      = 5;
   quitButtons[ii].buttonY      = 41;
@@ -19161,7 +13570,6 @@ initQuitButtons (buttonStruct *quitButtons)
   quitButtons[ii].xHalf        = quitButtons[ii].buttonWidth/2;
   quitButtons[ii].yHalf        = quitButtons[ii].buttonHeight/2;
   ++num;
-
   ii = quitReturn;
   quitButtons[ii].buttonX      = 5;
   quitButtons[ii].buttonY      = 75;
@@ -19175,202 +13583,20 @@ initQuitButtons (buttonStruct *quitButtons)
   quitButtons[ii].xHalf        = quitButtons[ii].buttonWidth/2;
   quitButtons[ii].yHalf        = quitButtons[ii].buttonHeight/2;
   ++num;
-
   return(num);
 }
 
-
 @
-\section{save3d.c}
-<<view3d/save3d.c>>=
-#define _SAVE3D_C
-
-#include <stdio.h>
-#include <string.h>
-<<view3d/header.h>>
-<<view3d/cpanel.h>>
-<<view3d/volume.h>>
-<<include/purty/volume.bitmap>>
-<<include/purty/volume.mask>>
-
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-#include "xspadfill.h1"
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-#define saveMASK ExposureMask
-#define saveCursorForeground monoColor(55)
-#define saveCursorBackground monoColor(197)
-#define saveTitleColor monoColor(70)
-#define saveButtonColor monoColor(195)
-#define saveFontHeight (saveFont->max_bounds.ascent+saveFont->max_bounds.descent)
-
-
-/***************************
- * int makeSavePanel() *
- ***************************/
-
-int
-makeSavePanel(void)
-{
-
+\subsection{makeSavePanel}
+\index{view3d!makeSavePanel}
+\index{makeSavePanel view3d}
+<<view3d>>=
+int makeSavePanel(void) {
   int i;
   XSetWindowAttributes saver,SaverAttrib;
   XSizeHints sizeh;
   Pixmap savebits, savemask;
   XColor saveColor,sColor;
-
   savebits = XCreateBitmapFromData(dsply,rtWindow, volumeBitmap_bits,
 				   volumeBitmap_width,volumeBitmap_height);
   savemask = XCreateBitmapFromData(dsply,rtWindow,volumeMask_bits,
@@ -19384,26 +13610,22 @@ makeSavePanel(void)
   XQueryColor(dsply,colorMap,&saveColor);
   sColor.pixel = saveCursorBackground;
   XQueryColor(dsply,colorMap,&sColor);
-  saver.cursor = XCreatePixmapCursor(dsply,savebits,savemask,
-				     &saveColor,&sColor,
-				     volumeBitmap_x_hot,volumeBitmap_y_hot);
-
-  saveWindow = XCreateWindow(dsply,control->controlWindow,
-			     controlWidth-saveWidth-2, controlHeight-saveHeight-2,
-                             saveWidth-2,saveHeight-2,2,
-			     CopyFromParent,InputOutput,CopyFromParent,
-			     controlCreateMASK,&saver);
-
+  saver.cursor = 
+    XCreatePixmapCursor(dsply,savebits,savemask,&saveColor,&sColor,
+                        volumeBitmap_x_hot,volumeBitmap_y_hot);
+  saveWindow = 
+    XCreateWindow(dsply,control->controlWindow,controlWidth-saveWidth-2, 
+                  controlHeight-saveHeight-2,saveWidth-2,saveHeight-2,2,
+                  CopyFromParent,InputOutput,CopyFromParent,
+                  controlCreateMASK,&saver);
   sizeh.flags  = USPosition | USSize;
   sizeh.x      = 0;
   sizeh.y      = 0;
   sizeh.width  = saveWidth-2;
   sizeh.height = saveHeight-2;
-
   XSetNormalHints(dsply,saveWindow,&sizeh);
   XSetStandardProperties(dsply,saveWindow,"Save Panel","Save Panel",
 			 None,NULL,0,&sizeh);
-
   /*** Create save buttons ***/
   initSaveButtons(control->buttonQueue);
   for (i=saveButtonsStart; i<(saveButtonsEnd); i++) {
@@ -19420,23 +13642,17 @@ makeSavePanel(void)
 	       &((control->buttonQueue[i]).buttonKey));
     XMapWindow(dsply,(control->buttonQueue[i]).self);
   }
-
   return(0);
-
 }  /* makeSavePanel() */
 
-
-/****************************
- * void drawSavePanel() *
- ****************************/
-
-void
-drawSavePanel(void)
-{
-
+@
+\subsection{drawSavePanel}
+\index{view3d!drawSavePanel}
+\index{drawSavePanel view3d}
+<<view3d>>=
+void drawSavePanel(void) {
   char *s;
   int i,strlength;
-
   GSetForeground(saveGC,(float)saveButtonColor,Xoption);
   for (i=saveButtonsStart; i<(saveButtonsEnd); i++) {
       GDraw3DButtonOut(saveGC,saveWindow,
@@ -19447,7 +13663,8 @@ drawSavePanel(void)
       s = (control->buttonQueue[i]).text;
       strlength = strlen(s);
       GSetForeground(trashGC,
-		     (float)monoColor((control->buttonQueue[i]).textColor),Xoption);
+		     (float)monoColor((control->buttonQueue[i]).textColor),
+                     Xoption);
       GDrawString(trashGC,saveWindow,
 		  (control->buttonQueue[i]).buttonX +
 		  centerX(processGC,s,strlength,
@@ -19456,138 +13673,16 @@ drawSavePanel(void)
 		  centerY(processGC,(control->buttonQueue[i]).buttonHeight),
 		  s,strlen(s),Xoption);
   }  /* for i in control->buttonQueue */
-
 }  /* drawSavePanel */
-@
-\section{savebut3d.c}
-<<view3d/savebut3d.c>>=
-#define _SAVEBUT3D_C
-
-<<view3d/header.h>>
-<<view3d/cpanel.h>>
-
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
 
-int 
-initSaveButtons (buttonStruct *saveButtons)
-{
+@
+\subsection{initSaveButtons}
+\index{view3d!initSaveButtons}
+\index{initSaveButtons view3d}
+<<view3d>>=
+int initSaveButtons(buttonStruct *saveButtons) {
   int ii;
   int num = 0;
-
   ii = saveExit;
   saveButtons[ii].buttonX      = 5;
   saveButtons[ii].buttonY      = 7;
@@ -19601,7 +13696,6 @@ initSaveButtons (buttonStruct *saveButtons)
   saveButtons[ii].xHalf        = saveButtons[ii].buttonWidth/2;
   saveButtons[ii].yHalf        = saveButtons[ii].buttonHeight/2;
   ++num;
-
   ii = pixmap;
   saveButtons[ii].buttonX      = 5;
   saveButtons[ii].buttonY      = 41;
@@ -19615,7 +13709,6 @@ initSaveButtons (buttonStruct *saveButtons)
   saveButtons[ii].xHalf        = saveButtons[ii].buttonWidth/2;
   saveButtons[ii].yHalf        = saveButtons[ii].buttonHeight/2;
   ++num;
-
   ii = ps;
   saveButtons[ii].buttonX              = 5;
   saveButtons[ii].buttonY              = 75;
@@ -19628,278 +13721,110 @@ initSaveButtons (buttonStruct *saveButtons)
   saveButtons[ii].textColor            = 149;
   saveButtons[ii].xHalf                = saveButtons[ii].buttonWidth/2;
   saveButtons[ii].yHalf                = saveButtons[ii].buttonHeight/2;
-
   return(num);
 }
 
-
 @
-\section{smoothshade3d.c}
-<<view3d/smoothshade3d.c>>=
-#define _SMOOTHSHADE_C
-
-#include <string.h>
-#include <math.h>
-#include <stdlib.h>
-
-<<view3d/header.h>>
-<<view3d/draw.h>>
-<<view3d/volume.h>>
-#define spadActionMode
-/* define spadEventMode */
-#define components
-
-#include "spadcolors.h1"
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-#include "util.h1"
-#include "xspadfill.h1"
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-#define SAFE_VALUE 892347
-
-char 
-get_cBuffer_axes(int ix)
-{
-	if( ix >=0 && ix <ARRAY_WIDTH) return (cBuffer[ix].axes);
-	return ('0');
+\subsection{getCBufferAxes}
+\index{view3d!getCBufferAxes}
+\index{getCBufferAxes view3d}
+<<view3d>>=
+char getCBufferAxes(int ix) {
+  if( ix >=0 && ix <ARRAY_WIDTH) return (cBuffer[ix].axes);
+  return ('0');
 }
 
-void 
-put_cBuffer_axes(int ix,char val)
-{
-	if( ix >=0 && ix <ARRAY_WIDTH) cBuffer[ix].axes = val;
+@
+\subsection{putCBufferAxes}
+\index{view3d!putCBufferAxes}
+\index{putCBufferAxes view3d}
+<<view3d>>=
+void putCBufferAxes(int ix,char val) {
+  if( ix >=0 && ix <ARRAY_WIDTH) cBuffer[ix].axes = val;
 }
 
-int 
-get_cBuffer_indx(int ix)
-{
-	if( ix >=0 && ix <ARRAY_WIDTH) return (cBuffer[ix].indx);
-	return (-1);
+@
+\subsection{getCBufferIndx}
+\index{view3d!getCBufferIndx}
+\index{getCBufferIndx view3d}
+<<view3d>>=
+int getCBufferIndx(int ix) {
+  if( ix >=0 && ix <ARRAY_WIDTH) return (cBuffer[ix].indx);
+  return (-1);
 }
 
-void 
-put_cBuffer_indx(int ix,int val)
-{
-	if( ix >=0 && ix <ARRAY_WIDTH) cBuffer[ix].indx = val;
+@
+\subsection{putCBufferIndx}
+\index{view3d!putCBufferIndx}
+\index{putCBufferIndx view3d}
+<<view3d>>=
+void putCBufferIndx(int ix,int val) {
+  if( ix >=0 && ix <ARRAY_WIDTH) cBuffer[ix].indx = val;
 }
 
-void 
-put_zBuffer(int ix,float val)
-{
-	if (ix >=0 && ix <ARRAY_WIDTH) zBuffer[ix] = val;
+@
+\subsection{putZBuffer}
+\index{view3d!putZBuffer}
+\index{putZBuffer view3d}
+<<view3d>>=
+void putZBuffer(int ix,float val) {
+  if (ix >=0 && ix <ARRAY_WIDTH) zBuffer[ix] = val;
 }
 
-float 
-get_zBuffer(int ix)
-{
-	return (zBuffer[ix]);
+@
+\subsection{getZBuffer}
+\index{view3d!getZBuffer}
+\index{getZBuffer view3d}
+<<view3d>>=
+float getZBuffer(int ix) {
+  return (zBuffer[ix]);
 }
 
-void 
-put_imageX(int ix,char val)
-{
+@
+\subsection{putImageX}
+\index{view3d!putImageX}
+\index{putImageX view3d}
+<<view3d>>=
+void putImageX(int ix,char val) {
   if (ix <=0 && ix <vwInfo.width) imageX->data[ix] = val;
 }
 
-
-
-
-/***************************
- * void drawPhongSpan()	   *
- *			   *
- * This routine sets the   *
- * buffer values for each  *
- * span of pixels which	   *
- * intersect the current   *
- * scanline.		   *
- ***************************/
-void 
-drawPhongSpan(triple pt,float N[3],int dFlag)
-{
+@
+\subsection{drawPhongSpan}
+This routine sets the buffer values for each span of pixels which
+intersect the current scanline.
+\index{view3d!drawPhongSpan}
+\index{drawPhongSpan view3d}
+<<view3d>>=
+void drawPhongSpan(triple pt,float N[3],int dFlag) {
   int		     xpixel,hue,shade;
   float		     colorindx, col;
   triple	     hs;
-
-
   /* negative values of xleft and xright have been pushed to machine0 */
-
   xpixel = (int)xleft;
-
-
   while (xpixel <= (int)xright) {
     /* if z is closer to viewer than value in zBuffer continue */
-    if ( (zC < get_zBuffer(xpixel)) ) {
+    if ( (zC < getZBuffer(xpixel)) ) {
       /* get the intensity for current point */
       col = phong(pt,N);
-      put_cBuffer_axes(xpixel,'0');
-      put_zBuffer(xpixel,zC);
+      putCBufferAxes(xpixel,'0');
+      putZBuffer(xpixel,zC);
       /* if mono (bw dsply) do black and white semi-random dithering */
       if (mono || (dFlag == PSoption) || viewport->monoOn) {
-	if (get_random() < 100.0*exp((double)-1.3*(pi_sq*(col-.2)*(col-.2))))  {
-	  put_cBuffer_indx(xpixel,black);
+	if (getRandom() < 100.0*exp((double)-1.3*(pi_sq*(col-.2)*(col-.2))))  
+        {
+	  putCBufferIndx(xpixel,black);
 	} else {
-	  put_cBuffer_indx(xpixel,white);
+	  putCBufferIndx(xpixel,white);
 	}
       } else {
 	/* glossy shading for one hue else dithered for many hues */
 	if (viewport->hueOffset == viewport->hueTop && !smoothError) {
 	  colorindx = (float)(smoothConst+1) * col;
 	  if (colorindx > (smoothConst+1)) colorindx = smoothConst+1;
-	  put_cBuffer_indx(xpixel,XPixelColor((int)colorindx-1));
+	  putCBufferIndx(xpixel,XPixelColor((int)colorindx-1));
 	} else { /* probabalistic multi-hued dithering */
-	  hs = norm_dist();
+	  hs = normDist();
 	  hue = (int)(intersectColor[0]+hs.x/20.0);
 	  /* cannot dither out of color map range */
 	  if (viewport->hueOffset < viewport->hueTop) {
@@ -19918,12 +13843,12 @@ drawPhongSpan(triple pt,float N[3],int dFlag)
 	    }
 	  }
 	  col += hs.y/6.0;  /* perturb intensity */
-	  if (col > 1.0) put_cBuffer_indx(xpixel,white);
+	  if (col > 1.0) putCBufferIndx(xpixel,white);
 	  else {
-	    if (col < 0.0) put_cBuffer_indx(xpixel,black);
+	    if (col < 0.0) putCBufferIndx(xpixel,black);
 	    else {
 	      shade = (int)(col * 4.0);
-	      put_cBuffer_indx(xpixel,XSolidColor(hue,shade));
+	      putCBufferIndx(xpixel,XSolidColor(hue,shade));
 	    }
 	  }
 	}
@@ -19937,27 +13862,17 @@ drawPhongSpan(triple pt,float N[3],int dFlag)
     pt.x += dpt.x;  pt.y += dpt.y;  pt.z += dpt.z;
     xpixel++;
   } /* while each pixel */
-
 }
 
-
-/***************************
- * void scanPhong()	 *
- *			   *
- * This routine takes all  *
- * polygons that intersect *
- * with the current scan-  *
- * line and calculates the *
- * intersecting x and z	   *
- * points as well as the   *
- * color at each point.	   *
- * Interpolation is done   *
- * according to Phong.	   *
- ***************************/
-
-void 
-scanPhong(int dFlag)
-{
+@
+\subsection{scanPhong}
+This routine takes all polygons that intersect with the current scanline 
+and calculates the intersecting x and z points as well as the color at 
+each point.  Interpolation is done according to Phong.
+\index{view3d!scanPhong}
+\index{scanPhong view3d}
+<<view3d>>=
+void scanPhong(int dFlag) {
   viewTriple *p1, *p2;
   polyList   *polygon;
   poly	     *p;
@@ -19967,7 +13882,6 @@ scanPhong(int dFlag)
   float	     intersectionx[2], intersectionz[2];
   float	     c1,c2,colortemp,ztemp,dY,diffy,diffx,n1[3],n2[3],NV[3];
   triple     ntemp, intersectPt[2], ptemp, pt, intersectN[2];
-
   /* polygon list intersecting the current scanline, will be modified to
      edge list structure */
   polygon = scanList[scanline];
@@ -19980,7 +13894,6 @@ scanPhong(int dFlag)
 	     (viewData.clipStuff && (p->partialClip  || p->totalClip ) ) ) ) {
       num = 0; /* 0 & 1, for the 2 edges of polygon that intersect scanline */
       numttt =0;
-
       if ((scanline >= (int)p->pymin) && (scanline <= (int)p->pymax)) {
 	/* which edges of the polygon intersect the scanline */
 	for (i=0, anIndex=p->indexPtr; i<p->numpts; i++) {
@@ -20068,33 +13981,28 @@ scanPhong(int dFlag)
     } /* clipped */
     polygon = polygon->next;
   } /* while still polygons */
-
 }
 
-/********************************************
- * boxTObuffer() writes the projection of   *
- * the x,y  bounding box to the z-buffer.   *
- ********************************************/
-
-void 
-boxTObuffer(void)
-{
+@
+\subsection{boxTObuffer}
+boxTObuffer() writes the projection of the x,y  bounding box to the z-buffer.
+\index{view3d!boxTObuffer}
+\index{boxTObuffer view3d}
+<<view3d>>=
+void boxTObuffer(void) {
   int	 xpix,i,j,k,count,decision;
   int	 xA,xB,yA,yB;
   float  x,xend,y,yend,diffy,dX,dY,dXY,intersectionx;
-
   for (i=0;i<6;i++) {
     if (box[i].inside) {
       for (j=0; j<3; j++) {
 	quadMesh[j].x = box[i].pointsPtr[j]->px;
 	quadMesh[j].y = box[i].pointsPtr[j]->py;
       }
-
       intersectionx = 0.0;
       for (k=0; k<2; k++) {
 	xA = quadMesh[k].x; yA = quadMesh[k].y;
 	xB = quadMesh[k+1].x; yB = quadMesh[k+1].y;
-
 /*
 	if (xA > graphWindowAttrib.width+1) xA = graphWindowAttrib.width+1;
 	if (xB > graphWindowAttrib.width+1) xB = graphWindowAttrib.width+1;
@@ -20111,17 +14019,15 @@ boxTObuffer(void)
 	} else {
 	  dXY = dX;
 	}
-
 	if (dXY < 0.0) dXY = -dXY;
-
 	if ((scanline == (int)y) && (absolute(dY) <= 1.0)) {
 	  if (x <= xend) {
 	    for (xpix = (int)x; xpix <= (int)xend; xpix++) {
-	      put_cBuffer_axes(xpix,'b');
+	      putCBufferAxes(xpix,'b');
 	    }
 	  } else {
 	    for (xpix = (int)x; xpix >= (int)xend; xpix--) {
-	      put_cBuffer_axes(xpix,'b');
+	      putCBufferAxes(xpix,'b');
 	    }
 	  }
 	} else {
@@ -20135,43 +14041,37 @@ boxTObuffer(void)
 	    intersectionx = x + dX/dY * diffy;
 	    for (count = (int)intersectionx;
 		 count <= (int)intersectionx + (int)dXY; count++) {
-	      put_cBuffer_axes(count,'b');
+	      putCBufferAxes(count,'b');
 	    }
 	  }
 	}
       }
-
     }
   }
-
 }
 
-/********************************************
- * clipboxTObuffer() writes the projection  *
- * of the x,y,z clipping region box to the  *
- * z-buffer.				    *
- ********************************************/
-
-void 
-clipboxTObuffer(void)
-{
+@
+\subsection{clipboxTObuffer}
+clipboxTObuffer() writes the projection of the x,y,z clipping region
+box to the z-buffer.
+\index{view3d!clipboxTObuffer}
+\index{clipboxTObuffer view3d}
+<<view3d>>=
+void clipboxTObuffer(void) {
   int	 xpix,i,j,k,count,decision;
   int	 xA,xB,yA,yB;
   float	 x,xend,y,yend,diffy,dX,dY,dXY,intersectionx;
-
   for (i=0;i<6;i++) {
     if (clipBox[i].inside) {
       for (j=0; j<3; j++) {
 	quadMesh[j].x = clipBox[i].pointsPtr[j]->px;
 	quadMesh[j].y = clipBox[i].pointsPtr[j]->py;
       }
-
       intersectionx = 0.0;
       for (k=0; k<2; k++) {
 	xA = quadMesh[k].x; yA = quadMesh[k].y;
 	xB = quadMesh[k+1].x; yB = quadMesh[k+1].y;
 /*
-
 	if (xA > graphWindowAttrib.width+1) xA = graphWindowAttrib.width+1;
 	if (xB > graphWindowAttrib.width+1) xB = graphWindowAttrib.width+1;
 	if (yA > graphWindowAttrib.height) yA = graphWindowAttrib.height;
@@ -20192,11 +14092,11 @@ clipboxTObuffer(void)
 	if ((scanline == (int)y) && (absolute(dY) <= 1.0)) {
 	  if (x <= xend) {
 	    for (xpix = (int)x; xpix <= (int)xend; xpix++) {
-	      put_cBuffer_axes(xpix,'c');
+	      putCBufferAxes(xpix,'c');
 	    }
 	  } else {
 	    for (xpix = (int)x; xpix >= (int)xend; xpix--) {
-	      put_cBuffer_axes(xpix,'c');
+	      putCBufferAxes(xpix,'c');
 	    }
 	  }
 	} else {
@@ -20210,33 +14110,27 @@ clipboxTObuffer(void)
 	    intersectionx = x + dX/dY * diffy;
 	    for (count = (int)intersectionx;
 		 count <= (int)intersectionx + (int)dXY; count++) {
-	      put_cBuffer_axes(count,'c');
+	      putCBufferAxes(count,'c');
 	    }
 	  }
 	}
       }
-
     }
   }
-
 }
 
-
-
-/********************************************
- * axesTObuffer() writes the projection of  *
- * the x,y,z axes to the z-buffer.	    *
- ********************************************/
-
-void 
-axesTObuffer(void)
-{
+@
+\subsection{axesTObuffer}
+axesTObuffer() writes the projection of the x,y,z axes to the z-buffer.
+\index{view3d!axesTObuffer}
+\index{axesTObuffer view3d}
+<<view3d>>=
+void axesTObuffer(void) {
   int	 xpix,i,count,decision;
   int	 xA,xB,yA,yB;
   float	 x,xend,y,yend,diffy,dX,dY,dXY,intersectionx;
   float	 zA,zB,z,zend;
   float	 dZ,dZX,dZY,intersectionz;
-
   intersectionz = 0.0;	intersectionx = 0.0;
   for (i=0; i<3; i++) {
     xA = axesXY[i][0]; yA = axesXY[i][1]; zA = axesZ[i][0];
@@ -20256,17 +14150,16 @@ axesTObuffer(void)
       dXY = dX/dY;
     if (dXY < 0.0) dXY = -dXY;
     dZX = dZ/dX;
-
     if ((scanline == (int)y) && (absolute(dY) <= 1.0)) {
       if (x <= xend) {
 	for (xpix = (int)x; xpix <= (int)xend; xpix++) {
-	  put_cBuffer_axes(xpix,'a');
-	  put_zBuffer(xpix,z + dZY * diffy);
+	  putCBufferAxes(xpix,'a');
+	  putZBuffer(xpix,z + dZY * diffy);
 	} /* for x */
       } else {
 	for (xpix = (int)x; xpix >= (int)xend; xpix--) {
-	  put_cBuffer_axes(xpix,'a');
-	  put_zBuffer(xpix,z + dZY * diffy);
+	  putCBufferAxes(xpix,'a');
+	  putZBuffer(xpix,z + dZY * diffy);
 	} /* for x */
       }
     } else {
@@ -20281,29 +14174,26 @@ axesTObuffer(void)
 	intersectionz = z + dZY * diffy;
 	for (count = (int)intersectionx;
 	     count <= (int)intersectionx + (int)dXY; count++) {
-	  put_cBuffer_axes(count,'a');
-	  put_zBuffer(count,intersectionz);
+	  putCBufferAxes(count,'a');
+	  putZBuffer(count,intersectionz);
 	  intersectionz += dZX;
 	}
       } /* if edge intersects scanline */
     }
   } /* for each axes */
-
 }
 
-/********************************************
- * scanLines() scanline z-buffer algorithm  *
- * initialize z-buffer and color buffer for *
- * all scanlines.			    *
- ********************************************/
-
-void 
-scanLines(int dFlag)
-{
+@
+\subsection{scanLines}
+scanLines() scanline z-buffer algorithm initialize z-buffer and color
+buffer for all scanlines.
+\index{view3d!scanLines}
+\index{scanLines view3d}
+<<view3d>>=
+void scanLines(int dFlag) {
   unsigned long pixColor;
   int		i;
   char		tempA;
-
   if (dFlag == Xoption) {
     if (viewmap_valid) {
       XFreePixmap(dsply,viewmap);
@@ -20332,7 +14222,6 @@ scanLines(int dFlag)
     quadMesh[4].x = 0;	quadMesh[4].y = 0;
     PSFillPolygon(GC9991, quadMesh, 5);
   }
-
   if (graphWindowAttrib.height >= physicalHeight)
     graphWindowAttrib.height = physicalHeight - 1;
   if (graphWindowAttrib.width >= physicalWidth)
@@ -20342,9 +14231,7 @@ scanLines(int dFlag)
   else
     strcpy(control->message,"          Writing Output            ");
   writeControlMessage();
-
   scanline = graphWindowAttrib.height-1;
-
   imageX = XCreateImage(/* display */        dsply,
 			/* visual */         DefaultVisual(dsply,scrn),
 			/* depth */          DefaultDepth(dsply,scrn),
@@ -20356,15 +14243,13 @@ scanLines(int dFlag)
 			/* bitmap_pad */     32,
 			/* bytes_per_line */ 0);
   imageX->data = (char *)malloc(imageX->bytes_per_line);
-
-
   while (scanline >= 0 && keepDrawingViewport()) {
     /* initialize buffer values for scanline */
     pixColor = backgroundColor;
     for (i=0; i < (int)graphWindowAttrib.width; i++) {
-      put_zBuffer(i,10000.0);
-      put_cBuffer_indx(i,-1);
-      put_cBuffer_axes(i,'0');
+      putZBuffer(i,10000.0);
+      putCBufferIndx(i,-1);
+      putCBufferAxes(i,'0');
       if (mono || viewport->monoOn)
 	if ((scanline % 2) == 0)
 	  if ((i % 2) == 0) {
@@ -20384,19 +14269,16 @@ scanLines(int dFlag)
 	if (i>=0 && i<vwInfo.width) XPutPixel(imageX,i,0,backgroundColor);
       }
     }
-
     /* writes the axes info to the buffers */
     if (viewData.box) boxTObuffer();
     if (viewData.clipbox) clipboxTObuffer();
     if (viewport->axesOn) axesTObuffer();
-
     /* fill buffers for current scanline */
     scanPhong(dFlag);
-
     for (i=0; i < (int)graphWindowAttrib.width; i++) {
       /* include bounding region info */
       if (viewData.box) {
-	if (get_cBuffer_axes(i) == 'b') {
+	if (getCBufferAxes(i) == 'b') {
 	  if (dFlag==Xoption) {
 	    if (mono || (viewport->monoOn)) pixColor = foregroundColor;
 	    else pixColor = boxInline;
@@ -20409,7 +14291,7 @@ scanLines(int dFlag)
       }
       /* include clipping box info */
       if (viewData.clipbox) {
-	if (get_cBuffer_axes(i)== 'c') {
+	if (getCBufferAxes(i)== 'c') {
 	  if (dFlag==Xoption) {
 	    if (mono || (viewport->monoOn)) pixColor = foregroundColor;
 	    else pixColor = clipBoxInline;
@@ -20422,7 +14304,7 @@ scanLines(int dFlag)
       }
       /* include axes info */
       if (viewport->axesOn) {
-	if (get_cBuffer_axes(i) == 'a') {
+	if (getCBufferAxes(i) == 'a') {
 	  if (dFlag == Xoption) {
 	    if (mono || (viewport->monoOn)) pixColor = foregroundColor;
 	    else pixColor = monoColor(axesColor);
@@ -20432,48 +14314,41 @@ scanLines(int dFlag)
 	    GDrawPoint(viewport->viewWindow, GC9991, i,scanline,dFlag);
 	  }
 	} /* if buffer slot is an axes point */
-	tempA = get_cBuffer_axes(i);
+	tempA = getCBufferAxes(i);
       } else tempA = '0';  /* else axes not on */
 
-      if (get_cBuffer_indx(i) >= 0 && (tempA == '0')) {
+      if (getCBufferIndx(i) >= 0 && (tempA == '0')) {
 	if (dFlag == Xoption) {
-	  GSetForeground(trashGC,(float)get_cBuffer_indx(i),dFlag);
-	  pixColor = get_cBuffer_indx(i);
+	  GSetForeground(trashGC,(float)getCBufferIndx(i),dFlag);
+	  pixColor = getCBufferIndx(i);
 	  if (i >=0 && i<vwInfo.width) XPutPixel(imageX,i,0,pixColor);
 	}
 	else {
-	  GSetForeground(GC9991,(float)get_cBuffer_indx(i),dFlag);
+	  GSetForeground(GC9991,(float)getCBufferIndx(i),dFlag);
 	  GDrawPoint(viewport->viewWindow, GC9991, i,scanline,dFlag);
 	}
       }
     } /* for each pixel in scanline */
-
     if (dFlag == Xoption) {
       XPutImage(dsply,viewport->viewWindow,trashGC,imageX,0,0,0,
 		scanline,vwInfo.width,1);
       XPutImage(dsply,viewmap,trashGC,imageX,0,0,0,
 		scanline,vwInfo.width,1);
     }
-
     scanline--;
-
   } /* while each scanline */
   XDestroyImage(imageX);
-
 }
 
-/*************************************
- * void freePolyList();		     *
- *				     *
- * frees up the global scanList l-l  *
- *************************************/
-
-void
-freePolyList (void)
-{
+@
+\subsection{freePolyList}
+frees up the global scanList l-l
+\index{view3d!freePolyList}
+\index{freePolyList view3d}
+<<view3d>>=
+void freePolyList(void) {
   polyList *P, *nextP;
   int  i;
-
   for (i = 0; (i < ARRAY_HEIGHT); i++) {
     P = scanList[i];
     while((P != NIL(polyList))) {
@@ -20482,27 +14357,22 @@ freePolyList (void)
       P = nextP;
     }
   }
-
 } /* freePolyList() */
 
-
-/********************************************
- * showAxesLabels() writes the axes labels  *
- * onto the viewmap of a graph.		    *
- ********************************************/
-
-void 
-showAxesLabels(int dFlag)
-{
+@
+\subsection{showAxesLabels}
+showAxesLabels() writes the axes labels onto the viewmap of a graph.
+\index{view3d!showAxesLabels}
+\index{showAxesLabels view3d}
+<<view3d>>=
+void showAxesLabels(int dFlag) {
   int  xcoord2,ycoord2;
-
   if (dFlag == Xoption)
     if (mono || (viewport->monoOn))
       GSetForeground(globGC,(float)foregroundColor,dFlag);
     else
       GSetForeground(globGC,(float)monoColor(labelColor),dFlag);
   else GSetForeground(GC9991,psBlack,dFlag);
-
   /* axes label for X */
   if ((int)axesZ[0][0] >= (int)axesZ[0][2]) {
     if (axesXY[0][2] < axesXY[0][0]) xcoord2 = axesXY[0][2]-5;
@@ -20516,7 +14386,6 @@ showAxesLabels(int dFlag)
         GDrawString(GC9991,viewport->viewWindow,xcoord2,ycoord2,"X",1,dFlag); 
     }
   }
-
   /* axes label for Y */
   if ((int)axesZ[1][0] >= (int)axesZ[1][1]) {
     if (axesXY[1][2] < axesXY[1][0]) xcoord2 = axesXY[1][2]-5;
@@ -20530,7 +14399,6 @@ showAxesLabels(int dFlag)
        GDrawString(GC9991,viewport->viewWindow,xcoord2,ycoord2,"Y",1,dFlag);
     }
   }
-
   /* axes label for Z */
   if ((int)axesZ[2][0] >= (int)axesZ[2][1]) {
     if (axesXY[2][2] < axesXY[2][0]) xcoord2 = axesXY[2][2]-5;
@@ -20546,28 +14414,23 @@ showAxesLabels(int dFlag)
   }
 }
 
-
-
-/********************************************
- * changeColorMap() modifies the color map  *
- * for moving in and out of smooth shading. *
- ********************************************/
-
-void 
-changeColorMap(void)
-{
+@
+\subsection{makeTriangle}
+changeColorMap() modifies the color map for moving in and out of
+smooth shading.
+\index{view3d!makeTriangle}
+\index{makeTriangle view3d}
+<<view3d>>=
+void changeColorMap(void) {
   int	      okay, i, hue, *index;
   poly	      *cp;
   viewTriple  *pt;
-
   strcpy(control->message,"         Make New Color Map         ");
   writeControlMessage();
   if ((viewport->hueOffset == viewport->hueTop) &&
       !mono && !viewport->monoOn) {
-
      /* colormap is not an even distribution across spectrum */
      /* see spadcolors.c code to understand why this is done */
-
     if (viewport->hueTop < 11) smoothHue = viewport->hueTop * 6;
     else
       if (viewport->hueTop > 10 && viewport->hueTop < 16) {
@@ -20576,7 +14439,6 @@ changeColorMap(void)
       else {
 	smoothHue = viewport->hueTop*12 - 12;
       }
-
     if (redoColor) {
        /* reallocate colormap for new hue */
       redoColor = no;
@@ -20619,35 +14481,24 @@ changeColorMap(void)
   } /* else hueOffset != hueTop */
 }
 
-
-/***********************
- * void drawPhong()    *
- *		       *
- * A general routine   *
- * for displaying a    *
- * list of polygons    *
- * using a simple      *
- * scanline z-buffer   *
- * algorithm with      *
- * phong shading.      *
- ***********************/
-
-void
-drawPhong(int dFlag)
-{
-
+@
+\subsection{drawPhong}
+A general routine for displaying a list of polygons using a simple
+scanline z-buffer algorithm with phong shading.
+\index{view3d!drawPhong}
+\index{drawPhong view3d}
+<<view3d>>=
+void drawPhong(int dFlag) {
     poly	  *p, *head;
     polyList	  *s;
     int		  i,j,hue;
     int		  *anIndex, redo;
     viewTriple	  *aPoint, *polyPt;
-
     redo = (recalc || redoSmooth);
     if (redo || redoColor || redoDither) {
       rotated = no;  zoomed = no;  translated = no;
       switchedPerspective = no;	 changedEyeDistance = no;
       redoSmooth = no;	movingLight = no;
-
       /* If only a color change don't recalculate polygon info. */
       if (!redo) {
 	/* glossy shading if a single hue is indicated */
@@ -20655,7 +14506,6 @@ drawPhong(int dFlag)
 	scanLines(dFlag);
 	/* if axes are on then show axes labels */
 	if (viewport->axesOn) showAxesLabels(dFlag);
-
 	/* show pixmap of image */
 	XCopyArea(dsply,viewmap,viewport->viewWindow,trashGC,0,0,
 		  vwInfo.width,vwInfo.height,0,0);
@@ -20671,7 +14521,6 @@ drawPhong(int dFlag)
 	    strcpy(control->message,"         Collecting Polygons        ");
 	    writeControlMessage();
 	    quickList = copyPolygons(viewData.polygons);
-
 	    if (keepDrawingViewport()) {
 	      strcpy(control->message,"         Projecting Polygons        ");
 	      writeControlMessage();
@@ -20709,7 +14558,6 @@ drawPhong(int dFlag)
 		  writeControlMessage();
 		  p = head;
 		  while ((p != NIL(poly)) && keepDrawingViewport()) {
-
 		    for (j = 0, anIndex = p->indexPtr;
 			 j < p->numpts; j++, anIndex++) {
 		      polyPt = refPt3D(viewData,*(anIndex));
@@ -20730,14 +14578,15 @@ drawPhong(int dFlag)
 			polyPt->sc = (float)hue;
 		      } /* multi-color dither */
 		    } /* for each point in polygon */
-
 		    if ( ! ( p->partialClipPz ||
 			     p->totalClipPz   ||
-			     (viewData.clipStuff && (p->partialClip  || p->totalClip ) ) ) ) {
+			     (viewData.clipStuff && 
+                              (p->partialClip  || p->totalClip ) ) ) ) {
 		      /* put polygon in each scanline list it intersects */
 		      for (i=(int)p->pymin; i<= (int)p->pymax; i++) {
 			if ( (i>=0) && (i<ARRAY_HEIGHT ) ){
-			   s = (polyList *)saymem("smoothShade.c",1,sizeof(polyList));
+			   s = (polyList *)
+                                   saymem("smoothShade.c",1,sizeof(polyList));
 			   s->polyIndx = p;
 			   s->next = scanList[i];
 			   scanList[i] = s;
@@ -20746,17 +14595,13 @@ drawPhong(int dFlag)
 		    } /* if polygon not clipped */
 		    p = p->next;
 		  } /* while still polygons */
-
 		  scanLines(dFlag);
-
 		  /* if axes are on then show axes labels */
 		  if (viewport->axesOn) showAxesLabels(dFlag);
-
 		  /* show pixmap of image */
 		  XCopyArea(dsply,viewmap,viewport->viewWindow,trashGC,0,0,
 			  vwInfo.width,vwInfo.height,0,0);
 		  /* freePolyList(scanList);   */
-
 		} /* keepDrawingViewport() after setting extreme values */
 	      } /* keepDrawingViewport() after projecting all polygons */
 	    } /* keepDrawingViewport() after collecting polygons */
@@ -20765,7 +14610,6 @@ drawPhong(int dFlag)
 	finishedList = !(scanline>0);
 	if (firstTime) firstTime = no;
       } /* not only a color change */
-
     } else { /* else just redisplay current pixmap of image */
       XCopyArea(dsply,viewmap,viewport->viewWindow,trashGC,0,0,
 		vwInfo.width,vwInfo.height,0,0);
@@ -20773,187 +14617,52 @@ drawPhong(int dFlag)
     clearControlMessage();
     strcpy(control->message,viewport->title);
     writeControlMessage();
-
 } /* drawPhong */
 
 @
-\section{spadaction3d.c}
-<<view3d/spadaction3d.c>>=
-#define _SPADACTION3D_C
 
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-
-<<view3d/header.h>>
-<<view3d/process.h>>
-<<view3d/draw.h>>
-
-#include "util.h1"
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-int 
-readViewman (void *info,int size)
-{
+@
+\subsection{readViewman}
+\index{view3d!readViewman}
+\index{readViewman view3d}
+<<view3d>>=
+int readViewman(void *info,int size) {
   int m = 0;
-
   sprintf(errorStr,"%s","read from viewport manager\n");
   m = check(read( 0, info, size));   
-
   return(m);
-
 }
-void 
-scalePoint (viewTriple *p)
-{
 
+@
+\subsection{scalePoint}
+\index{view3d!scalePoint}
+\index{scalePoint view3d}
+<<view3d>>=
+void scalePoint(viewTriple *p) {
   p->x *= viewData.scaleToView;
   p->y *= viewData.scaleToView;
   p->z *= viewData.scaleToView;
-
   if (viewData.cmin != viewData.cmax)
     p->c = (p->c - viewData.cmin)/(viewData.cmax-viewData.cmin);
   if (p->c > 1.0) p->c = 1.0;
   else if (p->c < 0) p->c = 0.0;
-
 } /* scalePoint */
 
-  
-/********************
- * int spadAction() *
- ********************/
-
-int 
-spadAction (void)
-{
+@
+\subsection{spadAction}
+\index{view3d!spadAction}
+\index{spadAction view3d}
+<<view3d>>=
+int spadAction(void) {
   int code, viewCommand;
   float f1, f2, f3;
   int i1, i2, i3;
-
-
   if (viewAloned==yes) {
       close(0);
       return(-1);
       }
   readViewman(&viewCommand, intSize);
-
   switch (viewCommand) {
-
   case rotate:
     readViewman(&f1, floatSize);	
     readViewman(&f2, floatSize);
@@ -20968,19 +14677,15 @@ spadAction (void)
     spadDraw=yes;
     rotated=yes; 
     viewport->yzOn = viewport->xzOn = viewport->xyOn = no;
-
     break;
-
   case zoom:
     readViewman(&f1, floatSize);	
     viewport->scale = f1;
     if (viewport->scale > maxScale) viewport->scale = maxScale;
     else if (viewport->scale < minScale) viewport->scale = minScale;          
-
     spadDraw=yes;
     zoomed = yes; 
     break;
-
   case zoomx:
     readViewman(&f1, floatSize);	
     readViewman(&f2, floatSize);	
@@ -21007,11 +14712,9 @@ spadAction (void)
         else if (viewport->scaleZ < minScale) viewport->scaleZ = minScale;
       }
     }
-          
     spadDraw=yes;
     zoomed = yes; 
     break;
-
   case translate:
     readViewman(&(viewport->deltaX),floatSize);
     readViewman(&(viewport->deltaY),floatSize);
@@ -21022,7 +14725,6 @@ spadAction (void)
     spadDraw=yes;
     translated = yes; 
     break;
-
   case modifyPOINT:
     readViewman(&i1,intSize);
     i1--;
@@ -21033,7 +14735,6 @@ spadAction (void)
     scalePoint(refPt3D(viewData,i1));
     spadDraw=yes;
     break;
-    
   case hideControl:
     readViewman(&i1,intSize);
     if (i1) {                         /* show control panel */
@@ -21047,7 +14748,6 @@ spadAction (void)
       }
     }
     break;
-
   case axesOnOff:
     readViewman(&i1,intSize);
     viewport->axesOn = i1;
@@ -21058,17 +14758,14 @@ spadAction (void)
     }
     if (viewport->haveControl) drawControlPanel();
     break;
-
 /* Non-uniform scaling is not in Axiom yet. */
 /* Neither is object or origin rotation. */
-
   case perspectiveOnOff:
     readViewman(&i1,intSize);
     viewData.perspective = i1;
     switchedPerspective = yes;
     spadDraw=yes;
     break;
-
   case region3D:
     readViewman(&i1,intSize);
     viewport->regionOn = i1;
@@ -21077,19 +14774,16 @@ spadAction (void)
     if (viewport->haveControl) drawControlPanel();
     redoSmooth = yes; 
     break;
-
   case clipRegionOnOff:
     readViewman(&i1,intSize);
     viewData.clipbox = i1;
     spadDraw=yes;
     break;
-
   case clipSurfaceOnOff:
     readViewman(&i1,intSize);
     viewData.clipStuff = i1;
     spadDraw=yes;
     break;
-
   case eyeDistanceData:
     readViewman(&f1,floatSize);
     viewData.eyeDistance = f1;
@@ -21100,14 +14794,12 @@ spadAction (void)
     spadDraw=yes;
     changedEyeDistance = yes; 
     break;
-
   case hitherPlaneData:
     readViewman(&f1,floatSize);
     viewData.clipPlane = f1;
     spadDraw=yes;
     changedEyeDistance = yes;
     break;
-
   case colorDef:
     readViewman(&(viewport->hueOffset),intSize);
     readViewman(&(viewport->numberOfHues),intSize);
@@ -21129,19 +14821,15 @@ spadAction (void)
     }
     if (viewport->haveControl) drawColorMap();
     break;
-
   case closeAll:
     code = check(write(Socket,&ack,intSize));
     goodbye(-1);
-    
-
   case moveViewport:
     readViewman(&i1,intSize);
     readViewman(&i2,intSize);
     XMoveWindow(dsply,viewport->titleWindow,i1,i2);
     XSync(dsply,0);
     break;
-
  case resizeViewport:
     readViewman(&i1,intSize);
     readViewman(&i2,intSize);
@@ -21150,7 +14838,6 @@ spadAction (void)
     spadDraw=yes;
     redoSmooth =yes; 
     break;
-
   case transparent:
   case opaqueMesh:
   case render:
@@ -21159,7 +14846,6 @@ spadAction (void)
     spadDraw=yes;
     redoSmooth =yes; 
     break;
-
   case lightDef:
     readViewman(&(viewport->lightVector[0]),floatSize);
     readViewman(&(viewport->lightVector[1]),floatSize);
@@ -21169,7 +14855,6 @@ spadAction (void)
     drawLightingAxes();
     XSync(dsply,0);
     break;
-
   case translucenceDef:
     readViewman(&backLightIntensity,floatSize);
     tempLightIntensity = backLightIntensity;
@@ -21178,7 +14863,6 @@ spadAction (void)
     drawLightTransArrow();
     XSync(dsply,0);
     break;
-
   case changeTitle:
     readViewman(&i1,intSize);
     readViewman(viewport->title,i1);
@@ -21198,7 +14882,6 @@ spadAction (void)
     } /* switch */      
     XFlush(dsply);
     break;
-
   case writeView:
     readViewman(&i1,intSize);
     readViewman(filename,i1);
@@ -21213,7 +14896,6 @@ spadAction (void)
     if (writeViewport(i3) < 0)
       fprintf(stderr,"          Nothing was written\n");
     break;
-
   case diagOnOff:
     readViewman(&i1,intSize);
     if (viewData.outlineRenderOn) {
@@ -21224,7 +14906,6 @@ spadAction (void)
       writeControlMessage();
     }
     break;
-
   case outlineOnOff:
     readViewman(&i1,intSize);
     if (viewData.style == render) {
@@ -21236,7 +14917,6 @@ spadAction (void)
       writeControlMessage();
     }
     break;
-
   case spadPressedAButton:
     readViewman(&i1,intSize);
     buttonAction(i1);
@@ -21244,285 +14924,58 @@ spadAction (void)
   default:
     return(-1);
   } /* switch */
-
-
   ack++;
   code = check(write(Socket,&ack,intSize));
   return(0);
-
 }
 
-
-@
-\section{static.h}
-<<view3d/static.h>>=
- /* This is a description of script character labels for the 
-    x, y, and z axes */
-
-static float axes[3][6] = {{-117,0,0,117,0,0},     /* x axis */
-			   {0,-117,0,0,117,0},     /* y axis */
-			   {0,0,-117,0,0,117}};    /* z axis */
-
-/* text labels are currently used */
-static float labels[basicScreen][7] = {
-  {105,0,4,106,0,3,labelColor},     /* script x label - 4 segments */
-  {106,0,3,112,0,10,labelColor},
-  {112,0,10,114,0,9,labelColor},
-  {106,0,10,113,0,3,labelColor},
-  {0,106,9,0,107,10,labelColor},    /* script y label - 7 segments */
-  {0,107,10,0,107,6,labelColor},
-  {0,107,6,0,113,5,labelColor},
-  {0,113,10,0,113,-3,labelColor},
-  {0,113,-3,0,111,-5,labelColor},
-  {0,111,-5,0,110,-1,labelColor},
-  {0,110,-1,0,114,3,labelColor},
-  {0,5,114,0,6,115,labelColor},     /* script z label - 8 segments */
-  {0,6,115,0,11,116,labelColor},
-  {0,11,116,0,12,113,labelColor},
-  {0,12,113,0,10,111,labelColor},
-  {0,10,111,0,11,110,labelColor},
-  {0,11,110,0,11,103,labelColor},
-  {0,11,103,0,9,102,labelColor},
-  {0,9,102,0,9,105,labelColor}};  
 @
-\section{stuff3d.c}
-<<view3d/stuff3d.c>>=
-#define _STUFF3D_C
-
-<<view3d/header.h>>
-
-#include  <stdlib.h>
-#include  <unistd.h>
-#include  <math.h>
-
-
-
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-/*#include "spadcolors.h"*/
-#include "util.h1"
-
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-/*****************************
- ***      traverse(n)      ***
- *** returns the nth point ***
- *** in a point resevoir   ***
- *****************************/
-
-viewTriple *
-traverse (int n)
-{
-
+\subsection{traverse}
+Returns the nth point in a point resevoir.
+\index{view3d!traverse}
+\index{traverse view3d}
+<<view3d>>=
+viewTriple *traverse(int n) {
   int i;
   viewTriple *v;
-
   v = splitPoints;
   for (i=0; i<n; i++) v = v->next;
   return(v);
-
 } /* traverse */
 
-
-/**************************/
-/***  float absolute(x) ***/
-/**************************/
-
-float
-absolute (float x)
-{
-
+@
+\subsection{absolute}
+\index{view3d!absolute}
+\index{absolute view3d}
+<<view3d>>=
+float absolute(float x) {
   if (x<0.0) return(-x);
   else return(x);
-
 }
 
-
-
-
-/****************************/
-/***  float get_random(x) ***/
-/****************************/
-
-float
-get_random(void)
-{
-
+@
+\subsection{getRandom}
+\index{view3d!getRandom}
+\index{getRandom view3d}
+<<view3d>>=
+float getRandom(void) {
   float x;
-
   x = (float)(rand() % 100);
   return(x);
-
 }
 
-
-
-
-/****************************/
-/***   float norm_dist()  ***/
-/****************************/
-
-triple
-norm_dist(void)
-{
-
+@
+\subsection{normDist}
+\index{view3d!normDist}
+\index{normDist view3d}
+<<view3d>>=
+triple normDist(void) {
   float   u1, u2, v1, v2, ss, rad;
-  triple  pert;
-
+  triple  pert  = {0,0,0};
   ss = 2.0;
   while (ss >= 1.0) {
-    u1 = get_random()/100.0;
-    u2 = get_random()/100.0;
+    u1 = getRandom()/100.0;
+    u2 = getRandom()/100.0;
     v1 = 2.0*u1 - 1.0;  v2 = 2.0*u2 - 1.0;
     ss = v1*v1 + v2*v2;
   }
@@ -21530,234 +14983,35 @@ norm_dist(void)
   rad = -2.0*log(ss)/ss;
   pert.x = v1 * sqrt(rad);
   pert.y = v2 * sqrt(rad);    
-
   return(pert);
 }
 
-
-
-/************************/
-/***  void goodbye()  ***/
-/************************/
-
-void
-goodbye(int sig)
-{
-
+@
+\subsection{goodbye}
+\index{view3d!goodbye}
+\index{goodbye view3d}
+<<view3d>>=
+void goodbye(int sig) {
   int Command;
-
   PSClose(); /* free PS file and data structure space */
-
   if (pixelSetFlag) FreePixels(dsply,colorMap,smoothConst);
   if (!viewAloned) {
      Command = viewportClosing;
      check(write(Socket,&Command,intSize));
      }
-
   XCloseDisplay(dsply);
   exit(0);
 }           /* goodbye */
 
-
-
 @
-\section{surface3d.c}
-<<view3d/surface3d.c>>=
-#define _SURFACE3D_C
-
-#include <string.h>
-#include <math.h>
-#include <stdlib.h>
-
-<<view3d/header.h>>
-<<view3d/draw.h>>
-#define spadActionMode
-/* define spadEventMode */
-#define components
-#include "com.h"
-
-#include "xspadfill.h1"
-#include "xshade.h1"
-#include "util.h1"
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-
-  /**** useful defines ****/
-
-#define precisionFactor 1024
-
-/* depthChecker turns on the extensive depth checking mechanisms
-   for the depth sort algorithm. Without it, the hidden surface
-   removal is just a sort by z which works remarkably well, but,
-   is insufficient and, at times, may end up being incorrect */
-#define depthChecker
-
-
-pointInfo ptIA, ptIB, ptIC; /* global to this file */
-
-/************************************
- * void drawLineComponent(p,dFlag)  *
- ************************************/
-
-void
-drawLineComponent (poly * p, int dFlag)
-{
+\subsection{drawLineComponent}
+\index{view3d!drawLineComponent}
+\index{drawLineComponent view3d}
+<<view3d>>=
+void drawLineComponent(poly * p, int dFlag) {
   int i, hue;
   int *anIndex;
   RGB col_rgb;
-
   /* If the polygon is clipped against the hither plane (clipPz) then
      it is not drawn...or...if the clipStuff is set to true, and
      the polygon is clipped against the user defined clip volume, it
@@ -21771,7 +15025,6 @@ drawLineComponent (poly * p, int dFlag)
       quadMesh[i].x = refPt3D(viewData,*anIndex)->px;
       quadMesh[i].y = refPt3D(viewData,*anIndex)->py;
     }
-
     if (dFlag==Xoption) {
       if (mono || viewport->monoOn)
 	GSetForeground(opaqueGC, (float)foregroundColor, dFlag);
@@ -21781,7 +15034,6 @@ drawLineComponent (poly * p, int dFlag)
       }
     } else
       GSetForeground(opaqueGC, psBlack, dFlag);
-
     if (dFlag==PSoption && !mono && !viewport->monoOn) {
       hue = getHue(p->color);
       col_rgb = hlsTOrgb((float)hue,0.5,0.8);
@@ -21795,48 +15047,37 @@ drawLineComponent (poly * p, int dFlag)
   }
 }
 
-
-
-/**************************************************
- * void drawOpaquePolygon(p,aGC,anotherGC)	  *
- **************************************************/
-
-void
-drawOpaquePolygon (poly *p,GC aGC,GC anotherGC,int dFlag)
-{
-
+@
+\subsection{drawOpaquePolygon}
+\index{view3d!drawOpaquePolygon}
+\index{drawOpaquePolygon view3d}
+<<view3d>>=
+void drawOpaquePolygon(poly *p,GC aGC,GC anotherGC,int dFlag) {
   int *anIndex, i, hue, isNaN = 0;
   RGB col_rgb;
-
   if (mono || viewport->monoOn) {
     GSetForeground(anotherGC, (float)foregroundColor, dFlag);
   } else {
     hue = hueValue(p->color);
     GSetForeground(anotherGC, (float)XSolidColor(hue,2), dFlag);
   }
-
   /* If the polygon is clipped against the hither plane (clipPz) then
      it is not drawn, or if the clipStuff is set to true, and
      the polygon is clipped against the user defined clip volume, it
      is also not drawn. */
-
   if (!((p->partialClipPz) || (viewData.clipStuff && (p->partialClip)))) {
-
     /* This routine should eventually only be skipped if
        p->totalClip is true and another routine would
        handle the partialClip. This routine would handle
        only those polygons without any clipped points. */
-
     for (i=0, anIndex=p->indexPtr; i<p->numpts; i++,anIndex++) {
       quadMesh[i].x = refPt3D(viewData,*anIndex)->px;
       quadMesh[i].y = refPt3D(viewData,*anIndex)->py;
       if (eqNANQ(quadMesh[i].x) || eqNANQ(quadMesh[i].y)) isNaN = 1;
     }
-
     quadMesh[i].x =refPt3D(viewData,*(p->indexPtr))->px;
     quadMesh[i].y =refPt3D(viewData,*(p->indexPtr))->py;
     if (eqNANQ(quadMesh[i].x) || eqNANQ(quadMesh[i].y)) isNaN = 1;
-
     if (dFlag==PSoption && !mono && !viewport->monoOn && !isNaN) {
       GSetForeground(GC9991, (float)backgroundColor, PSoption);
       PSFillPolygon(GC9991, quadMesh, p->numpts+1);
@@ -21869,22 +15110,15 @@ drawOpaquePolygon (poly *p,GC aGC,GC anotherGC,int dFlag)
   }   /* if not totally clipped */
 }
 
-
-
-/*************************************
- * poly *copyPolygons(polygonList)   *
- *				     *
- * copies the given list of polygons *
- * into a newly allocated list	     *
- *************************************/
-
-poly *
-copyPolygons (poly *polygonList)
-{
-
+@
+\subsection{copyPolygons}
+Copies the given list of polygons into a newly allocated list
+\index{view3d!copyPolygons}
+\index{copyPolygons view3d}
+<<view3d>>=
+poly *copyPolygons(poly *polygonList) {
   int i;
   poly *aPoly,*retval,*prev;
-
   prev = retval = aPoly = (poly *)saymem("surface.c",1,sizeof(poly));
   aPoly->indexPtr = (int *)saymem("surface.c",
 				  polygonList->numpts,sizeof(int));
@@ -21952,23 +15186,15 @@ copyPolygons (poly *polygonList)
   return(retval);
 }
 
-
-/******************************
- * void minMaxPolygons(aPoly) *
- *			      *
- * sets up the xmin,	      *
- * etc, for each polygon      *
- * for sorting and	      *
- * extent checking.	      *
- ******************************/
-
-void
-minMaxPolygons (poly *aPoly)
-{
-
+@
+\subsection{minMaxPolygons}
+Sets up the xmin, etc, for each polygon for sorting and extent checking.
+\index{view3d!minMaxPolygons}
+\index{minMaxPolygons view3d}
+<<view3d>>=
+void minMaxPolygons(poly *aPoly) {
   int *anIndex;
   int i;
-
   for (; aPoly != NIL(poly); aPoly = aPoly->next) {
     anIndex = aPoly->indexPtr;
     aPoly->pxmin = aPoly->pxmax = refPt3D(viewData,*anIndex)->px;
@@ -21990,7 +15216,6 @@ minMaxPolygons (poly *aPoly)
 	aPoly->pzmin = refPt3D(viewData,*anIndex)->pz;
       else if (refPt3D(viewData,*anIndex)->pz > aPoly->pzmax)
 	aPoly->pzmax = refPt3D(viewData,*anIndex)->pz;
-
       if (refPt3D(viewData,*anIndex)->x < aPoly->xmin)
 	aPoly->xmin = refPt3D(viewData,*anIndex)->x;
       else if (refPt3D(viewData,*anIndex)->x > aPoly->xmax)
@@ -22007,81 +15232,56 @@ minMaxPolygons (poly *aPoly)
   }
 }  /* minMaxPolygons */
 
-
-
-/***********************************
- * int polyCompare (p1,p2) *
- *				   *
- * returns -1 if p1 < p2	   *
- *	    0 if p1 = p2	   *
- *	    1 if p1 > p2	   *
- * note that this is the reverse   *
- * of what the msort requested.	   *
- * this is so that the list will   *
- * be sorted from max to min.	   *
- ***********************************/
-
-int
-polyCompare (poly *p1,poly *p2)
-{
-
+@
+\subsection{polyCompare}
+\begin{verbatim}
+returns -1 if p1 < p2
+         0 if p1 = p2
+         1 if p1 > p2
+\end{verbatim}
+Note that this is the reverse of what the msort requested.
+This is so that the list will be sorted from max to min.
+\index{view3d!polyCompare}
+\index{polyCompare view3d}
+<<view3d>>=
+int polyCompare(poly *p1,poly *p2) {
   if (p1->pzmax > p2->pzmax) return(-1);
   else if (p1->pzmax < p2->pzmax) return(1);
   else return(0);
 }
 
-/***********************
- * void calcEyePoint() *
- *		       *
- * sets the global     *
- * variable eyePoint[] *
- * to where the viewer *
- * is pointed towards  *
- ***********************/
-
-void
-calcEyePoint (void)
-{
-
+@
+\subsection{makeTriangle}
+Sets the global variable eyePoint[] to where the viewer is pointed towards.
+\index{view3d!makeTriangle}
+\index{makeTriangle view3d}
+<<view3d>>=
+void calcEyePoint(void) {
   eyePoint[0] = sinPhi * (sinTheta);
   eyePoint[1] = sinPhi * (-cosTheta);
   eyePoint[2] = cosPhi;
-
 }
 
-
-
-/*
- void drawPolygons()
- A general routine for displaying a list of polygons 
- with the proper hidden surfaces removed. Assumes the 
- list of polygons is in viewData.polygons. Needs a 
- routine to split intersecting polygons in object space.	       *
- */
-
-
-/**************************************
- * void drawRenderedPolygon(p,dFlag)  *
- *				      *
- * calculate the color for the	      *
- * polygon p and draw it	      *
- **************************************/
-
-void
-drawRenderedPolygon (poly *p,int dFlag)
-{
-
+@
+\subsection{makeTriangle}
+A general routine for displaying a list of polygons 
+with the proper hidden surfaces removed. Assumes the 
+list of polygons is in viewData.polygons. Needs a 
+routine to split intersecting polygons in object space.
+Calculate the color for the polygon p and draw it.
+\index{view3d!makeTriangle}
+\index{makeTriangle view3d}
+<<view3d>>=
+void drawRenderedPolygon(poly *p,int dFlag) {
   int	     i,hue,shade, isNaN = 0;
   float	     whichSide,H[3],P[3],LN,HN,diff,spec,tempLight,lumens,E[3],N[3];
   int	     *anIndex, *indx;
-  RGB	     col_rgb;
-
+  RGB	     col_rgb = {0.0,0.0,0.0};
   if (!((p->partialClipPz) || (viewData.clipStuff && (p->partialClip)))) {
       /* This routine should eventually only be skipped if
 	 p->totalClip is true and another routine would
 	 handle the partialClip. This routine would handle
 	 only those polygons without any clipped points. */
-
     for (i=0, anIndex=p->indexPtr; i<p->numpts; i++,anIndex++) {
       quadMesh[i].x = refPt3D(viewData,*anIndex)->px;
       quadMesh[i].y = refPt3D(viewData,*anIndex)->py;
@@ -22104,7 +15304,6 @@ drawRenderedPolygon (poly *p,int dFlag)
 	      refPt3D(viewData,*(indx+1))->wz +
 	      refPt3D(viewData,*(indx+2))->wz);
       normalizeVector(P);
-
       N[0] = p->N[0];  N[1] = p->N[1];  N[2] = p->N[2];
       normalizeVector(eyePoint);
       E[0] = 4.0*eyePoint[0] - P[0];
@@ -22117,7 +15316,6 @@ drawRenderedPolygon (poly *p,int dFlag)
 	   N[2]*viewport->lightVector[2];
       if (LN < 0.0) LN = -LN;
       diff = LN*Cdiff;
-
       if (LN > 0.0) {
         H[0] = E[0] + viewport->lightVector[0];
         H[1] = E[1] + viewport->lightVector[1];
@@ -22128,7 +15326,6 @@ drawRenderedPolygon (poly *p,int dFlag)
         spec = pow((double)absolute(HN),coeff);
         if (spec > 1.0) spec = 1.0;
       }
-
       lumens = ((Camb + 0.15) + diff + spec*Cspec);
       if (lumens > 1.0) lumens = 1.0;
       if (lumens < 0.0) lumens = 0.0;
@@ -22149,13 +15346,10 @@ drawRenderedPolygon (poly *p,int dFlag)
         } else
 	  whichSide = lumens*(totalShades-1);
       }
-
       tempLight = lightIntensity;
       if (lightIntensity < Camb) lightIntensity = Camb;
-
       shade = floor(lightIntensity * absolute(whichSide));
       lightIntensity = tempLight;
-
       if (shade < totalShades) {
 	/* shade < totalShades is (temporarily) necessary here
 	   because, currently, parameterizations for things like
@@ -22165,7 +15359,6 @@ drawRenderedPolygon (poly *p,int dFlag)
 	   would be undefined (since coincidental points would create
 	   a zero vector) and the shade would be large, hence,
 	   the conditional.  */
-
         if (mono || viewport->monoOn) {
 	  if (dFlag == Xoption) {
   	    XChangeShade(dsply,maxGreyShade-shade-1);
@@ -22175,7 +15368,8 @@ drawRenderedPolygon (poly *p,int dFlag)
 	  else if (dFlag == PSoption) { /* renderGC has number 9991 
 				     (see main.c, header.h) */
   	    GSetForeground(GC9991,
-			   1.0-(float)(maxGreyShade-shade-1)*psShadeMul,PSoption);
+			   1.0-(float)(maxGreyShade-shade-1)*psShadeMul,
+                           PSoption);
 	    PSFillPolygon(GC9991, quadMesh, p->numpts+1);
   	  }
         } else { /* not mono */
@@ -22187,7 +15381,6 @@ drawRenderedPolygon (poly *p,int dFlag)
   	  else if (dFlag == PSoption)  /* draws it out in monochrome  */
 	    PSColorPolygon(col_rgb.r,col_rgb.g,col_rgb.b,quadMesh,p->numpts+1);
         }	 /* if mono-else */
-
         if (viewData.outlineRenderOn) {
 	  if (viewport->diagonals) {
 	    if (dFlag == PSoption) {
@@ -22211,36 +15404,30 @@ drawRenderedPolygon (poly *p,int dFlag)
     } /* if not NaN */
     if (dFlag == Xoption) XMapWindow(dsply,viewport->viewWindow);
   }  /* if not clipped */
-
 } /* drawRenderedPolygon */
 
-
-void 
-freePointResevoir(void)
-{
-
+@
+\subsection{freePointResevoir}
+\index{view3d!freePointResevoir}
+\index{freePointResevoir view3d}
+<<view3d>>=
+void freePointResevoir(void) {
   viewTriple *v;
-
   while (splitPoints != NIL(viewTriple)) {
     v = splitPoints;
     splitPoints = splitPoints->next;
     free(v);
   }
-
 } /* freePointResevoir */
 
-/***********************************
- * void freeListOfPolygons(pList); *
- *				   *
- * frees up a list of polygons.	   *
- ***********************************/
-
-void
-freeListOfPolygons (poly *pList)
-{
-
+@
+\subsection{freeListOfPolygons}
+Frees up a list of polygons.
+\index{view3d!freeListOfPolygons}
+\index{freeListOfPolygons view3d}
+<<view3d>>=
+void freeListOfPolygons(poly *pList) {
   poly *nextP;
-
   for (; pList != NIL(poly); pList=nextP) {
     nextP=pList->next;
     free(pList->indexPtr);
@@ -22248,18 +15435,16 @@ freeListOfPolygons (poly *pList)
   }
 } /* freeListOfPolygons() */
 
-
-
-void
-drawPolygons(int dFlag)
-{
-
+@
+\subsection{drawPolygons}
+\index{view3d!drawPolygons}
+\index{drawPolygons view3d}
+<<view3d>>=
+void drawPolygons(int dFlag) {
   poly *p,*head;
   poly *tempQuick=NULL;
   int quickFirst=yes;
-
   if (recalc) {
-
     /* To get around multiple X Expose events the server tends
        to send upon startup, leave negation of firstTime to the end. */
     rotated = no;
@@ -22268,7 +15453,6 @@ drawPolygons(int dFlag)
     switchedPerspective = no;
     changedEyeDistance = no;
     redoSmooth = yes;
-
     if (keepDrawingViewport()) {
       if (!firstTime) {
 	strcpy(control->message,"          Creating Polygons         ");
@@ -22279,7 +15463,6 @@ drawPolygons(int dFlag)
       strcpy(control->message,"         Collecting Polygons        ");
       writeControlMessage();
       quickList = copyPolygons(viewData.polygons);
-
       if (keepDrawingViewport()) {
 	/* to get normal facing outside info	*/
 	strcpy(control->message,"         Projecting Polygons        ");
@@ -22296,11 +15479,9 @@ drawPolygons(int dFlag)
 	    if (keepDrawingViewport()) {
 	      calcEyePoint();
 	      head = p = quickList;
-
 	      clearControlMessage();
 	      strcpy(control->message,viewport->title);
 	      writeControlMessage();
-
 	      if (viewData.scaleDown) {
 		if (keepDrawingViewport()) {
 		  for (p=quickList;
@@ -22338,7 +15519,6 @@ drawPolygons(int dFlag)
 		  }
 		}
 	      }
-
 	      if (!quickFirst) {
 		/* append the rest of the polygons onto the list */
 		tempQuick->next = head;
@@ -22389,911 +15569,70 @@ drawPolygons(int dFlag)
   }
 } /* drawPolygons */
 
-
-
-
-
-
-
-/**************************
- * int lessThan(x,y)	  *
- * int greaterThan(x,y)	  *
- * int equal(x,y)	  *
- *			  *
- * Compares two floating  *
- * point numbers for	  *
- * precision of up to one *
- * place in a thousand.	  *
- * returns		  *
- *    1 if true		  *
- *    o otherwise	  *
- **************************/
-
-int
-lessThan (float x,float y)
-{
+@
+\subsection{lessThan}
+Compares two floating point numbers for	precision of up to one
+place in a thousand. Returns 1 if true 0 otherwise.
+\index{view3d!lessThan}
+\index{lessThan view3d}
+<<view3d>>=
+int lessThan(float x,float y) {
   int xI,yI;
-
   xI = x*precisionFactor;
   yI = y*precisionFactor;
   return(xI<yI);
 }
 
-int
-greaterThan (float x,float y)
-{
+@
+\subsection{greaterThan}
+Compares two floating point numbers for	precision of up to one
+place in a thousand. Returns 1 if true 0 otherwise.
+\index{view3d!greaterThan}
+\index{greaterThan view3d}
+<<view3d>>=
+int greaterThan(float x,float y) {
   int xI,yI;
-
   xI = x*precisionFactor;
   yI = y*precisionFactor;
   return(xI>yI);
 }
 
-int
-isNaN (float v)
-{
+@
+\subsection{isNaN}
+\index{view3d!isNaN}
+\index{isNaN view3d}
+<<view3d>>=
+int isNaN(float v) {
   return (v != v);
 }
 
-
-int
-isNaNPoint (float x,float y,float z)
-{
+@
+\subsection{isNaNPoint}
+\index{view3d!isNaNPoint}
+\index{isNaNPoint view3d}
+<<view3d>>=
+int isNaNPoint(float x,float y,float z) {
   return (isNaN(x) || isNaN(y) || isNaN(z));
 }
 
-int
-equal (float x,float y)
-{
+@
+\subsection{equal}
+\index{view3d!equal}
+\index{equal view3d}
+<<view3d>>=
+int equal(float x,float y) {
   int xI,yI;
-
   xI = x*precisionFactor;
   yI = y*precisionFactor;
   return(xI==yI);
 }
 
 @
-\section{testcol.c}
-<<view3d/testcol.c>>=
-#define _MAIN3D_C
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <signal.h>
-#include <math.h>
-
-<<view3d/header.h>>
-<<view3d/cpanel.h>>
-<<view3d/process.h>>
-#include "bsdsignal.h"
-
-#include "bsdsignal.h1"
-#include "util.h1"
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-#include "xspadfill.h1"
-#include "xshade.h1"
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-<<include/purty/spadbitmap.bitmap>>
-<<include/purty/spadmask.mask>>
-
-viewPoints      *viewport;
-GCptr           GChead=NULL;    /* ptr to head of ps GC linked list */
-char            *PSfilename;    /* output file name used in user directory */
-int             psInit=no;      /* need to call globaInitPs() each run */
-char            *envAXIOM;      /* used for ps file paths */
-int             maxGreyShade=0;
-GC              globalGC1, globalGC2, anotherGC, globGC, trashGC,
-                controlMessageGC, lightingGC, volumeGC, quitGC, processGC,
-                saveGC, graphGC, componentGC, opaqueGC, renderGC;
-unsigned long   foregroundColor, backgroundColor;  
-int             Socket=1, ack=1;
-Colormap        colorMap;
-viewTriple      *splitPoints;
-Display         *dsply;
-int             scrn;
-Window          rtWindow;
-HashTable       *table;
-int             mono, totalColors, totalSolid, totalDithered, totalHues, 
-                totalSolidShades, totalDitheredAndSolids,totalShades;
-XFontStruct     *globalFont, *buttonFont, *headerFont, *titleFont, *graphFont,
-                *lightingFont, *volumeFont, *quitFont, *saveFont,*serverFont;
-XGCValues       gcVals;
-unsigned long * spadColors;
-float           transform[4][4], transform1[4][4],
-                R[4][4], R1[4][4], S[4][4], T[4][4], I[4][4];
-float           A[4][4], B[4][4], D[4], E[4][4], F[4], array[4][4];
-
-int             followMouse=no,
-                viewportKeyNum=0;
-                                 /**********************/
-                                 /** global variables **/
-                                 /**********************/
-
-char            scaleReport[5];
-char            deltaXReport[5], deltaYReport[5];
-XSizeHints      viewSizeHints;
-
-GC              processGC;
-viewPoints      *viewport;
-controlPanelStruct      *control;
-char            *s;
-int             someInt;  
-
-/* check /usr/include/X11 for current implementation of
-   pixels (e.g. BlackPixel()) */
-
-           /** totalShades is initially set to totalShadesConst.
-               If X cannot allocate 8 shades for each hue, total-
-               Shades is decremented. there is currently only a check for
-               this value to be positive. --> something to add: change over 
-               to monochrome if totalShades=0. just modify the spadcolors.c
-               file. spadcolors.c has been modified so that it returns the
-               value for totalShades. since the return value had previously
-               been unused, a modification in this way ensures continued
-               support of other routines calling this function (e.g.
-               hypertex stuff). **/
-
-
-int             drawMore;
-
-int             spadMode=no,            /* yes if receiving Axiom command and
-                                           calling drawViewport */
-                spadDraw=no;            /* yes if drawing viewport for 
-                                           an Axiom command */
-int             spadSignalReceived=0;  /* yes if current state is a result of
-                                           a signal from Axiom */
-int             inNextEvent=no;         /* true just before a call to
-					   XNextEvent */
-jmp_buf         jumpFlag;
-
-char            errorStr[80];
-
-view3DStruct    viewData;
-
-Window          quitWindow, saveWindow;
-
-                /** variables below assume only one viewport per process **/
-
-Window          lightingWindow, lightingAxes;
-float           lightPointer[3], tempLightPointer[3];
-                
-int             axesXY[3][4];
-float           axesZ[3][2];
-
-float           lightIntensity=1.0, tempLightIntensity;
-float           backLightIntensity = 1.0;
-
-                /** used for writing viewport info out to a file **/
-char            filename[256];
-
-
-                /** used for draw viewport routines */
-float           sinTheta, sinPhi, cosTheta, cosPhi, viewScale, 
-                viewScaleX, viewScaleY, viewScaleZ, reScale;
-int             xCenter, yCenter;
-
-XWindowAttributes       vwInfo;
-XWindowAttributes	graphWindowAttrib;
-
-XPoint          *quadMesh;
-XImage          *imageX;
-int             *xPts;   /* pointer to projected points (x followed by y) */
-float           transform[4][4], transform1[4][4],
-                R[4][4], R1[4][4], S[4][4], T[4][4], I[4][4];
-float           A[4][4], B[4][4], D[4], E[4][4], F[4], array[4][4];
-                
-
-int             scanline, polyCount;
-polyList        *scanList[ARRAY_HEIGHT];
-float           xleft = (float)0 ,xright = (float)ARRAY_WIDTH;
-
-colorBuffer      cBuffer[ARRAY_WIDTH];
-float            zBuffer[ARRAY_WIDTH];
-
-float           zC, dzdx, lum, point_norm[3];
-float           intersectColor[2], dcolor;
-triple          dpt, dnorm;
-
-                /** eyePoint **/
-float           eyePoint[3];
-
-                /** tube stuff **/
-XPoint          polygonMesh[20];
-
-                /* bypass the hidden surface algorithm if no rotations, etc */
-int             saveFlag=no;
-int             firstTime=yes, noTrans = yes, startup = yes;
-int             redrawView = no;   /* set to yes when returning from
-				      subpanels */
-int             redoColor = no, pixelSetFlag = no, redoDither = no;
-int             redoSmooth = no, multiColorFlag = no;
-
-/* In order to set recalc to true (see draw.h) */
-int             finishedList=no, zoomed=yes, translated = yes,
-                changedIntensity, movingLight = no, writeImage = no,
-                rotated=yes, switchedPerspective, changedEyeDistance,
-                gotToggle = no;
-poly            *quickList;
-
-                /** if not connected to Axiom **/
-int             viewAloned;
-
-                /** for drawing the box **/
-viewTriple      corners[8], clipCorners[8];
-boxSideStruct   box[6], clipBox[6];
-
-                /** for freeing up points created frrom split polygons **/
-int             resMax=0;  /* number of points in the split point resevoir */
-
-                /** view volume stuff **/
-Window          volumeWindow;
-int             frustrumVertex;
-int             doingPanel=CONTROLpanel; /* rewrite titles in proper panel */
-int             doingVolume;
-
-int             screenX;  /* global floating point indicating mouse position
-			     on frustrum screen */
-float           xClipMinN, xClipMaxN,   /* normalized values for
-					   clip volume */
-                yClipMinN, yClipMaxN,
-                zClipMinN, zClipMaxN,
-                clipValue;              /* mouse input */
-float           pzMin, pzMax;   /* for a given (theta,phi): calculated in
-                                   drawViewport(), used in drawFrustrum() */
-
-                /** B/W shades **/
-                /** events from the viewport manager **/
-char            propertyName[14];
-char            propertyBuffer[256];
-
-                /* global ps variables */
-
-               /** Resource database **/
-XrmDatabase rDB;
-
-               /** variables used for smooth shading **/
-int    smoothError = no;
-Pixmap viewmap;
-float  Cspec = 0.30;
-float  Cdiff = 0.4;
-float  Camb = 0.3;
-float  coeff = 35.0;
-float  saturation = 0.8;
-int    smoothHue;
-int    smoothConst = 50;
-
-
-
-
-void
-main(void) 
-{
-
-  XGCValues     controlGCVals;
-  int           i, code;
-
-  char property[256];
-  char *prop = &property[0];
-  char *str_type[20];
-  XrmValue value;
-
-  Atom wm_delete_window;
-  XColor	       foreColor, backColor;
-  XSizeHints	       titleSizeHints;
-  Window	       viewTitleWindow, viewGraphWindow;
-  XSetWindowAttributes viewAttrib;
-  Pixmap spadbits,spadmask;
-
-  /**** Global inits ****/
-  splitPoints = NIL(viewTriple);
-
-  /**** Set up display ****/
-  if ((dsply = XOpenDisplay(getenv("DISPLAY"))) == NULL)
-    {fprintf(stderr,"Could not open display.\n");exit (-1);}
-  scrn = DefaultScreen(dsply);
-  rtWindow = RootWindow(dsply,scrn);
-
-  /**** link Xwindows to viewports - X10 feature ****/
-  table = XCreateAssocTable(nbuckets);  
-
-  /**** Create Axiom color map ****/
-  totalShades = 0;
-  totalColors = XInitSpadFill(dsply,scrn,&colorMap,
-                              &totalHues,&totalSolidShades,
-                              &totalDitheredAndSolids,&totalShades);
-  if (totalColors < 0) {
-    fprintf(stderr,"ERROR: Could not allocate all the necessary colors.\n");
-    exitWithAck(RootWindow(dsply,scrn),Window,-1);
-  }
-
-
-
-  PSGlobalInit();
-  /* must initiate before using any G/PS functions */
-  /* need character name: used as postscript GC variable */
-  /* need to create ps GCs for all GCs used by drawing in viewWindow */
-
-                     /* globalGC1 */
-  controlGCVals.foreground  = monoColor(axesColor);
-  controlGCVals.background  = backgroundColor;
-  globalGC1  = XCreateGC(dsply,rtWindow,GCForeground |
-                         GCBackground ,&controlGCVals);
-  carefullySetFont(globalGC1,globalFont);
-  PSCreateContext(globalGC1, "globalGC1", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-
-                     /* controlMessageGC */
-  controlGCVals.foreground  = controlMessageColor;
-  controlGCVals.background  = backgroundColor;
-  controlMessageGC      = XCreateGC(dsply,rtWindow,GCForeground |
-				    GCBackground ,&controlGCVals);
-  carefullySetFont(controlMessageGC,globalFont);
-
-                     /* globalGC2 */
-  controlGCVals.foreground = monoColor(labelColor);
-  globalGC2 = XCreateGC(dsply,rtWindow,GCForeground,&controlGCVals);
-  carefullySetFont(globalGC2,buttonFont);
-  PSCreateContext(globalGC2, "globalGC2", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-
-                     /* trashGC */
-  controlGCVals.function = GXcopy; 
-  trashGC  = XCreateGC(dsply,rtWindow,0 ,&controlGCVals);
-  carefullySetFont(trashGC,buttonFont);
-  PSCreateContext(trashGC, "trashGC", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-
-                    /* componentGC */
-  componentGC  = XCreateGC(dsply,rtWindow,0 ,&controlGCVals);
-  carefullySetFont(componentGC,buttonFont);
-  PSCreateContext(componentGC, "componentGC", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-
-                   /* opaqueGC */
-  opaqueGC  = XCreateGC(dsply,rtWindow,0 ,&controlGCVals);
-  carefullySetFont(opaqueGC,buttonFont);
-  PSCreateContext(opaqueGC, "opaqueGC", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-
-                   /* renderGC */
-  renderGC  = XCreateGC(dsply,rtWindow,0,&controlGCVals);
-  carefullySetFont(renderGC,buttonFont);
-  PSCreateContext(renderGC, "renderGC", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-
-                  /* globGC */
-  globGC = XCreateGC(dsply,rtWindow,0,&controlGCVals);
-  carefullySetFont(globGC,headerFont);
-  PSCreateContext(globGC, "globGC", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-
-                /* anotherGC */
-  controlGCVals.line_width = colorWidth;
-  anotherGC  = XCreateGC(dsply,rtWindow,GCBackground | GCLineWidth |
-                         GCFunction ,&controlGCVals);  
-  carefullySetFont(anotherGC,titleFont);
-  PSCreateContext(anotherGC, "anotherGC", psNormalWidth, psButtCap,
-		  psMiterJoin, psWhite, psBlack);
-
-  /* also create one for rendering (grayscale only for now) */
-  /* assign arbitrary number to renderGC as 9991 - see header.h */
-  PSCreateContext(GC9991, "renderGC", psNormalWidth, psButtCap,
-		  psRoundJoin, psWhite, psBlack );
-
-
-              /* processGC */
-  gcVals.background  = backgroundColor;
-  processGC = XCreateGC(dsply,rtWindow,GCBackground |
-			GCFillStyle,&gcVals);
-  carefullySetFont(processGC,buttonFont);
-
-              /* lightingGC */
-  controlGCVals.foreground = monoColor(axesColor);
-  controlGCVals.background = backgroundColor;
-  lightingGC  = XCreateGC(dsply,rtWindow,GCForeground | GCBackground
-			  ,&controlGCVals);
-  carefullySetFont(lightingGC,lightingFont);
-
-
-             /* volumeGC */
-  volumeGC = XCreateGC(dsply,rtWindow,GCForeground | GCBackground 
-		       ,&controlGCVals);
-  carefullySetFont(volumeGC,volumeFont);
-
-              /* quitGC */
-  quitGC  = XCreateGC(dsply,rtWindow,GCForeground | GCBackground 
-		      ,&controlGCVals);
-  carefullySetFont(quitGC,buttonFont);
-
-              /* saveGC */
-  saveGC  = XCreateGC(dsply,rtWindow,GCForeground | GCBackground 
-		      ,&controlGCVals);
-  carefullySetFont(saveGC,buttonFont);
-
-
-              /* graphGC */
-  graphGC  = XCreateGC(dsply,rtWindow,GCForeground | GCBackground 
-		       ,&controlGCVals);
-  carefullySetFont(graphGC,buttonFont);
-  if (!(viewport = (viewPoints *)saymem("viewport3D.c",
-					1,sizeof(viewPoints)))) {
-    fprintf(stderr,"Ran out of memory trying to create a viewport.\n");
-    exitWithAck(RootWindow(dsply,scrn),Window,-1);
-  }
-  /* Definition of the 4x4 identity matrix. */
-  I[0][0] = 1.0; I[0][1] = 0.0; I[0][2] = 0.0; I[0][3] = 0.0;
-  I[1][0] = 0.0; I[1][1] = 1.0; I[1][2] = 0.0; I[1][3] = 0.0;
-  I[2][0] = 0.0; I[2][1] = 0.0; I[2][2] = 1.0; I[2][3] = 0.0;
-  I[3][0] = 0.0; I[3][1] = 0.0; I[3][2] = 0.0; I[3][3] = 1.0;
-
-  viewport->viewportKey	 = viewportKeyNum++;
-  viewport->nextViewport = 0;
-  viewport->prevViewport = 0;
-  viewport->deltaX	 = viewport->deltaX0  = viewData.deltaX;
-  viewport->deltaY	 = viewport->deltaY0  = viewData.deltaY;
-  viewport->deltaZ	 = viewport->deltaZ0  = viewData.deltaZ;
-  viewport->scale	 = viewport->scale0   = viewData.scale;
-  viewport->scaleX	 = viewData.scaleX;
-  viewport->scaleY	 = viewData.scaleY;
-  viewport->scaleZ	 = viewData.scaleZ;
-  viewport->transX	 = (viewData.xmax + viewData.xmin)/2.0;
-  viewport->transY	 = (viewData.ymax + viewData.ymin)/2.0;
-  viewport->transZ	 = (viewData.zmax + viewData.zmin)/2.0;
-
-  viewport->theta = viewport->axestheta = viewport->theta0 = viewData.theta;
-  viewport->phi	  = viewport->axesphi	= viewport->phi0   = viewData.phi;
-  viewport->thetaObj = 0.0;
-  viewport->phiObj   = 0.0;
-
-  viewData.title = "untitled";
-  strcpy(viewport->title,viewData.title);
-
-  viewport->axesOn	 = yes;
-  viewport->regionOn	 = no;
-  viewport->monoOn	 = no;
-  viewport->zoomXOn	 = yes;
-  viewport->zoomYOn	 = yes;
-  viewport->zoomZOn	 = yes;
-
-  viewport->originrOn	 = yes;
-  viewport->objectrOn	 = no;
-  viewport->originFlag	 = no;
-
-  viewport->xyOn	 = no;
-  viewport->xzOn	 = no;
-  viewport->yzOn	 = no;
-
-  viewport->closing	 = no;
-  viewport->allowDraw	 = yes;	  /*if no, just draw axes the first time */
-  viewport->needNorm	 = yes;
-
-  viewport->lightVector[0] = -0.5;
-  viewport->lightVector[1] = 0.5;
-  viewport->lightVector[2] = 0.5;
-  viewport->translucency   = viewData.translucency;
-
-  viewport->hueOffset	   = viewData.hueOff;
-  viewport->numberOfHues   = viewData.numOfHues;
-  viewport->hueTop	   = viewData.hueOff + viewData.numOfHues;
-  if (viewport->hueTop > totalHues-1) viewport->hueTop = totalHues-1;
-  viewport->diagonals	   = viewData.diagonals;
-
-  /* make theta in [0..2pi) and phi in (-pi..pi] */
-  while (viewport->theta >= two_pi) {
-    viewport->theta -= two_pi;
-  }
-  while (viewport->theta < 0.0) {
-    viewport->theta += two_pi;
-  }
-  while (viewport->phi > pi) {
-    viewport->phi -= two_pi;
-  }
-  while (viewport->phi <= -pi) {
-    viewport->phi += two_pi;
-  }
-
-  while (viewport->axestheta >= two_pi) {
-    viewport->axestheta -= two_pi;
-  }
-  while (viewport->axestheta < 0.0) {
-    viewport->axestheta += two_pi;
-  }
-  while (viewport->axesphi > pi) {
-    viewport->axesphi -= two_pi;
-  }
-  while (viewport->axesphi <= -pi) {
-    viewport->axesphi += two_pi;
-  }
-
-  /* Initialize the rotation matrix about the origin. */
-  sinTheta  = sin(-viewport->theta);
-  cosTheta  = cos(-viewport->theta);
-  sinPhi    = sin(viewport->phi);
-  cosPhi    = cos(viewport->phi);
-  ROTATE(R);  /* angles theta and phi are global */
-
-  /* Initialize the rotation matrix about the object's center of volume. */
-  sinTheta  = sin(-viewport->thetaObj);
-  cosTheta  = cos(-viewport->thetaObj);
-  sinPhi    = sin(viewport->phiObj);
-  cosPhi    = cos(viewport->phiObj);
-  ROTATE1(R1);	/* angles theta and phi are global  */
-
-
-  /* Initialize the non-uniform scaling matrix. */
-  SCALE(viewport->scaleX,viewport->scaleY,viewport->scaleZ,S);
-  /* Initialize the translation matrix. */
-  TRANSLATE(-viewport->deltaX,-viewport->deltaY,0.0,T);
-	   /**** make the windows for the viewport ****/
-  spadbits = XCreateBitmapFromData(dsply,rtWindow,
-				   spadBitmap_bits,
-				   spadBitmap_width,spadBitmap_height);
-  spadmask = XCreateBitmapFromData(dsply,rtWindow,
-				   spadMask_bits,
-				   spadMask_width,spadMask_height);
-  viewAttrib.background_pixel = backgroundColor;
-  viewAttrib.border_pixel = foregroundColor;
-
-  viewAttrib.override_redirect = overrideManager;
-
-  viewAttrib.colormap = colorMap;
-  foreColor.pixel = foregroundColor;
-  backColor.pixel = backgroundColor;
-/*
-  foreColor.pixel = viewCursorForeground;
-  backColor.pixel = viewCursorBackground;
-*/
-  XQueryColor(dsply,colorMap,&foreColor);
-  XQueryColor(dsply,colorMap,&backColor);
-  viewAttrib.cursor = XCreatePixmapCursor(dsply,spadbits,spadmask,
-					  &foreColor,&backColor,spadBitmap_x_hot,spadBitmap_y_hot);
-  viewAttrib.event_mask = titleMASK;
-  if (viewData.vW) {
-    titleSizeHints.flags  = PPosition | PSize;
-    titleSizeHints.x	  = viewData.vX;
-    titleSizeHints.y	  = viewData.vY;
-    titleSizeHints.width  = viewData.vW;
-    titleSizeHints.height = viewData.vH;
-  } else {    /* ain't gonna allow this for now... */
-    titleSizeHints.flags  = PSize;
-    titleSizeHints.width  = viewWidth;
-    titleSizeHints.height = viewHeight;
-  }
-
-  viewTitleWindow = XCreateWindow(dsply,rtWindow,viewData.vX,viewData.vY,
-				  viewData.vW,viewData.vH,viewBorderWidth+3,
-				  CopyFromParent,InputOutput,CopyFromParent,
-				  viewportTitleCreateMASK,&viewAttrib);
-
-  wm_delete_window = XInternAtom(dsply, "WM_DELETE_WINDOW", False);
-  (void) XSetWMProtocols(dsply, viewTitleWindow, &wm_delete_window, 1);
-
-  XSetNormalHints(dsply,viewTitleWindow,&titleSizeHints);
-  if (strlen(viewport->title) < 30)
-    XSetStandardProperties(dsply,viewTitleWindow,"Axiom 3D",viewport->title,
-			   None,NULL,0,&titleSizeHints);
-  else
-    XSetStandardProperties(dsply,viewTitleWindow,"Axiom 3D","3D Axiom Graph",
-			   None,NULL,0,&titleSizeHints);
-  viewport->titleWindow = viewTitleWindow;
-
-  viewAttrib.event_mask = viewportMASK;
-  viewSizeHints.flags	= PPosition | PSize;
-  viewSizeHints.x	= -(viewBorderWidth+3);
-  viewSizeHints.y	= titleHeight;
-  viewSizeHints.width	= titleSizeHints.width;
-  viewSizeHints.height	= titleSizeHints.height-(titleHeight+appendixHeight);
-  viewGraphWindow = XCreateWindow(dsply,viewTitleWindow,
-				  viewSizeHints.x,viewSizeHints.y,
-				  viewSizeHints.width,viewSizeHints.height,
-				  viewBorderWidth+3,
-				  CopyFromParent,InputOutput,CopyFromParent,
-				  viewportCreateMASK,&viewAttrib);
-  XSetNormalHints(dsply,viewGraphWindow,&viewSizeHints);
-  XSetStandardProperties(dsply,viewGraphWindow,"","",None,NULL,0,
-			 &viewSizeHints);
-  viewport->viewWindow = viewGraphWindow;
-  graphWindowAttrib.width = viewSizeHints.width;
-  graphWindowAttrib.height = viewSizeHints.height;
-
-  if (viewport->hueOffset != viewport->hueTop) {
-    multiColorFlag = yes;
-    redoColor = no;
-  } else {
-    if (viewport->hueTop < 11)
-      smoothHue = viewport->hueTop*6;
-    else {
-      if (viewport->hueTop > 10 && viewport->hueTop < 16)
-	smoothHue = viewport->hueTop*20 - 140;
-      else smoothHue = viewport->hueTop*12 - 12;
-    }
-    redoColor = yes;
-  }
-
-
-}     /* main() */
-     
-
-
-@
-\section{transform3d.c}
-<<view3d/transform3d.c>>=
-#define _TRANSFORM3D_C
-
-<<view3d/header.h>>
-
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-void 
-matrixMultiply4x4(float xxA[4][4],float xxB[4][4],float array[4][4])   
-{
+\subsection{matrixMultiply4x4}
+\index{view3d!matrixMultiply4x4}
+\index{matrixMultiply4x4 view3d}
+<<view3d>>=
+void matrixMultiply4x4(float xxA[4][4],float xxB[4][4],float array[4][4]) {
   array[0][0] = xxA[0][0]*xxB[0][0] + xxA[0][1]*xxB[1][0] + 
                 xxA[0][2]*xxB[2][0] + xxA[0][3]*xxB[3][0]; 
   array[1][0] = xxA[1][0]*xxB[0][0] + xxA[1][1]*xxB[1][0] +
@@ -23328,332 +15667,160 @@ matrixMultiply4x4(float xxA[4][4],float xxB[4][4],float array[4][4])
                 xxA[3][2]*xxB[2][3] + xxA[3][3]*xxB[3][3]; 
 }
 
-
-void 
-vectorMatrix4(float xxD[4],float xxE[4][4],float xxF[4])   
-{
-  xxF[0]= xxD[0]*xxE[0][0] + xxD[1]*xxE[1][0] + xxD[2]*xxE[2][0] + xxD[3]*xxE[3][0]; 
-  xxF[1]= xxD[0]*xxE[0][1] + xxD[1]*xxE[1][1] + xxD[2]*xxE[2][1] + xxD[3]*xxE[3][1]; 
-  xxF[2]= xxD[0]*xxE[0][2] + xxD[1]*xxE[1][2] + xxD[2]*xxE[2][2] + xxD[3]*xxE[3][2]; 
-  xxF[3]= xxD[0]*xxE[0][3] + xxD[1]*xxE[1][3] + xxD[2]*xxE[2][3] + xxD[3]*xxE[3][3]; 
+@
+\subsection{vectorMatrix4}
+\index{view3d!vectorMatrix4}
+\index{vectorMatrix4 view3d}
+<<view3d>>=
+void vectorMatrix4(float xxD[4],float xxE[4][4],float xxF[4]) {
+  xxF[0]=xxD[0]*xxE[0][0]+xxD[1]*xxE[1][0]+xxD[2]*xxE[2][0]+xxD[3]*xxE[3][0]; 
+  xxF[1]=xxD[0]*xxE[0][1]+xxD[1]*xxE[1][1]+xxD[2]*xxE[2][1]+xxD[3]*xxE[3][1]; 
+  xxF[2]=xxD[0]*xxE[0][2]+xxD[1]*xxE[1][2]+xxD[2]*xxE[2][2]+xxD[3]*xxE[3][2]; 
+  xxF[3]=xxD[0]*xxE[0][3]+xxD[1]*xxE[1][3]+xxD[2]*xxE[2][3]+xxD[3]*xxE[3][3]; 
 }
 
-
-void 
-ROTATE(float xxR[4][4])  
-{
-  xxR[0][0]= -(cosTheta); xxR[0][1]= -(-sinTheta*cosPhi); xxR[0][2]= -(sinTheta*sinPhi);  xxR[0][3]= 0.0; 
-  xxR[1][0]= -(sinTheta); xxR[1][1]= -(cosTheta*cosPhi);  xxR[1][2]= -(-cosTheta*sinPhi); xxR[1][3]= 0.0; 
-  xxR[2][0]= 0.0;         xxR[2][1]= -(sinPhi);           xxR[2][2]= -(cosPhi);           xxR[2][3]= 0.0; 
-  xxR[3][0]= 0.0;         xxR[3][1]= 0.0;                 xxR[3][2]= 0.0;                 xxR[3][3]= -(1.0);
+@
+\subsection{ROTATE}
+\index{view3d!ROTATE}
+\index{ROTATE view3d}
+<<view3d>>=
+void ROTATE(float xxR[4][4]) {
+  xxR[0][0]= -(cosTheta); 
+  xxR[0][1]= -(-sinTheta*cosPhi); 
+  xxR[0][2]= -(sinTheta*sinPhi);  
+  xxR[0][3]= 0.0; 
+  xxR[1][0]= -(sinTheta); 
+  xxR[1][1]= -(cosTheta*cosPhi);  
+  xxR[1][2]= -(-cosTheta*sinPhi); 
+  xxR[1][3]= 0.0; 
+  xxR[2][0]= 0.0;         
+  xxR[2][1]= -(sinPhi);           
+  xxR[2][2]= -(cosPhi);           
+  xxR[2][3]= 0.0; 
+  xxR[3][0]= 0.0;         
+  xxR[3][1]= 0.0;                 
+  xxR[3][2]= 0.0;                 
+  xxR[3][3]= -(1.0);
 }
 
-void 
-ROTATE1(float xxR[4][4])  
-{
-  xxR[0][0]= (cosTheta); xxR[0][1]= (-sinTheta*cosPhi); xxR[0][2]= (sinTheta*sinPhi);  xxR[0][3]= 0.0; 
-  xxR[1][0]= (sinTheta); xxR[1][1]= (cosTheta*cosPhi);  xxR[1][2]= (-cosTheta*sinPhi); xxR[1][3]= 0.0; 
-  xxR[2][0]= 0.0;        xxR[2][1]= (sinPhi);           xxR[2][2]= (cosPhi);           xxR[2][3]= 0.0; 
-  xxR[3][0]= 0.0;        xxR[3][1]= 0.0;                xxR[3][2]= 0.0;                xxR[3][3]= (1.0);
+@
+\subsection{ROTATE1}
+\index{view3d!ROTATE1}
+\index{ROTATE1 view3d}
+<<view3d>>=
+void ROTATE1(float xxR[4][4]) {
+  xxR[0][0]= (cosTheta); 
+  xxR[0][1]= (-sinTheta*cosPhi); 
+  xxR[0][2]= (sinTheta*sinPhi);  
+  xxR[0][3]= 0.0; 
+  xxR[1][0]= (sinTheta); 
+  xxR[1][1]= (cosTheta*cosPhi);  
+  xxR[1][2]= (-cosTheta*sinPhi); 
+  xxR[1][3]= 0.0; 
+  xxR[2][0]= 0.0;        
+  xxR[2][1]= (sinPhi);           
+  xxR[2][2]= (cosPhi);           
+  xxR[2][3]= 0.0; 
+  xxR[3][0]= 0.0;        
+  xxR[3][1]= 0.0;                
+  xxR[3][2]= 0.0;                
+  xxR[3][3]= (1.0);
 }
 
-
-void 
-SCALE(float x,float y,float z,float xxS[4][4])  
-{
+@
+\subsection{SCALE}
+\index{view3d!SCALE}
+\index{SCALE view3d}
+<<view3d>>=
+void SCALE(float x,float y,float z,float xxS[4][4]) {
   xxS[0][0] = x;   xxS[0][1] = 0.0; xxS[0][2] = 0.0; xxS[0][3] = 0.0; 
   xxS[1][0] = 0.0; xxS[1][1] = y;   xxS[1][2] = 0.0; xxS[1][3] = 0.0; 
   xxS[2][0] = 0.0; xxS[2][1] = 0.0; xxS[2][2] = z;   xxS[2][3] = 0.0; 
   xxS[3][0] = 0.0; xxS[3][1] = 0.0; xxS[3][2] = 0.0; xxS[3][3] = 1.0;
 }
 
-
-void 
-TRANSLATE(float x,float y,float z,float xxT[4][4])   
-{
+@
+\subsection{TRANSLATE}
+\index{view3d!TRANSLATE}
+\index{TRANSLATE view3d}
+<<view3d>>=
+void TRANSLATE(float x,float y,float z,float xxT[4][4]) {
   xxT[0][0] = 1.0; xxT[0][1] = 0.0; xxT[0][2] = 0.0;  xxT[0][3] = 0.0; 
   xxT[1][0] = 0.0; xxT[1][1] = 1.0; xxT[1][2] = 0.0;  xxT[1][3] = 0.0; 
   xxT[2][0] = 0.0; xxT[2][1] = 0.0; xxT[2][2] = -1.0; xxT[2][3] = 0.0; 
   xxT[3][0] = x;   xxT[3][1] = y;   xxT[3][2] = z;    xxT[3][3] = 1.0;
 }
-@
-\section{viewport3d.c}
-<<view3d/viewport3d.c>>=
-#define _VIEWPORT3D_C
-
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-<<include/purty/spadbitmap.bitmap>>
-<<include/purty/spadmask.mask>>
-
-<<view3d/header.h>>
-    /*** definition for the axes and labels - this is the minimun that will be
-	 drawn on the window - thus allowing the user some idea of the
-	 orientation of the coordinate axes when rotating, etc. The
-	 drawing of the mesh is aborted when an appropriate X event occurs.
-	 The mesh should be scaled to the range of [-100..100] in all
-	 directions.  axisRange defines the range...change the stuff below
-	 if that has changed. ***/
-<<view3d/static.h>>
-<<view3d/draw.h>>
-<<view3d/volume.h>>
-#define spadActionMode
-/* define spadEventMode */
-#define components
-
-#include "util.h1"
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-#include "xspadfill.h1"
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-#define axesOffset  5
-
-Atom wm_delete_window;
-
-
-/***************************
- ***  void writeTitle()	 ***
- ***************************/
-
-void
-writeTitle (void)
-{
 
+@
+\subsection{writeTitle}
+Definition for the axes and labels - this is the minimun that will be
+drawn on the window - thus allowing the user some idea of the
+orientation of the coordinate axes when rotating, etc. The
+drawing of the mesh is aborted when an appropriate X event occurs.
+The mesh should be scaled to the range of [-100..100] in all
+directions.  axisRange defines the range...change the stuff below
+if that has changed. 
+\index{view3d!writeTitle}
+\index{writeTitle view3d}
+<<view3d>>=
+void writeTitle(void) {
   int			strlength;
   XWindowAttributes	twInfo;
-
   XGetWindowAttributes(dsply, viewport->titleWindow, &twInfo);
   if (mono || viewport->monoOn)
     GSetForeground(anotherGC, (float)foregroundColor, Xoption);
   else
     GSetForeground(anotherGC, (float)titleColor, Xoption);
   XClearWindow(dsply, viewport->titleWindow);
-
   strlength = strlen(viewport->title);
   GDrawImageString(anotherGC, viewport->titleWindow,
 		   centerX(anotherGC, viewport->title, strlength,
 			   twInfo.width), 15,
 		   viewport->title, strlength, Xoption);
-
 }
 
-
-/****************************
- * void drawPreViewport()   *
- *			    *
- * draws the axes and boxes *
- * before the actual stuff. *
- * all incoming signals	    *
- * should be block and no   *
- * check for pending X	    *
- * events are made.	    *
- *			    *
- ****************************/
-
-void
-drawPreViewport (int dFlag)
-{
-
+@
+\subsection{drawPreViewport}
+Draws the axes and boxes before the actual stuff. All incoming signals
+should be block and no check for pending X events are made.
+\index{view3d!drawPreViewport}
+\index{drawPreViewport view3d}
+<<view3d>>=
+void drawPreViewport(int dFlag) {
   int i, j, vPx0, vPy0, vPx1, vPy1;
       /* for drawing the box */
   float vPz, absTransX, absTransY;
   XPoint blackbox[3], line[2];
   RGB	 axes_rgb, clipbox_rgb, boundbox_rgb;
-
   axes_rgb.r = 0.8;	axes_rgb.g = 0.6;     axes_rgb.b = 0.2;
   clipbox_rgb.r = 0.4;	clipbox_rgb.g = 0.5;  clipbox_rgb.b = 0.9;
   boundbox_rgb.r = 0.4; boundbox_rgb.g = 0.7; boundbox_rgb.b = 0.9;
-
   XGetWindowAttributes(dsply, viewport->viewWindow, &vwInfo);
   graphWindowAttrib = vwInfo;
-
 	/* Calculate various factors for use in projection */
 	/* Scale so that plot the scaling between the axes remains constant
 	   and fits within the smaller of the two dimensions. */
-
   xCenter = vwInfo.width / 2;
   yCenter = vwInfo.height / 2;
-
   if (vwInfo.height <= vwInfo.width) {
     viewScale = viewport->scale * vwInfo.height / viewHeight;
   }
   else {
     viewScale = viewport->scale * vwInfo.width / viewWidth;
   }
-
 	     /* Draw the projected image */
     /** draw the axes without heeding to X interrupts, first **/
-
   if (dFlag == Xoption)   /* do this for X option only */
     XClearWindow(dsply, viewport->viewWindow);
-
   sinTheta  = sin(-viewport->axestheta);
   cosTheta  = cos(-viewport->axestheta);
   sinPhi    = sin(viewport->axesphi);
   cosPhi    = cos(viewport->axesphi);
-
   /* Create transformation matrices */
   ROTATE(R); /* angles theta and phi are global */
   SCALE(viewport->scaleX,viewport->scaleY,viewport->scaleZ,S);
   TRANSLATE(-viewport->deltaX,-viewport->deltaY,0.0,T);
-
   /**** Pre Draw Routine ****/
-
   if ((dFlag == PSoption) && (foregroundColor == white)) {
     GSetForeground(globGC,(float)backgroundColor,dFlag);
     blackbox[0].x = vwInfo.width;  blackbox[0].y = vwInfo.height;
@@ -23673,9 +15840,7 @@ drawPreViewport (int dFlag)
       PSColorPolygon(0.0,0.0,0.0,blackbox,4);
     }
   }
-
   /*  axes  */
-
   for (i=0; i < 3; i++) {
     projectStuff(axes[i][0],axes[i][1],axes[i][2],&vPx0,&vPy0,&vPz);
     axesXY[i][0] = vPx0; axesXY[i][1] = vPy0; axesZ[i][0] = vPz;
@@ -23726,11 +15891,9 @@ drawPreViewport (int dFlag)
       GSetForeground(globGC,(float)monoColor(buttonColor),dFlag);
     }	 /* if viewport->axesOn */
   }
-
   viewport->transX = (viewData.xmax + viewData.xmin)/2.0;
   viewport->transY = (viewData.ymax + viewData.ymin)/2.0;
   viewport->transZ = (viewData.zmax + viewData.zmin)/2.0;
-
   absTransX = absolute(viewport->transX);
   absTransY = absolute(viewport->transY);
   if ((absTransX > 0.5) || (absTransY > 0.5)) {
@@ -23742,20 +15905,17 @@ drawPreViewport (int dFlag)
   } else {
     reScale = 100.0;
   }
-
   sinTheta  = sin(-viewport->thetaObj);
   cosTheta  = cos(-viewport->thetaObj);
   sinPhi    = sin(viewport->phiObj);
   cosPhi    = cos(viewport->phiObj);
   ROTATE1(R1);
-
   if (viewport->originFlag) viewport->originFlag = no;
   sinTheta  = sin(-viewport->axestheta);
   cosTheta  = cos(-viewport->axestheta);
   sinPhi    = sin(viewport->axesphi);
   cosPhi    = cos(viewport->axesphi);
   ROTATE(R);
-
      /*	 region box */
   if (viewData.clipbox) {
     clipCorners[0].x = viewData.clipXmin;
@@ -23782,12 +15942,9 @@ drawPreViewport (int dFlag)
     clipCorners[7].x = viewData.clipXmin;
     clipCorners[7].y = viewData.clipYmax;
     clipCorners[7].z = viewData.clipZmax;
-
     GSetLineAttributes(trashGC,0,LineSolid,CapButt,JoinMiter,dFlag);
-
     /* project the 8 corners of the box */
     for (i=0;i<8;i++) projectAPoint(&(clipCorners[i]));
-
     for (i=0;i<6;i++) {
        clipBox[i].inside = ((clipBox[i].pointsPtr[2]->px -
 			     clipBox[i].pointsPtr[1]->px) *
@@ -23824,12 +15981,9 @@ drawPreViewport (int dFlag)
       }
     }
   }  /* if viewData.clipbox */
-
      /* VOLUME panel stuff */
   if ((doingPanel == VOLUMEpanel) || viewData.box) {
-
     GSetLineAttributes(trashGC,0,LineSolid,CapButt,JoinMiter,dFlag);
-
     for (i=0;i<8;i++) {
 	/* project the 8 corners of the box */
 	projectAPoint(&(corners[i]));
@@ -23839,7 +15993,6 @@ drawPreViewport (int dFlag)
 	} else
 	   pzMax = pzMin = corners[i].pz;
     }
-
     for (i=0;i<6;i++) {
 	/* Process the 6 sides of the boxes.
 	   Here, we calculate, for each side (defined by two segments)
@@ -23892,7 +16045,6 @@ drawPreViewport (int dFlag)
       }
     }
   }  /* if viewData.box */
-
 	 /* Write out view data */
   if (dFlag == Xoption) {   /* do this only for X option */
      writeControlMessage();
@@ -23900,35 +16052,26 @@ drawPreViewport (int dFlag)
   }
 }
 
-
-/********************************/
-/***  void drawTheViewport()  ***/
-/********************************/
-
-void
-drawTheViewport (int dFlag)
-{
-
+@
+\subsection{drawTheViewport}
+\index{view3d!drawTheViewport}
+\index{drawTheViewport view3d}
+<<view3d>>=
+void drawTheViewport(int dFlag) {
   int	 i,j;
   XPoint line[2];
   RGB	 clipbox_rgb, boundbox_rgb;
-
   clipbox_rgb.r = 0.4;	clipbox_rgb.g = 0.5;  clipbox_rgb.b = 0.9;
   boundbox_rgb.r = 0.4; boundbox_rgb.g = 0.7; boundbox_rgb.b = 0.9;
-
      /**** Draw Routine ****/
-
   if (viewport->allowDraw && (doingPanel != VOLUMEpanel)) {
     /* Do not draw the mesh stuff if we're in the process of changing
        the viewing volume; we just want to see the volume */
-
     /* drawMore allows the drawing to continue if no relevant XEvent occurs */
     drawMore = yes;
     drawMore = keepDrawingViewport();
     draw3DComponents(dFlag);
-
   } /*if viewport->allowDraw */
-
      /**** Post Draw Routine ****/
   if (viewData.clipbox) {   /* draw the front 3 lines of region box */
     GSetLineAttributes(trashGC,0,LineSolid,CapButt,JoinMiter,dFlag);
@@ -23960,7 +16103,6 @@ drawTheViewport (int dFlag)
       }
     }
   }
-
   if ((doingPanel==VOLUMEpanel) || viewData.box) {
     GSetLineAttributes(trashGC,0,LineSolid,CapButt,JoinMiter,dFlag);
     for (i=0; i<6; i++) {
@@ -23991,34 +16133,27 @@ drawTheViewport (int dFlag)
       }
     }
   }
-
   if (dFlag == Xoption)  /* do this for X option only */
      XFlush(dsply);
-
   if (smoothError) {
     strcpy(control->message,"Cannot alloc more smooth shades.");
     writeControlMessage();
     smoothError = no;
   }
-
 } /* drawTheViewport */
 
-/************************************
- ***  viewPoints *makeViewport()  ***
- ************************************/
-
-viewPoints *
-makeViewport (void)
-{
-
+@
+\subsection{makeViewport}
+\index{view3d!makeViewport}
+\index{makeViewport view3d}
+<<view3d>>=
+viewPoints *makeViewport(void) {
   Pixmap	       spadbits,spadmask;
   XSetWindowAttributes viewAttrib;
   XSizeHints	       titleSizeHints;
   Window	       viewTitleWindow, viewGraphWindow;
   XColor	       foreColor, backColor;
-
 	    /**** create a viewport ****/
-
   if (!(viewport = (viewPoints *)saymem("viewport3D.c",
 					1,sizeof(viewPoints)))) {
     fprintf(stderr,"Ran out of memory trying to create a viewport.\n");
@@ -24029,7 +16164,6 @@ makeViewport (void)
   I[1][0] = 0.0; I[1][1] = 1.0; I[1][2] = 0.0; I[1][3] = 0.0;
   I[2][0] = 0.0; I[2][1] = 0.0; I[2][2] = 1.0; I[2][3] = 0.0;
   I[3][0] = 0.0; I[3][1] = 0.0; I[3][2] = 0.0; I[3][3] = 1.0;
-
   viewport->viewportKey	 = viewportKeyNum++;
   viewport->nextViewport = 0;
   viewport->prevViewport = 0;
@@ -24043,44 +16177,35 @@ makeViewport (void)
   viewport->transX	 = (viewData.xmax + viewData.xmin)/2.0;
   viewport->transY	 = (viewData.ymax + viewData.ymin)/2.0;
   viewport->transZ	 = (viewData.zmax + viewData.zmin)/2.0;
-
   viewport->theta = viewport->axestheta = viewport->theta0 = viewData.theta;
   viewport->phi	  = viewport->axesphi	= viewport->phi0   = viewData.phi;
   viewport->thetaObj = 0.0;
   viewport->phiObj   = 0.0;
-
   strcpy(viewport->title,viewData.title);
-
   viewport->axesOn	 = yes;
   viewport->regionOn	 = no;
   viewport->monoOn	 = no;
   viewport->zoomXOn	 = yes;
   viewport->zoomYOn	 = yes;
   viewport->zoomZOn	 = yes;
-
   viewport->originrOn	 = yes;
   viewport->objectrOn	 = no;
   viewport->originFlag	 = no;
-
   viewport->xyOn	 = no;
   viewport->xzOn	 = no;
   viewport->yzOn	 = no;
-
   viewport->closing	 = no;
   viewport->allowDraw	 = yes;	  /*if no, just draw axes the first time */
   viewport->needNorm	 = yes;
-
   viewport->lightVector[0] = -0.5;
   viewport->lightVector[1] = 0.5;
   viewport->lightVector[2] = 0.5;
   viewport->translucency   = viewData.translucency;
-
   viewport->hueOffset	   = viewData.hueOff;
   viewport->numberOfHues   = viewData.numOfHues;
   viewport->hueTop	   = viewData.hueOff + viewData.numOfHues;
   if (viewport->hueTop > totalHues-1) viewport->hueTop = totalHues-1;
   viewport->diagonals	   = viewData.diagonals;
-
   /* make theta in [0..2pi) and phi in (-pi..pi] */
   while (viewport->theta >= two_pi) {
     viewport->theta -= two_pi;
@@ -24094,7 +16219,6 @@ makeViewport (void)
   while (viewport->phi <= -pi) {
     viewport->phi += two_pi;
   }
-
   while (viewport->axestheta >= two_pi) {
     viewport->axestheta -= two_pi;
   }
@@ -24107,22 +16231,18 @@ makeViewport (void)
   while (viewport->axesphi <= -pi) {
     viewport->axesphi += two_pi;
   }
-
   /* Initialize the rotation matrix about the origin. */
   sinTheta  = sin(-viewport->theta);
   cosTheta  = cos(-viewport->theta);
   sinPhi    = sin(viewport->phi);
   cosPhi    = cos(viewport->phi);
   ROTATE(R);  /* angles theta and phi are global */
-
   /* Initialize the rotation matrix about the object's center of volume. */
   sinTheta  = sin(-viewport->thetaObj);
   cosTheta  = cos(-viewport->thetaObj);
   sinPhi    = sin(viewport->phiObj);
   cosPhi    = cos(viewport->phiObj);
   ROTATE1(R1);	/* angles theta and phi are global  */
-
-
   /* Initialize the non-uniform scaling matrix. */
   SCALE(viewport->scaleX,viewport->scaleY,viewport->scaleZ,S);
   /* Initialize the translation matrix. */
@@ -24136,9 +16256,7 @@ makeViewport (void)
 				   spadMask_width,spadMask_height);
   viewAttrib.background_pixel = backgroundColor;
   viewAttrib.border_pixel = foregroundColor;
-
   viewAttrib.override_redirect = overrideManager;
-
   viewAttrib.colormap = colorMap;
   foreColor.pixel = foregroundColor;
   backColor.pixel = backgroundColor;
@@ -24148,8 +16266,9 @@ makeViewport (void)
 */
   XQueryColor(dsply,colorMap,&foreColor);
   XQueryColor(dsply,colorMap,&backColor);
-  viewAttrib.cursor = XCreatePixmapCursor(dsply,spadbits,spadmask,
-					  &foreColor,&backColor,spadBitmap_x_hot,spadBitmap_y_hot);
+  viewAttrib.cursor = 
+    XCreatePixmapCursor(dsply,spadbits,spadmask,&foreColor,
+                        &backColor,spadBitmap_x_hot,spadBitmap_y_hot);
   viewAttrib.event_mask = titleMASK;
   if (viewData.vW) {
     titleSizeHints.flags  = PPosition | PSize;
@@ -24162,23 +16281,20 @@ makeViewport (void)
     titleSizeHints.width  = viewWidth;
     titleSizeHints.height = viewHeight;
   }
-
   viewTitleWindow = XCreateWindow(dsply                   /* display */,
 				  rtWindow,               /* parent */
 				  viewData.vX,            /* x */
 				  viewData.vY,            /* y */
 				  viewData.vW,            /* width */
 				  viewData.vH,            /* height */
-				  /* viewBorderWidth+3*/ 0,      /* border width */
+				  /* viewBorderWidth+3*/ 0, /* border width */
 				  CopyFromParent,         /* depth */
 				  InputOutput,            /* class */
 				  CopyFromParent,         /* visual */
 				  viewportTitleCreateMASK,/* valuemask */
 				  &viewAttrib             /* attributes */);
-
   wm_delete_window = XInternAtom(dsply, "WM_DELETE_WINDOW", False);
   (void) XSetWMProtocols(dsply, viewTitleWindow, &wm_delete_window, 1);
-
   XSetNormalHints(dsply,viewTitleWindow,&titleSizeHints);
   if (strlen(viewport->title) < 30)
     XSetStandardProperties(dsply,viewTitleWindow,"Axiom 3D",viewport->title,
@@ -24187,7 +16303,6 @@ makeViewport (void)
     XSetStandardProperties(dsply,viewTitleWindow,"Axiom 3D","3D Axiom Graph",
 			   None,NULL,0,&titleSizeHints);
   viewport->titleWindow = viewTitleWindow;
-
   viewAttrib.event_mask = viewportMASK;
   viewSizeHints.flags	= PPosition | PSize;
   viewSizeHints.x	= -(viewBorderWidth+3);
@@ -24195,14 +16310,13 @@ makeViewport (void)
   viewSizeHints.y	= titleHeight;
   viewSizeHints.width	= titleSizeHints.width;
   viewSizeHints.height	= titleSizeHints.height-(titleHeight+appendixHeight);
-
   viewGraphWindow = XCreateWindow(dsply,                  /* display */
 				  viewTitleWindow,        /* parent */
 				  viewSizeHints.x,        /* x */
 				  viewSizeHints.y,        /* y */
 				  viewSizeHints.width,    /* width */
 				  viewSizeHints.height,   /* height */
-				  /* viewBorderWidth+3*/0,      /* border width */
+				  /* viewBorderWidth+3*/0, /* border width */
 				  CopyFromParent,         /* depth */
 				  InputOutput,            /* class */
 				  CopyFromParent,         /* visual */
@@ -24214,7 +16328,6 @@ makeViewport (void)
   viewport->viewWindow = viewGraphWindow;
   graphWindowAttrib.width = viewSizeHints.width;
   graphWindowAttrib.height = viewSizeHints.height;
-
   if (viewport->hueOffset != viewport->hueTop) {
     multiColorFlag = yes;
     redoColor = no;
@@ -24228,39 +16341,27 @@ makeViewport (void)
     }
     redoColor = yes;
   }
-
 	    /**** Make the control panel for the viewport. ****/
-
   XSync(dsply,0);
-
   control = viewport->controlPanel = makeControlPanel();
   makeLightingPanel();
   makeVolumePanel();
   makeSavePanel();
   makeQuitPanel();
-
   if ((viewport->haveControl = viewData.showCP))
     putControlPanelSomewhere(anywhere);
-
   firstTime = yes;
   return(viewport);
-
 } /* makeViewport() */
 
-
-/*****************************
- * void postMakeViewport()   *
- *			     *
- * post processing when	     *
- * creating a viewport.	     *
- *  1) assign min,max values *
- *     for the box volume    *
- *****************************/
-
-void
-postMakeViewport (void)
-{
-
+@
+\subsection{postMakeViewport}
+Post processing when creating a viewport.
+Assign min,max values for the box volume.
+\index{view3d!postMakeViewport}
+\index{postMakeViewport view3d}
+<<view3d>>=
+void postMakeViewport(void) {
   corners[0].x = viewData.xmin; corners[0].y = viewData.ymin;
   corners[0].z = viewData.zmin;
   corners[1].x = viewData.xmax; corners[1].y = viewData.ymin;
@@ -24277,87 +16378,65 @@ postMakeViewport (void)
   corners[6].z = viewData.zmax;
   corners[7].x = viewData.xmin; corners[7].y = viewData.ymax;
   corners[7].z = viewData.zmax;
-
   box[2].pointsPtr[0] = &(corners[0]);
   box[2].pointsPtr[1] = &(corners[1]);
   box[2].pointsPtr[2] = &(corners[2]);
   box[2].pointsPtr[3] = &(corners[3]);
-
   box[3].pointsPtr[0] = &(corners[1]);
   box[3].pointsPtr[1] = &(corners[5]);
   box[3].pointsPtr[2] = &(corners[6]);
   box[3].pointsPtr[3] = &(corners[2]);
-
   box[0].pointsPtr[0] = &(corners[4]);
   box[0].pointsPtr[1] = &(corners[7]);
   box[0].pointsPtr[2] = &(corners[6]);
   box[0].pointsPtr[3] = &(corners[5]);
-
   box[1].pointsPtr[0] = &(corners[0]);
   box[1].pointsPtr[1] = &(corners[3]);
   box[1].pointsPtr[2] = &(corners[7]);
   box[1].pointsPtr[3] = &(corners[4]);
-
   box[5].pointsPtr[0] = &(corners[3]);
   box[5].pointsPtr[1] = &(corners[2]);
   box[5].pointsPtr[2] = &(corners[6]);
   box[5].pointsPtr[3] = &(corners[7]);
-
   box[4].pointsPtr[0] = &(corners[0]);
   box[4].pointsPtr[1] = &(corners[4]);
   box[4].pointsPtr[2] = &(corners[5]);
   box[4].pointsPtr[3] = &(corners[1]);
-
    /* clip box */
-
   clipBox[0].pointsPtr[0] = &(clipCorners[0]);
   clipBox[0].pointsPtr[1] = &(clipCorners[1]);
   clipBox[0].pointsPtr[2] = &(clipCorners[2]);
   clipBox[0].pointsPtr[3] = &(clipCorners[3]);
-
   clipBox[1].pointsPtr[0] = &(clipCorners[1]);
   clipBox[1].pointsPtr[1] = &(clipCorners[5]);
   clipBox[1].pointsPtr[2] = &(clipCorners[6]);
   clipBox[1].pointsPtr[3] = &(clipCorners[2]);
-
   clipBox[2].pointsPtr[0] = &(clipCorners[4]);
   clipBox[2].pointsPtr[1] = &(clipCorners[7]);
   clipBox[2].pointsPtr[2] = &(clipCorners[6]);
   clipBox[2].pointsPtr[3] = &(clipCorners[5]);
-
   clipBox[3].pointsPtr[0] = &(clipCorners[0]);
   clipBox[3].pointsPtr[1] = &(clipCorners[3]);
   clipBox[3].pointsPtr[2] = &(clipCorners[7]);
   clipBox[3].pointsPtr[3] = &(clipCorners[4]);
-
   clipBox[4].pointsPtr[0] = &(clipCorners[3]);
   clipBox[4].pointsPtr[1] = &(clipCorners[2]);
   clipBox[4].pointsPtr[2] = &(clipCorners[6]);
   clipBox[4].pointsPtr[3] = &(clipCorners[7]);
-
   clipBox[5].pointsPtr[0] = &(clipCorners[0]);
   clipBox[5].pointsPtr[1] = &(clipCorners[4]);
   clipBox[5].pointsPtr[2] = &(clipCorners[5]);
   clipBox[5].pointsPtr[3] = &(clipCorners[1]);
-
-
 }
 
-
-/*****************************************
- *** int keepDrawingViewport() ***
- *****************************************/
-
-
-
-
-int
-keepDrawingViewport(void)
-{
-
+@
+\subsection{keepDrawingViewport}
+\index{view3d!keepDrawingViewport}
+\index{keepDrawingViewport view3d}
+<<view3d>>=
+int keepDrawingViewport(void) {
   XEvent peekEvent;
   int retVal;
-
   if (XPending(dsply)) {
     XPeekEvent(dsply,&peekEvent);
     if (((peekEvent.type == Expose) &&
@@ -24384,254 +16463,18 @@ keepDrawingViewport(void)
   } else {
     retVal = !followMouse;
   }
-
   if (writeImage) retVal = yes;
   drawMore = no;
   return(retVal);
-
 }
-@
-\section{volume3d.c}
-<<view3d/volume3d.c>>=
-#define _VOLUME3D_C
 
-#include <math.h>
-#include <string.h>
-
-<<view3d/header.h>>
-<<view3d/cpanel.h>>
-<<view3d/process.h>>
-<<view3d/volume.h>>
-<<include/purty/volume.bitmap>>
-<<include/purty/volume.mask>>
-
-
-
-#include "xspadfill.h1"
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-#define eyeDistMessX (frusX(eyeWinX+27))
-#define eyeDistMessY (frusY(eyeWinY-5))
-#define hitherMessX (frusX(hitherWinX+15))
-#define hitherMessY (frusY(hitherWinY))
-
-#define clipXMessX (control->buttonQueue[clipXBut].buttonX + \
-		    control->buttonQueue[clipXBut].xHalf)
-#define clipXMessY (control->buttonQueue[clipXBut].buttonY + 2)
-#define clipYMessX (control->buttonQueue[clipYBut].buttonX + \
-		    control->buttonQueue[clipYBut].buttonWidth-2)
-#define clipYMessY (control->buttonQueue[clipYBut].buttonY + \
-		    control->buttonQueue[clipYBut].yHalf)
-#define clipZMessX (control->buttonQueue[clipZBut].buttonX + \
-		    control->buttonQueue[clipZBut].xHalf+4)
-#define clipZMessY (control->buttonQueue[clipZBut].buttonY + \
-		    control->buttonQueue[clipZBut].yHalf-4)
-
-#define volumeCursorForeground monoColor(68)
-#define volumeCursorBackground monoColor(197)
-
-#define hitherBoxColor	monoColor(141)
-#define hitherBoxTop	(frustrumMidY - 10)
-#define hitherBoxHeight 20
-
-#define clipButtonColor 144
-#define toggleColor 42
-#define arcColor 75
-
-#define arcSize	  6
-#define tinyArc	  5
-#define blank 4
-#define toggleX 190
-#define toggleY 280
-
-#define oldWay
-
-#define frusX(x) (control->buttonQueue[frustrumBut].buttonX + x)
-#define frusY(y) (control->buttonQueue[frustrumBut].buttonY + y)
-
-#define clipMessX 7
-#define clipMessY (control->buttonQueue[clipXBut].buttonY + 15)
-   /* someotherFont holds title font (see main.c) */
-#define clipMessDy (globalFont->max_bounds.ascent/2 + \
-		    globalFont->max_bounds.descent)
-static char *clipMess = "Clip Volume";
-
-#define eyeMess1Dy clipMessDy
-#define eyeMess1X 7
-#define eyeMess1Y (frustrumY + 40 + 3*eyeMess1Dy)
-static char *eyeMess1 = "Eye";
-
-#define eyeMess2X (globalFont->max_bounds.width + 14)
-#define eyeMess2Y (frustrumY + 40)
-#define eyeMess2Dy eyeMess1Dy
-static char *eyeMess2 = "Reference";
-
-
- /*  global stuff  */
-int flatClipBoxX[8], flatClipBoxY[8];
-
-
-
-
-/******************* volume buttons **********************/
-
-int
-initVolumeButtons (buttonStruct *volumeButtons)
-{
+@
+\subsection{initVolumeButtons}
+\index{view3d!initVolumeButtons}
+\index{initVolumeButtons view3d}
+<<view3d>>=
+int initVolumeButtons(buttonStruct *volumeButtons) {
   int ii, num = 0;
-
   ii = volumeReturn;
   volumeButtons[ii].buttonX	 = 154;
   volumeButtons[ii].buttonY	 = 370;
@@ -24645,7 +16488,6 @@ initVolumeButtons (buttonStruct *volumeButtons)
   volumeButtons[ii].xHalf	 = volumeButtons[ii].buttonWidth/2;
   volumeButtons[ii].yHalf	 = volumeButtons[ii].buttonHeight/2;
   ++num;
-
   ii = volumeAbort;
   volumeButtons[ii].buttonX	 = 36;
   volumeButtons[ii].buttonY	 = 370;
@@ -24659,7 +16501,6 @@ initVolumeButtons (buttonStruct *volumeButtons)
   volumeButtons[ii].xHalf	 = volumeButtons[ii].buttonWidth/2;
   volumeButtons[ii].yHalf	 = volumeButtons[ii].buttonHeight/2;
   ++num;
-
   ii = frustrumBut;
   volumeButtons[ii].buttonX	 = frustrumWindowX;
   volumeButtons[ii].buttonY	 = frustrumWindowY;
@@ -24673,7 +16514,6 @@ initVolumeButtons (buttonStruct *volumeButtons)
   volumeButtons[ii].xHalf	 = volumeButtons[ii].buttonWidth/2;
   volumeButtons[ii].yHalf	 = volumeButtons[ii].buttonHeight/2;
   ++num;
-
   ii = perspectiveBut;
   volumeButtons[ii].buttonX	 = toggleX;
   volumeButtons[ii].buttonY	 = toggleY;
@@ -24687,7 +16527,6 @@ initVolumeButtons (buttonStruct *volumeButtons)
   volumeButtons[ii].xHalf	 = volumeButtons[ii].buttonWidth/2;
   volumeButtons[ii].yHalf	 = volumeButtons[ii].buttonHeight/2;
   ++num;
-
   ii = clipRegionBut;
   volumeButtons[ii].buttonX	 = toggleX;
   volumeButtons[ii].buttonY	 = toggleY+20;
@@ -24701,7 +16540,6 @@ initVolumeButtons (buttonStruct *volumeButtons)
   volumeButtons[ii].xHalf	 = volumeButtons[ii].buttonWidth/2;
   volumeButtons[ii].yHalf	 = volumeButtons[ii].buttonHeight/2;
   ++num;
-
   ii = clipSurfaceBut;
   volumeButtons[ii].buttonX	 = toggleX;
   volumeButtons[ii].buttonY	 = toggleY+40;
@@ -24715,7 +16553,6 @@ initVolumeButtons (buttonStruct *volumeButtons)
   volumeButtons[ii].xHalf	 = volumeButtons[ii].buttonWidth/2;
   volumeButtons[ii].yHalf	 = volumeButtons[ii].buttonHeight/2;
   ++num;
-
   ii = clipXBut;
   volumeButtons[ii].buttonX	 = clipXButX;
   volumeButtons[ii].buttonY	 = clipXButY;
@@ -24729,7 +16566,6 @@ initVolumeButtons (buttonStruct *volumeButtons)
   volumeButtons[ii].xHalf	 = volumeButtons[ii].buttonWidth/2;
   volumeButtons[ii].yHalf	 = volumeButtons[ii].buttonHeight/2;
   ++num;
-
   ii = clipYBut;
   volumeButtons[ii].buttonX	 = clipYButX;
   volumeButtons[ii].buttonY	 = clipYButY;
@@ -24743,7 +16579,6 @@ initVolumeButtons (buttonStruct *volumeButtons)
   volumeButtons[ii].xHalf	 = volumeButtons[ii].buttonWidth/2;
   volumeButtons[ii].yHalf	 = volumeButtons[ii].buttonHeight/2;
   ++num;
-
   ii = clipZBut;
   volumeButtons[ii].buttonX	 = clipZButX;
   volumeButtons[ii].buttonY	 = clipZButY;
@@ -24757,25 +16592,20 @@ initVolumeButtons (buttonStruct *volumeButtons)
   volumeButtons[ii].xHalf	 = volumeButtons[ii].buttonWidth/2;
   volumeButtons[ii].yHalf	 = volumeButtons[ii].buttonHeight/2;
   ++num;
-
   return(num);
 }
 
-
-/*************************
- * int makeVolumePanel() *
- *************************/
-
-void
-makeVolumePanel (void)
-{
-
+@
+\subsection{makeVolumePanel}
+\index{view3d!makeVolumePanel}
+\index{makeVolumePanel view3d}
+<<view3d>>=
+void makeVolumePanel(void) {
   int i;
   XSetWindowAttributes cwAttrib, controlAttrib;
   XSizeHints sizehint;
   Pixmap volumebits, volumemask;
   XColor foreColor, backColor;
-
   volumebits = XCreateBitmapFromData(dsply,rtWindow,volumeBitmap_bits,
 				     volumeBitmap_width,volumeBitmap_height);
   volumemask = XCreateBitmapFromData(dsply,rtWindow,volumeMask_bits,
@@ -24797,7 +16627,6 @@ makeVolumePanel (void)
 			       -3,-3,controlWidth,controlHeight,3,
 			       CopyFromParent,InputOutput,CopyFromParent,
 			       controlCreateMASK,&cwAttrib);
-
   sizehint.flags  = USPosition | USSize;
   sizehint.x	  = 0;
   sizehint.y	  = 0;
@@ -24807,9 +16636,7 @@ makeVolumePanel (void)
   XSetNormalHints(dsply,volumeWindow,&sizehint);
   XSetStandardProperties(dsply,volumeWindow,"Volume Panel 3D",
 			 "View Volume",None,NULL,0,&sizehint);
-
       /*** volume frustrum window ***/
-
     /*** do volume buttons ***/
   initVolumeButtons(control->buttonQueue);
   for (i=volumeButtonsStart; i<(volumeButtonsEnd); i++) {
@@ -24826,14 +16653,14 @@ makeVolumePanel (void)
 	       &((control->buttonQueue[i]).buttonKey));
     XMapWindow(dsply,(control->buttonQueue[i]).self);
   }
-
 }  /* makeVolumePanel() */
 
-
-void
-drawClipXBut (void)
-{
-
+@
+\subsection{drawClipXBut}
+\index{view3d!drawClipXBut}
+\index{drawClipXBut view3d}
+<<view3d>>=
+void drawClipXBut(void) {
   XClearArea(dsply,volumeWindow,clipXButX,clipXButY,
 	     majorAxis+blank,minorAxis+blank,False);
   GSetForeground(trashGC,(float)monoColor(toggleColor),Xoption);
@@ -24877,26 +16704,25 @@ drawClipXBut (void)
 	    (control->buttonQueue[clipXBut]).buttonWidth,
 	    (control->buttonQueue[clipXBut]).buttonY +
 	    (control->buttonQueue[clipXBut]).yHalf,Xoption);
-
   GSetForeground(trashGC,(float)monoColor(arcColor),Xoption);
   GFillArc(trashGC,volumeWindow,
 	   (int)(xClipMinN * (majorAxis-tinyArc) + clipXButX),	/* x value */
 	   (int)(clipXButY + minorAxis/2 + 1),			/* y value */
-	   arcSize,arcSize,0,360*64,Xoption);		    /* 64 units per degree */
+	   arcSize,arcSize,0,360*64,Xoption);	    /* 64 units per degree */
   GFillArc(trashGC,volumeWindow,
 	   (int)(xClipMaxN * (majorAxis-tinyArc) + clipXButX),	/* x value */
 	   (int)(clipXButY + minorAxis/2 - 7),			/* y value */
-	   arcSize,arcSize,0,360*64,Xoption);		    /* 64 units per degree */
-
+	   arcSize,arcSize,0,360*64,Xoption);	    /* 64 units per degree */
   GSetForeground(volumeGC,(float)monoColor(toggleColor),Xoption);
   GDrawString(volumeGC,volumeWindow,clipXMessX,clipXMessY,"X",1,Xoption);
-
 }
 
-void
-drawClipYBut (void)
-{
-
+@
+\subsection{drawClipYBut}
+\index{view3d!drawClipYBut}
+\index{drawClipYBut view3d}
+<<view3d>>=
+void drawClipYBut(void) {
   XClearArea(dsply,volumeWindow,clipYButX,clipYButY,
 	     minorAxis+blank,majorAxis+blank,False);
   GSetForeground(trashGC,(float)monoColor(toggleColor),Xoption);
@@ -24940,29 +16766,26 @@ drawClipYBut (void)
 	    (control->buttonQueue[clipYBut]).xHalf,
 	    (control->buttonQueue[clipYBut]).buttonY +
 	    (control->buttonQueue[clipYBut]).buttonHeight,Xoption);
-
   GSetForeground(trashGC,(float)monoColor(arcColor),Xoption);
-
   /* note: minimum buttons closer to the box */
   GFillArc(trashGC,volumeWindow,
 	   (int)(clipYButX + minorAxis/2 - 8),
 	   (int)(yClipMinN * (majorAxis-tinyArc) + clipYButY),
-	   arcSize,arcSize,90*64,360*64,Xoption);	/* 64 units per degree */
+	   arcSize,arcSize,90*64,360*64,Xoption); /* 64 units per degree */
   GFillArc(trashGC,volumeWindow,
 	   (int)(clipYButX + minorAxis/2 + 3),
 	   (int)(yClipMaxN * (majorAxis-tinyArc) + clipYButY),
-	   arcSize,arcSize,90*64,360*64,Xoption);	/* 64 units per degree */
-
+	   arcSize,arcSize,90*64,360*64,Xoption); /* 64 units per degree */
   GSetForeground(volumeGC,(float)monoColor(toggleColor),Xoption);
   GDrawString(volumeGC,volumeWindow,clipYMessX,clipYMessY,"Y",1,Xoption);
-
 }
 
-
-void
-drawClipZBut (void)
-{
-
+@
+\subsection{drawClipZBut}
+\index{view3d!drawClipZBut}
+\index{drawClipZBut view3d}
+<<view3d>>=
+void drawClipZBut(void) {
   XClearArea(dsply,volumeWindow,clipZButX,clipZButY,
 	     midAxis+blank,midAxis+blank,False);
   GSetForeground(trashGC,(float)monoColor(toggleColor),Xoption);
@@ -24970,45 +16793,36 @@ drawClipZBut (void)
 	    clipZButBotEndX,clipZButBotEndY,Xoption);
   GDrawLine(trashGC,volumeWindow,clipZButTopEndX-4,clipZButTopEndY,
 	    clipZButTopEndX,clipZButTopEndY,Xoption);
-
   GDrawLine(trashGC,volumeWindow,clipZButTopEndX,clipZButTopEndY-4,
 	    clipZButTopEndX,clipZButTopEndY,Xoption);
-
   GDrawLine(trashGC,volumeWindow,clipZButBotEndX+4,clipZButBotEndY,
 	    clipZButBotEndX,clipZButBotEndY,Xoption);
-
   GDrawLine(trashGC,volumeWindow,clipZButBotEndX,clipZButBotEndY+4,
 	    clipZButBotEndX,clipZButBotEndY,Xoption);
-
-
   GSetForeground(trashGC,(float)monoColor(arcColor),Xoption);
   GFillArc(trashGC,volumeWindow,
 	   (int)(zClipMinN * midAxis * zFactor + clipZButTopEndX - 3),
 	   (int)(zClipMinN * midAxis * zFactor + clipZButTopEndY + 3),
-	   arcSize,arcSize,45*64,360*64,Xoption);	/* 64 units per degree */
+	   arcSize,arcSize,45*64,360*64,Xoption);/* 64 units per degree */
   GFillArc(trashGC,volumeWindow,
 	   (int)(zClipMaxN * midAxis * zFactor + clipZButTopEndX + 3),
 	   (int)(zClipMaxN * midAxis * zFactor + clipZButTopEndY - 5),
-	   arcSize,arcSize,45*64,360*64,Xoption);	/* 64 units per degree */
-
+	   arcSize,arcSize,45*64,360*64,Xoption);/* 64 units per degree */
   GSetForeground(volumeGC,(float)monoColor(toggleColor),Xoption);
   GDrawString(volumeGC,volumeWindow,clipZMessX,clipZMessY,"Z",1,Xoption);
-
 }
 
-
-void
-drawClipVolume (void)
-{
-
+@
+\subsection{drawClipVolume}
+\index{view3d!drawClipVolume}
+\index{drawClipVolume view3d}
+<<view3d>>=
+void drawClipVolume(void) {
   float xminL,xmaxL,yminL,ymaxL,zminL,zmaxL;
-
   XClearArea(dsply,volumeWindow,backFaceX-1,backFaceY,
 	     lengthFace+deltaFace+2,lengthFace+deltaFace+1,False);
-
   GSetForeground(trashGC,(float)boxInline,Xoption);	/*boxOutline=133*/
   GSetLineAttributes(trashGC,0,LineSolid,CapButt,JoinMiter,Xoption);
-
   /* define corners of volume, clockwise, back to front */
   xminL = xClipMinN*lengthFace;
   xmaxL = xClipMaxN*lengthFace;
@@ -25016,7 +16830,6 @@ drawClipVolume (void)
   ymaxL = yClipMaxN*lengthFace;
   zminL = zClipMinN*zLength;
   zmaxL = (1-zClipMaxN)*zLength;  /* percentage upwards from bottom */
-
   flatClipBoxX[0]   = backFaceX + xminL + zminL;
   flatClipBoxY[0]   = backFaceY + yminL + zminL;
   flatClipBoxX[1]   = backFaceX + xmaxL + zminL;
@@ -25033,39 +16846,36 @@ drawClipVolume (void)
   flatClipBoxY[6]   = frontFaceY + ymaxL - zmaxL;
   flatClipBoxX[7]   = flatClipBoxX[4];
   flatClipBoxY[7]   = flatClipBoxY[6];
-
   /* now draw the volume */
   GDrawRectangle(trashGC,volumeWindow,
 		 flatClipBoxX[0],flatClipBoxY[0],
 		 flatClipBoxX[2]-flatClipBoxX[0],
 		 flatClipBoxY[2]-flatClipBoxY[0],Xoption);
-  GDrawLine(trashGC,volumeWindow,
-	    flatClipBoxX[0],flatClipBoxY[0],flatClipBoxX[4],flatClipBoxY[4],Xoption);
-  GDrawLine(trashGC,volumeWindow,
-	    flatClipBoxX[1],flatClipBoxY[1],flatClipBoxX[5],flatClipBoxY[5],Xoption);
-  GDrawLine(trashGC,volumeWindow,
-	    flatClipBoxX[2],flatClipBoxY[2],flatClipBoxX[6],flatClipBoxY[6],Xoption);
-  GDrawLine(trashGC,volumeWindow,
-	    flatClipBoxX[3],flatClipBoxY[3],flatClipBoxX[7],flatClipBoxY[7],Xoption);
+  GDrawLine(trashGC,volumeWindow,flatClipBoxX[0],flatClipBoxY[0],
+            flatClipBoxX[4],flatClipBoxY[4],Xoption);
+  GDrawLine(trashGC,volumeWindow,flatClipBoxX[1],flatClipBoxY[1],
+            flatClipBoxX[5],flatClipBoxY[5],Xoption);
+  GDrawLine(trashGC,volumeWindow,flatClipBoxX[2],flatClipBoxY[2],
+            flatClipBoxX[6],flatClipBoxY[6],Xoption);
+  GDrawLine(trashGC,volumeWindow,flatClipBoxX[3],flatClipBoxY[3],
+            flatClipBoxX[7],flatClipBoxY[7],Xoption);
   GSetForeground(trashGC,(float)boxOutline,Xoption);
   GDrawRectangle(trashGC,volumeWindow,
 		 flatClipBoxX[4],flatClipBoxY[4],
 		 flatClipBoxX[6]-flatClipBoxX[4],
 		 flatClipBoxY[6]-flatClipBoxY[4],Xoption);
   /* make sure volumeGC is set properly before calling these functions */
-
 } /* drawClipVolume() */
 
-
-void
-drawHitherControl (void)
-{
-
+@
+\subsection{drawHitherControl}
+\index{view3d!drawHitherControl}
+\index{drawHitherControl view3d}
+<<view3d>>=
+void drawHitherControl(void) {
   float xx,b,slope;
   int hitherTop, hitherBot;
-
   float b0x,b1x;
-
    /* draw box indicating minimum and maximum distance of projection */
   GSetForeground(trashGC,(float)hitherBoxColor,Xoption);
   b0x = (pzMin - clipPlaneMin)/(clipPlaneMax-clipPlaneMin);
@@ -25075,10 +16885,8 @@ drawHitherControl (void)
   GDraw3DButtonOut(trashGC,volumeWindow,
 		 (int)(b0x),frusY(hitherBoxTop),
 		 (int)fabs(b1x-b0x),hitherBoxHeight,Xoption);
-
     /* draw the hither plane */
   GSetForeground(trashGC,(float)hitherColor,Xoption);
-
   /* percentage x */
   xx = ((viewData.clipPlane-clipPlaneMin)/(clipPlaneMax-clipPlaneMin));
   xx = hitherMaxX - xx*(hitherMaxX - hitherMinX);  /* screen x */
@@ -25092,7 +16900,6 @@ drawHitherControl (void)
   hitherBot = slope * xx + b + 0.5;
   GDrawLine(trashGC,volumeWindow, frusX((int)xx),frusY(hitherTop),
 	    frusX((int)xx),frusY(hitherBot),Xoption);
-
   /* draw hither control box and bar */
   GDraw3DButtonOut(trashGC,volumeWindow,
 		 frusX(hitherWinX),frusY(hitherWinY+5),
@@ -25101,38 +16908,35 @@ drawHitherControl (void)
 	    frusX(hitherMinX),frusY(hitherBarY+5),
 	    frusX(hitherMaxX),frusY(hitherBarY+5),Xoption);
   /* draw hither plane I/O pointer arrow */
-
   GDrawLine(trashGC,volumeWindow,
 	    frusX((int)xx),frusY(hitherBarY+2),
 	    frusX((int)xx),frusY(hitherBarY+8),Xoption);
-
    /* print string label */
   GSetForeground(volumeGC,(float)hitherColor,Xoption);
-  GDrawString(volumeGC,volumeWindow,hitherMessX,hitherMessY,"Hither",6,Xoption);
-
+  GDrawString(volumeGC,volumeWindow,hitherMessX,hitherMessY,
+              "Hither",6,Xoption);
 }
 
-void
-drawEyeControl (void)
-{
-
+@
+\subsection{drawEyeControl}
+\index{view3d!drawEyeControl}
+\index{drawEyeControl view3d}
+<<view3d>>=
+void drawEyeControl(void) {
   float here;
   int there;
-
   GSetForeground(trashGC,(float)eyeColor,Xoption);
-
     /* draw the eyeDistance box & slide bar */
-  GDraw3DButtonOut(trashGC,volumeWindow,
-		 frusX(eyeWinX),frusY(eyeWinY+5),eyeWidth,eyeHeight,Xoption);
-  GDrawLine(trashGC,volumeWindow,
-	    frusX(eyeMinX),frusY(eyeBarY+5),frusX(eyeMaxX),frusY(eyeBarY+5),Xoption);
+  GDraw3DButtonOut(trashGC,volumeWindow,frusX(eyeWinX),frusY(eyeWinY+5),
+                   eyeWidth,eyeHeight,Xoption);
+  GDrawLine(trashGC,volumeWindow,frusX(eyeMinX),frusY(eyeBarY+5),
+            frusX(eyeMaxX),frusY(eyeBarY+5),Xoption);
   here = (viewData.eyeDistance - minEyeDistance) /
 	 (maxEyeDistance - minEyeDistance);
   here = pow((double)here,0.333333);
   there = here * (eyeMaxX - eyeMinX) + eyeMinX;	 /* screen x */
-  GDrawLine(trashGC,volumeWindow,
-	    frusX(there),frusY(eyeBarY+2),frusX(there),frusY(eyeBarY+8),Xoption);
-
+  GDrawLine(trashGC,volumeWindow,frusX(there),frusY(eyeBarY+2),
+            frusX(there),frusY(eyeBarY+8),Xoption);
     /* draw the eye */
   GSetLineAttributes(trashGC,2,LineSolid,CapButt,JoinMiter,Xoption);
   GSetForeground(trashGC,(float)monoColor(52),Xoption);
@@ -25150,25 +16954,19 @@ drawEyeControl (void)
 	    frusX(there+4),frusY(frustrumMidY+2),
 	    frusX(there+3),frusY(frustrumMidY),Xoption);
   GSetLineAttributes(trashGC,0,LineSolid,CapButt,JoinMiter,Xoption);
-
   /* draw string label */
   GSetForeground(volumeGC,(float)eyeColor,Xoption);
   GDrawString(volumeGC,volumeWindow,eyeDistMessX,eyeDistMessY,
 	      "Eye Distance",strlen("eye distance"),Xoption);
-
 }
 
-
-/**************************
- * void drawFrustrum() *
- **************************/
-
-void
-drawFrustrum (void)
-{
-
+@
+\subsection{drawFrustrum}
+\index{view3d!drawFrustrum}
+\index{drawFrustrum view3d}
+<<view3d>>=
+void drawFrustrum(void) {
   float normalizedEyeDistance;
-
   XClearArea(dsply,volumeWindow,
 	     control->buttonQueue[frustrumBut].buttonX,
 	     control->buttonQueue[frustrumBut].buttonY,
@@ -25189,26 +16987,18 @@ drawFrustrum (void)
   GDrawLine(trashGC,volumeWindow,
 	    frusX(frustrumX),frusY(frustrumBotY),
 	    frusX(frustrumVertex),frusY(frustrumMidY),Xoption);
-
   /* draw controls */
   drawHitherControl();
   drawEyeControl();
-
 } /* drawFrustrum() */
 
-
-
-/**************************
- * void drawVolumePanel() *
- **************************/
-
-void
-drawVolumePanel (void)
-{
-
+@
+\subsection{drawVolumePanel}
+\index{view3d!drawVolumePanel}
+\index{drawVolumePanel view3d}
+<<view3d>>=
+void drawVolumePanel(void) {
   int i,strlength;
-
-
 	    /* Draw some lines for volume panel. */
   GSetForeground(trashGC,(float)foregroundColor,Xoption);
   GSetLineAttributes(trashGC,3,LineSolid,CapButt,JoinMiter,Xoption);
@@ -25219,7 +17009,6 @@ drawVolumePanel (void)
 	    volumeTitleA, Xoption);
   GDrawLine(trashGC, volumeWindow, 0, volumeTitleB, controlWidth,
 	    volumeTitleB, Xoption);
-
   writeControlTitle(volumeWindow);
   s = "Viewing Volume Panel";
   strlength = strlen(s);
@@ -25227,20 +17016,16 @@ drawVolumePanel (void)
   GDrawString(anotherGC,volumeWindow,
 	      centerX(anotherGC,s,strlength,controlWidth),
 	      volumeTitleA+18,s,strlength,Xoption);
-
   GSetForeground(anotherGC,(float)monoColor(toggleColor),Xoption);
   GDrawString(anotherGC,volumeWindow,
 	      control->buttonQueue[perspectiveBut].buttonX + 4,
 	      control->buttonQueue[perspectiveBut].buttonY - 17,
 	      "Settings", 8, Xoption);
-
   GSetForeground(trashGC,(float)monoColor(toggleColor),Xoption);
   GDraw3DButtonOut(trashGC,volumeWindow,
 		 control->buttonQueue[perspectiveBut].buttonX - 7,
 		 control->buttonQueue[perspectiveBut].buttonY - 36,
 		 100,100,Xoption);
-
-
   for (i=0; i<strlen(clipMess); i++)
     GDrawString(trashGC,volumeWindow,clipMessX,clipMessY + i*clipMessDy,
 		&(clipMess[i]),1,Xoption);
@@ -25250,12 +17035,12 @@ drawVolumePanel (void)
   for (i=0; i<strlen(eyeMess2); i++)
     GDrawString(trashGC,volumeWindow,eyeMess2X,eyeMess2Y + i*eyeMess2Dy,
 		&(eyeMess2[i]),1,Xoption);
-
   GSetLineAttributes(trashGC,0,LineSolid,CapButt,JoinMiter,Xoption);
   GSetForeground(trashGC,(float)volumeButtonColor,Xoption);
   for (i=volumeButtonsStart; i<(volumeButtonsEnd); i++) {
     GSetForeground(trashGC,
-		   (float)monoColor((control->buttonQueue[i]).textColor),Xoption);
+                  (float)monoColor((control->buttonQueue[i]).textColor),
+                  Xoption);
     switch (i) {
     case perspectiveBut:
     case clipRegionBut:
@@ -25267,7 +17052,8 @@ drawVolumePanel (void)
 		     (control->buttonQueue[i]).buttonWidth,
 		     (control->buttonQueue[i]).buttonHeight,Xoption);
       GSetForeground(volumeGC,
-		     (float)monoColor((control->buttonQueue[i]).textColor),Xoption);
+		     (float)monoColor((control->buttonQueue[i]).textColor),
+                     Xoption);
       GDrawString(volumeGC,volumeWindow,
 		  (control->buttonQueue[i]).buttonX +
 		  (control->buttonQueue[i]).buttonWidth + 4,
@@ -25299,24 +17085,18 @@ drawVolumePanel (void)
 		    (control->buttonQueue[i]).buttonY +
 		    centerY(volumeGC,(control->buttonQueue[i]).buttonHeight),
 		    "x",1,Xoption);
-
       break;
-
     case clipXBut:
       drawClipXBut();
       break;
-
     case clipYBut:
       drawClipYBut();
       break;
-
     case clipZBut:
       drawClipZBut();
       break;
-
     case frustrumBut:
       break;
-
     default:
       GDraw3DButtonOut(trashGC,volumeWindow,
 		     (control->buttonQueue[i]).buttonX,
@@ -25326,7 +17106,8 @@ drawVolumePanel (void)
       s = (control->buttonQueue[i]).text;
       strlength = strlen(s);
       GSetForeground(trashGC,
-		     (float)monoColor((control->buttonQueue[i]).textColor),Xoption);
+		     (float)monoColor((control->buttonQueue[i]).textColor),
+                     Xoption);
       GDrawString(trashGC,volumeWindow,
 		  (control->buttonQueue[i]).buttonX +
 		  centerX(processGC,s,strlength,
@@ -25336,335 +17117,19 @@ drawVolumePanel (void)
 		  s,strlen(s),Xoption);
     }  /* switch */
   }  /* for i in volumeButtons */
-
   drawFrustrum();
   drawClipVolume();   /*** put in header ***/
   drawClipXBut();
   drawClipYBut();
   drawClipZBut();
-
 } /* drawVolumePanel() */
 
-
 @
-\section{volume.h}
-<<view3d/volume.h>>=
-/*#define rightLeft*/
-#define leftRight
-#define newStuff
-
-   /******* Define's ********/
-      /*** box colors ***/
-#define boxInline	monoColor(140)
-#define boxOutline	monoColor(140)
-#define clipBoxInline	monoColor(148) 
-#define clipBoxOutline	monoColor(148) 
-
-#define lightB		205
-#define lightPotA	(control->buttonQueue[lightMoveZ].buttonY - 15)
-#define lightPotB	(control->buttonQueue[lightMoveZ].buttonY +\
-			 control->buttonQueue[lightMoveZ].buttonHeight + 7)
-#define lightTransL	(control->buttonQueue[lightTranslucent].buttonX - 20)
-
-#define volumeTitleColor monoColor(77)
-#define volumeTitleA	190
-#define volumeTitleB	217
-
-#define volumeMASK	ExposureMask
-
-#define frustrumColor	monoColor(147)
-#define frustrumX	30
-#define frustrumY	20
-#define frustrumLength	100
-#define frustrumMidY	70    /* frustrumY + frustrumLength/2 */
-#define frustrumBotY	(frustrumY + frustrumLength)
-#ifdef  newStuff
-#define frustrumMin	(control->buttonQueue[frustrumBut].xHalf)
-#define frustrumMax	(frustrumMin + \
-			 (control->buttonQueue[frustrumBut].xHalf))
-#endif
-
-#define hitherColor	monoColor(68)   /* clipping plane */
-#define hitherMinX	(frustrumX + 5)
-#define hitherMaxX	(frustrumMin - 30)
-#define hitherWinX	(hitherMinX - 5)
-#define hitherWinY	(frustrumBotY + 10)
-#define hitherWidth	(hitherMaxX - hitherMinX + 10)
-#define hitherHeight	20
-#define hitherBarY	(hitherWinY + 10)   /* hitherWinY + hitherHeight/2 */
-
-#ifdef  newStuff
-#define eyeColor	monoColor(131)
-#define eyeMinX		frustrumMin
-#define eyeMaxX		frustrumMax
-#define eyeWinX		(eyeMinX - 5)
-#define eyeWinY		hitherWinY
-#define eyeWidth	(eyeMaxX - eyeMinX + 10)
-#define eyeHeight	hitherHeight
-#define eyeBarY		hitherBarY
-#endif
-
-#define volumeButtonColor	monoColor(157)
-
-#define frustrumWindowX		30
-#define frustrumWindowY		28
-#define frustrumWindowWidth	(controlWidth - 60)
-#define frustrumWindowHeight	(frustrumBotY + 40)
-
-/**** clip volume ****/
-#define lengthFace	80
-#ifdef  rightLeft
-#define backFaceX	190
-#endif
-#ifdef  leftRight
-#define backFaceX	33
-#endif
-#define backFaceY	255
-#define deltaFace	25
-#define zLength		35.355 /* sqrt(2*deltaFace^2) */
-#ifdef  rightLeft
-#define frontFaceX	(backFaceX - deltaFace)
-#endif
-#ifdef  leftRight
-#define frontFaceX	(backFaceX + deltaFace)
-#endif
-#define frontFaceY	(backFaceY + deltaFace)
-
-
-#define majorAxis	lengthFace    /* size of the potentiometers */
-#define minorAxis	20
-#define midAxis		40
-
-#define clipXButX	backFaceX
-#define clipXButY	(backFaceY-30)
-
-#ifdef  rightLeft
-#define clipYButX	(frontFaceX - minorAxis - 10)
-#endif
-#ifdef  leftRight
-#define clipYButX	(frontFaceX + lengthFace + 10)
-#endif
-#define clipYButY	frontFaceY
-
-#ifdef  rightLeft
-#define clipZButX	clipYButX  /* align left side */
-#endif
-#ifdef  leftRight
-#define clipZButX	(clipYButX+minorAxis-midAxis) /* align right side */
-#endif
-#define clipZButY	clipXButY
-
-#define zFactor		0.6   /* ratio of clipZBut box & actual input area */
-#define minDistXY	0.1   /* min distance between normalized clip faces */
-#define minDistZ	0.06  /* 2/3 of XY */
-
-
-#ifdef  rightLeft
-#define AA		(clipZButX + midAxis)
-#define BB		clipZButY
-#define CC		backFaceX
-#define DD		backFaceY
-#define EE		frontFaceX
-#define FF		frontFaceY
-#define clipZButTopEndX ((AA+BB+CC-DD)/2)
-#define clipZButTopEndY ((AA+BB-CC+DD)/2)
-#define clipZButBotEndX ((AA+BB+EE-FF)/2)
-#define clipZButBotEndY ((AA+BB-EE+FF)/2)
-#endif
-
-#ifdef  leftRight
-#define AA		clipZButX
-#define BB		clipZButY
-#define CC		(backFaceX + majorAxis)
-#define DD		backFaceY
-#define EE		(frontFaceX + majorAxis)
-#define FF		frontFaceY
-
-#define clipZButTopEndX ((AA-BB+CC+DD)/2)
-#define clipZButTopEndY ((BB-AA+CC+DD)/2)
-#define clipZButBotEndX ((AA-BB+EE+FF)/2)
-#define clipZButBotEndY ((BB-AA+EE+FF)/2)
-#endif
-@
-\section{write3d.c}
-<<view3d/write3d.c>>=
-#define _WRITE3D_C
-
-#include <stdio.h>
-#include <stdlib.h>
-
-<<view3d/header.h>>
-<<include/write.h>>
-#define spadActionMode
-/* define spadEventMode */
-#define components
-
-
-#include "pixmap.h1"
-#include "xshade.h1"
-extern int PSCreateFile(int , Window , Window , char * );
-extern int GdrawsDrawFrame(int , Window , Window , char * );
-extern int GdrawsSetDimension(Window , Window );
-extern int GDrawImageString(GC , Window , int , int , char * , int , int );
-extern int GDrawArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int GDrawLine(GC , Window , int , int , int , int , int );
-extern int GDrawLines(GC , Window , XPoint * , int , int , int );
-extern int GDrawPoint(Window , GC , int , int , int );
-extern int GDrawString(GC , Window , int , int , char * , int , int );
-extern int GFillArc(GC , Window , int , int , unsigned int , unsigned int , int , int , int );
-extern int PSGlobalInit(void );
-extern int PSInit(Window , Window );
-extern int PSCreateContext(GC , char * , int , int , int , float , float );
-extern char * PSfindGC(GC );
-extern int GSetForeground(GC , float , int );
-extern int GSetBackground(GC , float , int );
-extern int GSetLineAttributes(GC , int , int , int , int , int );
-extern int PSClose(void );
-extern int centerX(GC , char * , int , int );
-extern int centerY(GC , int );
-extern int PSColorPolygon(float , float , float , XPoint * , int );
-extern int PSColorwOutline(float , float , float , XPoint * , int );
-extern int PSDrawColor(float , float , float , XPoint * , int );
-extern int PSFillPolygon(GC , XPoint * , int );
-extern int PSFillwOutline(GC , XPoint * , int );
-extern HashTable * XCreateAssocTable(int );
-extern void XMakeAssoc(Display * , HashTable * , Window , int * );
-extern int * XLookUpAssoc(Display * , HashTable * , Window );
-extern void XDeleteAssoc(Display * , HashTable * , Window );
-extern int GDrawRectangle(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonOut(GC , Window , short , short , short , short , int );
-extern int GDraw3DButtonIn(GC , Window , short , short , short , short , int );
-extern int GDrawPushButton(Display * , GC , GC , GC , Window , short , short , short , short , int , char * , unsigned long , unsigned long , int );
-#ifdef _GFUN_C
-static void filecopy(FILE * , FILE * );
-static int TrivEqual(Window , Window );
-static int TrivHashCode(Window , int );
-#endif
-
-extern viewTriple * traverse(int );
-extern float absolute(float );
-extern float get_random(void );
-extern triple norm_dist(void );
-extern void goodbye(int);
-extern int initButtons(buttonStruct * );
-extern int writeViewport(int );
-extern int initVolumeButtons(buttonStruct * );
-extern void makeVolumePanel(void );
-extern void drawClipXBut(void );
-extern void drawClipYBut(void );
-extern void drawClipZBut(void );
-extern void drawClipVolume(void );
-extern void drawHitherControl(void );
-extern void drawEyeControl(void );
-extern void drawFrustrum(void );
-extern void drawVolumePanel(void );
-extern void drawColorMap(void);
-extern void writeControlTitle(Window );
-extern void clearControlMessage(void);
-extern void writeControlMessage(void);
-extern void drawControlPanel(void);
-extern controlXY getControlXY(int );
-extern controlPanelStruct * makeControlPanel(void);
-extern void putControlPanelSomewhere(int );
-extern void matrixMultiply4x4(float [4][4] , float [4][4] , float [4][4]);
-extern void vectorMatrix4(float [4] , float [4][4] , float [4]);
-extern void ROTATE(float [4][4]);
-extern void ROTATE1(float [4][4]);
-extern void SCALE(float  , float  , float  , float [4][4]);
-extern void TRANSLATE(float  , float  , float  , float [4][4]);
-extern void closeViewport(void);
-extern float phong(triple  , float [3]);
-extern int hueValue(float );
-extern int getHue(float );
-extern float Value(float  , float  , float );
-extern RGB hlsTOrgb(float  , float  , float );
-extern poly * merge(poly *  , poly *  , int (*)(poly *  , poly * ));
-extern poly * msort(poly *  , int  , int  , int (*)(poly *  , poly * ));
-extern void drawLineComponent(poly *  , int );
-extern void drawOpaquePolygon(poly *  , GC  , GC  , int );
-extern poly * copyPolygons(poly * );
-extern void minMaxPolygons(poly * );
-extern int polyCompare(poly *  , poly * );
-extern void calcEyePoint(void );
-extern void drawRenderedPolygon(poly *  , int );
-extern void freePointResevoir(void);
-extern void freeListOfPolygons(poly * );
-extern void drawPolygons(int );
-extern int lessThan(float  , float );
-extern int greaterThan(float  , float );
-extern int isNaN(float );
-extern int isNaNPoint(float  , float  , float );
-extern int equal(float  , float );
-extern void getMeshNormal(float, float, float, float, float, float,
-                          float, float, float, float, float, float [3]);
-extern void normalizeVector(float * );
-extern float dotProduct(float *  , float *  , int );
-extern void project(viewTriple *  , XPoint *  , int );
-extern void projectAPoint(viewTriple * );
-extern void projectAllPoints(void);
-extern void projectAllPolys(poly * );
-extern void projectAPoly(poly * );
-extern void projectStuff(float, float, float, int *, int *, float *);
-extern int makeLightingPanel(void);
-extern void drawLightingAxes(void);
-extern void drawLightTransArrow(void);
-extern void drawLightingPanel(void);
-extern int initLightButtons(buttonStruct * );
-extern int readViewman(void *  , int );
-extern void scalePoint(viewTriple * );
-extern int spadAction(void);
-extern void writeTitle(void);
-extern void drawPreViewport(int );
-extern void drawTheViewport(int );
-extern int keepDrawingViewport(void);
-extern viewPoints * makeViewport(void);
-extern void postMakeViewport(void);
-extern mouseCoord getPotValue(short  , short  , short  , short );
-extern mouseCoord getLinearPotValue(short  , short  , short  , short );
-extern void buttonAction(int );
-extern void processEvents(void);
-extern int initQuitButtons(buttonStruct * );
-extern int makeQuitPanel(void);
-extern void drawQuitPanel(void);
-extern void scaleComponents(void);
-extern void makeTriangle(int  , int  , int );
-extern void triangulate(void);
-extern void readComponentsFromViewman(void);
-extern void calcNormData(void);
-extern viewPoints * make3DComponents(void);
-extern void draw3DComponents(int );
-extern char get_cBuffer_axes(int );
-extern void put_cBuffer_axes(int  , char );
-extern int get_cBuffer_indx(int );
-extern void put_cBuffer_indx(int  , int );
-extern void put_zBuffer(int  , float );
-extern float get_zBuffer(int );
-extern void put_imageX(int  , char );
-extern void drawPhongSpan(triple  , float [3] , int );
-extern void scanPhong(int );
-extern void boxTObuffer(void );
-extern void clipboxTObuffer(void );
-extern void axesTObuffer(void );
-extern void scanLines(int );
-extern void freePolyList(void );
-extern void showAxesLabels(int );
-extern void changeColorMap(void );
-extern void drawPhong(int );
-extern int initSaveButtons(buttonStruct * );
-extern int makeSavePanel(void);
-extern void drawSavePanel(void);
-extern int main(void);
-extern void mergeDatabases(void);
-
-
-  /* upper limit as to how many kinds of files could be written (numBits-1) */
-#define numBits (8*sizeof(int))
-#define StellarColors 9
-
-int 
-writeViewport (int thingsToWrite)
-{
-
+\subsection{writeViewport}
+\index{view3d!writeViewport}
+\index{writeViewport view3d}
+<<view3d>>=
+int writeViewport(int thingsToWrite) {
   int               i, j, k, ii, code, *anIndex;
   LLPoint           *anLLPoint;
   LPoint            *anLPoint;
@@ -25674,7 +17139,6 @@ writeViewport (int thingsToWrite)
   char              viewDirName[80], viewDataFilename[80],
                     viewBitmapFilename[80], viewPixmapFilename[80],
                     command[80];
-
   XGetWindowAttributes(dsply,viewport->titleWindow,&vwInfo);
   sprintf(viewDirName,"%s%s",filename,".view"); 
   sprintf(command,"%s%s%s","rm -r ",viewDirName," >  /dev/null 2>&1");
@@ -25685,7 +17149,6 @@ writeViewport (int thingsToWrite)
     fprintf(stderr,"   Error: Cannot create %s\n",viewDirName);
     return(-1);
   } else {
-
             /*** Create the data file ***/
     sprintf(viewDataFilename,"%s%s",viewDirName,"/data");
     if ((viewDataFile = fopen(viewDataFilename,"w")) == NULL) {
@@ -25714,7 +17177,6 @@ writeViewport (int thingsToWrite)
 	      viewport->translucency);
       fprintf(viewDataFile,"%d %g\n",viewData.perspective,
 	      viewData.eyeDistance);
-
       /* write out the generalized 3D components */
       fprintf(viewDataFile,"%d\n",viewData.numOfPoints);
       for (i=0; i<viewData.numOfPoints; i++) {
@@ -25740,12 +17202,11 @@ writeViewport (int thingsToWrite)
       } /* for LLPoints in LLLPoints (i) */
       fclose(viewDataFile);
     }  /* else was able to open file under the given filename */
-
            /* write out special files */
     for (ii=1; ii<numBits; ii++) {   /* write.h is one-based */
       if (thingsToWrite & (1<<ii)) {
         switch (ii) {
-        case Bitmap:
+        case aBitmap:
             /*** Create the pixmap (bitmaps need leaf name) ***/
           sprintf(viewBitmapFilename,"%s%s%s",viewDirName,"/","image.bm");
           XGetWindowAttributes(dsply,viewport->viewWindow,&vwInfo);
@@ -25753,8 +17214,7 @@ writeViewport (int thingsToWrite)
 				  viewport->titleWindow,vwInfo.width,
 				  vwInfo.height+vwInfo.border_width+20,-1,-1);
           break;
-
-        case Pixmap:
+        case aPixmap:
             /*** Create the pixmap (bitmaps need leaf name) ***/
           sprintf(viewPixmapFilename,"%s%s%s",viewDirName,"/","image.xpm");
           XGetWindowAttributes(dsply,viewport->viewWindow,&vwInfo);
@@ -25762,8 +17222,7 @@ writeViewport (int thingsToWrite)
                                    viewport->titleWindow,0,0,vwInfo.width,
                                    vwInfo.height+titleHeight);
           break;
-
-        case Image:
+        case anImage:
             /*** Create the image (bitmaps need leaf name) ***/
           writeImage = yes;
           sprintf(viewPixmapFilename,"%s%s%s",viewDirName,"/","image.xpm");
@@ -25793,11 +17252,9 @@ writeViewport (int thingsToWrite)
           code = XWriteBitmapFile(dsply,viewBitmapFilename,
 				  viewport->titleWindow,vwInfo.width,
 				  vwInfo.height+vwInfo.border_width+20,-1,-1);
-                                  
           writeImage = no;
           break;
-
-        case Postscript:
+        case aPostscript:
             /*** Create postscript output for viewport (in axiom3d.ps) ***/
          sprintf(PSfilename,"%s%s",viewDirName,"/axiom3d.ps");
 	 if (PSInit(viewport->viewWindow,viewport->titleWindow) == psError)
@@ -25810,16 +17267,301 @@ writeViewport (int thingsToWrite)
         } /* switch on ii */
       }  /* if thingsToWrite >> ii */
     }  /* for ii */
-
     return(0);
   }    /* else create directory okay */
-
 }
+
+@
+\subsection{main}
+\index{view3d!main}
+\index{main view3d}
+<<view3d>>=
+int main(void) {
+  XGCValues     controlGCVals;
+  int           i, code;
+  char property[256];
+  char *prop = &property[0];
+  char *str_type[20];
+  XrmValue value;
+  /**** Global inits ****/
+  splitPoints = NIL(viewTriple);
+  /**** Set up display ****/
+  if ((dsply = XOpenDisplay(getenv("DISPLAY"))) == NULL)
+    {fprintf(stderr,"Could not open display.\n");exit (-1);}
+  scrn = DefaultScreen(dsply);
+  rtWindow = RootWindow(dsply,scrn);
+  XSetErrorHandler(theHandler);
+  /*   XSynchronize(dsply,False); */
+  /**** link Xwindows to viewports - X10 feature ****/
+  table = XCreateAssocTable(nbuckets);  
+  /**** Create Axiom color map ****/
+  totalShades = 0;
+  totalColors = XInitSpadFill(dsply,scrn,&colorMap,
+                              &totalHues,&totalSolidShades,
+                              &totalDitheredAndSolids,&totalShades);
+  if (totalColors < 0) {
+    fprintf(stderr,"ERROR: Could not allocate all the necessary colors.\n");
+    exitWithAck(RootWindow(dsply,scrn),Window,-1);
+  }
+  mergeDatabases();
+  /*** Determine whether monochrome or color is used ***/
+  if (XrmGetResource(rDB,"Axiom.3D.monochrome","",str_type,&value) == True){
+     (void) strncpy(prop,value.addr,(int)value.size);
+     }
+  else {
+     (void) strcpy(prop, "off");
+     }
+  mono = ((totalSolid == 2) || (strcmp(prop,"on") == 0));
+  if (mono) maxGreyShade=XInitShades(dsply,scrn) ;
+
+  if (XrmGetResource(rDB,"Axiom.3D.inverse","",str_type,&value) == True){
+     (void) strncpy(prop,value.addr,(int)value.size);
+     }
+  else {
+     (void) strcpy(prop, "off");
+     }
+
+  if (mono) {
+    if (strcmp(prop,"on") == 0) {  /* 0 if equal - inverse video */
+      foregroundColor = white;
+      backgroundColor = black;
+    } else {  /* off - no inverse video */
+      foregroundColor = black;
+      backgroundColor = white;
+    }
+  } else {  /* inverse of inverse in color (for some strange reason) */
+    if (strcmp(prop,"on") == 0) {  /* 0 if equal - inverse video */
+      foregroundColor = white;
+      backgroundColor = black;
+    } else {  /* off - no inverse video */
+      foregroundColor = black;
+      backgroundColor = white;
+    }
+  }
+  /* read default file name for postScript output */
+  if (XrmGetResource(rDB,"Axiom.3D.postscriptFile","",str_type,&value) == True){
+     (void) strncpy(prop,value.addr,(int)value.size);
+     }
+  else {
+     (void) strcpy(prop, "axiom3d.ps");
+     }
+  PSfilename = (char *)malloc(strlen(prop)+1);
+  strcpy(PSfilename,prop);
+  XSync(dsply,0);
+  /**** Open global fonts ****/
+   serverFont = XQueryFont(dsply,XGContextFromGC(DefaultGC(dsply,scrn)));
+  if (XrmGetResource(rDB,"Axiom.3D.messageFont","Axiom.3D.Font",str_type,&value) == True){
+     (void) strncpy(prop,value.addr,(int)value.size);
+     }
+  else {
+     (void) strcpy(prop,messageFontDefault);
+     }
+  if ((globalFont = XLoadQueryFont(dsply, prop)) == NULL) {
+     fprintf(stderr, "Warning:  could not get the %s font for messageFont\n",prop);
+     globalFont = serverFont;
+  }
+  if (XrmGetResource(rDB,"Axiom.3D.buttonFont","Axiom.3D.Font",str_type,&value) == True){
+     (void) strncpy(prop,value.addr,(int)value.size);
+     }
+  else {
+     (void) strcpy(prop,buttonFontDefault);
+     }
+  if ((buttonFont = XLoadQueryFont(dsply, prop)) == NULL) {
+     fprintf(stderr, "Warning:  could not get the %s font for buttonFont\n",prop);
+     buttonFont = serverFont;
+  }
+  if (XrmGetResource(rDB,"Axiom.3D.headerFont","Axiom.3D.Font",str_type,&value) == True){
+     (void) strncpy(prop,value.addr,(int)value.size);
+     }
+  else {
+     (void) strcpy(prop,headerFontDefault);
+     }
+  if ((headerFont = XLoadQueryFont(dsply, prop)) == NULL) {
+     fprintf(stderr, "Warning:  could not get the %s font for headerFont\n",prop);
+     headerFont = serverFont;
+  }
+  if (XrmGetResource(rDB,"Axiom.3D.titleFont","Axiom.3D.Font",str_type,&value) == True){
+     (void) strncpy(prop,value.addr,(int)value.size);
+     }
+  else {
+     (void) strcpy(prop,titleFontDefault);
+     }
+  if ((titleFont = XLoadQueryFont(dsply, prop)) == NULL) {
+     fprintf(stderr, "Warning:  could not get the %s font for titleFont\n",prop);
+     titleFont = serverFont;
+  }
+  if (XrmGetResource(rDB,"Axiom.3D.lightingFont","Axiom.3D.Font",str_type,&value) == True){
+     (void) strncpy(prop,value.addr,(int)value.size);
+     }
+  else {
+     (void) strcpy(prop,lightingFontDefault);
+     }
+  if ((lightingFont = XLoadQueryFont(dsply, prop)) == NULL) {
+     fprintf(stderr, "Warning:  could not get the %s font for lightingFont\n",prop);
+     lightingFont = serverFont;
+  }
+  if (XrmGetResource(rDB,"Axiom.3D.volumeFont","Axiom.3D.Font",str_type,&value) == True){
+     (void) strncpy(prop,value.addr,(int)value.size);
+     }
+  else {
+     (void) strcpy(prop,volumeFontDefault);
+     }
+  if ((volumeFont = XLoadQueryFont(dsply, prop)) == NULL) {
+     fprintf(stderr, "Warning:  could not get the %s font for volumeFont\n",prop);
+     volumeFont = serverFont;
+  }
+ /**** Create widely used Graphic Contexts ****/
+  PSGlobalInit();
+  /* must initiate before using any G/PS functions */
+  /* need character name: used as postscript GC variable */
+  /* need to create ps GCs for all GCs used by drawing in viewWindow */
+                     /* globalGC1 */
+  controlGCVals.foreground  = monoColor(axesColor);
+  controlGCVals.background  = backgroundColor;
+  globalGC1  = XCreateGC(dsply,rtWindow,GCForeground |
+                         GCBackground ,&controlGCVals);
+  carefullySetFont(globalGC1,globalFont);
+  PSCreateContext(globalGC1, "globalGC1", psNormalWidth, psButtCap,
+		  psMiterJoin, psWhite, psBlack);
+                     /* controlMessageGC */
+  controlGCVals.foreground  = controlMessageColor;
+  controlGCVals.background  = backgroundColor;
+  controlMessageGC      = XCreateGC(dsply,rtWindow,GCForeground |
+				    GCBackground ,&controlGCVals);
+  carefullySetFont(controlMessageGC,globalFont);
+                     /* globalGC2 */
+  controlGCVals.foreground = monoColor(labelColor);
+  globalGC2 = XCreateGC(dsply,rtWindow,GCForeground,&controlGCVals);
+  carefullySetFont(globalGC2,buttonFont);
+  PSCreateContext(globalGC2, "globalGC2", psNormalWidth, psButtCap,
+		  psMiterJoin, psWhite, psBlack);
+                     /* trashGC */
+  controlGCVals.function = GXcopy; 
+  trashGC  = XCreateGC(dsply,rtWindow,0 ,&controlGCVals);
+  carefullySetFont(trashGC,buttonFont);
+  PSCreateContext(trashGC, "trashGC", psNormalWidth, psButtCap,
+		  psMiterJoin, psWhite, psBlack);
+                    /* componentGC */
+  componentGC  = XCreateGC(dsply,rtWindow,0 ,&controlGCVals);
+  carefullySetFont(componentGC,buttonFont);
+  PSCreateContext(componentGC, "componentGC", psNormalWidth, psButtCap,
+		  psMiterJoin, psWhite, psBlack);
+                   /* opaqueGC */
+  opaqueGC  = XCreateGC(dsply,rtWindow,0 ,&controlGCVals);
+  carefullySetFont(opaqueGC,buttonFont);
+  PSCreateContext(opaqueGC, "opaqueGC", psNormalWidth, psButtCap,
+		  psMiterJoin, psWhite, psBlack);
+                   /* renderGC */
+  renderGC  = XCreateGC(dsply,rtWindow,0,&controlGCVals);
+  carefullySetFont(renderGC,buttonFont);
+  PSCreateContext(renderGC, "renderGC", psNormalWidth, psButtCap,
+		  psMiterJoin, psWhite, psBlack);
+                  /* globGC */
+  globGC = XCreateGC(dsply,rtWindow,0,&controlGCVals);
+  carefullySetFont(globGC,headerFont);
+  PSCreateContext(globGC, "globGC", psNormalWidth, psButtCap,
+		  psMiterJoin, psWhite, psBlack);
+                /* anotherGC */
+  controlGCVals.line_width = colorWidth;
+  anotherGC  = XCreateGC(dsply,rtWindow,GCBackground | GCLineWidth |
+                         GCFunction ,&controlGCVals);  
+  carefullySetFont(anotherGC,titleFont);
+  PSCreateContext(anotherGC, "anotherGC", psNormalWidth, psButtCap,
+		  psMiterJoin, psWhite, psBlack);
+  /* also create one for rendering (grayscale only for now) */
+  /* assign arbitrary number to renderGC as 9991 - see header.h */
+  PSCreateContext(GC9991, "renderGC", psNormalWidth, psButtCap,
+		  psRoundJoin, psWhite, psBlack );
+              /* processGC */
+  gcVals.background  = backgroundColor;
+  processGC = XCreateGC(dsply,rtWindow,GCBackground |
+			GCFillStyle,&gcVals);
+  carefullySetFont(processGC,buttonFont);
+              /* lightingGC */
+  controlGCVals.foreground = monoColor(axesColor);
+  controlGCVals.background = backgroundColor;
+  lightingGC  = XCreateGC(dsply,rtWindow,GCForeground | GCBackground
+			  ,&controlGCVals);
+  carefullySetFont(lightingGC,lightingFont);
+             /* volumeGC */
+  volumeGC = XCreateGC(dsply,rtWindow,GCForeground | GCBackground 
+		       ,&controlGCVals);
+  carefullySetFont(volumeGC,volumeFont);
+              /* quitGC */
+  quitGC  = XCreateGC(dsply,rtWindow,GCForeground | GCBackground 
+		      ,&controlGCVals);
+  carefullySetFont(quitGC,buttonFont);
+              /* saveGC */
+  saveGC  = XCreateGC(dsply,rtWindow,GCForeground | GCBackground 
+		      ,&controlGCVals);
+  carefullySetFont(saveGC,buttonFont);
+              /* graphGC */
+  graphGC  = XCreateGC(dsply,rtWindow,GCForeground | GCBackground 
+		       ,&controlGCVals);
+  carefullySetFont(graphGC,buttonFont);
+  /**** Get Data from the Viewport Manager ****/
+  i    = 123;   /* Used in viewman, what is this for? */
+  code = check(write(Socket,&i,intSize));
+  /* Check if I am getting stuff from Axiom or, if I am viewalone. */
+  readViewman(&viewAloned,intSize);
+  readViewman(&viewData,sizeof(view3DStruct));
+  readViewman(&i,intSize);
+  if (!(viewData.title = (char *)saymem("main.c",i,sizeof(char)))) {
+    fprintf(stderr,"VIEW3D: Fatal Error>> Ran out of memory trying to receive\
+                         the title.\n");
+    exitWithAck(RootWindow(dsply,scrn),Window,-1);
+  }
+  readViewman(viewData.title,i);
+  readViewman(&(viewData.lightVec[0]),floatSize);
+  readViewman(&(viewData.lightVec[1]),floatSize);
+  readViewman(&(viewData.lightVec[2]),floatSize);
+  viewData.scaleDown = yes;
+  switch (viewData.typeOf3D) {
+  /* Currently, the view3DType information doesn't get sent from
+     Axiom - all surfaces are alike regardless of how they
+     were created. We may revert back to receiving this information
+     in case we want to take advantage of certain properties of
+     certain surfaces (e.g. z=f(x,y)). */
+
+        case view3DType:
+        case viewTubeType:
+                viewport = make3DComponents();
+                viewData.box = no;
+                viewData.pointSize = 3;
+                break;
+  }; /* switch typeOf3D */
+  /*************************************************
+   ** Do some temporary assignments that would    **
+   ** later be coded in the makeViewport routines **
+   ** when the corresponding code has been put    **
+   ** into the viewalone, viewman and spad files. **
+   *************************************************/
+  viewData.distortX     = viewData.distortY = viewData.distortZ = 1;
+  viewData.clipPlane    = clipPlaneMin;
+  viewData.clipStuff    = yes;
+  xClipMinN = yClipMinN = zClipMinN = 0.0;
+  xClipMaxN = yClipMaxN = zClipMaxN = 1.0;
+  control = viewport->controlPanel;
+  bsdSignal(SIGTERM,goodbye,DontRestartSystemCalls);
+  bsdSignal(SIGSEGV,goodbye,DontRestartSystemCalls);
+  /** send acknowledgement to viewport manager**/
+  i = 345;
+  sprintf(errorStr,"sending window info to viewport manager");
+  check(write(Socket,&(viewport->viewWindow),sizeof(Window))); 
+  viewmap = XCreatePixmap(dsply,viewport->viewWindow,
+			  vwInfo.width,vwInfo.height,
+			  DisplayPlanes(dsply,scrn));
+  viewmap_valid = 1;
+  processEvents();
+  goodbye(-1);
+  return(0); /* control never gets here but compiler complains */
+}     /* main() */
+     
 @
 \chapter{gdraws}
 \label{gdraws}
 
-Thi section contains a set of functions for handling 
+This section contains a set of functions for handling 
 postscript generation. This is handled by defining a set of cover
 functions for the X routines, as in GDrawArc versus XDrawArc.
 When the Xoption is set the X routine is called. When the PSoption 
@@ -25938,27 +17680,13 @@ units on the axes.
 
 @
 \section{gfun.c}
-<<gdraws/gfun.c>>=
-#define _GFUN_C
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <X11/Xlib.h>
-
-#define yes		1
-#define no		0
-
-@
 Indices for PostScript draw procedures.
 
 The order of these defined variables are very important; they are used
 to create the OUTPUT file.  Essentially, PSCreateFile() loops through the
 index of 0 to psDrawNo and checks if the file/procedure is used.  If so,
 the file is copied to the output file.
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 #define output		0		/* output file */
 #define headerps	1		/* postscript header file */
@@ -25987,7 +17715,7 @@ the file is copied to the output file.
 PostScript structures
 \label{psStruct}
 \index{psStruct}
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 typedef struct _psStruct {	/* data structure for ps routines info */
 	int	flag;
 	char	filename[200];
@@ -25995,64 +17723,12 @@ typedef struct _psStruct {	/* data structure for ps routines info */
 
 psStruct psData[psDrawNo];	/* need psDrawNo of them */
 
-
-@
-These variables are expected to be declared in within client programs, eg,
-main.c in view2d and view3d.
-<<gdraws/gfun.c>>=
-extern	int		scrn;	       /* screen */
-extern	Display		*dsply;	       /* display */
-extern	char		*envAXIOM;     /* environment variable AXIOM or DEVE */
-
-<<include/g.h>>
-#include "hash.h"
-#include "hash.h1"
-extern int PSCreateFile(int,Window,Window,char *);
-extern int GdrawsDrawFrame(int,Window,Window,char *);
-extern int GdrawsSetDimension(Window,Window);
-extern int GDrawImageString(GC,Window,int,int,char *,int,int);
-extern int GDrawArc(GC,Window,int,int,unsigned int,unsigned int,int,int,int);
-extern int GDrawLine(GC,Window,int,int,int,int,int);
-extern int GDrawLines(GC,Window,XPoint *,int,int,int);
-extern int GDrawPoint(Window,GC,int,int,int);
-extern int GDrawString(GC,Window,int,int,char *,int,int);
-extern int GFillArc(GC,Window,int,int,unsigned int,unsigned int,int,int,int);
-extern int PSGlobalInit(void);
-extern int PSInit(Window,Window);
-extern int PSCreateContext(GC,char *,int,int,int,float,float);
-extern char *PSfindGC(GC);
-extern int GSetForeground(GC,float,int);
-extern int GSetBackground(GC,float,int);
-extern int GSetLineAttributes(GC,int,int,int,int,int);
-extern int PSClose(void);
-extern int centerX(GC,char *,int,int);
-extern int centerY(GC,int);
-extern int PSColorPolygon(float,float,float,XPoint *,int);
-extern int PSColorwOutline(float,float,float,XPoint *,int);
-extern int PSDrawColor(float,float,float,XPoint *,int);
-extern int PSFillPolygon(GC,XPoint *,int);
-extern int PSFillwOutline(GC,XPoint *,int);
-extern HashTable * XCreateAssocTable(int);
-extern void XMakeAssoc(Display *,HashTable *,Window,int *);
-extern int *XLookUpAssoc(Display *,HashTable *,Window);
-extern void XDeleteAssoc(Display *,HashTable *,Window);
-extern int GDrawRectangle(GC,Window,short,short,short,short,int);
-extern int GDraw3DButtonOut(GC,Window,short,short,short,short,int);
-extern int GDraw3DButtonIn(GC,Window,short,short,short,short,int);
-extern int GDrawPushButton(Display *,GC,GC,GC,Window,short,short,short,
-                           short,int,char *,unsigned long,unsigned long,int);
-#ifdef _GFUN_C
-static void filecopy(FILE *,FILE *);
-static int TrivEqual(Window,Window);
-static int TrivHashCode(Window,int);
-#endif
-
 @
 \subsection{filecopy}
 \label{filecopy}
 \index{gdraws!filecopy}
 Given 2 file pointers, this function copies file ifp to file ofp
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 static void filecopy(FILE * ifp, FILE * ofp)
 { int c;
@@ -26068,7 +17744,7 @@ PSCreateFile generates the output file by using the order of defined
 variables; they are used to create the OUTPUT file.  Essentially,
 PSCreateFile() loop through the index of 0 to psDrawNo and checks if the
 file/procedure is used. If so, the file is included into the output file.
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int PSCreateFile(
          int bWidth,            /* border width of picture frame */
@@ -26119,7 +17795,7 @@ int PSCreateFile(
 This function draws the frame of the picture, which corresponds to the
 picture frame on the X display.  In addition, it draws the title window as
 well as the title of the picture.
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int GdrawsDrawFrame(
           int borderW,          /* border width */
@@ -26151,7 +17827,7 @@ int GdrawsDrawFrame(
 \label{GdrawsSetDimension}
 \index{gdraws!GdrawsSetDimension}
 GdrawsSetDimension sets the dimension of the picture.
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int GdrawsSetDimension(Window viewWindow, Window titleWindow) {
   FILE *fp;
@@ -26192,7 +17868,7 @@ int GdrawsSetDimension(Window viewWindow, Window titleWindow) {
 \index{gdraws!GDrawImageString}
 GDrawImageString draws an image text string 
 See \ref{XDrawImageString} on page~\pageref{XDrawImageString}
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int GDrawImageString(
                  GC gc,         /* graphics context */
@@ -26232,7 +17908,7 @@ int GDrawImageString(
 \index{gdraws!GDrawArc}
 GDrawArc draws an arc.
 See \ref{XDrawArc} on page~\pageref{XDrawArc}
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int GDrawArc(
          GC gc,                 /* graphics context */
@@ -26271,7 +17947,7 @@ int GDrawArc(
 \index{gdraws!GDrawLine}
 GDrawLine draws a line.
 See \ref{XDrawLine} on page~\pageref{XDrawLine}
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int GDrawLine(
           GC gc,                /* graphics context */
@@ -26307,7 +17983,7 @@ int GDrawLine(
 \label{GDrawLines}
 \index{gdraws!GDrawLines}
 GDrawLines draws lines.
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int GDrawLines(
            GC gc,               /* graphics context */
@@ -26353,7 +18029,7 @@ int GDrawLines(
 \index{gdraws!GDrawPoint}
 GDrawPoint draws a point.
 (See Section \ref{XDrawPoint} on page~\pageref{XDrawPoint}),
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int GDrawPoint(
            Window wid,          /* window id */
@@ -26389,7 +18065,7 @@ int GDrawPoint(
 \label{GDrawRectangle}
 \index{gdraws!GDrawRectangle}
 GDrawRectangle draws a rectangle.
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int GDrawRectangle(
                GC gc,
@@ -26426,7 +18102,7 @@ int GDrawRectangle(
 \label{GDraw3DButtonIn}
 \index{gdraws!GDraw3DButtonIn}
 GDraw3DButtonOut draws a rectangle with 3D shading on rhs and bottom
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int GDraw3DButtonOut(
                  GC gc,
@@ -26447,7 +18123,7 @@ int GDraw3DButtonOut(
 \label{GDraw3DButtonIn}
 \index{gdraws!GDraw3DButtonIn}
 GDraw3DButtonIn draws a rectangle with 3D shading on lhs and top
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int GDraw3DButtonIn(
                 GC gc,
@@ -26469,7 +18145,7 @@ int GDraw3DButtonIn(
 \label{GDrawPushButton}
 \index{gdraws!GDrawPushButton}
 GDrawPushButton draws a push button whose appearance depends on ``isOn.''
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int GDrawPushButton(
                 Display * display,
@@ -26477,13 +18153,13 @@ int GDrawPushButton(
                 Window windowId,
                 short int x,short int y,short  int width,short  int height,
                 int isOn, char *text,
-                unsigned long buttonColor, unsigned long color,
+                unsigned long buttoncolor, unsigned long color,
                 int dFlag)
 {
   int len = strlen(text);
   if (dFlag == Xoption)
     XClearArea(display, windowId, x, y, width + 1, height + 1, False);
-  GSetForeground(gc1, (float) buttonColor, dFlag);
+  GSetForeground(gc1, (float) buttoncolor, dFlag);
   if (isOn)
     GDraw3DButtonIn(gc1, windowId, x, y, width, height, dFlag);
   else
@@ -26501,7 +18177,7 @@ int GDrawPushButton(
 \index{gdraws!GDrawString}
 Draws a string.
 See \ref{XDrawString} on page~\pageref{XDrawString}.
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int GDrawString(
             GC gc,              /* graphics context */
@@ -26540,7 +18216,7 @@ int GDrawString(
 \index{gdraws!GFillArc}
 Draws and fills an arc with foreground color.
 See \ref{XFillArc} on page~\pageref{XFillArc}.
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int GFillArc(
          GC gc,                 /* graphics context */
@@ -26580,7 +18256,7 @@ int GFillArc(
 \index{gdraws!PSGlobalInit}
 Initializes the path and files to be used.
 This needs to be called only once each session.
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int PSGlobalInit(void) {
   char *tmp;
@@ -26681,7 +18357,7 @@ int PSGlobalInit(void) {
 \index{gdraws!PSInit}
 This needs to be called for every postscript file generated.
 It initializes the procedure flags.
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int PSInit(Window vw, Window tw) {
   if (!psInit) {
@@ -26720,12 +18396,12 @@ is device-dependent, thus, we'll leave it and use default. Also lineStyle
 is solid in ps by default, thus we don't need to set it. We'll leave out
 line style here since we really never used anything other than line solid
 which is the default line style in postscript.
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int PSCreateContext(
                 GC gc,       /* graphics context */
                 char *C_gc,     /* GC name to be used as postscript variable */
-                int lineWidth, int capStyle, int joinStyle,
+                int linewidth, int capstyle, int joinstyle,
                 float bg, float fg)
 {
   FILE *fp;
@@ -26753,8 +18429,8 @@ int PSCreateContext(
 	    psData[GCdictps].filename);
     return (psError);
   }
-  fprintf(fp, "\t%d\t%d\t%d\n\t%f\t%f\t/%s\tmakeDict\n", joinStyle,
-	  capStyle, lineWidth, bg, fg, C_gc);
+  fprintf(fp, "\t%d\t%d\t%d\n\t%f\t%f\t/%s\tmakeDict\n", joinstyle,
+	  capstyle, linewidth, bg, fg, C_gc);
   return (fclose(fp));
 }
 
@@ -26764,7 +18440,7 @@ int PSCreateContext(
 \index{gdraws!PSfindGC}
 Looks into GC linked list with gc (unsigned long) as index to find the
 character name.
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 char *PSfindGC(GC gc) {
   GCptr curGC;
@@ -26785,7 +18461,7 @@ char *PSfindGC(GC gc) {
 \index{gdraws!GSetForeground}
 Sets foreground color.
 See \ref{XSetForeground} on page~\pageref{XSetForeground}.
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int GSetForeground(
                GC gc,           /* graphics context */
@@ -26822,7 +18498,7 @@ int GSetForeground(
 \index{gdraws!GSetBackground}
 Sets background color.
 See \ref{XSetBackground} on page~\pageref{XSetBackground}.
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int GSetBackground(
                GC gc,           /* graphics context */
@@ -26861,21 +18537,21 @@ int GSetBackground(
 Notice that we'll not setting line style for
 postscript.  This is because solid is the ls in ps and in view3d and 2d,
 we really don't use anything else than solid.
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int GSetLineAttributes(
                    GC gc,
-                   int lineWidth, int lineStyle, int capStyle, int joinStyle,
+                   int linewidth, int linestyle, int capstyle, int joinstyle,
                    int dFlag) {
   int s = 0;
   switch (dFlag) {
     case Xoption:
-      XSetLineAttributes(dsply, gc, lineWidth, lineStyle,capStyle, joinStyle);
+      XSetLineAttributes(dsply, gc, linewidth, linestyle,capstyle, joinstyle);
       break;
     case PSoption: {
       FILE *fp;
       int psCap, psJoin;
-      switch (capStyle) {
+      switch (capstyle) {
         case 0:           /* CapNotLast is not implemented in ps */
         case 1:
           psCap = psButtCap;
@@ -26887,10 +18563,10 @@ int GSetLineAttributes(
           psCap = psPSqCap;
           break;
         default:
-          fprintf(stderr, "cap style: %d unknown, using default.\n", capStyle);
+          fprintf(stderr, "cap style: %d unknown, using default.\n", capstyle);
           psCap = psButtCap;
       }
-      switch (joinStyle) {
+      switch (joinstyle) {
         case 0:
           psJoin = psMiterJoin;
           break;
@@ -26901,7 +18577,7 @@ int GSetLineAttributes(
           psJoin = psBevelJoin;
           break;
         default:
-          fprintf(stderr,"join style: %d unknown, using default.\n",joinStyle);
+          fprintf(stderr,"join style: %d unknown, using default.\n",joinstyle);
           psJoin = psMiterJoin;
       }
       /*
@@ -26915,7 +18591,7 @@ int GSetLineAttributes(
 	return (0);
       }
       fprintf(fp, "\t%d\t%d\t%d\t%s\tsetLineAttributes\n",
-	      lineWidth, psCap, psJoin, PSfindGC(gc));
+	      linewidth, psCap, psJoin, PSfindGC(gc));
       s = fclose(fp);
     }
       break;
@@ -26933,7 +18609,7 @@ int GSetLineAttributes(
 \index{gdraws!PSClose}
 This procedure frees the data structure used for GC information, and also
 unlinks the GC dictionary file.
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int PSClose(void) {
   if (GChead != NULL) { /* free memory used by GC struct */
@@ -26951,7 +18627,7 @@ int PSClose(void) {
 \subsection{centerX}
 \label{centerX}
 \index{gdraws!centerX}
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int centerX(GC viewGCx,char * theString,int strlength,int windowWidth)
 { XFontStruct *fontStruct;
@@ -26970,7 +18646,7 @@ int centerX(GC viewGCx,char * theString,int strlength,int windowWidth)
 \subsection{centerY}
 \label{centerY}
 \index{gdraws!centerY}
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int centerY(GC viewGCy,int windowHeight) {
   XFontStruct *fontStruct;
@@ -26993,7 +18669,7 @@ int centerY(GC viewGCy,int windowHeight) {
 \index{gdraws!PSColorPolygon}
 PSColorPolygon draws and fills a polygon given data in XPoint.
 (See \ref{XFillPolygon} on page~\pageref{XFillPolygon})
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int PSColorPolygon(
                float r, float g, float b,       /* red, green and blue color
@@ -27026,7 +18702,7 @@ int PSColorPolygon(
 \label{PSColorwOutline}
 \index{gdraws!PSColorwOutline}
 PSColorwOutline draws and also outlines the colored polygon.
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int PSColorwOutline(
                 float r, float g, float b,      /* red, green and blue color
@@ -27058,7 +18734,7 @@ int PSColorwOutline(
 \index{gdraws!PSDrawColor}
 This function does what XDraw would do, notice that only a subset of
 attributes in GC is implemented -- adequate for our purpose now
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int PSDrawColor(
     float r, float g, float b,  /* red, green and blue color components */
@@ -27090,7 +18766,7 @@ int PSDrawColor(
 \index{gdraws!PSFillPolygon}
 PSFillPolygon draws and fills a polygon given data in XPoint.
 (See \ref{XFillPolygon} on page~\pageref{XFillPolygon}).
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int PSFillPolygon(
               GC gc,               /* graphics context */
@@ -27121,7 +18797,7 @@ int PSFillPolygon(
 \label{PSFillwOutline}
 \index{gdraws!PSFillwOutline}
 PSFillwOutline draws and also outlines the filled polygon.
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int PSFillwOutline(
                GC gc,           /* graphics context */
@@ -27149,7 +18825,7 @@ int PSFillwOutline(
 \subsection{TrivEqual}
 \label{TrivEqual}
 \index{gdraws!TrivEqual}
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 static int TrivEqual(Window s1,Window s2) {
   return ( s1 == s2);
@@ -27159,7 +18835,7 @@ static int TrivEqual(Window s1,Window s2) {
 \subsection{TrivHashCode}
 \label{TrivHashCode}
 \index{gdraws!TrivHashCode}
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 static int TrivHashCode(Window s,int size) {
   return (s % size);
@@ -27169,7 +18845,7 @@ static int TrivHashCode(Window s,int size) {
 \subsection{XCreateAssocTable}
 \label{XCreateAssocTable}
 \index{gdraws!XCreateAssocTable}
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 HashTable *XCreateAssocTable(int size) {
   HashTable * table;
@@ -27183,7 +18859,7 @@ HashTable *XCreateAssocTable(int size) {
 \subsection{XMakeAssoc}
 \label{XMakeAssoc}
 \index{gdraws!XMakeAssoc}
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 void XMakeAssoc(Display * dsp, HashTable *table, Window w, int * p) {
   hash_insert(table,(char *) p, (char *) w);
@@ -27193,7 +18869,7 @@ void XMakeAssoc(Display * dsp, HashTable *table, Window w, int * p) {
 \subsection{XLookUpAssoc}
 \label{XLookUpAssoc}
 \index{gdraws!XLookUpAssoc}
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 int *XLookUpAssoc(Display * dsp, HashTable *table,Window w) {
   return (int *) hash_find(table,(char *)w);
@@ -27203,7 +18879,7 @@ int *XLookUpAssoc(Display * dsp, HashTable *table,Window w) {
 \subsection{XDeleteAssoc}
 \label{XDeleteAssoc}
 \index{gdraws!XDeleteAssoc}
-<<gdraws/gfun.c>>=
+<<gfun.c>>=
 
 void XDeleteAssoc(Display * dsp,HashTable * table, Window w) {
   hash_delete(table,(char *) w);
@@ -27223,19 +18899,12 @@ CFLAGS	    = ${CCF} -I${SRC}/include -I${SRC}/hyper
 
 HEADERS =  ${SRC}/include/hash.h  ${SRC}/include/hash.h1 
 
-PSFiles= ${PS}/colorpoly.ps ${PS}/colorwol.ps  ${PS}/draw.ps      \
-         ${PS}/drawIstr.ps  ${PS}/drawarc.ps   ${PS}/drawcolor.ps \
-         ${PS}/drawline.ps  ${PS}/drawlines.ps ${PS}/drawpoint.ps \
-         ${PS}/drawrect.ps  ${PS}/drawstr.ps   ${PS}/drwfilled.ps \
-         ${PS}/end.ps       ${PS}/fillarc.ps   ${PS}/fillpoly.ps  \
-         ${PS}/fillwol.ps   ${PS}/header.ps    ${PS}/setup.ps
-
 all: ${MIDOBJ}/gfun.o ${PSFiles} 
 	@ echo 21 finished making gdraws from ${BOOK}
 
 ${MIDOBJ}/gfun.o: ${HEADERS} ${BOOK}
 	@ echo 2 making ${MIDOBJ}/gfun.o from ${BOOK}
-	@( cd ${MIDINT} ; ${TANGLE} -R"gdraws/gfun.c" ${BOOK} >gfun.c )
+	@( cd ${MIDINT} ; ${TANGLE} -R"gfun.c" ${BOOK} >gfun.c )
 	@ ( cd ${MIDOBJ} ; ${CC} -c ${CFLAGS} ${MIDINT}/gfun.c )
 
 ${PS}/colorpoly.ps: ${BOOK} 
@@ -27326,7 +18995,7 @@ operand stack configuration in order to use psColorPoly:
 this draws a polygon by connecting all the points and fills the
 region with foreground color
 \end{verbatim}
-<<gdraws/psfiles/colorpoly>>=
+<<psfiles/colorpoly>>=
 /psColorPoly
         {	gsave
                 newpath
@@ -27354,7 +19023,7 @@ operand stack configuration in order to use psDrawFilled:
 this draws lines connecting all the points and fills the
 region with background color (default: 1, or white).
 \end{verbatim}
-<<gdraws/psfiles/colorwol>>=
+<<psfiles/colorwol>>=
 /psColorwOutline
         {	gsave
                 newpath
@@ -27384,7 +19053,7 @@ and height specifies the rectangle which encases the arc.
 Origin is at upper left corner of rectangle.
 This function uses "scale" to make cricles and ellipses.
 \end{verbatim}
-<<gdraws/psfiles/drawarc>>=
+<<psfiles/drawarc>>=
 /psDrawArc 
         {	gsave
                 newpath
@@ -27418,7 +19087,7 @@ operand stack configuration in order to use psDrawColor:
 	graphics-context dictionary
 to draw lines connecting points in vlist[0] to vlist[n]
 \end{verbatim}
-<<gdraws/psfiles/drawcolor>>=
+<<psfiles/drawcolor>>=
 /psDrawColor
         {	gsave
                 newpath
@@ -27443,7 +19112,7 @@ operand stack configuration in order to use psDrawIStr:
 it draws a text string in foreground color on top of bounding box of
 string, which is in background color.
 \end{verbatim}
-<<gdraws/psfiles/drawIstr>>=
+<<psfiles/drawIstr>>=
 /psDrawIStr
         {	gsave
 		newpath					%% for rectangle
@@ -27493,7 +19162,7 @@ operand stack configuration in order to use psDrawLine:
 	graphics-context dictionary
 this draws a line from (x0, y0) to (x1, y1).
 \end{verbatim}
-<<gdraws/psfiles/drawline>>=
+<<psfiles/drawline>>=
 /psDrawLine
         {	gsave
                 newpath
@@ -27517,7 +19186,7 @@ operand stack configuration in order to use psDrawLines:
 	graphics-context dictionary
 this draws lines connecting all the points.
 \end{verbatim}
-<<gdraws/psfiles/drawlines>>=
+<<psfiles/drawlines>>=
 /psDrawLines
         {	gsave
                 newpath
@@ -27539,7 +19208,7 @@ operand stack configuration in order to use psDrawPoint:
 	graphics-context dictionary
 this draws a point at (x0, y0).
 \end{verbatim}
-<<gdraws/psfiles/drawpoint>>=
+<<psfiles/drawpoint>>=
 /psDrawPoint
         {	gsave
                 newpath
@@ -27563,7 +19232,7 @@ operand stack configuration in order to use psDraw:
 	graphics-context dictionary
 to draw lines connecting points in vlist[0] to vlist[n]
 \end{verbatim}
-<<gdraws/psfiles/draw>>=
+<<psfiles/draw>>=
 /psDraw
         {	gsave
                 newpath
@@ -27588,7 +19257,7 @@ operand stack configuration in order to use psDrawRect:
 this draws an outline of a rectangle whose origin is at (x,y) and is width
 + 1 wide and height + 1 tall.
 \end{verbatim}
-<<gdraws/psfiles/drawrect>>=
+<<psfiles/drawrect>>=
 /psDrawRect
         {	gsave
                 newpath
@@ -27608,7 +19277,7 @@ operand stack configuration in order to use psDrawStr:
 	graphics-context dictionary
 this function draws a text string at (x,y).
 \end{verbatim}
-<<gdraws/psfiles/drawstr>>=
+<<psfiles/drawstr>>=
 /psDrawStr
         {	gsave
 		newpath
@@ -27633,7 +19302,7 @@ operand stack configuration in order to use psDrawFilled:
 this draws lines connecting all the points and fills the
 region with background color (default: 1, or white).
 \end{verbatim}
-<<gdraws/psfiles/drwfilled>>=
+<<psfiles/drwfilled>>=
 /psDrawFilled
         {	gsave
                 newpath
@@ -27649,7 +19318,7 @@ region with background color (default: 1, or white).
 \subsection{end}
 \begin{verbatim}
 \end{verbatim}
-<<gdraws/psfiles/end>>=
+<<psfiles/end>>=
 
    cleartomark					%% clearing operand stack
 
@@ -27677,7 +19346,7 @@ and height specifies the rectangle which encases the arc.
 Origin is at upper left corner of rectangle.
 This function uses "scale" to make cricles and ellipses.
 \end{verbatim}
-<<gdraws/psfiles/fillarc>>=
+<<psfiles/fillarc>>=
 /psFillArc
         {	gsave
 		yVal moveto
@@ -27713,7 +19382,7 @@ operand stack configuration in order to use psDrawFilled:
 this draws a polygon by connecting all the points and fills the
 region with foreground color
 \end{verbatim}
-<<gdraws/psfiles/fillpoly>>=
+<<psfiles/fillpoly>>=
 /psFillPoly
         {	gsave
                 newpath
@@ -27741,7 +19410,7 @@ operand stack configuration in order to use psDrawFilled:
 this draws lines connecting all the points and fills the
 region with background color (default: 1, or white).
 \end{verbatim}
-<<gdraws/psfiles/fillwol>>=
+<<psfiles/fillwol>>=
 /psFillwOutline
         {	gsave
                 newpath
@@ -27759,7 +19428,7 @@ region with background color (default: 1, or white).
 \subsection{header}
 \begin{verbatim}
 \end{verbatim}
-<<gdraws/psfiles/header>>=
+<<psfiles/header>>=
 %!PS-Adobe-2.0
 %%DocumentFonts: Times-Roman
 %%Creator: Axiom
@@ -27920,7 +19589,7 @@ region with background color (default: 1, or white).
 \subsection{setup}
 \begin{verbatim}
 \end{verbatim}
-<<gdraws/psfiles/setup>>=
+<<psfiles/setup>>=
 %-------------------------- script --------------------------%
 
 % 1 inch 1 inch translate
@@ -28498,36 +20167,9 @@ information macros or functions.
 			/* height */         1,
 			/* bitmap\_pad */     32,
 			/* bytes\_per\_line */ 0);
-\item XImage slicer\_image\_stuff
 \item XSizeHints sizehint;
 \item XGetImage(dsply, slicer\_pixmap, 0, 0, slicer\_width, slicer\_height,
 			  AllPlanes, ZPixmap);
-\item XSetFunction(dsply, contourGC, GXcopy);
-\item XDrawRectangle(dsply,contourWindow, contourGC /* ZZZ */,
-                     (control->buttonQueue[i]).buttonX,
-		     (control->buttonQueue[i]).buttonY,
-                     (control->buttonQueue[i]).buttonWidth,
-		     (control->buttonQueue[i]).buttonHeight);
-\item XClearArea(dsply, contourWindow, long\_str\_X, long\_str\_Y - 12,
-	     long\_W + 50, 18, False);
-\item XDrawString(dsply, contourWindow, anotherGC,
-	      long\_str\_X, long\_str\_Y,
-	      stringo, strlen(stringo));
-\item XDrawArc(dsply, contourWindow, contourGC /* ZZZ */,
-	   long\_corner\_X, long\_corner\_Y,
-	   long\_W, long\_H,
-	   0, 360*64);
-\item XDrawLine(dsply, contourWindow, 
-\item XFillArc(dsply, contourWindow, contourGC /* ZZZ */,
-	   tip\_x - (dotSize>>1), tip\_y - (dotSize>>1),
-	   dotSize, dotSize,
-	   0, 360*64);
-\item XPutImage(dsply, contourWindow, contourGC,
-	    slicer\_image,
-	    0, 0, 
-	    slicer\_image\_X,
-	    slicer\_image\_Y,
-	    slicer\_width, slicer\_height);
 \item XChangeShade(dsply, i);
 \item XShadeRectangle(dsply,cp->controlWindow,
 		      colormapX + colorOffsetX + i*shadeWidth,
@@ -28577,64 +20219,77 @@ information macros or functions.
 \label{Makefile}
 <<*>>=
 BOOK=${SPD}/books/bookvol8.pamphlet
+WORK=${OBJ}/${SYS}/graph
+OUTLIB=	${MNT}/${SYS}/lib
+OUTBIN=	${MNT}/${SYS}/bin
+LIB=    ${OBJ}/${SYS}/lib
+TESTFILE=${MNT}/${SYS}/graph/parabola.view
+PS=	${MNT}/${SYS}/lib/graph
+
+PSFiles= ${PS}/colorpoly.ps ${PS}/colorwol.ps  ${PS}/draw.ps      \
+         ${PS}/drawIstr.ps  ${PS}/drawarc.ps   ${PS}/drawcolor.ps \
+         ${PS}/drawline.ps  ${PS}/drawlines.ps ${PS}/drawpoint.ps \
+         ${PS}/drawrect.ps  ${PS}/drawstr.ps   ${PS}/drwfilled.ps \
+         ${PS}/end.ps       ${PS}/fillarc.ps   ${PS}/fillpoly.ps  \
+         ${PS}/fillwol.ps   ${PS}/header.ps    ${PS}/setup.ps
+
+CFLAGS  = ${CCF} -I${SRC}/include
+LDFLAGS = ${LDF} -lX11 -lm
+
+VLIBS=${LIB}/sockio-c.o ${LIB}/util.o  ${LIB}/bsdsignal.o 
+
+LIBS= ${VLIBS}      ${LIB}/pixmap.o    ${LIB}/halloc.o  ${LIB}/spadcolors.o \
+      ${LIB}/hash.o ${LIB}/xspadfill.o ${LIB}/xdither.o ${LIB}/xshade.o   
+
+all: ${LIBS} dirs ${OUTLIB}/viewman ${OUTLIB}/view2d ${OUTLIB}/view3d \
+     ${OUTBIN}/viewalone ${TESTFILE}/data ${PSFiles}
+	@ echo 0 finished ${BOOK}
+
+dirs: 
+	@ echo 1 making target directories for bookvol8
+	@ mkdir -p ${WORK}
+	@ mkdir -p ${OUTBIN}
+	@ mkdir -p ${OUTLIB}
+	@ mkdir -p ${TESTFILE}
+	@ mkdir -p ${PS}
+
+${OUTLIB}/viewman: ${BOOK}
+	@ echo 2 making ${OUTLIB}/viewman from ${BOOK}
+	@( cd ${WORK} ; \
+           ${TANGLE} -R"viewman" ${BOOK} >viewman.c ; \
+	   ${CC} ${CFLAGS} -c viewman.c ; \
+	   ${CC} ${VLIBS} viewman.o -o ${OUTLIB}/viewman ${LDFLAGS} )
+
+${OUTLIB}/view2d: ${BOOK}
+	@ echo 3 making ${OUTLIB}/view2d from ${BOOK}
+	@( cd ${WORK} ; \
+           ${TANGLE} -R"view2d" ${BOOK} >view2d.c ; \
+	   ${CC} ${CFLAGS} -c view2d.c ; \
+	   ${CC} ${LIBS} view2d.o -o ${OUTLIB}/view2d ${LDFLAGS} )
+
+${OUTLIB}/view3d: ${BOOK}
+	@ echo 4 making ${OUTLIB}/view3d from ${BOOK}
+	@( cd ${WORK} ; \
+           ${TANGLE} -R"view3d" ${BOOK} >view3d.c ; \
+	   ${CC} ${CFLAGS} -c view3d.c ; \
+	   ${CC} ${LIBS} view3d.o -o ${OUTLIB}/view3d ${LDFLAGS} )
+
+${OUTBIN}/viewalone: ${BOOK}
+	@ echo 5 making ${OUTBIN}/viewalone from ${BOOK}
+	@( cd ${WORK} ; \
+	   ${TANGLE} -R"viewalone" ${BOOK} >viewalone.c ; \
+	   ${CC} ${CFLAGS} -c viewalone.c ; \
+	   ${CC} ${VLIBS} viewalone.o -o ${OUTBIN}/viewalone ${LDFLAGS} )
+
+${TESTFILE}/data: ${BOOK}
+	@ echo 6 making ${TESTFILE} from ${BOOK}
+	@ (cd ${TESTFILE} ; \
+	   ${TANGLE} -R"parabola.view/data" ${BOOK} >data ; \
+	   ${TANGLE} -R"parabola.view/graph0" ${BOOK} >graph0 )
 
-all: viewmandir gdrawsdir view2ddir view3ddir viewalonedir
-	@ echo 24 finished ${IN}
-
-viewmandir: ${BOOK}
-	@ echo 1 making viewman from ${BOOK}
-	@ mkdir -p ${OBJ}/${SYS}/graph/viewman
-	@ mkdir -p ${OBJ}/${SYS}/lib
-	@ mkdir -p ${MNT}/${SYS}/lib
-	@ mkdir -p ${MNT}/${SYS}/doc/src/graph
-	@ mkdir -p ${INT}/graph/viewman
-	@( cd ${INT}/graph/viewman ; \
-	  ${TANGLE} -t8 -R"viewman/Makefile" ${BOOK} >Makefile ; \
-          ${ENV} ${MAKE} )
-
-gdrawsdir: ${BOOK}
-	@ echo 5 making gdraws from ${BOOK}
-	@ mkdir -p ${OBJ}/${SYS}/graph/gdraws
-	@ mkdir -p ${MNT}/${SYS}/lib
-	@ mkdir -p ${MNT}/${SYS}/lib/graph
-	@ mkdir -p ${MNT}/${SYS}/doc/src/graph
-	@ mkdir -p ${INT}/graph/gdraws
-	@( cd ${INT}/graph/gdraws ; \
-	  ${TANGLE} -t8 -R"gdraws/Makefile" ${BOOK} >Makefile ; \
-	  ${ENV} ${MAKE} )
-
-view3ddir: ${BOOK}
-	@ echo 9 making view3d from ${BOOK}
-	@ mkdir -p ${OBJ}/${SYS}/graph/view3d
-	@ mkdir -p ${OBJ}/${SYS}/lib
-	@ mkdir -p ${OBJ}/${SYS}/graph/gdraws
-	@ mkdir -p ${MNT}/${SYS}/lib
-	@ mkdir -p ${MNT}/${SYS}/doc/src/graph
-	@ mkdir -p ${INT}/graph/view3d
-	@( cd ${INT}/graph/view3d ; \
-	  ${TANGLE} -t8 -R"view3d/Makefile" ${BOOK} >Makefile ; \
-	  ${ENV} ${MAKE} )
-
-view2ddir: ${BOOK}
-	@ echo 13 making view2d from ${BOOK}
-	@ mkdir -p ${OBJ}/${SYS}/graph/view2d
-	@ mkdir -p ${OBJ}/${SYS}/lib
-	@ mkdir -p ${MNT}/${SYS}/lib
-	@ mkdir -p ${MNT}/${SYS}/doc/src/graph
-	@ mkdir -p ${INT}/graph/view2d
-	@( cd ${INT}/graph/view2d ; \
-	  ${TANGLE} -t8 -R"view2d/Makefile" ${BOOK} >Makefile ; \
-	  ${ENV} ${MAKE} )
-
-viewalonedir: ${BOOK}
-	@ echo 17 making viewalone from ${BOOK}
-	@ mkdir -p ${OBJ}/${SYS}/graph/viewalone
-	@ mkdir -p ${MNT}/${SYS}/bin
-	@ mkdir -p ${MNT}/${SYS}/doc/src/graph
-	@ mkdir -p ${INT}/graph/viewalone
-	@( cd ${INT}/graph/viewalone ; \
-	  ${TANGLE} -t8 -R"viewalone/Makefile" ${BOOK} >Makefile ; \
-	  ${ENV} ${MAKE} )
+${PS}/%.ps: ${BOOK} 
+	@ echo 7 ${PS}/$*.ps from ${BOOK} 
+	@ ${TANGLE} -R"psfiles/$*" ${BOOK} >${PS}/$*.ps
 
 @
 \begin{thebibliography}{99}
@@ -28657,6 +20312,8 @@ Literate Programming''\\
 {\bf http://www.eecs.harvard.edu/ $\tilde{}$nr/noweb}
 \bibitem{7} Daly, Timothy, "The Axiom Literate Documentation"\\
 {\bf http://axiom.axiom-developer.org/axiom-website/documentation.html}
+\bibitem{8} von Seggern, David "CRC Standard Curves and Surfaces"
+CRC Press, Inc. 1993 ISBN 0-8493-0196-3
 \end{thebibliography}
 \printindex
 \end{document}
diff --git a/books/bookvol9.pamphlet b/books/bookvol9.pamphlet
index eeb65df..e9ab535 100644
--- a/books/bookvol9.pamphlet
+++ b/books/bookvol9.pamphlet
@@ -1,4 +1,5 @@
-\documentclass{book}
+\documentclass[dvipdfm]{book}
+\usepackage{hyperref}
 \usepackage{axiom}
 \usepackage{makeidx}
 \makeindex
diff --git a/books/ps/CRCp27-2.1.1.ps b/books/ps/CRCp27-2.1.1.ps
new file mode 100644
index 0000000..9a96a7f
--- /dev/null
+++ b/books/ps/CRCp27-2.1.1.ps
@@ -0,0 +1,1736 @@
+%!PS-Adobe-3.0
+%%Creator: GIMP PostScript file plugin V 1.17 by Peter Kirchgessner
+%%Title: p27-2.1.1.ps
+%%CreationDate: Thu Jun  5 03:25:02 2008
+%%DocumentData: Clean7Bit
+%%LanguageLevel: 2
+%%Pages: 1
+%%BoundingBox: 14 14 548 582
+%%EndComments
+%%BeginProlog
+% Use own dictionary to avoid conflicts
+10 dict begin
+%%EndProlog
+%%Page: 1 1
+% Translate for offset
+14.173228346456694 14.173228346456694 translate
+% Translate to begin of first scanline
+0 566.92913385826773 translate
+533.34087278587481 -566.92913385826773 scale
+% Image geometry
+524 557 8
+% Transformation matrix
+[ 524 0 0 557 0 0 ]
+% Strings to hold RGB-samples per scanline
+/rstr 524 string def
+/gstr 524 string def
+/bstr 524 string def
+{currentfile /ASCII85Decode filter /RunLengthDecode filter rstr readstring pop}
+{currentfile /ASCII85Decode filter /RunLengthDecode filter gstr readstring pop}
+{currentfile /ASCII85Decode filter /RunLengthDecode filter bstr readstring pop}
+true 3
+%%BeginData:        55991 ASCII Bytes
+colorimage
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO~>
+JcC<$JcC<$p&BO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D]W;lktp&G$lmf*7eL&V,QL&V,QM#Vu~>
+k5PD]W;lktp&G$lmf*7eL&V,QL&V,QM#Vu~>
+k5PD]W;lktp&G$lmf*7eL&V,QL&V,QM#Vu~>
+N;rnXp&G$lJcG9?!!%TMMuS;~>
+N;rnXp&G$lJcG9?!!%TMMuS;~>
+N;rnXp&G$lJcG9?!!%TMMuS;~>
+N;rnXp&G$lJcG9?!!%TMMuS;~>
+N;rnXp&G$lJcG9?!!%TMMuS;~>
+N;rnXp&G$lJcG9?!!%TMMuS;~>
+N;rnXp&G$lJcG9?!!%TMMuS;~>
+N;rnXp&G$lJcG9?!!%TMMuS;~>
+N;rnXp&G$lJcG9?!!%TMMuS;~>
+N;rnXp&G$lJcG9?!!%TMMuS;~>
+N;rnXp&G$lJcG9?!!%TMMuS;~>
+N;rnXp&G$lJcG9?!!%TMMuS;~>
+N;rnXp&G$lJcG9?!!%TMMuS;~>
+N;rnXp&G$lJcG9?!!%TMMuS;~>
+N;rnXp&G$lJcG9?!!%TMMuS;~>
+%%EndData
+showpage
+%%Trailer
+end
+%%EOF
diff --git a/changelog b/changelog
index 5abd176..3914214 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,22 @@
+20080618 tpd books/ps/CRCp27-2.1.1.ps added
+20080618 tpd src/Makefile build sman directory from bookvol6
+20080618 tpd src/sman/bookvol6 moved to books directory
+20080618 tpd src/Makefile complete build of graph directory from bookvol8
+20080618 tpd books/Makefile use sed to filter the toc files
+20080618 tpd books/bookvol8 complete build of graph directory from bookvol8
+20080618 tpd books/bookvol12 use hyperref
+20080618 tpd books/bookvol11 use hyperref
+20080618 tpd books/bookvol10 use hyperref
+20080618 tpd books/bookvol9 use hyperref
+20080618 tpd books/bookvol8 use hyperref
+20080618 tpd books/bookvol7 use hyperref
+20080618 tpd books/bookvol6 use hyperref
+20080618 tpd books/bookvol5 use hyperref
+20080618 tpd books/bookvol4 use hyperref
+20080618 tpd books/bookvol3 use hyperref
+20080618 tpd books/bookvol2 use hyperref
+20080618 tpd books/bookvol1 use hyperref
+20080618 tpd books/bookvol0 use hyperref
 20080614 tpd books/bookvol8 compress viewalone to a single C file
 20080613 tpd books/bookvol8 compress viewman.c to a single file
 20080612 tpd books/bookvol12 point to The Axiom Literate Documentation
diff --git a/src/Makefile.pamphlet b/src/Makefile.pamphlet
index 5914820..238e18e 100644
--- a/src/Makefile.pamphlet
+++ b/src/Makefile.pamphlet
@@ -106,29 +106,14 @@ clefclean: ${SRC}/clef/Makefile
 Superman (sman) is the master process that runs all of the other
 processes including axiom, clef, nagman, graphics, and hyperdoc
 <<smandir>>=
-smandir: ${SRC}/sman/Makefile
+smandir: ${SPD}/books/bookvol6.pamphlet
 	@echo 5 making ${SRC}/sman
 	@mkdir -p ${INT}/sman
 	@mkdir -p ${OBJ}/${SYS}/sman
 	@mkdir -p ${MNT}/${SYS}/doc/src/sman
-	@(cd sman ; ${ENV} ${MAKE} )
-
-${SRC}/sman/Makefile: ${SRC}/sman/Makefile.pamphlet
-	@echo 6 making ${SRC}/sman/Makefile from ${SRC}/sman/Makefile.pamphlet
 	@( cd sman ; \
-           ${DOCUMENT} ${NOISE} Makefile ; \
-           cp Makefile.dvi ${MNT}/${SYS}/doc/src/sman.Makefile.dvi )
-
-smandocument: ${SRC}/sman/Makefile
-	@echo 7 documenting ${SRC}/sman
-	@mkdir -p ${INT}/doc/src/sman
-	@( cd sman ; ${ENV} ${MAKE} document )
-
-smanclean: ${SRC}/sman/Makefile
-	@echo 8 cleaning ${SRC}/sman
-	@( cd sman ; ${ENV} ${MAKE} clean )
-	@rm -f ${SRC}/sman/Makefile
-	@rm -f ${SRC}/sman/Makefile.dvi
+           ${TANGLE} -t8 ${SPD}/books/bookvol6.pamphlet >Makefile ; \
+           ${ENV} ${MAKE} )
 
 @
 \subsection{The share directory}
@@ -435,10 +420,8 @@ hyperdir: ${SPD}/books/bookvol7.pamphlet
 <<graphdir>>=
 graphdir: ${SPD}/books/bookvol8.pamphlet
 	@echo 8 making graph from bookvol8
-	@mkdir -p ${INT}/graph/parabola
 	@mkdir -p ${OBJ}/${SYS}/graph
-	@mkdir -p ${INT}/graph
-	@(cd ${INT}/graph ; \
+	@(cd ${OBJ}/${SYS}/graph ; \
 	  ${TANGLE} -t8 ${SPD}/books/bookvol8.pamphlet >Makefile ; \
 	  ${ENV} ${MAKE} )
 
diff --git a/src/sman/bookvol6.pamphlet b/src/sman/bookvol6.pamphlet
deleted file mode 100644
index 2c2a20c..0000000
--- a/src/sman/bookvol6.pamphlet
+++ /dev/null
@@ -1,7170 +0,0 @@
-\documentclass{book}
-\usepackage{axiom}
-\usepackage{makeidx}
-\makeindex
-\usepackage{graphicx}
-\begin{document}
-\begin{titlepage}
-\center{\includegraphics{ps/axiomfront.ps}}
-\vskip 0.1in
-\includegraphics{ps/bluebayou.ps}\\
-\vskip 0.1in
-{\Huge{The 30 Year Horizon}}
-\vskip 0.1in
-$$
-\begin{array}{lll}
-Manuel\ Bronstein      & William\ Burge   & Timothy\ Daly \\
-James\ Davenport       & Michael\ Dewar   & Martin\ Dunstan \\
-Albrecht\ Fortenbacher & Patrizia\ Gianni & Johannes\ Grabmeier \\
-Jocelyn\ Guidry        & Richard\ Jenks   & Larry\ Lambe \\
-Michael\ Monagan       & Scott\ Morrison  & William\ Sit \\
-Jonathan\ Steinbach    & Robert\ Sutor    & Barry\ Trager \\
-Stephen\ Watt          & Jim\ Wen         & Clifton\ Williamson
-\end{array}
-$$
-\center{\large{VOLUME 6: AXIOM COMMAND}}
-\end{titlepage}
-\pagenumbering{roman}
-
-Portions Copyright (c) 2005 Timothy Daly
-
-The Blue Bayou image Copyright (c) 2004 Jocelyn Guidry
-
-Portions Copyright (c) 2004 Martin Dunstan
-
-Portions Copyright (c) 1991-2002, The Numerical ALgorithms Group 
-Ltd. All rights reserved.
-
-This book and the Axiom software is licensed as follows:
-
-Redistribution and use in source and binary forms, with or 
-without modification, are permitted provided that the following 
-conditions are met:
-\begin{itemize}
-\item Redistributions of source code must retain the above 
-      copyright notice, this list of conditions and the following 
-      disclaimer.
-
-\item Redistributions in binary form must reproduce the above 
-      copyright notice, this list of conditions and the following 
-      disclaimer in the documentation and/or other materials 
-      provided with the distribution.
-
-\item Neither the name of The Numerical ALgorithms Group Ltd. nor 
-      the names of its contributors may be used to endorse or promote 
-      products derived from this software without specific prior 
-      written permission.
-\end{itemize}
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
-INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
-POSSIBILITY OF SUCH DAMAGE.
-
-Inclusion of names in the list of credits is based on historical
-information and is as accurate as possible. Inclusion of names
-does not in any way imply an endorsement but represents historical
-influence on Axiom development.
-\vfill
-\eject
-\begin{tabular}{lll}
-Cyril Alberga         & Roy Adler             & Richard Anderson\\
-George Andrews        & Henry Baker           & Stephen Balzac\\
-Yurij Baransky        & David R. Barton       & Gerald Baumgartner\\
-Gilbert Baumslag      & Fred Blair            & Vladimir Bondarenko\\
-Mark Botch            & Alexandre Bouyer      & Peter A. Broadbery\\
-Martin Brock          & Manuel Bronstein      & Florian Bundschuh\\
-William Burge         & Quentin Carpent       & Bob Caviness\\
-Bruce Char            & Cheekai Chin          & David V. Chudnovsky\\
-Gregory V. Chudnovsky & Josh Cohen            & Christophe Conil\\
-Don Coppersmith       & George Corliss        & Robert Corless\\
-Gary Cornell          & Meino Cramer          & Claire Di Crescenzo\\
-Timothy Daly Sr.      & Timothy Daly Jr.      & James H. Davenport\\
-Jean Della Dora       & Gabriel Dos Reis      & Michael Dewar\\
-Claire DiCrescendo    & Sam Dooley            & Lionel Ducos\\
-Martin Dunstan        & Brian Dupee           & Dominique Duval\\
-Robert Edwards        & Heow Eide-Goodman     & Lars Erickson\\
-Richard Fateman       & Bertfried Fauser      & Stuart Feldman\\
-Brian Ford            & Albrecht Fortenbacher & George Frances\\
-Constantine Frangos   & Timothy Freeman       & Korrinn Fu\\
-Marc Gaetano          & Rudiger Gebauer       & Kathy Gerber\\
-Patricia Gianni       & Holger Gollan         & Teresa Gomez-Diaz\\
-Laureano Gonzalez-Vega& Stephen Gortler       & Johannes Grabmeier\\
-Matt Grayson          & James Griesmer        & Vladimir Grinberg\\
-Oswald Gschnitzer     & Jocelyn Guidry        & Steve Hague\\
-Vilya Harvey          & Satoshi Hamaguchi     & Martin Hassner\\
-Ralf Hemmecke         & Henderson             & Antoine Hersen\\
-Pietro Iglio          & Richard Jenks         & Kai Kaminski\\
-Grant Keady           & Tony Kennedy          & Paul Kosinski\\
-Klaus Kusche          & Bernhard Kutzler      & Larry Lambe\\
-Frederic Lehobey      & Michel Levaud         & Howard Levy\\
-Rudiger Loos          & Michael Lucks         & Richard Luczak\\
-Camm Maguire          & Bob McElrath          & Michael McGettrick\\
-Ian Meikle            & David Mentre          & Victor S. Miller\\
-Gerard Milmeister     & Mohammed Mobarak      & H. Michael Moeller\\
-Michael Monagan       & Marc Moreno-Maza      & Scott Morrison\\
-Mark Murray           & William Naylor        & C. Andrew Neff\\
-John Nelder           & Godfrey Nolan         & Arthur Norman\\
-Jinzhong Niu          & Michael O'Connor      & Kostas Oikonomou\\
-Julian A. Padget      & Bill Page             & Jaap Weel\\
-Susan Pelzel          & Michel Petitot        & Didier Pinchon\\
-Claude Quitte         & Norman Ramsey         & Michael Richardson\\
-Renaud Rioboo         & Jean Rivlin           & Nicolas Robidoux\\
-Simon Robinson        & Michael Rothstein     & Martin Rubey\\
-Philip Santas         & Alfred Scheerhorn     & William Schelter\\
-Gerhard Schneider     & Martin Schoenert      & Marshall Schor\\
-Fritz Schwarz         & Nick Simicich         & William Sit\\
-Elena Smirnova        & Jonathan Steinbach    & Christine Sundaresan\\
-Robert Sutor          & Moss E. Sweedler      & Eugene Surowitz\\
-James Thatcher        & Baldir Thomas         & Mike Thomas\\
-Dylan Thurston        & Barry Trager          & Themos T. Tsikas\\
-Gregory Vanuxem       & Bernhard Wall         & Stephen Watt\\
-Juergen Weiss         & M. Weller             & Mark Wegman\\
-James Wen             & Thorsten Werther      & Michael Wester\\
-John M. Wiley         & Berhard Will          & Clifton J. Williamson\\
-Stephen Wilson        & Shmuel Winograd       & Robert Wisbauer\\
-Sandra Wityak         & Waldemar Wiwianka     & Knut Wolf\\
-Clifford Yapp         & David Yun             & Richard Zippel\\
-Evelyn Zoernack       & Bruno Zuercher        & Dan Zwillinger 
-\end{tabular}
-\eject
-\tableofcontents
-\vfill
-\eject
-\setlength{\parindent}{0em}
-\setlength{\parskip}{1ex}
-{\Large{\bf New Foreword}}
-\vskip .25in
-
-On October 1, 2001 Axiom was withdrawn from the market and ended
-life as a commercial product.
-On September 3, 2002 Axiom was released under the Modified BSD
-license, including this document.
-On August 27, 2003 Axiom was released as free and open source
-software available for download from the Free Software Foundation's
-website, Savannah.
-
-Work on Axiom has had the generous support of the Center for 
-Algorithms and Interactive Scientific Computation (CAISS) at
-City College of New York. Special thanks go to Dr. Gilbert 
-Baumslag for his support of the long term goal.
-
-The online version of this documentation is roughly 1000 pages.
-In order to make printed versions we've broken it up into three
-volumes. The first volume is tutorial in nature. The second volume
-is for programmers. The third volume is reference material. We've
-also added a fourth volume for developers. All of these changes
-represent an experiment in print-on-demand delivery of documentation.
-Time will tell whether the experiment succeeded.
-
-Axiom has been in existence for over thirty years. It is estimated to
-contain about three hundred man-years of research and has, as of
-September 3, 2003, 143 people listed in the credits. All of these
-people have contributed directly or indirectly to making Axiom
-available.  Axiom is being passed to the next generation. I'm looking
-forward to future milestones.
-
-With that in mind I've introduced the theme of the ``30 year horizon''.
-We must invent the tools that support the Computational Mathematician
-working 30 years from now. How will research be done when every bit of
-mathematical knowledge is online and instantly available? What happens
-when we scale Axiom by a factor of 100, giving us 1.1 million domains?
-How can we integrate theory with code? How will we integrate theorems
-and proofs of the mathematics with space-time complexity proofs and
-running code? What visualization tools are needed? How do we support
-the conceptual structures and semantics of mathematics in effective
-ways? How do we support results from the sciences? How do we teach
-the next generation to be effective Computational Mathematicians?
-
-The ``30 year horizon'' is much nearer than it appears.
-
-\vskip .25in
-%\noindent
-Tim Daly\\
-CAISS, City College of New York\\
-November 10, 2003 ((iHy))
-\vfill
-\eject
-\pagenumbering{arabic}
-\setcounter{chapter}{0} % Chapter 1
-\chapter{Overview}
-The axiom system consists of a set of processes managed by the
-superman process.  The superman process, called sman, is normally
-invoked from the axiom shell script in order to start a tree of
-subprocesses.
-
-The {\tt axiom} command is a shell script that collects the 
-command line options for the {\tt sman} process, sets some shell
-variables, and then invokes {\tt sman}. 
-
-The {\tt sman} process starts the following tree of processes:
-\begin{verbatim}
-     --xterm---bash---sman-|-AXIOMsys
-                           |-clef---spadclient
-                           |-hypertex
-                           |-session
-                           |-sman
-                           |-viewman
-\end{verbatim}
-
-\chapter{The axiom Command}
-The {\tt axiom} command starts everything for Axiom. The options
-for the {\tt axiom} command are:
-\begin{verbatim}
-axiom
-  [-ht    |-noht]      whether to use HyperDoc
-  [-gr    |-nogr]      whether to use Graphics
-  [-clef  |-noclef]    whether to use Clef
-  [-nonag |-nag]       whether to use NAG
-  [-noiw  |-iw]        start in interpreter in a separate window
-  [-ihere |-noihere]   start an interpreter in this window
-  [-nox]               don't use X Windows
-  [-go  |-nogo]        whether to start system
-  [-ws wsname]         use named workspace
-  [-list]              list workspaces only
-  [-grprog fname]      use named program for Graphics
-  [-nagprog fname]     use named program for Nag
-  [-htprog fname]      use named program for HyperDoc
-  [-clefprog fname]    use named program for Clef
-  [-sessionprog fname] use named program for session
-  [-clientprog fname]  use named program for spadclient
-  [-h]                 show usage
-\end{verbatim}
-
-In detail, the command options are:
-\subsection{[-ht $\vert$ -noht]}
-\begin{verbatim}
-  [-ht    |-noht]      whether to use HyperDoc
-\end{verbatim}
-{\tt Hyperdoc}\cite{7} is the documentation tool for Axiom. The
-{\tt -ht} option, enabled by default, will start this tool.
-See Jenks\cite{1} Chapter 3 for further information on the 
-{\tt hyperdoc} subsystem.
-
-\subsection{[-gr $\vert$ -nogr]}
-\begin{verbatim}
-  [-gr    |-nogr]      whether to use Graphics
-\end{verbatim}
-The {\tt graphics}\cite{8} subsystem is enabled using the 
-{\tt -gr} option, enabled by default. Graphics will appear as a
-result of a draw command, such as
-\begin{verbatim}
- draw(sin(x),x=0..1)
-\end{verbatim}
-Note that attempting to use draw commands when the graphics is
-disabled will simply hang the interpreter waiting for a response.
-See Jenks\cite{1} Chapter 7 for further information on the 
-{\tt graphics} subsystem.
-
-\subsection{[-clef $\vert$ -noclef]}
-\begin{verbatim}
-  [-clef  |-noclef]    whether to use Clef
-\end{verbatim}
-The {\tt clef} (Command Line Edit Facility) allows for command completion.
-The list of command completion strings is in the last chapter of this
-document. If {\tt clef}, enabled by default, is running then you can type:
-\begin{verbatim}
- x:Dena<tab>
-\end{verbatim}
-and this will automatically be expanded to:
-\begin{verbatim}
- x:DenavitHartenbergMatrix
-\end{verbatim}
-
-The {\tt clef} program also allows command line editing. The commands are
-special keyboard keys.
-\begin{itemize}
-\item HOME move to beginning of the line
-\item END move to the end of the line
-\item CTRL-END delete to end of the line
-\item TAB command completion (multiple tabs give new choices)
-\item UPARROW move back thru commands
-\item DOWNARROW move forward thru commands
-\item LEFTARROW move left on the line
-\item RIGHTARROW move right on the line
-\item INSERT toggle insert/overstrike
-\end{itemize}
-See Jenks\cite{1} page 21 for further information on the {\tt clef} command.
-
-\subsection{[-nonag $\vert$ -nag]}
-\begin{verbatim}
-  [-nonag |-nag]       whether to use NAG
-\end{verbatim}
-The {\tt nag} option, disabled by default, will attempt to start
-the {\tt nagman} program in the \$AXIOM/lib subdirectory. Since
-the open source version does not include the NAG numeric libraries
-this option does not work.
-
-\subsection{[-noiw $\vert$ -iw]}
-\begin{verbatim}
-  [-noiw  |-iw]        start in interpreter in a separate window
-\end{verbatim}
-The {\tt iw} option, disabled by default, will start a second
-interpreter in its own window with its own frame. The fact that
-the second interpreter is in its own frame can be seen using the
-{\tt )frame} command. For instance, if you type
-\begin{verbatim}
- axiom -iw
-\end{verbatim}
-there will be two interpreter windows available, one in the current
-window and one in a new window. In the current window if you type:
-\begin{verbatim}
- )frame names
-\end{verbatim}
-you will see:
-\begin{verbatim}
-   The names of the existing frames are:
-            frame0 
-            frame1 
-            initial 
-      The current frame is the first one listed.
-\end{verbatim}
-
-In the second window, if you type
-\begin{verbatim}
- )frame names
-\end{verbatim}
-you will see:
-\begin{verbatim}
-   The names of the existing frames are:
-            frame1 
-            frame0 
-            initial 
-      The current frame is the first one listed.
-\end{verbatim}
-Setting
-\begin{verbatim}
- x:=3
-\end{verbatim}
-in the second window will set the variable $x$ in the frame {\tt frame1}.
-Switching to the first window and typing:
-\begin{verbatim}
- x
-\end{verbatim}
-gives:
-\begin{verbatim}
-
-   (1)  x
-                             Type: Variable x
-\end{verbatim}
-since the first window is in {\tt frame0} and the variable $x$ is
-defined in {\tt frame1}.
-But we can switch frames in the first window using
-\begin{verbatim}
- )frame next
-\end{verbatim}
-and then
-\begin{verbatim}
- x
-\end{verbatim}
-gives:
-\begin{verbatim}
-
-   (2)  3
-                             Type: PositiveInteger
-\end{verbatim}
-and now the two windows share the same frame space. 
-See Jenks\cite{1} page 579 for further information on the {\tt frame} command.
-
-\subsection{[-ihere $\vert$ -noihere]}
-\begin{verbatim}
-  [-ihere |-noihere]   start an interpreter in this window
-\end{verbatim}
-This option determines whether Axiom will start in the current window.
-Using this option alone is not particularly useful and it is generally
-used in combination with the {\tt -iw} option:
-\begin{verbatim}
- axiom -noihere -iw &
-\end{verbatim}
-
-However, used alone, as in:
-\begin{verbatim}
- axiom -noihere &
-\end{verbatim}
-it will start Axiom and show the Hyperdoc window. Graphics will also
-work from the Hyperdoc pages.
-
-\subsection{[-nox]}
-\begin{verbatim}
-  [-nox]               don't use X Windows
-\end{verbatim}
-allows Axiom to start the interpreter without Hyperdoc or the graphics
-subsystem. This is useful for starting Axiom in an emacs buffer.
-
-\subsection{[-go $\vert$ -nogo]}
-\begin{verbatim}
-  [-go  |-nogo]        whether to start system
-\end{verbatim}
-uses the {\tt -go} option, enabled by default, controls whether
-the system starts from the command line. If the {\tt -nogo}
-option is chosen the system prints the command line that would
-have been issued. This is useful for finding out what the command
-line options to {\tt sman} will be. For instance:
-\begin{verbatim}
- axiom -nogo -iw
-\end{verbatim}
-does not start Axiom but types out:
-\begin{verbatim}
-Would now start the processes.
-exec ~/mnt/linux/bin/sman -iw -ws ~/mnt/linux/bin/AXIOMsys
-\end{verbatim}
-
-\subsection{[-ws wsname]}
-\begin{verbatim}
-  [-ws wsname]         use named workspace
-\end{verbatim}
-In the {\tt -nogo} command above you can see that the default
-workspace name is 
-\begin{verbatim}
--ws ~/mnt/linux/bin/AXIOMsys
-\end{verbatim}
-This option allows you to change that. This is useful for
-debugging new system builds. During build a debugging version
-of Axiom is created in the {\tt obj/linux/bin} directory. The
-{\tt debugsys} image uses interpreted lisp code rather than
-compiled code. This makes it possible to do deep debugging. To
-use this workspace you would incant:
-\begin{verbatim}
- cd youraxiombuild
- export AXIOM=`pwd`/mnt/linux
- export PATH=$AXIOM/bin:$PATH
- axiom -ws obj/linux/bin/debugsys
-\end{verbatim}
-
-
-\subsection{[-list]}
-\begin{verbatim}
-  [-list]              list workspaces only
-\end{verbatim}
-shows you the executable workspaces. Generally in a built system
-there is only one, called\\
-{\tt \$AXIOM/bin/AXIOMsys}.
-
-\subsection{[-grprog fname]}
-\begin{verbatim}
-  [-grprog fname]      use named program for Graphics
-\end{verbatim}
-allows you to specify which program to use for the graphics.
-By default this is\\
-{\tt \$AXIOM/lib/viewman}.
-
-\subsection{[-nagprog fname]}
-\begin{verbatim}
-  [-nagprog fname]     use named program for Nag
-\end{verbatim}
-allows you to specify which program to use for the NAG library
-connection. By default this is\\
-{\tt \$AXIOM/lib/nagman} but it is disabled by default.
-
-\subsection{[-htprog fname]}
-\begin{verbatim}
-  [-htprog fname]      use named program for Hyperdoc
-\end{verbatim}
-allows you tp specify which program to use for Hyperdoc. By
-default it is\\
-{\tt \$AXIOM/bin/hypertex -s}.
-
-\subsection{[-clefprog fname]}
-\begin{verbatim}
-  [-clefprog fname]    use named program for Clef
-\end{verbatim}
-allows you to specify which program to use for clef. By default
-it is\\ 
-{\tt \$AXIOM/bin/clef -f \$AXIOM/lib/command.list -e}.
-
-\subsection{[-sessionprog fname]}
-\begin{verbatim}
-  [-sessionprog fname] use named program for session
-\end{verbatim}
-allows you to specify the session manager program. By default it is\\
-{\tt \$AXIOM/lib/session}.
-
-\subsection{[-clientprog fname]}
-\begin{verbatim}
-  [-clientprog fname]  use named program for spadclient
-\end{verbatim}
-allows you to specify the spadclient program. By default it is\\
-{\tt \$AXIOM/lib/spadclient}.
-
-\subsection{[-h]}
-\begin{verbatim}
-  [-h]                 show usage
-\end{verbatim}
-
-<<axiomcmd>>=
-#!/bin/sh
-
-@
-The {\tt MALLOCTYPE} shell variable is an {\tt IBM} {\tt AIX}
-shell variable that controls buckets based extensions in the default
-memory allocator which may enhance performance. AIX uses a new
-memory management routine that does not zero {\tt malloc} memory
-and does not round up to the nearest power of 2, unlike most non-AIX
-systems. This can cause failures so we protect against that here.
-See the AIX Performance Tuning Guide\cite{9} for details.
-<<axiomcmd>>=
-
-MALLOCTYPE=3.1
-export MALLOCTYPE
-
-@
-The {\tt nagman} process needs to know the hostname
-<<axiomcmd>>=
-HOST=`hostname`
-export HOST
-
-@
-There are 4 basic utilities used by this script.
-The {\tt ciao} script for immediate exit:
-<<axiomcmd>>=
-ciao() {
-	echo "Goodbye."
-	exit 1
-}
-
-@
-The {\tt needsubopt} script which is used to issue an error message
-when one of the command line options requires an option:
-<<axiomcmd>>=
-needsubopt () {
-	echo "The $1 option requires an argument."
-	ciao
-}
-@
-The {\tt showuse} script which gives basic command line help:
-<<axiomcmd>>=
-showuse() {
-echo "axiom"
-echo "  [-ht    |-noht]      whether to use HyperDoc"
-echo "  [-gr    |-nogr]      whether to use Graphics"
-echo "  [-clef  |-noclef]    whether to use Clef"
-echo "  [-nonag |-nag]       whether to use NAG"
-echo "  [-noiw  |-iw]        start in interpreter in a separate window"
-echo "  [-ihere |-noihere]   start an interpreter in this window"
-echo "  [-nox]               don't use X Windows"
-echo "  [-go  |-nogo]        whether to start system"
-echo "  [-ws wsname]         use named workspace"
-echo "  [-list]              list workspaces only"
-echo "  [-grprog fname]      use named program for Graphics"
-echo "  [-nagprog fname]     use named program for Nag"
-echo "  [-htprog fname]      use named program for HyperDoc"
-echo "  [-clefprog fname]    use named program for Clef"
-echo "  [-sessionprog fname] use named program for session"
-echo "  [-clientprog fname]  use named program for spadclient"
-echo "  [-h]                 show usage"
-}
-
-@
-List the various workspaces if asked.
-<<axiomcmd>>=
-listwspaces()
-{
-        echo "$1"
-        ls -l $2 | grep "sys$"
-        echo ""
-}
-
-@
-Step 1. Ensure the environment is set.
-
-Just process ``-h''. If it exists in the command line then we
-print out the simple command line help menu.
-<<axiomcmd>>=
-
-if [ "$*" = "-h" ] ; then
-     showuse
-fi
-@
-
-We assume that Axiom is installed in the standard place on
-a linux system. We will modify this assumption as we process
-the environment and command line. The term {\tt spad} is an
-historical shortened version of the name {\tt scratchpad},
-the original name of the {\tt Axiom} system.
-<<axiomcmd>>=
-SPADDEFAULT=/usr/local/axiom/mnt/linux
-
-@
-If the {\tt \$AXIOM} shell variable is set then we use it.\\
-If not, then if the {\tt \$SPAD} shell variable is set then we use it.\\
-If not, then we try to use the default value above.\\
-If not, we simply fail.
-<<axiomcmd>>=
-if [ "$SPAD" = "" ] ; then
-  if [ "$AXIOM" = "" ] ; then
-    SPAD=$SPADDEFAULT
-    echo "AXIOM variable is not set"
-    echo "assuming AXIOM = $SPAD"
-    AXIOM=$SPAD
-    export AXIOM
-  else
-    SPAD=$AXIOM
-  fi
-  export SPAD
-else
-  if [ "$AXIOM" = "" ] ; then
-    echo "AXIOM variable is not set"
-    echo "but SPAD = $SPAD"
-    echo "Using AXIOM = $SPAD"
-    AXIOM=$SPAD
-    export AXIOM
-  else
-    if [ ! "$SPAD" = "$AXIOM" ] ; then
-       echo "ignoring SPAD variable"
-       SPAD=$AXIOM
-    fi
-  fi
-fi
-
-@
-If we get here then all attempts to find axiom have failed
-so we complain and exit.
-<<axiomcmd>>=
-if [ ! -d "$SPAD" ] ; then
-  echo "The directory for Axiom, $SPAD, does not exist."
-  ciao
-fi
-
-@
-If we get here we now
-know where axiom lives. We need to see if we can find the
-Aldor compiler. Aldor is optional and is not part of the open source
-version of Axiom due to license issues. However you can install it
-under the location specified by the {\tt \$AXIOMXLROOT} shell variable.
-If the compiler is found we add it to the {\tt PATH}.
-This shell variable defaults to the location:\\
-{\tt \$AXIOM/compiler}
-<<axiomcmd>>=
-if [ "$AXIOMXLROOT" = "" ] ; then 
-AXIOMXLROOT=${AXIOM}/compiler
-fi
-export AXIOMXLROOT
-PATH=$AXIOM/bin:$AXIOMXLROOT/bin:${PATH}
-export PATH
-
-@
-Name the workspace directories.
-<<axiomcmd>>=
-rootwsdir=$SPAD/bin
-
-@
-Step 2. Process command line arguments.
-
-First we set up the defaults for command-line arguments.
-We don't want just a list by default
-<<axiomcmd>>=
-list=no
-
-@
-We default to actually executing the workspace.
-<<axiomcmd>>=
-go=yes
-
-@
-We default to the {\tt AXIOMsys} workspace.
-<<axiomcmd>>=
-wsname=AXIOMsys
-
-@
-And all other options are unset.
-<<axiomcmd>>=
-otheropts=""
-
-@
-For each option on the command line do
-<<axiomcmd>>=
-while [ "$*" != "" ] ; do
-@
-<<axiomcmd>>=
-
-	case $1 in
-@
-If the user specified list anywhere then we give the workspace list
-and exit.
-<<axiomcmd>>=
-
-        -list)  list=yes
-                go=no;;
-@
-If the user specified {\tt go} or {\tt nogo} we handle that case
-<<axiomcmd>>=
-	-go)	go=yes ;;
-	-nogo)	go=no ;;
-
-@
-The workspace option requires an argument which follows immediately.
-If the argument is missing we complain and exit.
-<<axiomcmd>>=
-	-ws)
-		if [ "$2" = "" ] ; then needsubopt "$1" ; fi
-		shift
-		wsname="$1"
-		;;
-
-@
-We can specify the various subprograms to use.
-<<axiomcmd>>=
-	-nagprog|-grprog|-htprog|-clefprog|-sessionprog|-clientprog)
-		if [ "$2" = "" ] ; then needsubopt "$1" ; fi
-		otheropts="$otheropts  $1 $2"
-		shift
-		;;
-@
-These options were not explained earlier and are only for developer use.
-<<axiomcmd>>=
-        -paste|-rm|-rv)
-		if [ "$2" = "" ] ; then needsubopt "$1" ; fi
-		otheropts="$otheropts  $1 $2"
-		shift
-		;;
-@
-We handle the various [{\tt -option} $\vert$ {\tt -nooption}] cases
-<<axiomcmd>>=
-	-clef|-noclef|-gr|-nogr|-ht|-noht|-iw|-noiw)
-		otheropts="$otheropts $1"
-		;;
-        -ihere|-noihere|-nox|-nag|-nonag)
-		otheropts="$otheropts $1"
-		;;
-@
-The user wanted help so we will not execute.
-<<axiomcmd>>=
-	-h)
-		go=no
-		;;
-@
-The user is confused. Complain and exit.
-<<axiomcmd>>=
-	*)	echo "Unknown option: $1"
-		echo "To use a specific workspace use, e.g.: spad -ws $1"
-		ciao
-		;;
-	esac
-@
-Move to the next option and loop.
-<<axiomcmd>>=
-
-	shift
-done
-
-@
-Step 3. Handle options that require special case handling.
-
-The user just wanted to know what workspaces are available.
-<<axiomcmd>>=
-if [ $list = yes ] ; then
- listwspaces "AXIOM workspaces in \$AXIOM/bin = $rootwsdir: " $rootwsdir
-fi
-
-@
-Try to ensure a suitable workspace on this host.
-<<axiomcmd>>=
-if [ `expr $wsname : '.*/.*'` = 0 ] ; then
-	serverws=$rootwsdir/$wsname
-else
-	serverws=$wsname
-fi
-@
-If we can't find the executable then we complain and exit.
-<<axiomcmd>>=
-
-if [ ! -x $serverws ] ; then
-        echo "Cannot find the executable $serverws"
-	showuse
-	ciao
-fi
-@
-The user just wanted to see what would happen so we output the
-command line and exit.
-<<axiomcmd>>=
-if [ $go = no ] ; then
-	echo "Would now start the processes."
-	echo exec $SPAD/bin/sman $otheropts -ws $serverws
-	exit 0
-fi
-@
-All of the options have been processed so we start {\tt sman}
-<<axiomcmd>>=
-exec $SPAD/bin/sman $otheropts -ws $serverws
-
-@
-\chapter{The {\tt sman} program}
-\section{sman.h}
-The spad\_proc structure holds information about the process id
-of a child process, what to do when it dies, and the shell command
-line necessary to restart the process. There is a linked list of
-these structures which maintains the process list for axiom.
-<<sman.h>>=
-/* Process control definitions.  Used by fork_you and spawn_of_hell */
-
-/* When a process dies it kills off everything else */
-#define Die 1
-/* When a process dies, do nothing */
-#define NadaDelShitsky  2
-/* When a process dies start it up again */
-#define DoItAgain       3
-/* When hypertex dies, clean its socket */
-#define CleanHypertexSocket 4
-
-typedef struct spad_proc {
-  int	proc_id;	/* process id of child */
-  int	death_action;	/* one of the above constants */
-  char	*command;	/* sh command line to restart the process */
-  struct spad_proc *next;
-} SpadProcess;
-
-@
-\section{sman}
-\subsection{includes}
-<<sman.includes>>=
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include <pwd.h>
-#include <fcntl.h>
-#include <termios.h>
-#include <errno.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <signal.h>
-
-#if defined(SUN4OS5platform) || defined(HP10platform)
-#include <sys/stropts.h>
-#endif
-
-#include "com.h"
-#include "bsdsignal.h"
-#include "sman.h"
-
-#include "bsdsignal.h1"
-#include "sockio-c.h1"
-#include "openpty.h1"
-#include "sman.h1"
-
-@
-\subsection{variables}
-<<sman.variables>>=
-char *ws_path;                  /* location of the AXIOM executable */
-int start_clef;			/* start clef under spad */
-int start_graphics;		/* start the viewman */
-int start_nagman;               /* start the nagman */
-int start_ht;			/* start hypertex */
-int start_spadclient;		/* Start the client spad buffer */
-int start_local_spadclient;	/* Start the client spad buffer */
-int use_X;			/* Use the X windows environment */
-int server_num;			/* AXIOM server number */
-@
-We add a debug flag so we can print information about what [[sman]]
-is trying to do. This change is pervasive as it touches nearly every
-routine.
-<<sman.variables>>=
-int tpd=0;                      /* to-print-debug information */
-
-/************************************************/
-/* definitions of programs which sman can start */
-/************************************************/
-
-<<the viewman command line>>
-<<the nagman command line>>
-<<the hypertex command line>>
-<<the clef command line>>
-<<the session manager command line>>
-<<the spadclient command line>>
-char *PasteFile = NULL;
-char *MakeRecordFile = NULL;
-char *VerifyRecordFile = NULL;
-
-SpadProcess *spad_process_list = NULL;
-/***************************/
-/* sman defaults file name */
-/***************************/
-
-#define SpadDefaultFile "spadprof.input"
-
-char ClefCommandLine[256];
-
-#define BufSize      4096 	/* size of communication buffer */
-char big_bad_buf[BufSize];      /* big I/O buffer */
-
-Sock *session_io = NULL;        /* socket connecting to session manager */
-
-/***********************************************************/
-/* Some characters used and externally defined in edible.h */
-/***********************************************************/
-
-unsigned char  _INTR, _QUIT, _ERASE, _KILL, _EOF, _EOL, _RES1, _RES2;
-
-/*************************************/
-/* Stuff for opening pseudo-terminal */
-/*************************************/
-
-int ptsNum, ptcNum;
-char ptsPath[20], ptcPath[20];
-
-char **new_envp;                /* new environment for AXIOM */
-int child_pid;                  /* child's process id */
-struct termios oldbuf;           /* the original settings */
-struct termios childbuf;         /* terminal structure for user i/o */
-
-int nagman_signal=0;
-int death_signal = 0;
-
-@
-\subsection{process\_arguments}
-<<sman.processarguments>>=
-static void
-process_arguments(int argc,char ** argv)
-{
-  int arg;
-  if (tpd == 1) fprintf(stderr,"sman:process_arguments entered\n");
-  for (arg = 1; arg < argc; arg++) {
-    if      (strcmp(argv[arg], "-debug")      == 0)
-      tpd = 1;
-    else if (strcmp(argv[arg], "-noclef")      == 0)
-      start_clef = 0;
-    else if (strcmp(argv[arg], "-clef")        == 0)
-      start_clef = 1;
-    else if (strcmp(argv[arg], "-gr")          == 0)
-      start_graphics = 1;
-    else if (strcmp(argv[arg], "-nogr")        == 0)
-      start_graphics = 0;
-    else if (strcmp(argv[arg], "-nag")          == 0)
-      start_nagman = 1;
-    else if (strcmp(argv[arg], "-nonag")        == 0)
-      start_nagman = 0;
-    else if (strcmp(argv[arg], "-ht")          == 0)
-      start_ht = 1;
-    else if (strcmp(argv[arg], "-noht")        == 0)
-      start_ht = 0;
-    else if (strcmp(argv[arg], "-iw")          == 0)
-      start_spadclient = 1;
-    else if (strcmp(argv[arg], "-ihere")       == 0)
-      start_local_spadclient = 1;
-    else if (strcmp(argv[arg], "-noihere")     == 0)
-      start_local_spadclient = 0;
-    else if (strcmp(argv[arg], "-noiw")        == 0)
-      start_spadclient = 0;
-    else if (strcmp(argv[arg], "-ws")          == 0)
-      ws_path = argv[++arg];
-    else if (strcmp(argv[arg], "-comp")        == 0)
-      ws_path = "$AXIOM/etc/images/comp";
-    else if (strcmp(argv[arg], "-nox")         == 0)
-      {
-	use_X = 0;
-	start_local_spadclient = 1;
-	start_spadclient = 0;
-	start_ht = 0;
-	start_graphics = 0;
-      }
-    else if (strcmp(argv[arg], "-grprog")      == 0)
-      GraphicsProgram = argv[++arg];
-    else if (strcmp(argv[arg], "-nagprog")      == 0)
-      NagManagerProgram = argv[++arg];
-    else if (strcmp(argv[arg], "-htprog")      == 0)
-      HypertexProgram = argv[++arg];
-    else if (strcmp(argv[arg], "-clefprog")    == 0) {
-      strcpy(ClefCommandLine,argv[++arg]);
-    ClefProgram = 
-        strcat(ClefCommandLine, " -f $AXIOM/lib/command.list -e ");
-    }
-    else if (strcmp(argv[arg], "-sessionprog") == 0)
-      SessionManagerProgram = argv[++arg];
-    else if (strcmp(argv[arg], "-clientprog")  == 0)
-      SpadClientProgram = argv[++arg];
-    else if (strcmp(argv[arg], "-rm")  == 0)
-      MakeRecordFile = argv[++arg];
-    else if (strcmp(argv[arg], "-rv")  == 0)
-      VerifyRecordFile = argv[++arg];
-    else if (strcmp(argv[arg], "-paste")  == 0)
-      PasteFile = argv[++arg];
-    else {
-      fprintf(stderr, "Usage: sman <-clef|-noclef> <-gr|-nogr> <-ht|-noht>");
-      fprintf(stderr, " <-iw|-noiw> <-nag|-nonag> <-nox> <-comp>");
-      fprintf(stderr, " <-ws spad_workspace> <-grprog path> <-htprog path>");
-      fprintf(stderr, " <-clefprog path> <-sessionprog path> <-nagprog path>");
-      fprintf(stderr, " <-clientprog path>\n");
-      exit(-1);
-    }
-  }
-  if (tpd == 1)
-  { fprintf(stderr,"  sman ");
-    if (start_clef == 0)
-      fprintf(stderr,"-noclef ");
-    else
-      fprintf(stderr,"-clef ");
-    if (start_graphics == 0)
-      fprintf(stderr,"-nogr ");
-    else
-      fprintf(stderr,"-gr ");
-    if (start_nagman == 0)
-      fprintf(stderr,"-nonag ");
-    else
-      fprintf(stderr,"-nag ");
-    if (start_ht == 0)
-      fprintf(stderr,"-noht ");
-    else
-      fprintf(stderr,"-ht ");
-    if (start_spadclient == 0)
-      fprintf(stderr,"-noiw ");
-    else
-      fprintf(stderr,"-iw ");
-    if (start_local_spadclient == 0)
-      fprintf(stderr,"-noihere ");
-    else
-      fprintf(stderr,"-ihere ");
-    if (start_local_spadclient == 0)
-      fprintf(stderr,"-noihere ");
-    else
-      fprintf(stderr,"-ihere ");
-    if (use_X == 0)
-      fprintf(stderr,"-nox ");
-    fprintf(stderr,"-ws ");
-    fprintf(stderr,"'%s' ",ws_path);
-    fprintf(stderr,"-grprog ");
-    fprintf(stderr,"'%s' ",GraphicsProgram);
-    fprintf(stderr,"-nagprog ");
-    fprintf(stderr,"'%s' ",NagManagerProgram);
-    fprintf(stderr,"-htprog ");
-    fprintf(stderr,"'%s' ",HypertexProgram);
-    fprintf(stderr,"-clefprog ");
-    fprintf(stderr,"'%s' ",ClefCommandLine);
-    fprintf(stderr,"-sessionprog ");
-    fprintf(stderr,"'%s' ",SessionManagerProgram);
-    fprintf(stderr,"-clientprog ");
-    fprintf(stderr,"'%s' ",SpadClientProgram);
-    fprintf(stderr,"-rm ");
-    fprintf(stderr,"'%s' ",MakeRecordFile);
-    fprintf(stderr,"-rv ");
-    fprintf(stderr,"'%s' ",VerifyRecordFile);
-    fprintf(stderr,"-paste ");
-    fprintf(stderr,"'%s' ",PasteFile);
-    fprintf(stderr,"\n");
-  }
-  if (tpd == 1) fprintf(stderr,"sman:process_arguments exit\n");
-}
-
-@
-\subsection{should\_I\_clef}
-<<sman.shouldIclef>>=
-static int 
-should_I_clef(void)
-{
-  return(1);
-}
-
-@
-\subsection{in\_X}
-<<sman.inX>>=
-static int 
-in_X(void)
-{
-  if (getenv("DISPLAY")) return 1;
-  return 0;
-}
-
-@
-\subsection{set\_up\_defaults}
-These are the default values for sman. A '1' value means that
-sman will try to start the given process, a '0' value means not
-starting the process.
-
-We do not have replacement code for the [[nagman]] process nor
-do we have a copy of the [[nag fortran library]] to test the process.
-Until this changes we set [[start_nagman = 0]] in order to disable
-starting this process by default.
-<<sman.setupdefaults>>=
-static  void
-set_up_defaults(void)
-{
-  if (tpd == 1) fprintf(stderr,"sman:set_up_defaults entered\n");
-  start_clef = should_I_clef();
-  start_graphics = 1;
-  start_nagman = 0;
-  start_ht = 1;
-  start_spadclient = 0;
-  start_local_spadclient = 1;
-  use_X = isatty(0) && in_X();
-  ws_path = "$AXIOM/bin/AXIOMsys";
-  if (tpd == 1) fprintf(stderr,"sman:set_up_defaults exit\n");
-}
-
-@
-\subsection{process\_options}
-<<sman.processoptions>>=
-static void
-process_options(int argc, char **argv)
-{
-  if (tpd == 1) fprintf(stderr,"sman:process_options entered\n");
-  set_up_defaults();
-  process_arguments(argc, argv);
-  if (tpd == 1) fprintf(stderr,"sman:process_options exit\n");
-}
-
-@
-\subsection{death\_handler}
-<<sman.deathhandler>>=
-static void
-death_handler(int sig)
-{
-  death_signal = 1;
-}
-
-@
-\subsection{nagman\_handler}
-<<sman.nagmanhandler>>=
-static void 
-nagman_handler(int sig)
-{
-  nagman_signal=1;
-}
-
-@
-\subsection{sman\_catch\_signals}
-<<sman.smancatchsignals>>=
-static void
-sman_catch_signals(void)
-{
-  
-  /* Set up the signal handlers for sman */
-  bsdSignal(SIGINT,  SIG_IGN,RestartSystemCalls);
-  bsdSignal(SIGTERM, death_handler,RestartSystemCalls);
-  bsdSignal(SIGQUIT, death_handler,RestartSystemCalls);
-  bsdSignal(SIGHUP,  death_handler,RestartSystemCalls);
-  bsdSignal(SIGILL,  death_handler,RestartSystemCalls);
-  bsdSignal(SIGTRAP, death_handler,RestartSystemCalls);
-  bsdSignal(SIGIOT,  death_handler,RestartSystemCalls);
-  bsdSignal(SIGBUS,  death_handler,RestartSystemCalls);
-  bsdSignal(SIGSEGV, death_handler,RestartSystemCalls);
-  /* don't restart wait call on SIGUSR1  */
-  bsdSignal(SIGUSR1, nagman_handler,DontRestartSystemCalls); 
-  /* ONLY nagman should send this.
-     If an error (such as C-c) interrupts a NAGLINK call, nagman
-     gets a signal to clean up. We need to start another nagman 
-     almost immediately to process the next NAGLINK request.
-     Since nagman takes a while to clean up, we treat it specially.
-     nagman should send a signal (USR1) to sman.
-     sman should respond by spawning a new nagman.
-     
-     so nagman is NOT a DoItAgain but a NadaDelShitsky.
-     
-     The USR1 mechanism does not work for HPUX 9 - use DoItAgain 
-     */
-
-}
-
-@
-\subsection{fix\_env}
-insert SPADSERVER and SPADNUM variables into the environemnt
-<<sman.fixenv>>=
-static void
-fix_env(char **envp, int spadnum)
-{
-  int len, i;
-  char *sn;
-  for(len = 0; envp[len] != NULL; len++);
-  new_envp = (char **) malloc((len + 3) * sizeof(char *));
-  new_envp[0] = "SPADSERVER=TRUE";
-  sn = (char *) malloc(20 * sizeof(char));
-  sprintf(sn, "SPADNUM=%d", spadnum);
-  new_envp[1] = sn;
-  for(i=0; i<=len; i++)
-    new_envp[i+2] = envp[i];
-}
-
-@
-\subsection{init\_term\_io}
-<<sman.inittermio>>=
-static void
-init_term_io(void)
-{
-  if(!isatty(0)) return;
-  if( tcgetattr(0, &oldbuf) == -1) {
-    perror("getting termios");
-    return ; 			/*  exit(-1); */
-  }
-  if( tcgetattr(0, &childbuf) == -1) {
-    perror("getting termios");
-    return ; 			/*   exit(-1); */
-  }
-  _INTR = oldbuf.c_cc[VINTR];
-  _QUIT = oldbuf.c_cc[VQUIT];
-  _ERASE = oldbuf.c_cc[VERASE];
-  _KILL = oldbuf.c_cc[VKILL];
-  _EOF = oldbuf.c_cc[VEOF];
-  _EOL = oldbuf.c_cc[VEOL];
-}
-
-@
-\subsection{strPrefix}
-<<sman.strPrefix>>=
-static char *
-strPrefix(char *prefix,char * s)
-{
-  while (*prefix != '\0' && *prefix == *s) {
-    prefix++;
-    s++;
-  }
-  if (*prefix == '\0') return s;
-  return NULL;
-}
-
-@
-\subsection{check\_spad\_proc}
-<<sman.checkspadproc>>=
-static void
-check_spad_proc(char *file, char *prefix)
-{
-  char *num;
-  int pid;
-  if ((num = strPrefix(prefix, file))) {
-    pid = atoi(num);
-    if (pid > 2) {
-      kill(pid, 0);
-      if (kill(pid, 0) == -1 && errno == ESRCH) {
-	unlink(file);
-      }
-    }
-  }
-}
-
-@
-\subsection{clean\_up\_old\_sockets}
-<<sman.cleanupoldsockets>>=
-static void
-clean_up_old_sockets(void)
-{
-  char com[512], tmp_file[128];
-  FILE *file;
-  int len;
-  sprintf(tmp_file, "/tmp/socks.%d", server_num);
-  sprintf(com, "ls /tmp/.d* /tmp/.s* /tmp/.i* /tmp/.h* 2> %s > %s",
-	  tmp_file, tmp_file);
-  system(com);
-  file = fopen(tmp_file, "r");
-  if (file == NULL) {
-    fprintf(stderr, "Can't open socket listing file\n");
-    return;
-  }
-  while(fgets(com, 512, file) != NULL) {
-    len = strlen(com);
-    if (len) com[len-1] = '\0';
-    else break;
-    check_spad_proc(com, "/tmp/.d");
-    check_spad_proc(com, "/tmp/.s");
-    check_spad_proc(com, "/tmp/.i");
-    check_spad_proc(com, "/tmp/.h");
-  }
-  fclose(file);
-  unlink(tmp_file);
-}
-
-@
-\subsection{fork\_you}
-<<sman.forkyou>>=
-static SpadProcess *
-fork_you(int death_action)
-{
-  /* fork a new process, giving it a default death action */
-  /* return NULL in child, SpadProcess in parent          */
-  int child_pid = fork();
-  SpadProcess *proc;
-  if (!child_pid) return NULL;
-  proc = (SpadProcess *) malloc(sizeof(SpadProcess));
-  proc->proc_id = child_pid;
-  proc->death_action = death_action;
-  proc->command = NULL;
-  proc->next = spad_process_list;
-  spad_process_list = proc;
-  return proc;
-}
-
-@
-\subsection{exec\_command\_env}
-Note that the next-to-last argument of {\tt execle} must be an
-explicit NULL pointer. The previous naked 0 value was not correct.
-<<sman.execcommandenv>>=
-static void
-exec_command_env(char *command,char ** env)
-{
-  char new_command[512];
-  sprintf(new_command, "exec %s", command);
-  execle("/bin/sh","/bin/sh", "-c", new_command, (char *)0, env);
-}
-
-@
-\subsection{spawn\_of\_hell}
-<<sman.spawnofhell>>=
-static SpadProcess *
-spawn_of_hell(char *command, int death_action)
-{
-  SpadProcess *proc = fork_you(death_action);
-  if (proc != NULL) {
-    proc->command = command;
-    return proc;
-  }
-  exec_command_env(command, new_envp);
-  return NULL;
-}
-
-@
-\subsection{start\_the\_spadclient}
-run a AXIOM client in the main process
-<<sman.startthespadclient>>=
-static void
-start_the_spadclient(void)
-{
-  char command[256];
-  if (start_clef)
-#ifdef RIOSplatform
-    sprintf(command, 
-	    "aixterm -sb -sl 500 -name axiomclient -n AXIOM -T AXIOM -e %s %s",
-	    ClefProgram, SpadClientProgram);
-#else
-  sprintf(command, 
-	  "xterm -sb -sl 500 -name axiomclient -n AXIOM -T AXIOM -e %s %s",
-	  ClefProgram, SpadClientProgram);
-#endif
-  else
-#ifdef RIOSplatform
-    sprintf(command, 
-	    "aixterm -sb -sl 500 -name axiomclient -n AXIOM -T AXIOM -e %s", 
-	    SpadClientProgram);
-#else
-  sprintf(command, 
-	  "xterm -sb -sl 500 -name axiomclient -n AXIOM -T AXIOM -e %s", 
-	  SpadClientProgram);
-#endif
-  if (tpd == 1) 
-    fprintf(stderr,"sman:start_the_spadclient: %s\n",command);
-  spawn_of_hell(command, NadaDelShitsky);
-}
-
-@
-\subsection{start\_the\_local\_spadclient}
-<<sman.startthelocalspadclient>>=
-static void
-start_the_local_spadclient(void)
-{
-  char command[256];
-  if (start_clef)
-    sprintf(command, "%s  %s", ClefProgram, SpadClientProgram);
-  else
-    sprintf(command, "%s", SpadClientProgram);
-  if (tpd == 1) 
-    fprintf(stderr,"sman:start_the_local_spadclient: %s\n",command);
-  spawn_of_hell(command, NadaDelShitsky);
-}
-
-@
-\subsection{start\_the\_nagman}
-<<sman.startthenagman>>=
-static void
-start_the_nagman(void)
-{
-#if defined(HP9platform)
-  spawn_of_hell(NagManagerProgram,DoItAgain);
-#else
-  spawn_of_hell(NagManagerProgram,NadaDelShitsky );
-#endif
-}
-
-@
-\subsection{start\_the\_session\_manager}
-<<sman.startthesessionmanager>>=
-static void
-start_the_session_manager(void)
-{
-  spawn_of_hell(SessionManagerProgram, Die);
-}
-
-@
-\subsection{start\_the\_hypertex}
-<<sman.startthehypertex>>=
-static void
-start_the_hypertex(void)
-{
-  char prog[512];
-
-  if (PasteFile){
-    sprintf(prog, "%s -k -ip %s", HypertexProgram, PasteFile);
-    spawn_of_hell(prog, NadaDelShitsky);
-  }
-  else if (MakeRecordFile){
-    sprintf(prog, "%s -k -rm %s", HypertexProgram,MakeRecordFile );
-    spawn_of_hell(prog, NadaDelShitsky);
-  }
-  else if (VerifyRecordFile){
-    sprintf(prog, "%s -k -rv %s", HypertexProgram, VerifyRecordFile);
-    spawn_of_hell(prog, NadaDelShitsky);
-  }
-  /* If we restart hyperdoc from the axiom command prompt */
-  else spawn_of_hell(HypertexProgram, CleanHypertexSocket);
-}
-
-@
-\subsection{start\_the\_graphics}
-<<sman.startthegraphics>>=
-static void
-start_the_graphics(void)
-{
-  spawn_of_hell(GraphicsProgram, DoItAgain);
-}
-
-@
-\subsection{fork\_Axiom}
-<<sman.forkAxiom>>=
-/* Start the AXIOM session in a separate process, */
-/* using a pseudo-terminal to catch all input and output */
-static void 
-fork_Axiom(void)
-{
-  char augmented_ws_path[256];  /* will append directory path */
-  char *tmp_pointer;
-  SpadProcess *proc;
-
-  proc =  fork_you(Die);
-  child_pid = (proc == NULL ? 0 : proc->proc_id);
-  switch(child_pid) {
-  case -1 :
-    fprintf(stderr, "Can't create a new process \n");
-    exit(0);
-  case 0:
-    /* Dissasociate from my parents group so all my child processes */
-    /* look at my terminal as the controlling terminal for the      */
-    /* group                                                        */
-
-    if(setsid() < 0) {
-      perror("Dissassociating from parents group");
-      exit(-1);
-    }
-
-    close(ptsNum);
-    /* Now reopen the server side, so that pg, su, etc. work properly */
-
-    if ((ptsNum =  open(ptsPath, O_RDWR)) < 0 ) {
-      perror("fork_Axiom: Failed to reopen server");
-      exit(-1);
-    }
-#if defined(SUN4OS5platform) || defined(HP10platform)
-    ioctl(ptsNum,I_PUSH,"ptem");
-    ioctl(ptsNum,I_PUSH,"ldterm");
-#endif
-
-    /* since I am the child, I can close ptc, and dup pts for all its */
-    /* standard descriptors                                           */
-
-    if( (dup2(ptsNum, 0) == -1) ||
-        (dup2(ptsNum, 1) == -1) ||
-        (dup2(ptsNum, 2) == -1)  ) {
-      perror("trying to dupe the child");
-      exit(-1);
-    }
-    close(ptcNum);
-    close(ptsNum);
-
-
-    /* I also have to turn off echoing, since I am echoing all the */
-    /* input myself                  */
-
-    childbuf.c_lflag &= ~ECHO;
-    if( tcsetattr(0, TCSAFLUSH, &childbuf) == -1) {
-      perror("setting the term buffer");
-      exit(-1); 
-    }
-    strcpy(augmented_ws_path,ws_path);          /* write the name    */
-    strcat(augmented_ws_path," ");              /* space             */
-    strcat(augmented_ws_path,ws_path);          /* name again        */
-    tmp_pointer = (char *)
-      strrchr(augmented_ws_path,'/');      /*pointer to last /  */
-    *(++tmp_pointer) = '\0';
-    exec_command_env(augmented_ws_path, new_envp);
-
-    /*    fprintf(stderr, "Cannot execute the %s system.\n", ws_path); */
-
-    exit(0);
-  }
-}
-
-@
-\subsection{start\_the\_Axiom}
-<<sman.starttheAxiom>>=
-static void
-start_the_Axiom(char **envp)
-{
-  server_num = make_server_number();
-  clean_up_old_sockets();
-  if (server_num == -1) {
-    fprintf(stderr, "could not get an AXIOM server number\n");
-    exit(-1);
-  }
-  if (ptyopen(&ptcNum, &ptsNum, ptcPath, ptsPath) == -1) {
-    perror("start_the_Axiom: ptyopen failed");
-    exit(-1);
-  }
-  fix_env(envp, server_num);
-  fork_Axiom();
-  close(ptsNum);
-}
-
-@
-\subsection{clean\_up\_sockets}
-In order to be able to restart hyperdoc from the axiom command prompt
-we need to remove the socket for this server.
-<<sman.cleanupsockets>>=
-static void
-clean_hypertex_socket(void)
-{
-   char name[256];
-   sprintf(name, "%s%d", MenuServerName, server_num);
-   unlink(name); 
-}
-
-static void
-clean_up_sockets(void)
-{
-  char name[256];
-  sprintf(name, "%s%d", SpadServer, server_num);
-  unlink(name);
-  sprintf(name, "%s%d", SessionServer, server_num);
-  unlink(name);
-  sprintf(name, "%s%d", SessionIOName, server_num);
-  unlink(name);
-  clean_hypertex_socket();
-}
-
-@
-\subsection{read\_from\_spad\_io}
-<<sman.readfromspadio>>=
-static void
-read_from_spad_io(int ptcNum)
-{
-  int ret_code = 0, i=0;
-  static int mes_len =0; 
-  ret_code = read(ptcNum, big_bad_buf, BufSize);
-  if (ret_code == -1) {
-    clean_up_sockets();
-    exit(-1);
-  }
-  if (session_io == NULL) {
-    if (ret_code < mes_len)
-      mes_len -= ret_code;
-    else {
-      if (mes_len > 0) {
-	i = mes_len;
-	mes_len = 0;
-      }
-      else
-	i = 0;
-      ret_code = write(1, big_bad_buf+i, ret_code-i);
-    }
-  }
-  else
-    ret_code = swrite(session_io, big_bad_buf, ret_code,
-		      "writing to session man");
-  if (ret_code == -1) {
-    perror("writing output to session manager");
-    clean_up_sockets();
-    exit(-1);
-  }
-}
-
-@
-\subsection{read\_from\_manager}
-<<sman.readfrommanager>>=
-static void
-read_from_manager(int ptcNum)
-{
-  int ret_code;
-  ret_code = sread(session_io, big_bad_buf, BufSize, "reading session io");
-  if (ret_code == -1) {
-    return;
-  }
-  ret_code = write(ptcNum, big_bad_buf, ret_code);
-  if (ret_code == -1) {
-    return;
-  }
-}
-
-@
-\subsection{manage\_spad\_io}
-<<sman.managespadio>>=
-static void
-manage_spad_io(int ptcNum)
-{
-  int ret_code, i, p;
-  fd_set rd;
-  while (1) {
-    rd = socket_mask;
-    FD_SET(ptcNum, &rd);
-    if (session_io != NULL)
-      FD_SET(session_io->socket, &rd);
-    ret_code = sselect(FD_SETSIZE, &rd, 0, 0, NULL);
-    if (ret_code == -1) {
-      perror("Session manager select");
-      clean_up_sockets();
-      exit(-1);
-    }
-    if (FD_ISSET(ptcNum, &rd)) {
-      read_from_spad_io(ptcNum);
-    }
-    for(i=0; i<2; i++) {
-      if (server[i].socket > 0 && FD_ISSET(server[i].socket, &rd)) {
-	p = accept_connection(server+i);
-	switch(p) {
-	case SessionIO:
-	  session_io = purpose_table[SessionIO];
-	  /*  printf("connected session manager\n\r");*/
-	  printf("\n");
-	  break;
-	default:
-	  printf("sman: Unkown connection request type: %d\n", p);
-	  break;
-	}
-      }
-    }
-    if (session_io != NULL && FD_ISSET(session_io->socket, &rd)) {
-      read_from_manager(ptcNum);
-    }
-  }
-}
-
-@
-\subsection{init\_spad\_process\_list}
-<<sman.initspadprocesslist>>=
-static void
-init_spad_process_list(void)
-{
-  spad_process_list = NULL;
-}
-
-@
-\subsection{print\_spad\_process\_list}
-<<sman.printspadprocesslist>>=
-#if 0
-static void
-print_spad_process_list()
-{
-  SpadProcess *proc;
-  for(proc = spad_process_list; proc != NULL; proc = proc->next)
-    fprintf(stderr, "proc_id = %d, death_action = %d\n", proc->proc_id,
-	    proc->death_action);
-}
-#endif
-
-@
-\subsection{find\_child}
-<<sman.findchild>>=
-static SpadProcess *
-find_child(int proc_id)
-{
-  SpadProcess *proc;
-  for(proc = spad_process_list; proc != NULL; proc = proc->next)
-    if (proc->proc_id == proc_id) return proc;
-  return NULL;
-}
-
-@
-\subsection{kill\_all\_children}
-<<sman.killallchildren>>=
-static void
-kill_all_children(void)
-{
-  char name[256];
-  SpadProcess *proc;
-  
-  
-  for(proc = spad_process_list; proc != NULL; proc = proc->next) {
-    kill(proc->proc_id, SIGTERM);
-  }
-  sprintf(name, "/tmp/hyper%d.input",server_num);
-  unlink(name);
-
-}
-
-@
-\subsection{clean\_up\_terminal}
-<<sman.cleanupterminal>>=
-static void
-clean_up_terminal(void)
-{
-  tcsetattr(0, TCSAFLUSH, &oldbuf);
-}
-
-@
-\subsection{monitor\_children}
-<<sman.monitorchildren>>=
-static void
-monitor_children(void)
-{
-  int dead_baby, stat;
-  SpadProcess *proc;
-  while (1) {
-    stat = 0;
-    dead_baby = wait(&stat);
-    /* Check the value of dead_baby, since wait may have returned
-       a pid but subsequently we have received a signal.  Yeuch! 
-       In order to restart hyperdoc from the axiom command prompt
-       we no longer call clean_up_terminal */
-    if (dead_baby == -1 && death_signal) {
-      kill_all_children();
-      clean_up_sockets();
-      sleep(2);
-      exit(0);
-    }
-    /* Check the value of dead_baby, since wait may have returned
-       a pid but subsequently we have received a signal.  Yeuch! */
-    if(dead_baby == -1 && nagman_signal) {
-      nagman_signal=0;
-      spawn_of_hell(NagManagerProgram,NadaDelShitsky);
-      continue;
-    }
-
-    if (dead_baby == -1) {
-      fprintf(stderr, "sman: wait returned -1\n");
-      continue;
-    }
-    proc = find_child(dead_baby);
-    if (proc == NULL) {
-      /*      fprintf(stderr, "sman: %d is not known to be a child process\n",
-	      dead_baby);
-	      */
-      continue;
-    }
-    switch(proc->death_action) {
-    /* In order to restart hyperdoc from the axiom command prompt
-       we no longer call clean_up_terminal. Instead we've added a
-       case to just clean up the socket. */
-    case Die:
-      kill_all_children();
-      clean_up_sockets();
-      sleep(2);
-      exit(0);
-    case NadaDelShitsky:
-      break;
-    case DoItAgain:
-      spawn_of_hell(proc->command, DoItAgain);
-      break;
-    case CleanHypertexSocket:
-      clean_hypertex_socket();
-      break;
-    }
-  }
-}
-
-@
-\subsection{main sman}
-The main procedure should return an [[int]]. We change the return value
-here and in [[src/include/sman.h1]].
-<<sman.result>>=
-  return(0);
-@
-<<sman.main>>=
-int
-main(int argc, char *argv[],char *envp[])
-{
-  if (tpd == 1) fprintf(stderr,"sman:main entered\n");
-  bsdSignal(SIGINT,  SIG_IGN,RestartSystemCalls);
-  process_options(argc, argv);
-
-  init_term_io();
-  init_spad_process_list();
-  start_the_Axiom(envp);
-  if (open_server(SessionIOName) == -2) {
-    fprintf(stderr, "Fatal error opening I/O socket\n");
-    clean_up_sockets();
-    exit(-1);
-  }
-  start_the_session_manager();
-  if (start_spadclient)       start_the_spadclient();
-  if (start_local_spadclient) start_the_local_spadclient();
-  if (start_nagman)           start_the_nagman();
-  if (start_ht)               start_the_hypertex();
-  if (start_graphics)         start_the_graphics();
-  sleep(1);
-
-  if (fork_you(Die) != NULL) {
-    sman_catch_signals();
-    monitor_children();
-    exit(0);
-  }
-  manage_spad_io(ptcNum);
-  if (tpd == 1) fprintf(stderr,"sman:main exit\n");
-<<sman.result>>
-}
-
-@
-\subsection{sman}
-<<sman>>=
-#define _SMAN_C
-
-<<sman.includes>>
-<<sman.variables>>
-<<sman.processarguments>>
-<<sman.shouldIclef>>
-<<sman.inX>>
-<<sman.setupdefaults>>
-<<sman.processoptions>>
-<<sman.deathhandler>>
-<<sman.nagmanhandler>>
-<<sman.smancatchsignals>>
-<<sman.fixenv>>
-<<sman.inittermio>>
-<<sman.strPrefix>>
-<<sman.checkspadproc>>
-<<sman.cleanupoldsockets>>
-<<sman.forkyou>>
-<<sman.execcommandenv>>
-<<sman.spawnofhell>>
-<<sman.startthespadclient>>
-<<sman.startthelocalspadclient>>
-<<sman.startthenagman>>
-<<sman.startthesessionmanager>>
-<<sman.startthehypertex>>
-<<sman.startthegraphics>>
-<<sman.forkAxiom>>
-<<sman.starttheAxiom>>
-<<sman.cleanupsockets>>
-<<sman.readfromspadio>>
-<<sman.readfrommanager>>
-<<sman.managespadio>>
-<<sman.initspadprocesslist>>
-<<sman.printspadprocesslist>>
-<<sman.findchild>>
-<<sman.killallchildren>>
-<<sman.cleanupterminal>>
-<<sman.monitorchildren>>
-<<sman.main>>
-
-@
-\chapter{Support Routines}
-\section{Command Completion}
-Hyperdoc has the ability to do command completion. The known commands
-are listed, one entry per line, in a file called command.list. 
-\chapter{The {\tt viewman} program}
-<<the viewman command line>>=
-char *GraphicsProgram = "$AXIOM/lib/viewman";
-@
-\chapter{The {\tt nagman} program}
-<<the nagman command line>>=
-char *NagManagerProgram = "$AXIOM/lib/nagman";
-@
-\section{nag.x}
-<<nag.nag.x>>=
-
-/*
- * msg.x: Remote message printing protocol
- */
-const MAXASP = 10;
-
-/*
- * the nago structure is essentially a variable length string
- */
-
-struct nago {
-  opaque z <>;
-  };
-struct nagerr {
-nago p;
-nago q;
-};
-
-struct host{
-nago h <>;
-};
-
-struct nagst {
-
-/* Okay, if you understand this bit you know the essentials of how the link
- * works. h <> is an array of nago, which is an array of fortran source 
- * code, the length of the array being the no. of asps (0 for most routines).
- * y is the actual (XDR) input data for the routine. nm is the name of the
- * routine. id is a tag identifying the host/axiom session. Finally per is a
- * number telling whether or not to erase old fortran files on the remote
- * machine (persistence - the number per distinct fortran files will be 
- * stored, any more than this and earlier ones will be deleted.
- */
-
-  nago h <>;
-  nago y;
-  nago nm;
-  nago id;
-  int per;
-  };
-program NAGPROG {
-   version NAGVERS {
-       nagerr CALLNAG(nagst) = 1;
-       nago NAGMON(int)=2;
-       void AXEND(nago)=3;
-   } = 1;
-/*
- * the following number is very important. It tells the 
- * portmapper what number to register the nag daemon under.
- * There are rules about which number to pick - check SUN
- * technical info for more details
- */
-} = 100088;
-
-
-@
-\section{nagman}
-\subsection{includes}
-<<nag.includes>>=
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h> 
-#include <string.h>
-#include <errno.h>
-#include <termios.h>
-#include <signal.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <rpc/rpc.h>     /* always needed */ 
-#include <fcntl.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include "nag.h"  /* generated by rpcgen */
-#include "com.h"
-#include "bsdsignal.h"
-#include "sockio-c.h1"
-#include "bsdsignal.h1"
-#include "nagman.h1"
-
-@
-\subsection{variables}
-<<nag.variables>>=
-#ifdef ALPHAplatform
-extern int getdomainname( char *, int );
-#endif
-#ifdef SUN4OS5platform
-extern int getdomainname( char *, int );
-extern int gethostname( char *, int );
-#endif
-
-nagerr * callnag_1(nagst *,CLIENT *);
-nago * nagmon_1(int *,CLIENT *);
-void * axend_1(nago *,CLIENT *);
-
-#define DO 1
-#define DONT 0
-
-int hnum, vmax;
-char *datafile, *resultsfile;
-
-struct hostnode {
-  char * name;
-  struct hostnode *next; 
-} *hlist=NULL;
-
-nagst nag4;
-Sock *sock1;
-
-@
-\subsection{term}
-this code runs when the user quits axiom. before nagman dies, it does
-an rpc call to nagd to tell it to get rid of files etc. The rpc call in
-question is [[axend_1]]
-we also send a USR1 to sman to beget another nagman
-<<nag.term>>=
-static void 
-term(int sig)
-{
-  CLIENT *cld;
-  void *res;
-  struct hostnode *pnode;
-
-#ifndef HP9platform /* can't figure out a way to do this on HP/UX 9 */
-  kill(atoi(getenv("SPADNUM")) , SIGUSR1);
-#endif
-
-
-  if(hnum!=0)
-    {
-      unlink(datafile);
-      unlink(resultsfile);
-    }
-
-  for(pnode=hlist;pnode!=NULL;pnode=pnode->next)
-    {
-      cld=clnt_create(pnode->name,NAGPROG, NAGVERS, "tcp");
-      if (cld == NULL)
-	goto NOHOST;
-
-      res=axend_1(&(nag4.id),cld);
-    NOHOST:
-      clnt_destroy(cld);
-    }
-  exit(0);
-}
-
-@
-\subsection{size\_of\_file}
-<<nag.sizeoffile>>=
-static long 
-size_of_file(char *filename)
-{
-  struct stat buf_stat;
-
-  stat(filename,&buf_stat);
-  return (buf_stat.st_size);
-
-}
-
-@
-\subsection{rpcloop}
-<<nag.rpcloop>>=
-static void 
-rpcloop(void)
-{
-  CLIENT *cl;
-  int res,j,v=0,u,showMessage;
-  long i;
-  register struct hostent *alias1, *alias2;
-  struct in_addr *addrnum;
-  u_long junk;
-  struct timeval tv;
-  nagerr *result;
-  char *Buf , *buf1;
-  char *ffile[MAXASP];
-  char routine[12], naghost[256];
-  FILE *nfp1, *nfp2, *nfp3;
-  struct hostnode *phost;
-  int fd;
-  
-  for (;;)
-    {
-      
-      if((Buf=get_string(sock1))==NULL) term(1); /* one string carries all */
-      
-      if(hnum!=0)
-	{
-	  /* call parameters */
-	  free(nag4.nm.z.z_val); /* the routine name */
-	  free(nag4.y.z.z_val);  /* the XDR data */
-	  for(i=0;i<v;i++)
-	    {
-	      unlink(ffile[i]);
-	      free(ffile[i]); /* the asp filenames */
-	      free(nag4.h.h_val[i].z.z_val); /* the asps themselves*/
-	    }
-	  free(nag4.h.h_val); /* the asps array */
-	  unlink(datafile);
-	  unlink(resultsfile);
-	  free(resultsfile);
-	  free(datafile);
-	  vmax= (v>vmax)? v : vmax;
-	}
-      
-      
-      
-      
-      buf1=strtok(Buf," ");
-      if (buf1) strcpy(naghost,buf1);
-      else printf("can't parse the naghost\n");
-      /* INFO         printf("%s\n",naghost);*/
-      
-      buf1=strtok(NULL," ");
-      if (buf1) strcpy(routine,buf1);
-      else printf("can't parse the routine\n");
-      /* INFO         printf("%s\n",routine);*/
-      
-      /* make copy of filenames because we will reuse Buf before deleting the files*/
-      buf1=strtok(NULL," ");
-      if (buf1) resultsfile=strdup(buf1);
-      else printf("can't parse the resultsfile file\n");	
-      /* INFO         printf("%s\n",resultsfile);*/
-      
-      buf1=strtok(NULL," ");  
-      if (buf1) datafile=strdup(buf1); 
-      else printf("can't parse the datafile file\n");  
-      /* INFO         printf("%s\n",datafile);*/
-      
-      buf1=strtok(NULL," ");
-      if (buf1) nag4.per=atoi(buf1);
-      else printf("can't parse the persistence\n");
-      /* INFO         printf("%d\n",nag4.per);*/
-      
-      buf1=strtok(NULL," ");
-      if (buf1) {
-	if (!strcmp(buf1,"on")) showMessage=DO;
-	else showMessage=DONT;
-      }
-      else printf("can't parse the messages flag\n");
-      /* INFO         printf("%s\n",buf1);*/
-      
-      v=0; /* asp counter */
-      while( (buf1=strtok(NULL," ")) )
-	{
-	  ffile[v++]=strdup(buf1);
-	  /* INFO 	      	printf("%s\n",ffile[v-1]);*/
-	}
-      
-      /* INFO  	printf("number of asps seen %d\n",v);*/
-      
-      if(showMessage==DO) printf("nagman:acknowledging request for %s\n",routine);
-      
-      res=0;  /* prepare result integer to be sent to Lisp */
-      
-      if((nfp3=fopen(resultsfile,"w"))==NULL)
-	{
-	  printf("can't open output file\n");
-	  goto END;
-	}
-      
-      /* nag4.h is the XDR array of asp text */
-      nag4.h.h_len=v;
-      nag4.h.h_val=(nago *)malloc((v)*sizeof(nago));
-      
-      
-      /* get asp text in call argument */
-      for(u=0;u<v;u++)
-	{
-	  /* this should be done by mmap */
-	  if((nfp1=fopen(ffile[u],"r"))==NULL)
-	    {
-	      fprintf(stderr,"can't open asp file %s\n",ffile[u]);
-	      fclose(nfp1);
-	      goto END;
-	    }
-	  fclose(nfp1);
-	  i=size_of_file(ffile[u]);
-
-	  /* allocs memory for the file */
-	  nag4.h.h_val[u].z.z_val= (char *)malloc((i+1)*sizeof(char)); 
-	  
-	  fd=open(ffile[u],O_RDONLY);
-	  read(fd,nag4.h.h_val[u].z.z_val,i);
-	  close(fd);
-	  /* make null-term. string */
-	  nag4.h.h_val[u].z.z_val[i]='\0'; 
-	  /* set the length */
-	  nag4.h.h_val[u].z.z_len=strlen(nag4.h.h_val[u].z.z_val); 
-	}
-      
-      
-      nag4.nm.z.z_val=strdup(routine);
-      nag4.nm.z.z_len=strlen(routine);
-      
-      /* get XDR data in call argument */
-      /* should be done by mmap */
-      if((nfp2=fopen(datafile,"r"))==NULL)
-	{
-	  fprintf(stderr,"can't open data file\n");
-	  fclose(nfp2);
-	  goto END;
-	}
-      
-      fclose(nfp2);
-      i=size_of_file(datafile);
-      nag4.y.z.z_val=(char *)malloc(i*sizeof(char));
-      
-      fd=open(datafile,O_RDONLY);
-      read(fd,nag4.y.z.z_val,i);
-      close(fd);
-      nag4.y.z.z_len=i;
-      
-      
-      /*
-       * Create client "handle" used for calling MESSAGEPROG on
-       * the server designated on the command line.  We tell
-       * the RPC package to use the "tcp" protocol when
-       * contacting the server.
-       */
-      
-      /* update naghost by lookup */
-      
-      if ((junk = inet_addr(naghost))!=-1)
-	{
-	  addrnum=(struct in_addr *)junk;
-	  if((alias2=gethostbyaddr((char *)&addrnum,
-				   sizeof(addrnum),
-				   AF_INET))!=NULL)
-	    strcpy(naghost,alias2->h_name);
-	  else
-	    if((alias1=gethostbyname(naghost))!=NULL)
-	      strcpy(naghost,alias1->h_name);
-	}
-      else
-	if((alias1=gethostbyname(naghost))!=NULL)
-	  strcpy(naghost,alias1->h_name);
-      
-      
-      
-      
-      cl = clnt_create(naghost, NAGPROG, NAGVERS, "tcp");
-      if (cl == NULL)
-	{
-	  /*
-	   * Couldn't establish connection with server.
-	   * Print error message and die.
-	   */
-	  clnt_pcreateerror(naghost);
-	  goto END;
-	}
-      else
-	if (showMessage==DO)
-	  printf("nagman:connection successful to %s\n",naghost);
-      
-      /*
-       * this number here sets the "timeout" for the rpc call. after this number
-       * of seconds, the call will quit if no response is received
-       *
-       */
-      
-      tv.tv_sec=1000000;
-      tv.tv_usec=0;
-      clnt_control(cl,CLSET_TIMEOUT,(char *)&tv);
-      
-      
-      result = callnag_1(&nag4, cl);
-      
-      for(phost=hlist;phost!=NULL;phost=phost->next)
-	{
-	  /*
-	   * hlist is the "hostlist" of sites that have been contacted by nagman.
-	   * here we check if this call is contacting a new site, and if so add it
-	   * to the hostlist
-	   *
-	   */
-	  
-	  if(!strcmp(phost->name,naghost))
-	    goto SKIP;
-	}
-      
-      if(hnum==0) {
-	hlist=(struct hostnode *)malloc(sizeof(struct hostnode));
-	hlist->name=strdup(naghost);
-	hlist->next=NULL;
-      }
-      
-      else {
-	phost=(struct hostnode *)malloc(sizeof(struct hostnode));
-	phost->name=strdup(naghost);
-	phost->next=hlist;
-	hlist=phost;
-      }
-      hnum++;
-      
-      
-    SKIP:
-      if (result == NULL)
-	{
-	  /*
-	   * An error occurred while calling the server.
-	   * Print error message and die.
-	   */
-	  if (showMessage==DO)
-	    printf("nagman:no results (error) from %s\n",naghost);
-	  clnt_perror(cl,naghost);
-	  clnt_destroy(cl);
-	  goto END;
-	}
-      
-      /*
-       * (*result).p is the part of the result with the XDRed results in it 
-       * (numbers). (*result).q is the part with (text) error messages that 
-       * have come from the NAG library. If there is neither an XDR result,
-       * nor a text error message from the library, then something is wrong
-       * so we just print out the "no result or error returned" message.
-       *
-       */
-      
-      else if ((*result).p.z.z_len==0)
-	{
-	  if((*result).q.z.z_len==0)
-	    {
-	      if (showMessage==DO)
-		printf("nagman:empty result (error) from %s\n",naghost);
-	      clnt_destroy(cl);
-	      goto END;
-	    }
-	  else
-	    {
-	      if (showMessage==DO)
-		printf("nagman:receiving results from %s\n\n",naghost);
-	      for(j=0;j<(*result).q.z.z_len;j++)
-		printf("%c",(*result).q.z.z_val[j]);
-	      clnt_destroy(cl);
-	      goto END;
-	    }
-	}
-      else
-	if (showMessage==DO)
-	  printf("nagman:receiving results from %s\n\n",naghost);
-      
-      if (showMessage==DO)
-	fwrite(result->q.z.z_val,sizeof(char),result->q.z.z_len,stdout);
-      
-      /*INFO		printf("\nRESULTS of length %d\n",(*result).p.z.z_len);*/
-      
-      fwrite(result->p.z.z_val,sizeof(char),result->p.z.z_len, nfp3);
-      res=1;
-      clnt_destroy(cl);
-      
-      /*
-       * in case of any type of error, a goto END in the above code causes
-       * nagman to skip here and return to AXIOM
-       *
-       */
-      
-      
-    END:
-      fclose(nfp3);
-      /*
-       * if everything has gone alright, send_int returns the integer res=1. If
-       * not it returns res=0. This is detected by the boot code which acts 
-       * accordingly.
-       */
-      send_int(sock1,res);
-      free(Buf);
-    }
-  
-  
-}
-
-@
-\subsection{catchSignals}
-catchSignals sets up signal handling. If nagman gets a sigterm it does not
-die but goes back to rpcloop
-<<nag.catchSignals>>=
-static void 
-catchSignals(void)
-{
-  bsdSignal(SIGTERM,term,RestartSystemCalls);
-  bsdSignal(SIGSEGV,term,RestartSystemCalls);
-}
-
-@
-\subsection{main nagman}
-<<nag.main>>=
-void 
-main(int argc,char **argv)
-{
-  char this[256],*hname,*dname,*spadnum;
-  int stat;
- 
-  catchSignals();
-  stat=gethostname(this,256);
-  if (stat!=0) perror("gethostname");
-  hname=strdup(this);
-
-  stat=getdomainname(this,256);
-  if (stat!=0) perror("getdomainname");
-  dname=strdup(this);
-  spadnum=getenv("SPADNUM");
-  if (spadnum==0) {
-    fprintf(stderr,"nagman error: SPADNUM is not in the environment\n");
-    exit(0);
-  }
-
-  /* some machines return a full name from hostname 
-     need to check hname has a . in it */
-
-  if  (strchr(hname,'.'))
-    /* '.' found */
-    sprintf(this,"%s_%i",hname,atoi(spadnum));
-  else
-    /* substring not found */
-    sprintf(this,"%s.%s_%i",hname,dname,atoi(spadnum));
-
-  /* this must contain the Internet address of the current host */
-  nag4.id.z.z_val=strdup(this);
-  nag4.id.z.z_len=strlen(nag4.id.z.z_val);
-  hnum=0;
-  vmax=0;
-  /*
-   * this line sets up a socket for communication with the lisp
-   */
-
-  sock1 = connect_to_local_server(SpadServer, DebugWindow, 120 /*seconds*/);
-  if (!sock1) exit(0);
-
-  rpcloop();
-}
-
-@
-\subsection{nagman}
-<<nagman>>=
-#define _NAGMAN_C
-<<nag.includes>>
-<<nag.variables>>
-<<nag.term>>
-<<nag.sizeoffile>>
-<<nag.rpcloop>>
-<<nag.catchSignals>>
-<<nag.main>>
-@
-
-\chapter{The {\tt hypertex} program}
-<<the hypertex command line>>=
-char *HypertexProgram = "$AXIOM/bin/hypertex -s";
-@
-\chapter{The {\tt clef} program}
-<<the clef command line>>=
-char *ClefProgram = "$AXIOM/bin/clef -f $AXIOM/lib/command.list -e ";
-@
-\chapter{The {\tt session} program}
-<<the session manager command line>>=
-char *SessionManagerProgram = "$AXIOM/lib/session";
-@
-\section{session}
-\subsection{includes}
-<<ses.includes>>=
-#include <stdlib.h>
-#include <sys/time.h>
-#include <stdio.h>
-#include <string.h>
-#include <signal.h>
-#ifdef SGIplatform
-#include <bstring.h>
-#endif
-#include "com.h"
-#include "bsdsignal.h"
-#include "sockio-c.h1"
-#include "bsdsignal.h1"
-#include "session.h1"
-
-@
-\subsection{variables}
-<<ses.variables>>=
-#define BufSize		4096	/* size of communication buffer */
-
-typedef struct sock_list {      /* linked list of Sock */
-  Sock Socket;
-  struct sock_list *next;
-} Sock_List;
-
-Sock *spad_io = (Sock *) 0;	   /* to_server socket for SessionIO */
-Sock *spad_server = (Sock *) 0;    /* to_server socket for SpadServer    */
-Sock *menu_client = (Sock *) 0;	   /* to_client socket for MenuServerName  */
-Sock *active_session = (Sock *) 0; /* pointer to currently active session */
-
-Sock_List *plSock = (Sock_List *) 0;
-
-char big_bad_buf[BufSize];	/* big I/O buffer */
-int num_active_clients = 0;	/* number of InterpWindows attached */
-int reading_output = 0;
-fd_set session_socket_mask;
-
-@
-\subsection{usr1\_handler}
-<<ses.usr1handler>>=
-static void 
-usr1_handler(int sig)
-{
-  return;
-}
-
-@
-\subsection{usr2\_handler}
-SIGUSR2 is generated by spadclients.
-We interpret it as an interrupt for the Lisp.
-<<ses.usr2handler>>=
-static void 
-usr2_handler(int sig)
-{
-  send_signal(spad_server, SIGINT);
-  return;
-}
-
-@
-\subsection{term\_handler}
-<<ses.termhandler>>=
-static void 
-term_handler(int sig)
-{
-  exit(1);
-}
-
-@
-\subsection{pr}
-<<ses.pr>>=
-static void
-pr()
-{
-  Sock_List *pSock;
-  
-  fprintf(stderr,"The socket list:\n");
-  for(pSock=plSock;pSock!=(Sock_List *)0;pSock=pSock->next){
-    fprintf(stderr,"(%d,%d,%d)\t",
-      pSock->Socket.pid, 2<<(pSock->Socket.socket), pSock->Socket.frame);
-  }
-  fprintf(stderr,"\n");
-}
-
-@
-\subsection{close\_client}
-<<ses.closeclient>>=
-static void
-close_client(int frame)
-{
-  Sock_List *pSock,*locSock;
-  int socket_fd;
-  
-  /* we will check for frame equality,
-     kill with send_signal,
-     notify HyperTex so that it updates its list (if it's a spadbuf),
-     repair the list,
-     unset the active_session,
-     update num_active_clients
-     */
-  
-  
-  /* first check head */
-#ifdef DEBUG
-fprintf(stderr,"close_client(%d)\n",frame);
-#endif
-  
-  if ( (plSock) && (plSock->Socket.frame == frame) ){
-    socket_fd = plSock->Socket.socket;
-    send_signal((Sock *)plSock, SIGTERM);
-    if ( menu_client != (Sock *) 0){
-      send_int(menu_client,CloseClient);
-      send_int(menu_client,(*plSock).Socket.pid);
-    } 
-#ifdef DEBUG
-fprintf(stderr,"trying to clear %u\n",socket_fd);
-#endif
-    FD_CLR(socket_fd,&session_socket_mask);
-    locSock = plSock;
-    if ((*plSock).next == (Sock_List *) 0) 
-      {plSock = (Sock_List *) 0;}
-    else
-      {plSock = plSock->next;}
-    active_session = (Sock *) 0;
-    num_active_clients--;
-    free(locSock);
-  }
-  
-  /* now check the rest */
-  
-  else {
-    for (pSock=plSock; pSock->next != (Sock_List *) 0 ; pSock=pSock->next)
-      if (pSock->next->Socket.frame == frame){
-	socket_fd = pSock->next->Socket.socket;
-	send_signal((Sock *)pSock->next, SIGTERM);
-	if ( menu_client != (Sock *) 0){
-	  send_int(menu_client,CloseClient);
-	  send_int(menu_client,(*plSock).Socket.pid);
-	}
-#ifdef DEBUG
-fprintf(stderr,"trying to clear %u\n",socket_fd);
-#endif
-	FD_CLR(socket_fd,&session_socket_mask);
-	locSock = pSock->next;
-	if (  pSock->next->next == (Sock_List *) 0  )
-	  { pSock->next= (Sock_List *) 0;}
-	else
-	  { pSock->next = pSock->next->next;}
-	num_active_clients--;
-	active_session = (Sock *) 0;
-	free(locSock);
-	break;
-      }
-  }
-#ifdef DEBUG
-pr();
-#endif
-}
-
-@
-\subsection{read\_SpadServer\_command}
-<<ses.readSpadServercommand>>=
-static void 
-read_SpadServer_command(void)
-{
-  int cmd, frame, num;
-  cmd  = get_int(spad_server);
-  switch (cmd) {
-  case EndOfOutput:
-    if (menu_client != (Sock *) 0) send_signal(menu_client, SIGUSR2); 
-    if (reading_output != 0) reading_output = 0;
-    break;
-  case QueryClients:
-    /*  don't count MenuServer */
-    num =  num_active_clients ;
-    send_int(spad_server, num);
-    break;
-  case CloseClient:
-    frame = get_int(spad_server);
-    if (frame != -1) close_client(frame); 
-    break;
-  case SendXEventToHyperTeX:
-    break;
-  default:
-    fprintf(stderr, "session : unknown command from SpadServer %d\n", cmd);
-    break;
-  }
-}
-
-@
-\subsection{test\_sock\_for\_process}
-<<ses.testsockforprocess>>=
-static int
-test_sock_for_process(Sock *sock)
-{
-  if (sock == (Sock *)0 ) return -1;
-  return kill(sock->pid, 0);
-}
-
-@
-\subsection{read\_menu\_client\_command}
-<<ses.readmenuclientcommand>>=
-static void
-read_menu_client_command(void)
-{
-  int cmd,frame, i,socket_fd;
-  Sock_List *pSock;
-  
-  /* save it for possible clearing */
-  socket_fd =  menu_client->socket;
-
-  if (test_sock_for_process(menu_client) == -1) {
-    FD_CLR(socket_fd,&session_socket_mask);
-    menu_client = (Sock *) 0; 
-    reading_output = 0;
-    return;
-  }
-  cmd = get_int(menu_client);
-  switch(cmd) {
-  case -1:		/* socket closed */
-    FD_CLR(socket_fd,&session_socket_mask);
-    menu_client = (Sock *) 0;
-    reading_output = 0;
-    break;
-  case SwitchFrames:
-#ifdef DEBUG
-fprintf(stderr,"menu:SwitchFrames\n");
-#endif
-    frame = get_int(menu_client);
-    send_int(spad_server, SwitchFrames);
-    send_int(spad_server, frame);
-    for(i=0,pSock=plSock; pSock != (Sock_List *) 0 ; i++,pSock=pSock->next)
-      if ((pSock->Socket.frame == frame)) {
-	active_session = (Sock *)pSock;
-	reading_output = 1;
-	break;
-      }
-    if (i == num_active_clients) {
-      /* fprintf(stderr, "Couldn't find socket for frame %d\n", frame); */
-    }
-    break;
-  case QuerySpad:
-#ifdef DEBUG
-fprintf(stderr,"menu:QuerySpad\n");
-#endif
-    send_int(menu_client, reading_output);
-    break;
-  default:
-    fprintf(stderr, "session : unknown command from MenuServer: %d\n", cmd);
-    menu_client = (Sock *) 0;
-    break;
-  }
-}
-
-@
-\subsection{read\_from\_spad\_io}
-<<ses.readfromspadio>>=
-static void
-read_from_spad_io(void)
-{
-  int ret_code;
-  ret_code = sread(spad_io, big_bad_buf, BufSize, "session: stdout socket");
-  if (ret_code == -1) return;
-  if(active_session != (Sock *) 0) {
-    ret_code = swrite(active_session, big_bad_buf, ret_code,
-		      NULL);
-  }
-}
-
-@
-\subsection{kill\_spad}
-<<ses.killspad>>=
-static void
-kill_spad(void)
-{
-  int i;
-  Sock_List *pSock;
-  
-  send_signal(spad_server, SIGTERM);
-  for  (pSock=plSock,i=0;
-	(i<num_active_clients) && (pSock != (Sock_List *) 0); 
-	i++,pSock=pSock->next) {
-    if ((pSock->Socket).socket != 0)
-      send_signal((Sock *)pSock, SIGTERM);
-  }
-  if (menu_client != (Sock *) 0) send_signal(menu_client, SIGTERM);
-  exit(0);
-}
-
-@
-\subsection{accept\_session\_connection}
-<<ses.acceptsessionconnection>>=
-static int
-accept_session_connection(Sock *server_sock)
-{
-  int sock_fd, ret_code;
-  Sock_List *pls;
-  
-  /* Could be three things : KillSpad MenuServer InterpWindow  */
-  
-  pls = (Sock_List *) malloc(sizeof (Sock_List));
-  sock_fd = accept(server_sock->socket, 0, 0);
-  if (sock_fd == -1) {
-    perror("session : accepting connection");
-    return -1;
-  }
-  (pls->Socket).socket = sock_fd;
-    get_socket_type((Sock *)pls);
-    
-    switch((pls->Socket).purpose) {
-    case KillSpad:
-      kill_spad();
-      return KillSpad;
-      free(pls);
-    case MenuServer:
-#ifdef DEBUG
-      fprintf(stderr,"session: accepted MenuServer , fd = %d\n",sock_fd);
-#endif
-      menu_client = &(pls->Socket);
-      FD_SET(menu_client->socket, &session_socket_mask);
-      return MenuServer;
-    case InterpWindow:
-#ifdef DEBUG
-      fprintf(stderr,"session: accepted InterpWindow , fd = %d\n",sock_fd);
-#endif
-      
-      /* new Sock is put at the head of the list */
-      if (plSock == (Sock_List *)0 ) {
-	plSock = pls;
-	plSock->next = (Sock_List *)0 ;
-      }
-      else{
-	pls->next = plSock;
-	plSock = pls;
-      }
-      
-      /* we need to maintain session_socket_mask here 
-         since we roll our own accept */
-      
-      FD_SET(plSock->Socket.socket, &session_socket_mask);
-      send_int(spad_server, CreateFrame);
-      {
-          int command = get_int(spad_server);
-          /* XXX hack -- the whole protocol looks broken, we just
-          try to detect losage */
-          if (command != CreateFrameAnswer) {
-              fprintf(stderr, "session: non-fatal, got out of sync "
-                               "with Spad server\n  (lost race)\n");
-          /*    exit(1); */
-          }
-      }
-      plSock->Socket.frame = get_int(spad_server);
-      active_session = (Sock *)plSock;
-      get_string_buf(spad_server, big_bad_buf, BufSize);
-      ret_code = swrite((Sock *)plSock, big_bad_buf, strlen(big_bad_buf)+1,
-			"session: writing to InterpWindow");
-      if (ret_code == -1) 
-	return -1;
-      num_active_clients++;
-#ifdef DEBUG
-pr();
-#endif
-      return plSock->Socket.purpose;
-    }
-    return (-1);
-}
-
-@
-\subsection{read\_from\_session}
-<<ses.readfromsession>>=
-static void
-read_from_session(Sock *sock)
-{
-  int ret_code;
-  if (sock != active_session) {
-    send_int(spad_server, SwitchFrames);
-    send_int(spad_server, sock->frame);
-  }
-  active_session = sock;
-  ret_code = sread(sock, big_bad_buf, BufSize, 
-		   "session: reading InterpWindow");
-  if (ret_code == -1) {
-    active_session = (Sock *) 0;
-    reading_output = 0;
-    return;
-  }
-  ret_code = swrite(spad_io, big_bad_buf, ret_code,
-		    "session: writing SessionIO");
-  if (ret_code == -1) {
-    active_session = (Sock *)0 ;
-    reading_output = 0;
-    return;
-  }
-  reading_output = 1;
-}
-
-@
-\subsection{manage\_sessions}
-<<ses.managesessions>>=
-static void
-manage_sessions(void)
-{
-  int ret_code;
-  fd_set rd, wr, ex;
-  Sock_List  *pSock;
-  
-  reading_output = 0;
-  while (1) {
-    FD_ZERO(&rd);
-    FD_ZERO(&wr);
-    FD_ZERO(&ex);
-
-    /* Allow server socket and all connections if not waiting for output
-       socket_mask is maintained by libspad.a  */
-#ifdef DEBUG
-fprintf(stderr,"session_socket_mask=%u ",*((long *)session_socket_mask.fds_bits));
-#endif
-    rd = session_socket_mask;
-    if (!reading_output) {
-      rd = session_socket_mask;
-    }
-
-    /* Allow the active_session if set */
-    if (active_session) FD_SET(active_session->socket, &rd);
-#ifdef DEBUG
-fprintf(stderr,"[rd=%u ",*((long *)rd.fds_bits));
-#endif
-
-    ret_code = sselect(FD_SETSIZE, &rd, &wr, &ex, NULL);
-    if (ret_code == -1) {
-	break;
-    }
-#ifdef DEBUG
-fprintf(stderr,"rd=%u]\n",*((long *)rd.fds_bits));
-#endif
-    
-    if ((menu_client != (Sock *) 0)  && FD_ISSET(menu_client->socket, &rd)) {
-      /* MenuServer wants to talk */
-      read_menu_client_command(); }
-    
-    
-    if (FD_ISSET(spad_io->socket, &rd)) {
-      /* Lisp has output */
-      read_from_spad_io(); }
-    
-    
-    if (FD_ISSET(server[1].socket, &rd)) {
-      /* Someone wants to connect to our server socket */
-      accept_session_connection(server+1); }
-    
-    
-    for(pSock=plSock; pSock != (Sock_List *) 0 ; pSock=pSock->next) {
-      if ((active_session == (Sock *)pSock || !reading_output) &&
-	  (pSock->Socket).socket>0 && FD_ISSET(pSock->Socket.socket, &rd)) {
-	/* An InterpWindow */
-	read_from_session((Sock *)pSock); }
-    }
-    
-    
-    if (FD_ISSET(spad_server->socket, &rd)) {
-      /* The Lisp socket */
-      read_SpadServer_command(); }
-  }
-}
-
-@
-\subsection{main sessionmanager}
-<<ses.main>>=
-int
-main(void)
-{
-
-#ifdef DEBUG2
-  /* delay for attaching with debugger before interesting things happen */
-  sleep(30);
-#endif
-
- /* spad_server connects to Lisp server socket         
-    read_SpadServer_command handles requests */
-  spad_server = connect_to_local_server(SpadServer, SessionManager, Forever);
-  if (spad_server == (Sock *) 0) {
-    fprintf(stderr, "session: Cannot connect to AXIOM server!\n");
-    exit(0);
-  }
-  else {
-#ifdef DEBUG
-    fprintf(stderr, "session: connected SpadServer , fd = %d\n",
-	    spad_server->socket);
-#endif  
-    FD_SET(spad_server->socket, &session_socket_mask);
-  }
-
-
-  /* spad_io connects to SessionIOName server socket
-    this is Lisp std IO read_from_spad_io handles requests */
-  spad_io = connect_to_local_server(SessionIOName, SessionIO, Forever);
-  if (spad_io == (Sock *) 0) {
-    fprintf(stderr, "session: Cannot connect to AXIOM IO!\n");
-    exit(0);
-  }
-  else {
-#ifdef DEBUG
-    fprintf(stderr,"session: connected SessionIOName , fd = %d\n",
-	    spad_io->socket);
-#endif  
-    FD_SET(spad_io->socket, &session_socket_mask);
-  }
-  bsdSignal(SIGUSR2, usr2_handler,DontRestartSystemCalls);
-  bsdSignal(SIGUSR1, usr1_handler,RestartSystemCalls);
-  bsdSignal(SIGINT,  SIG_IGN,RestartSystemCalls);
-  bsdSignal(SIGTERM, term_handler,RestartSystemCalls);
-
-  /* open_server opens the server socket so that we can accept connections
-    we expect connections from spadbuf/spadclient(purpose:InterpWindow) 
-    and hypertex (MenuServer) */
-
-  if (open_server(SessionServer) == -2) {
-    fprintf(stderr, "session: Cannot make server socket!\n");
-    exit(-1);
-  }
-  else {
-#ifdef DEBUG
-    fprintf(stderr, "session: opened SessionServer , fd = %d\n",
-	    server[1].socket);
-#endif  
-    FD_SET(server[1].socket,&session_socket_mask);
-  }
-  manage_sessions();
-  return(0);
-}
-
-@
-\subsection{session}
-<<session>>=
-/* #define DEBUG */
-#define _SESSION_C
-
-<<ses.includes>>
-<<ses.variables>>
-<<ses.usr1handler>>
-<<ses.usr2handler>>
-<<ses.termhandler>>
-<<ses.pr>>
-<<ses.closeclient>>
-<<ses.readSpadServercommand>>
-<<ses.testsockforprocess>>
-<<ses.readmenuclientcommand>>
-<<ses.readfromspadio>>
-<<ses.killspad>>
-<<ses.acceptsessionconnection>>
-<<ses.readfromsession>>
-<<ses.managesessions>>
-<<ses.main>>
-
-@
-\chapter{The {\tt spadclient} program}
-<<the spadclient command line>>=
-char *SpadClientProgram = "$AXIOM/lib/spadclient";
-@
-\section{spadclient}
-<<spadclient>>=
-#define _SPADCLIENT_C
-
-#include <stdio.h>
-#include <signal.h>
-#include "com.h"
-#include "bsdsignal.h"
-
-#include "bsdsignal.h1"
-#include "sockio-c.h1"
-#include "spadclient.h1"
-
-Sock *sock;
-
-static void 
-inter_handler(int sig)
-{
-  send_signal(sock, SIGUSR2);
-  fflush(stderr);
-}
-
-
-int 
-main(void)
-{
-  sock = connect_to_local_server(SessionServer, InterpWindow, Forever);
-  bsdSignal(SIGINT, inter_handler,RestartSystemCalls); 
-  remote_stdio(sock);
-  return(0);
-}
-
-@
-\chapter{The Command Completion List}
-<<command.list>>=
--
-/
-/\
-^
-^=
-~
-~=
-*
-**
-\/
-#
-+
-<
-<=
-=
->
->=
-0
-1
-abelianGroup
-abs
-absolutelyIrreducible?
-accuracyIF
-acos
-acosh
-acoshIfCan
-acosIfCan
-acot
-acoth
-acothIfCan
-acotIfCan
-acsc
-acsch
-acschIfCan
-acscIfCan
-aCubic
-adaptive
-adaptive?
-adaptive3D?
-addBadValue
-addChild!
-addData!
-addField!
-addiag
-addMatch
-addMatchRestricted
-addmod
-addPoint
-addPoint2
-addPointLast
-adjoint
-airyAi
-airyBi
-Aleph
-algDsolve
-algebraic?
-algebraicCoefficients?
-algebraicDecompose
-algebraicOf
-algebraicSort
-algebraicVariables
-algint
-algintegrate
-algSplitSimple
-aLinear
-allRootsOf
-alphabetic
-alphabetic?
-alphanumeric
-alphanumeric?
-alternating
-alternatingGroup
-alternative?
-An
-AND
-And
-and
-anfactor
-antiAssociative?
-antiCommutative?
-antiCommutator
-anticoord
-antisymmetric?
-antisymmetricTensors
-any
-any?
-append
-appendPoint
-apply
-applyQuote
-applyRules
-approximants
-approximate
-approxNthRoot
-approxSqrt
-aQuadratic
-aQuartic
-areEquivalent?
-arg1
-arg2
-argscript
-argument
-argumentList!
-argumentListOf
-arity
-aromberg
-arrayStack
-asec
-asech
-asechIfCan
-asecIfCan
-asimpson
-asin
-asinh
-asinhIfCan
-asinIfCan
-aspFilename
-assert
-assign
-assoc
-associatedEquations
-associatedSystem
-associates?
-associative?
-associator
-associatorDependence
-atan
-atanh
-atanhIfCan
-atanIfCan
-atom?
-atoms
-atrapezoidal
-att2Result
-augment
-autoReduced?
-axes
-axesColorDefault
-B1solve
-back
-backOldPos
-badNum
-badValues
-bag
-balancedBinaryTree
-balancedFactorisation
-bandedHessian
-bandedJacobian
-base
-baseRDE
-baseRDEsys
-BasicMethod
-basicSet
-basis
-basisOfCenter
-basisOfCentroid
-basisOfCommutingElements
-basisOfLeftAnnihilator
-basisOfLeftNucleus
-basisOfLeftNucloid
-basisOfMiddleNucleus
-basisOfNucleus
-basisOfRightAnnihilator
-basisOfRightNucleus
-basisOfRightNucloid
-bat
-bat1
-beauzamyBound
-belong?
-bernoulli
-bernoulliB
-besselI
-besselJ
-besselK
-besselY
-Beta
-bezoutDiscriminant
-bezoutMatrix
-bezoutResultant
-bfEntry
-bfKeys
-binary
-binaryFunction
-binarySearchTree
-binaryTournament
-binaryTree
-binomial
-binomThmExpt
-bipolar
-bipolarCylindrical
-biRank
-birth
-bit?
-bitCoef
-bitLength
-bits
-bitTruth
-bivariate?
-bivariatePolynomials
-bivariateSLPEBR
-blankSeparate
-block
-blue
-bombieriNorm
-bool
-bool?
-bottom!
-boundOfCauchy
-box
-brace
-bracket
-branchIfCan
-branchPoint?
-branchPointAtInfinity?
-bright
-brillhartIrreducible?
-brillhartTrials
-bringDown
-bsolve
-btwFact
-bubbleSort!
-build
-BumInSepFFE
-bumprow
-bumptab
-bumptab1
-BY
-c02aff
-c02agf
-c05adf
-c05nbf
-c05pbf
-c06eaf
-c06ebf
-c06ecf
-c06ekf
-c06fpf
-c06fqf
-c06frf
-c06fuf
-c06gbf
-c06gcf
-c06gqf
-c06gsf
-cache
-cAcos
-cAcosh
-cAcot
-cAcoth
-cAcsc
-cAcsch
-calcRanges
-call
-cap
-car
-cardinality
-cartesian
-cAsec
-cAsech
-cAsin
-cAsinh
-cAtan
-cAtanh
-cCos
-cCosh
-cCot
-cCoth
-cCsc
-cCsch
-cdr
-ceiling
-center
-central?
-certainlySubVariety?
-cExp
-cfirst
-chainSubResultants
-changeBase
-changeMeasure
-changeName
-changeNameToObjf
-changeThreshhold
-changeVar
-changeWeightLevel
-char
-character?
-characteristic
-characteristicPolynomial
-characteristicSerie
-characteristicSet
-charClass
-charpol
-charthRoot
-chebyshevT
-chebyshevU
-check
-checkCxResult
-checkForZero
-checkMxCDF
-checkMxDF
-checkPrecision
-checkResult
-checkRur
-child
-child?
-children
-chineseRemainder
-chiSquare
-chiSquare1
-choosemon
-chvar
-Ci
-className
-clearCache
-clearDenominator
-clearFortranOutputStack
-clearTable!
-clearTheFTable
-clearTheIFTable
-clearTheSymbolTable
-clikeUniv
-clip
-clipBoolean
-clipParametric
-clipPointsDefault
-clipSurface
-clipWithRanges
-cLog
-close
-close!
-closeComponent
-closed?
-closedCurve
-closedCurve?
-cn
-code
-coef
-coefChoose
-coefficient
-coefficients
-coerce
-coerceImages
-coerceListOfPairs
-coerceP
-coercePreimagesImages
-coHeight
-coleman
-collect
-collectQuasiMonic
-collectUnder
-collectUpper
-color
-colorDef
-colorFunction
-column
-combineFeatureCompatibility
-commaSeparate
-comment
-common
-commonDenominator
-commutative?
-commutativeEquality
-commutator
-comp
-compactFraction
-companionBlocks
-comparison
-compBound
-compdegd
-compile
-compiledFunction
-complement
-complementaryBasis
-complete
-completeEchelonBasis
-completeEval
-completeHensel
-completeHermite
-completeSmith
-complex
-complex?
-complexEigenvalues
-complexEigenvectors
-complexElementary
-complexExpand
-complexForm
-complexIntegrate
-complexLimit
-complexNormalize
-complexNumeric
-complexNumericIfCan
-complexRoots
-complexSolve
-complexZeros
-component
-components
-compose
-composite
-composites
-computeBasis
-computeCycleEntry
-computeCycleLength
-computeInt
-computePowers
-concat
-concat!
-cond
-condition
-conditionP
-conditions
-conditionsForIdempotents
-conical
-conjHerm
-conjug
-conjugate
-conjugates
-connect
-connect?
-cons
-consnewpol
-const
-constant
-constant?
-constantCoefficientRicDE
-constantIfCan
-constantKernel
-constantLeft
-constantOperator
-constantOpIfCan
-constantRight
-constantToUnaryFunction
-constDsolve
-construct
-contains?
-content
-continue
-continuedFraction
-contract
-contractSolve
-controlPanel
-convergents
-convert
-coord
-coordinate
-coordinates
-copies
-copy
-copy!
-copyInto!
-corrPoly
-cos
-cos2sec
-cosh
-cosh2sech
-coshIfCan
-cosIfCan
-cosSinInfo
-cot
-cot2tan
-cot2trig
-coth
-coth2tanh
-coth2trigh
-cothIfCan
-cotIfCan
-count
-countable?
-countRealRoots
-countRealRootsMultiple
-cPower
-cRationalPower
-create
-create3Space
-createGenericMatrix
-createIrreduciblePoly
-createLowComplexityNormalBasis
-createLowComplexityTable
-createMultiplicationMatrix
-createMultiplicationTable
-createNormalElement
-createNormalPoly
-createNormalPrimitivePoly
-createPrimitiveElement
-createPrimitiveNormalPoly
-createPrimitivePoly
-createRandomElement
-createThreeSpace
-createZechTable
-credPol
-crest
-critB
-critBonD
-critM
-critMonD1
-critMTonD1
-critpOrder
-critT
-cross
-crushedSet
-csc
-csc2sin
-csch
-csch2sinh
-cschIfCan
-cscIfCan
-cSec
-cSech
-cSin
-cSinh
-csubst
-cTan
-cTanh
-cubic
-cup
-currentSubProgram
-curry
-curryLeft
-curryRight
-curve
-curve?
-curveColor
-curveColorPalette
-cycle
-cycleElt
-cycleEntry
-cycleLength
-cyclePartition
-cycleRagits
-cycles
-cycleSplit!
-cycleTail
-cyclic
-cyclic?
-cyclicCopy
-cyclicEntries
-cyclicEqual?
-cyclicGroup
-cyclicParents
-cyclicSubmodule
-cyclotomic
-cyclotomicDecomposition
-cyclotomicFactorization
-cylindrical
-D
-d01ajf
-d01akf
-d01alf
-d01amf
-d01anf
-d01apf
-d01aqf
-d01asf
-d01bbf
-d01fcf
-d01gaf
-d01gbf
-d02bbf
-d02bhf
-d02cjf
-d02ejf
-d02gaf
-d02gbf
-d02kef
-d02raf
-d03edf
-d03eef
-d03faf
-dAndcExp
-dark
-datalist
-ddFact
-debug
-debug3D
-dec
-decimal
-declare
-declare!
-decompose
-decomposeFunc
-decrease
-decreasePrecision
-deepCopy
-deepestInitial
-deepestTail
-deepExpand
-defineProperty
-definingEquations
-definingInequation
-definingPolynomial
-degree
-degreePartition
-degreeSubResultant
-degreeSubResultantEuclidean
-delay
-delete
-delete!
-deleteProperty!
-deleteRoutine!
-delta
-denom
-denominator
-denominators
-denomLODE
-denomRicDE
-depth
-dequeue
-dequeue!
-deref
-deriv
-derivationCoordinates
-derivative
-destruct
-determinant
-df2ef
-df2fi
-df2mf
-df2st
-dflist
-dfRange
-diag
-diagonal
-diagonal?
-diagonalMatrix
-diagonalProduct
-diagonals
-dictionary
-diff
-difference
-differentialVariables
-differentiate
-digamma
-digit
-digit?
-digits
-dihedral
-dihedralGroup
-dilog
-dim
-dimension
-dimensionOfIrreducibleRepresentation
-dimensions
-dimensionsOf
-diophantineSystem
-dioSolve
-direction
-directory
-directProduct
-directSum
-discreteLog
-discriminant
-discriminantEuclidean
-display
-dispose!
-distance
-distdfact
-distFact
-distribute
-div
-divergence
-divide
-divideExponents
-divideIfCan
-divideIfCan!
-divisor
-divisorCascade
-divisors
-dmp2rfi
-dmpToHdmp
-dmpToP
-dn
-dom
-domainOf
-dominantTerm
-dot
-double
-double?
-doubleComplex?
-doubleDisc
-doubleRank
-doubleResultant
-doublyTransitive?
-draw
-drawComplex
-drawComplexVectorField
-drawCurves
-drawStyle
-drawToScale
-droot
-duplicates
-duplicates?
-e
-e01baf
-e01bef
-e01bff
-e01bgf
-e01bhf
-e01daf
-e01saf
-e01sbf
-e01sef
-e01sff
-e02adf
-e02aef
-e02agf
-e02ahf
-e02ajf
-e02akf
-e02baf
-e02bbf
-e02bcf
-e02bdf
-e02bef
-e02daf
-e02dcf
-e02ddf
-e02def
-e02dff
-e02gaf
-e02zaf
-e04dgf
-e04fdf
-e04gcf
-e04jaf
-e04mbf
-e04naf
-e04ucf
-e04ycf
-edf2df
-edf2ef
-edf2efi
-edf2fi
-ef2edf
-Ei
-eigenMatrix
-eigenvalues
-eigenvector
-eigenvectors
-eisensteinIrreducible?
-elColumn2!
-elem?
-element?
-elementary
-elements
-elliptic
-elliptic?
-ellipticCylindrical
-elRow1!
-elRow2!
-elt
-empty
-empty?
-endOfFile?
-endSubProgram
-enqueue!
-enterInCache
-enterPointData
-entries
-entry
-entry?
-enumerate
-epilogue
-EQ
-eq
-eq?
-equality
-equation
-erf
-error
-errorInfo
-errorKind
-escape
-euclideanGroebner
-euclideanNormalForm
-euclideanSize
-euler
-eulerE
-eulerPhi
-eval
-evaluate
-evaluateInverse
-even?
-evenInfiniteProduct
-evenlambert
-every?
-exactQuotient
-exactQuotient!
-exists?
-exp
-exp1
-expand
-expandLog
-expandPower
-expandTrigProducts
-expenseOfEvaluation
-expenseOfEvaluationIF
-expextendedint
-expIfCan
-expint
-expintegrate
-expintfldpoly
-explicitEntries?
-explicitlyEmpty?
-explicitlyFinite?
-explimitedint
-explogs2trigs
-exponent
-exponential
-exponential1
-exponentialOrder
-exponents
-expPot
-expr
-expressIdealMember
-exprHasAlgebraicWeight
-exprHasLogarithmicWeights
-exprHasWeightCosWXorSinWX
-exprToGenUPS
-exprToUPS
-exprToXXP
-expt
-exptMod
-exQuo
-exquo
-extend
-extendedEuclidean
-extendedint
-extendedIntegrate
-extendedResultant
-extendedSubResultantGcd
-extendIfCan
-extension
-extensionDegree
-exteriorDifferential
-external?
-externalList
-extract!
-extractBottom!
-extractClosed
-extractIfCan
-extractIndex
-extractPoint
-extractProperty
-extractSplittingLeaf
-extractTop!
-eyeDistance
-F
-f01brf
-f01bsf
-f01maf
-f01mcf
-f01qcf
-f01qdf
-f01qef
-f01rcf
-f01rdf
-f01ref
-f02aaf
-f02abf
-f02adf
-f02aef
-f02aff
-f02agf
-f02ajf
-f02akf
-f02awf
-f02axf
-f02bbf
-f02bjf
-f02fjf
-f02wef
-f02xef
-f04adf
-f04arf
-f04asf
-f04atf
-f04axf
-f04faf
-f04jgf
-f04maf
-f04mbf
-f04mcf
-f04qaf
-f07adf
-f07aef
-f07fdf
-f07fef
-f2df
-F2FG
-f2st
-factor
-factor1
-factorAndSplit
-factorByRecursion
-factorFraction
-factorGroebnerBasis
-factorial
-factorials
-factorList
-factorOfDegree
-factorPolynomial
-factors
-factorset
-factorSFBRlcUnit
-factorsOfCyclicGroupSize
-factorsOfDegree
-factorSquareFree
-factorSquareFreeByRecursion
-factorSquareFreePolynomial
-failed
-failed?
-false
-ffactor
-FG2F
-fglmIfCan
-fi2df
-fibonacci
-field
-fields
-figureUnits
-filename
-fill!
-fillPascalTriangle
-filterUntil
-filterWhile
-find
-findCycle
-finite?
-finiteBasis
-finiteBound
-fintegrate
-first
-firstDenom
-firstNumer
-firstSubsetGray
-firstUncouplingMatrix
-fixedDivisor
-fixedPoint
-fixedPointExquo
-fixedPoints
-fixPredicate
-flagFactor
-flatten
-flexible?
-flexibleArray
-float
-float?
-floatlist
-floatlist?
-floor
-fmecg
-forLoop
-FormatArabic
-FormatRoman
-formula
-fortran
-fortranCarriageReturn
-fortranCharacter
-fortranCompilerName
-fortranComplex
-fortranDouble
-fortranDoubleComplex
-fortranInteger
-fortranLinkerArgs
-fortranLiteral
-fortranLiteralLine
-fortranLogical
-fortranReal
-fortranTypeOf
-fprindINFO
-fracPart
-fractionFreeGauss!
-fractionPart
-fractRadix
-fractRagits
-freeOf?
-Frobenius
-frobenius
-front
-froot
-frst
-fTable
-fullDisplay
-fullPartialFraction
-function
-functionIsContinuousAtEndPoints
-functionIsFracPolynomial?
-functionIsOscillatory
-Gamma
-gbasis
-gcd
-gcdcofact
-gcdcofactprim
-gcdPolynomial
-gcdprim
-gcdPrimitive
-gderiv
-GE
-generalInfiniteProduct
-generalizedContinuumHypothesisAssumed
-generalizedContinuumHypothesisAssumed?
-generalizedEigenvector
-generalizedEigenvectors
-generalizedInverse
-generalLambert
-generalPosition
-generalSqFr
-generalTwoFactor
-generate
-generateIrredPoly
-generator
-generators
-generic
-generic?
-genericLeftDiscriminant
-genericLeftMinimalPolynomial
-genericLeftNorm
-genericLeftTrace
-genericLeftTraceForm
-genericPosition
-genericRightDiscriminant
-genericRightMinimalPolynomial
-genericRightNorm
-genericRightTrace
-genericRightTraceForm
-genus
-geometric
-getBadValues
-getButtonValue
-getCode
-getCurve
-getDatabase
-getExplanations
-getGoodPrime
-getGraph
-gethi
-getlo
-getMatch
-getMeasure
-getMultiplicationMatrix
-getMultiplicationTable
-getOrder
-getPickedPoints
-getRef
-getStream
-getVariableOrder
-getZechTable
-GF2FG
-goodnessOfFit
-goodPoint
-GospersMethod
-goto
-gradient
-graeffe
-gramschmidt
-graphCurves
-graphImage
-graphs
-graphState
-graphStates
-green
-groebgen
-groebner
-groebner?
-groebnerFactorize
-groebnerIdeal
-groebSolve
-ground
-ground?
-GT
-halfExtendedResultant1
-halfExtendedResultant2
-halfExtendedSubResultantGcd1
-halfExtendedSubResultantGcd2
-harmonic
-has?
-hash
-hasHi
-hasoln
-hasPredicate?
-hasSolution?
-hasTopPredicate?
-Hausdorff
-hclf
-hconcat
-hcrf
-hdmpToDmp
-hdmpToP
-head
-headReduce
-headReduced?
-headRemainder
-heap
-heapSort
-height
-henselFact
-HenselLift
-hermite
-hermiteH
-HermiteIntegrate
-hessian
-hex
-hexDigit
-hexDigit?
-hi
-high
-highCommonTerms
-hitherPlane
-hMonic
-HMS
-homogeneous?
-horizConcat
-hspace
-htrigs
-hue
-hyperelliptic
-hypergeometric0F1
-iCompose
-id
-ideal
-idealiser
-idealiserMatrix
-idealSimplify
-identification
-identity
-identityMatrix
-identitySquareMatrix
-iExquo
-iflist2Result
-iFTable
-ignore?
-iiabs
-iiacos
-iiacosh
-iiacot
-iiacoth
-iiacsc
-iiacsch
-iiasec
-iiasech
-iiasin
-iiasinh
-iiatan
-iiatanh
-iibinom
-iicos
-iicosh
-iicot
-iicoth
-iicsc
-iicsch
-iidprod
-iidsum
-iiexp
-iifact
-iiGamma
-iilog
-iiperm
-iipow
-iisec
-iisech
-iisin
-iisinh
-iisqrt2
-iisqrt3
-iitan
-iitanh
-imag
-imagE
-imagI
-imagi
-imaginary
-imagJ
-imagj
-imagK
-imagk
-implies
-in?
-inc
-incr
-increase
-increasePrecision
-increment
-incrementBy
-incrementKthElement
-index
-index?
-indices
-indiceSubResultant
-indiceSubResultantEuclidean
-indicialEquation
-indicialEquationAtInfinity
-indicialEquations
-inf
-infieldint
-infieldIntegrate
-infinite?
-infiniteProduct
-infinity
-infinityNorm
-infix
-infix?
-infLex?
-infRittWu?
-inGroundField?
-inHallBasis?
-init
-initial
-initializeGroupForWordProblem
-initiallyReduce
-initiallyReduced?
-initials
-initTable!
-innerEigenvectors
-innerint
-innerSolve
-innerSolve1
-input
-inR?
-inRadical?
-inrootof
-insert
-insert!
-insertBottom!
-insertionSort!
-insertMatch
-insertRoot!
-insertTop!
-inspect
-int
-int?
-intChoose
-intcompBasis
-integer
-integer?
-integerBound
-integerIfCan
-integers
-integral
-integral?
-integralAtInfinity?
-integralBasis
-integralBasisAtInfinity
-integralCoordinates
-integralDerivationMatrix
-integralLastSubResultant
-integralMatrix
-integralMatrixAtInfinity
-integralRepresents
-integrate
-intensity
-intermediateResultsIF
-internal?
-internalAugment
-internalDecompose
-internalInfRittWu?
-internalIntegrate
-internalIntegrate0
-internalLastSubResultant
-internalSubPolSet?
-internalSubQuasiComponent?
-internalZeroSetSplit
-interpolate
-interpret
-interpretString
-interReduce
-intersect
-interval
-intlist
-intlist?
-intPatternMatch
-inv
-inverse
-inverseColeman
-inverseIntegralMatrix
-inverseIntegralMatrixAtInfinity
-inverseLaplace
-invertible?
-invertibleElseSplit?
-invertibleSet
-invertIfCan
-invmod
-invmultisect
-invWrite
-iomode
-ipow
-iprint
-iroot
-irreducible?
-irreducibleFactor
-irreducibleFactors
-irreducibleRepresentation
-Is
-is?
-isAbsolutelyIrreducible?
-isExpt
-isList
-isMult
-isobaric?
-isOp
-isPlus
-isPower
-isQuotient
-isTimes
-iter
-iteratedInitials
-jacobi
-jacobian
-jacobiIdentity?
-janko2
-jordanAdmissible?
-jordanAlgebra?
-karatsuba
-karatsubaDivide
-karatsubaOnce
-kernel
-kernels
-key
-key?
-keys
-kmax
-knownInfBasis
-kovacic
-kroneckerDelta
-KrullNumber
-ksec
-label
-lagrange
-LagrangeInterpolation
-laguerre
-laguerreL
-lambda
-lambert
-laplace
-laplacian
-largest
-last
-lastSubResultant
-lastSubResultantElseSplit
-lastSubResultantEuclidean
-latex
-laurent
-laurentIfCan
-laurentRep
-Lazard
-Lazard2
-LazardQuotient
-LazardQuotient2
-lazy?
-lazyEvaluate
-lazyGintegrate
-lazyIntegrate
-lazyIrreducibleFactors
-lazyPquo
-lazyPrem
-lazyPremWithDefault
-lazyPseudoDivide
-lazyPseudoQuotient
-lazyPseudoRemainder
-lazyResidueClass
-lazyVariations
-lcm
-ldf2lst
-ldf2vmf
-LE
-leader
-leadingBasisTerm
-leadingCoefficient
-leadingCoefficientRicDE
-leadingExponent
-leadingIdeal
-leadingIndex
-leadingMonomial
-leadingSupport
-leadingTerm
-leaf?
-leastAffineMultiple
-leastMonomial
-leastPower
-leaves
-left
-leftAlternative?
-leftCharacteristicPolynomial
-leftDiscriminant
-leftDivide
-leftExactQuotient
-leftExtendedGcd
-leftFactor
-leftFactorIfCan
-leftGcd
-leftLcm
-leftMinimalPolynomial
-leftMult
-leftNorm
-leftOne
-leftPower
-leftQuotient
-leftRank
-leftRankPolynomial
-leftRecip
-leftRegularRepresentation
-leftRemainder
-leftScalarTimes!
-leftTrace
-leftTraceMatrix
-leftTrim
-leftUnit
-leftUnits
-leftZero
-legendre
-legendreP
-lend!
-length
-lepol
-less?
-level
-leviCivitaSymbol
-lex
-lexGroebner
-lexico
-lexTriangular
-lfextendedint
-lfextlimint
-lfinfieldint
-lfintegrate
-lflimitedint
-lfunc
-lhs
-li
-library
-lieAdmissible?
-lieAlgebra?
-LiePoly
-LiePolyIfCan
-lift
-lifting
-lifting1
-light
-lighting
-limit
-limitedint
-limitedIntegrate
-limitPlus
-linear
-linear?
-linearAssociatedExp
-linearAssociatedLog
-linearAssociatedOrder
-linearDependence
-linearDependenceOverZ
-linearlyDependent?
-linearlyDependentOverZ?
-linearMatrix
-linearPart
-linearPolynomials
-linears
-lineColorDefault
-linGenPos
-linkToFortran
-linSolve
-lintgcd
-list
-list?
-listBranches
-listConjugateBases
-listexp
-listLoops
-listOfLists
-listOfMonoms
-ListOfTerms
-listRepresentation
-lists
-listYoungTableaus
-lllip
-lllp
-llprop
-lo
-localAbs
-localIntegralBasis
-localReal?
-localUnquote
-LODO2FUN
-log
-log10
-log2
-logGamma
-logical?
-logIfCan
-logpart
-lookup
-loopPoints
-low
-lowerCase
-lowerCase!
-lowerCase?
-lowerPolynomial
-LowTriBddDenomInv
-lp
-lprop
-lquo
-lSpaceBasis
-lstart!
-LT
-lyndon
-lyndon?
-LyndonBasis
-LyndonCoordinates
-lyndonIfCan
-LyndonWordsList
-LyndonWordsList1
-magnitude
-mainCharacterization
-mainCoefficients
-mainContent
-mainDefiningPolynomial
-mainForm
-mainKernel
-mainMonomial
-mainMonomials
-mainPrimitivePart
-mainSquareFreePart
-mainValue
-mainVariable
-mainVariable?
-mainVariables
-make
-makeCos
-makeCrit
-makeEq
-makeFloatFunction
-makeFR
-makeGraphImage
-makeMulti
-makeObject
-makeop
-makeprod
-makeRecord
-makeResult
-makeSceneGraph
-makeSeries
-makeSin
-makeSketch
-makeSUP
-makeTerm
-makeUnit
-makeVariable
-makeViewport2D
-makeViewport3D
-makeYoungTableau
-makingStats?
-mantissa
-map
-map!
-mapBivariate
-mapCoef
-mapdiv
-mapDown!
-mapExpon
-mapExponents
-mapGen
-mapMatrixIfCan
-mapmult
-mapSolve
-mapUnivariate
-mapUnivariateIfCan
-mapUp!
-mask
-mat
-match
-match?
-mathieu11
-mathieu12
-mathieu22
-mathieu23
-mathieu24
-matrix
-matrixConcat3D
-matrixDimensions
-matrixGcd
-max
-maxColIndex
-maxdeg
-maximumExponent
-maxIndex
-maxint
-maxPoints
-maxPoints3D
-maxrank
-maxrow
-maxRowIndex
-mdeg
-measure
-measure2Result
-meatAxe
-medialSet
-member?
-members
-merge
-merge!
-mergeDifference
-mergeFactors
-mesh
-mesh?
-meshFun2Var
-meshPar1Var
-meshPar2Var
-message
-messagePrint
-middle
-midpoint
-midpoints
-mightHaveRoots
-min
-minColIndex
-mindeg
-mindegTerm
-minGbasis
-minimalPolynomial
-minimize
-minimumDegree
-minimumExponent
-minIndex
-minordet
-minPoints
-minPoints3D
-minPol
-minPoly
-minrank
-minRowIndex
-minset
-minus!
-minusInfinity
-mirror
-mix
-mkAnswer
-mkcomm
-mkIntegral
-mkPrim
-modifyPoint
-modifyPointData
-modTree
-modularFactor
-modularGcd
-modularGcdPrimitive
-module
-moduleSum
-moduloP
-modulus
-moebius
-moebiusMu
-monic?
-monicCompleteDecompose
-monicDecomposeIfCan
-monicDivide
-monicLeftDivide
-monicModulo
-monicRightDivide
-monicRightFactorIfCan
-monom
-monomial
-monomial?
-monomialIntegrate
-monomialIntPoly
-monomials
-monomRDE
-monomRDEsys
-more?
-moreAlgebraic?
-morphism
-move
-movedPoints
-mpsode
-mr
-mulmod
-multiEuclidean
-multiEuclideanTree
-multinomial
-multiple
-multiple?
-multiplyCoefficients
-multiplyExponents
-multisect
-multiset
-multivariate
-multMonom
-musserTrials
-mvar
-myDegree
-nagCosInt
-nagDAiryAi
-nagDAiryBi
-nagDFT
-nagEigenvalues
-nagEigenvectors
-nagEllipticIntegralRC
-nagEllipticIntegralRD
-nagEllipticIntegralRF
-nagEllipticIntegralRJ
-nagErf
-nagErfC
-nagExpInt
-nagFresnelC
-nagFresnelS
-nagHankelH1
-nagHankelH2
-nagHermitianDFT
-nagHermitianInverseDFT
-nagIncompleteGammaP
-nagIncompleteGammaQ
-nagInverseDFT
-nagKelvinBei
-nagKelvinBer
-nagKelvinKei
-nagKelvinKer
-nagMin
-nagPolygonIntegrate
-nagScaledDAiryAi
-nagScaledDAiryBi
-nagScaledHankelH1
-nagScaledHankelH2
-nagSinInt
-name
-nand
-nary?
-ncols
-negative?
-neglist
-new
-newLine
-newReduc
-newSubProgram
-newTypeLists
-next
-nextColeman
-nextIrreduciblePoly
-nextItem
-nextLatticePermutation
-nextNormalPoly
-nextNormalPrimitivePoly
-nextPartition
-nextPrime
-nextPrimitiveNormalPoly
-nextPrimitivePoly
-nextsousResultant2
-nextSublist
-nextsubResultant2
-nextSubsetGray
-nil
-nilFactor
-nlde
-node
-node?
-nodeOf?
-nodes
-noKaratsuba
-noLinearFactor?
-noncommutativeJordanAlgebra?
-nonLinearPart
-nonQsign
-nonSingularModel
-nor
-norm
-normal
-normal?
-normal01
-normalDenom
-normalDeriv
-normalElement
-normalForm
-normalise
-normalize
-normalizeAtInfinity
-normalized?
-normalizedAssociate
-normalizedDivide
-normalizeIfCan
-normDeriv2
-normFactors
-normInvertible?
-NOT
-Not
-not
-notelem
-npcoef
-nrows
-nsqfree
-nthCoef
-nthExpon
-nthExponent
-nthFactor
-nthFlag
-nthFractionalTerm
-nthr
-nthRoot
-nthRootIfCan
-Nul
-null
-null?
-nullary
-nullary?
-nullity
-nullSpace
-number?
-numberOfChildren
-numberOfComponents
-numberOfComposites
-numberOfComputedEntries
-numberOfCycles
-numberOfDivisors
-numberOfFactors
-numberOfFractionalTerms
-numberOfHues
-numberOfImproperPartitions
-numberOfIrreduciblePoly
-numberOfMonomials
-numberOfNormalPoly
-numberOfOperations
-numberOfPrimitivePoly
-numberOfVariables
-numer
-numerator
-numerators
-numeric
-numericalIntegration
-numericalOptimization
-numericIfCan
-numFunEvals
-numFunEvals3D
-obj
-objectOf
-objects
-oblateSpheroidal
-ocf2ocdf
-octon
-odd?
-oddInfiniteProduct
-oddintegers
-oddlambert
-ode
-ode1
-ode2
-ODESolve
-OMbindTCP
-OMclose
-OMcloseConn
-OMconnectTCP
-OMconnInDevice
-OMconnOutDevice
-OMencodingBinary
-OMencodingSGML
-OMencodingUnknown
-OMencodingXML
-omError
-OMgetApp
-OMgetAtp
-OMgetAttr
-OMgetBind
-OMgetBVar
-OMgetEndApp
-OMgetEndAtp
-OMgetEndAttr
-OMgetEndBind
-OMgetEndBVar
-OMgetEndError
-OMgetEndObject
-OMgetError
-OMgetFloat
-OMgetInteger
-OMgetObject
-OMgetString
-OMgetSymbol
-OMgetType
-OMgetVariable
-OMlistCDs
-OMlistSymbols
-OMmakeConn
-OMopenFile
-OMopenString
-OMParseError?
-OMputApp
-OMputAtp
-OMputAttr
-OMputBind
-OMputBVar
-OMputEndApp
-OMputEndAtp
-OMputEndAttr
-OMputEndBind
-OMputEndBVar
-OMputEndError
-OMputEndObject
-OMputError
-OMputFloat
-OMputInteger
-OMputObject
-OMputString
-OMputSymbol
-OMputVariable
-OMread
-OMReadError?
-OMreadFile
-OMreadStr
-OMreceive
-OMsend
-OMserve
-OMsetEncoding
-OMsupportsCD?
-OMsupportsSymbol?
-OMunhandledSymbol
-OMUnknownCD?
-OMUnknownSymbol?
-OMwrite
-one?
-oneDimensionalArray
-op
-open
-open?
-operation
-operator
-operators
-opeval
-optAttributes
-optimize
-option
-option?
-optional
-optional?
-options
-optpair
-OR
-Or
-or
-orbit
-orbits
-ord
-order
-orthonormalBasis
-outerProduct
-outlineRender
-output
-outputArgs
-outputAsFortran
-outputAsScript
-outputAsTex
-outputFixed
-outputFloating
-outputForm
-outputGeneral
-outputList
-outputMeasure
-outputSpacing
-over
-overbar
-overlabel
-overlap
-overset?
-pack!
-packageCall
-packHS
-pade
-padecf
-padicallyExpand
-padicFraction
-pair?
-palgextint
-palgextint0
-palginfieldint
-palgint
-palgint0
-palgintegrate
-palglimint
-palglimint0
-palgLODE
-palgLODE0
-palgRDE
-palgRDE0
-parabolic
-parabolicCylindrical
-paraboloidal
-parametersOf
-parametric?
-ParCond
-ParCondList
-paren
-parent
-partialDenominators
-partialFraction
-partialNumerators
-partialQuotients
-particularSolution
-partition
-partitions
-parts
-pascalTriangle
-pastel
-pattern
-patternMatch
-patternMatchTimes
-patternVariable
-pdct
-PDESolve
-pdf2df
-pdf2ef
-perfectNthPower?
-perfectNthRoot
-perfectSqrt
-perfectSquare?
-permanent
-permutation
-permutationGroup
-permutationRepresentation
-permutations
-perspective
-phiCoord
-pHS
-physicalLength
-physicalLength!
-pi
-pile
-plenaryPower
-pleskenSplit
-plot
-plotPolar
-plus
-plus!
-plusInfinity
-pmComplexintegrate
-pmintegrate
-po
-point
-point?
-pointColor
-pointColorDefault
-pointColorPalette
-pointData
-pointlist
-pointlist?
-pointLists
-pointPlot
-points
-pointSizeDefault
-poisson
-pol
-polar
-polarCoordinates
-polCase
-pole?
-PollardSmallFactor
-polygamma
-polygon
-polygon?
-polynomial
-polynomialZeros
-polyPart
-polyRDE
-polyred
-polyRicDE
-pomopo!
-pop!
-popFortranOutputStack
-position
-position!
-positive?
-positiveRemainder
-positiveSolve
-possiblyInfinite?
-possiblyNewVariety?
-postfix
-pow
-power
-power!
-powerAssociative?
-powern
-powers
-powerSum
-powmod
-pquo
-pr2dmp
-precision
-predicate
-predicates
-prefix
-prefix?
-prefixRagits
-prem
-prepareDecompose
-prepareSubResAlgo
-preprocess
-presub
-presuper
-previous
-prevPrime
-primaryDecomp
-prime
-prime?
-primeFactor
-primeFrobenius
-primes
-primextendedint
-primextintfrac
-primintegrate
-primintfldpoly
-primitive?
-primitiveElement
-primitiveMonomials
-primitivePart
-primitivePart!
-primlimintfrac
-primlimitedint
-primPartElseUnitCanonical
-primPartElseUnitCanonical!
-prinb
-principal?
-principalIdeal
-prindINFO
-prinpolINFO
-prinshINFO
-print
-printCode
-printHeader
-printInfo
-printInfo!
-printingInfo?
-printStatement
-printStats!
-printTypes
-probablyZeroDim?
-problemPoints
-processTemplate
-prod
-product
-prolateSpheroidal
-prologue
-properties
-property
-pseudoDivide
-pseudoQuotient
-pseudoRemainder
-psolve
-ptFunc
-pToDmp
-pToHdmp
-ptree
-puiseux
-pureLex
-purelyAlgebraic?
-purelyAlgebraicLeadingMonomial?
-purelyTranscendental?
-push!
-pushdown
-pushdterm
-pushFortranOutputStack
-pushucoef
-pushuconst
-pushup
-put!
-putColorInfo
-putGraph
-qelt
-qfactor
-qinterval
-qPot
-qqq
-qroot
-qsetelt!
-quadratic
-quadratic?
-quadraticForm
-quadraticNorm
-quartic
-quasiAlgebraicSet
-quasiComponent
-quasiMonic?
-quasiMonicPolynomials
-quasiRegular
-quasiRegular?
-quatern
-queue
-quickSort
-quickWrite
-quo
-quoByVar
-quote
-quoted?
-quotedOperators
-quotient
-quotientByP
-radical
-radicalEigenvalues
-radicalEigenvector
-radicalEigenvectors
-radicalOfLeftTraceForm
-radicalRoots
-radicalSimplify
-radicalSolve
-radix
-radPoly
-raisePolynomial
-ramified?
-ramifiedAtInfinity?
-ran
-randnum
-random
-randomLC
-randomR
-range
-rangeIsFinite
-rangePascalTriangle
-ranges
-rank
-rarrow
-ratDenom
-ratDsolve
-rational
-rational?
-rationalApproximation
-rationalFunction
-rationalIfCan
-rationalPoint?
-rationalPoints
-rationalPower
-ratpart
-ratPoly
-ravel
-rCoord
-rdHack1
-rdregime
-read
-read!
-readable?
-readIfCan!
-readLine!
-readLineIfCan!
-real
-real?
-realEigenvalues
-realEigenvectors
-realElementary
-realRoots
-realSolve
-realZeros
-recip
-reciprocalPolynomial
-recolor
-recoverAfterFail
-rectangularMatrix
-recur
-red
-redmat
-redPo
-redPol
-redpps
-reduce
-reduceBasisAtInfinity
-reduceByQuasiMonic
-reduced?
-reducedContinuedFraction
-reducedDiscriminant
-reducedForm
-reducedQPowers
-reducedSystem
-reduceLODE
-ReduceOrder
-reduction
-reductum
-ref
-refine
-regime
-region
-regularRepresentation
-reindex
-relationsIdeal
-relativeApprox
-relerror
-rem
-remainder
-RemainderList
-remove
-remove!
-removeConstantTerm
-removeCoshSq
-removeCosSq
-removeDuplicates
-removeDuplicates!
-removeIrreducibleRedundantFactors
-removeRedundantFactors
-removeRedundantFactorsInContents
-removeRedundantFactorsInPols
-removeRoughlyRedundantFactorsInContents
-removeRoughlyRedundantFactorsInPol
-removeRoughlyRedundantFactorsInPols
-removeSinhSq
-removeSinSq
-removeSquaresIfCan
-removeSuperfluousCases
-removeSuperfluousQuasiComponents
-removeZero
-removeZeroes
-rename
-rename!
-render
-renderToFile!
-reopen!
-reorder
-repeating
-repeating?
-repeatUntilLoop
-replace
-replaceKthElement
-representationType
-represents
-repSq
-reseed
-reset
-reset!
-resetAttributeButtons
-resetBadValues
-resetNew
-resetVariableOrder
-reshape
-resize
-rest
-restorePrecision
-result
-resultant
-resultantEuclidean
-resultantEuclideannaif
-resultantnaif
-resultantReduit
-resultantReduitEuclidean
-retract
-retractable?
-retractIfCan
-returns
-returnType!
-returnTypeOf
-reverse
-reverse!
-reverseLex
-revert
-rewriteIdealWithHeadRemainder
-rewriteIdealWithQuasiMonicGenerators
-rewriteIdealWithRemainder
-rewriteSetByReducingWithParticularGenerators
-rewriteSetWithReduction
-RF2UTS
-rhs
-ricDsolve
-ridHack1
-right
-rightAlternative?
-rightCharacteristicPolynomial
-rightDiscriminant
-rightDivide
-rightExactQuotient
-rightExtendedGcd
-rightFactorCandidate
-rightFactorIfCan
-rightGcd
-rightLcm
-rightMinimalPolynomial
-rightMult
-rightNorm
-rightOne
-rightPower
-rightQuotient
-rightRank
-rightRankPolynomial
-rightRecip
-rightRegularRepresentation
-rightRemainder
-rightScalarTimes!
-rightTrace
-rightTraceMatrix
-rightTrim
-rightUnit
-rightUnits
-rightZero
-rischDE
-rischDEsys
-rischNormalize
-RittWuCompare
-rk4
-rk4a
-rk4f
-rk4qc
-roman
-romberg
-rombergo
-root
-root?
-rootBound
-rootKerSimp
-rootNormalize
-rootOf
-rootOfIrreduciblePoly
-rootPoly
-rootPower
-rootProduct
-rootRadius
-rootSimp
-rootsOf
-rootSplit
-rotate
-rotate!
-rotatex
-rotatey
-rotatez
-roughBase?
-roughBasicSet
-roughEqualIdeals?
-roughSubIdeal?
-roughUnitIdeal?
-round
-routines
-row
-rowEch
-rowEchelon
-rowEchelonLocal
-rowEchLocal
-rquo
-rroot
-rspace
-rst
-rubiksGroup
-rule
-rules
-ruleset
-rur
-s01eaf
-s13aaf
-s13acf
-s13adf
-s14aaf
-s14abf
-s14baf
-s15adf
-s15aef
-s17acf
-s17adf
-s17aef
-s17aff
-s17agf
-s17ahf
-s17ajf
-s17akf
-s17dcf
-s17def
-s17dgf
-s17dhf
-s17dlf
-s18acf
-s18adf
-s18aef
-s18aff
-s18dcf
-s18def
-s19aaf
-s19abf
-s19acf
-s19adf
-s20acf
-s20adf
-s21baf
-s21bbf
-s21bcf
-s21bdf
-safeCeiling
-safeFloor
-safetyMargin
-sample
-satisfy?
-saturate
-save
-say
-sayLength
-scalarMatrix
-scalarTypeOf
-scale
-scaleRoots
-scan
-ScanArabic
-ScanFloatIgnoreSpaces
-ScanFloatIgnoreSpacesIfCan
-scanOneDimSubspaces
-ScanRoman
-schema
-schwerpunkt
-screenResolution
-screenResolution3D
-script
-scripted?
-scripts
-sdf2lst
-se2rfi
-search
-sec
-sec2cos
-sech
-sech2cosh
-sechIfCan
-secIfCan
-second
-seed
-SEGMENT
-segment
-select
-select!
-selectAndPolynomials
-selectFiniteRoutines
-selectfirst
-selectIntegrationRoutines
-selectMultiDimensionalRoutines
-selectNonFiniteRoutines
-selectODEIVPRoutines
-selectOptimizationRoutines
-selectOrPolynomials
-selectPDERoutines
-selectPolynomials
-selectsecond
-selectSumOfSquaresRoutines
-semicolonSeparate
-semiDegreeSubResultantEuclidean
-semiDiscriminantEuclidean
-semiIndiceSubResultantEuclidean
-semiLastSubResultantEuclidean
-semiResultantEuclidean1
-semiResultantEuclidean2
-semiResultantEuclideannaif
-semiResultantReduitEuclidean
-semiSubResultantGcdEuclidean1
-semiSubResultantGcdEuclidean2
-separant
-separate
-separateDegrees
-separateFactors
-sequences
-series
-seriesSolve
-seriesToOutputForm
-set
-setAdaptive
-setAdaptive3D
-setAttributeButtonStep
-setButtonValue
-setchildren!
-setClipValue
-setClosed
-setColumn!
-setCondition!
-setDifference
-setelt
-setelt!
-setEmpty!
-setEpilogue!
-setErrorBound
-setFieldInfo
-setfirst!
-setFormula!
-setImagSteps
-setIntersection
-setLabelValue
-setlast!
-setleaves!
-setleft!
-setLegalFortranSourceExtensions
-setMaxPoints
-setMaxPoints3D
-setMinPoints
-setMinPoints3D
-setnext!
-setOfMinN
-setOrder
-setPoly
-setPosition
-setPredicates
-setprevious!
-setPrologue!
-setProperties
-setProperty
-setRealSteps
-setref
-setrest!
-setright!
-setRow!
-setScreenResolution
-setScreenResolution3D
-setStatus
-setStatus!
-setsubMatrix!
-setTex!
-setTopPredicate
-setUnion
-setValue!
-setvalue!
-setVariableOrder
-SFunction
-sh
-shade
-shallowCopy
-shallowExpand
-shanksDiscLogAlgorithm
-shellSort
-shift
-shiftLeft
-shiftRight
-shiftRoots
-show
-showAll?
-showAllElements
-showArrayValues
-showAttributes
-showClipRegion
-showFortranOutputStack
-showIntensityFunctions
-showRegion
-showScalarValues
-showTheFTable
-showTheIFTable
-showTheRoutinesTable
-showTheSymbolTable
-showTypeInOutput
-shrinkable
-shuffle
-shufflein
-Si
-sign
-signAround
-simpleBounds?
-simplify
-simplifyExp
-simplifyLog
-simplifyPower
-simpson
-simpsono
-sin
-sin?
-sin2csc
-sincos
-singleFactorBound
-singRicDE
-singular?
-singularAtInfinity?
-singularitiesOf
-sinh
-sinh2csch
-sinhcosh
-sinhIfCan
-sinIfCan
-size
-size?
-sizeLess?
-sizeMultiplication
-sizePascalTriangle
-skewSFunction
-slash
-slex
-smith
-sn
-sncndn
-socf2socdf
-solid
-solid?
-solve
-solve1
-solveid
-solveInField
-solveLinear
-solveLinearlyOverQ
-solveLinearPolynomialEquation
-solveLinearPolynomialEquationByFractions
-solveLinearPolynomialEquationByRecursion
-solveRetract
-someBasis
-sort
-sort!
-sortConstraints
-sorted?
-space
-sparsityIF
-specialTrigs
-spherical
-split
-split!
-splitConstant
-splitDenominator
-splitLinear
-splitNodeOf!
-splitSquarefree
-sPol
-sqfree
-sqfrFactor
-sqrt
-square?
-squareFree
-squareFreeFactors
-squareFreeLexTriangular
-squareFreePart
-squareFreePolynomial
-squareFreePrim
-squareMatrix
-squareTop
-stack
-standardBasisOfCyclicSubmodule
-start!
-startPolynomial
-startStats!
-startTable!
-startTableGcd!
-startTableInvSet!
-status
-stFunc1
-stFunc2
-stFuncN
-stiffnessAndStabilityFactor
-stiffnessAndStabilityOfODEIF
-stirling1
-stirling2
-stop
-stop!
-stopMusserTrials
-stopTable!
-stopTableGcd!
-stopTableInvSet!
-stoseIntegralLastSubResultant
-stoseInternalLastSubResultant
-stoseInvertible?
-stoseInvertible?reg
-stoseInvertibleSet
-stoseInvertibleSetreg
-stoseInvertibleSetsqfreg
-stoseInvertible?sqfreg
-stoseLastSubResultant
-stosePrepareSubResAlgo
-stoseSquareFreePart
-string
-string?
-stripCommentsAndBlanks
-strongGenerators
-stronglyReduce
-stronglyReduced?
-structuralConstants
-sts2stst
-SturmHabicht
-SturmHabichtCoefficients
-SturmHabichtMultiple
-SturmHabichtSequence
-sturmSequence
-sturmVariationsOf
-style
-sub
-subCase?
-subHeight
-subMatrix
-submod
-subNode?
-subNodeOf?
-subPolSet?
-subQuasiComponent?
-subResultantChain
-subResultantGcd
-subResultantGcdEuclidean
-subResultantsChain
-subresultantSequence
-subresultantVector
-subscript
-subscriptedVariables
-subSet
-subset?
-subspace
-subst
-substitute
-substring?
-subtractIfCan
-subTriSet?
-suchThat
-suffix?
-sum
-summation
-sumOfDivisors
-sumOfKthPowerDivisors
-sumOfSquares
-sumSquares
-sup
-supDimElseRittWu?
-super
-superHeight
-superscript
-supersub
-supRittWu?
-surface
-swap
-swap!
-swapColumns!
-swapRows!
-sylvesterMatrix
-sylvesterSequence
-symbol
-symbol?
-symbolIfCan
-symbolTable
-symbolTableOf
-symFunc
-symmetric?
-symmetricDifference
-symmetricGroup
-symmetricPower
-symmetricProduct
-symmetricRemainder
-symmetricSquare
-symmetricTensors
-systemCommand
-systemSizeIF
-t
-tab
-tab1
-table
-tableau
-tableForDiscreteLogarithm
-tablePow
-tail
-tan
-tan2cot
-tan2trig
-tanAn
-tanh
-tanh2coth
-tanh2trigh
-tanhIfCan
-tanIfCan
-tanintegrate
-tanNa
-tanQ
-tanSum
-taylor
-taylorIfCan
-taylorQuoByVar
-taylorRep
-tensorProduct
-terms
-test
-testDim
-testModulus
-tex
-thetaCoord
-third
-timer
-times
-times!
-title
-top
-top!
-topFortranOutputStack
-topPredicate
-toroidal
-torsion?
-torsionIfCan
-toScale
-toseInvertible?
-toseInvertibleSet
-toseLastSubResultant
-toseSquareFreePart
-totalDegree
-totalDifferential
-totalfract
-totalGroebner
-totalLex
-totolex
-tower
-trace
-trace2PowMod
-traceMatrix
-tracePowMod
-trailingCoefficient
-tRange
-transcendenceDegree
-transcendent?
-transcendentalDecompose
-transform
-translate
-transpose
-trapezoidal
-trapezoidalo
-traverse
-tree
-triangSolve
-triangular?
-triangularSystems
-triangulate
-trigs
-trigs2explogs
-trim
-trivialIdeal?
-true
-trueEqual
-trunc
-truncate
-tryFunctionalDecomposition
-tryFunctionalDecomposition?
-tube
-tubePlot
-tubePoints
-tubePointsDefault
-tubeRadius
-tubeRadiusDefault
-tValues
-twist
-twoFactor
-typeList
-typeLists
-unary?
-unaryFunction
-uncouplingMatrices
-unexpand
-uniform
-uniform01
-union
-uniqueID
-unit
-unit?
-unitCanonical
-unitNormal
-unitNormalize
-units
-unitsColorDefault
-unitVector
-univariate
-univariate?
-univariatePolynomial
-univariatePolynomials
-univariatePolynomialsGcds
-univariateSolve
-univcase
-universe
-unmakeSUP
-unparse
-unprotectedRemoveRedundantFactors
-unrankImproperPartitions0
-unrankImproperPartitions1
-unravel
-untab
-UnVectorise
-unvectorise
-UP2ifCan
-UP2UTS
-updatD
-update
-upDateBranches
-updateStatus!
-updatF
-upperCase
-upperCase!
-upperCase?
-UpTriBddDenomInv
-useEisensteinCriterion
-useEisensteinCriterion?
-useNagFunctions
-userOrdered?
-useSingleFactorBound
-useSingleFactorBound?
-usingTable?
-UTS2UP
-validExponential
-value
-var1Steps
-var1StepsDefault
-var2Steps
-var2StepsDefault
-variable
-variables
-variationOfParameters
-vark
-varList
-varselect
-vconcat
-vector
-Vectorise
-vectorise
-vedf2vef
-vertConcat
-viewDefaults
-viewDeltaXDefault
-viewDeltaYDefault
-viewPhiDefault
-viewpoint
-viewport2D
-viewport3D
-viewPosDefault
-viewSizeDefault
-viewThetaDefault
-viewWriteAvailable
-viewWriteDefault
-viewZoomDefault
-virtualDegree
-void
-vput!
-vspace
-vstart!
-walkTree
-weakBiRank
-weierstrass
-weight
-weighted
-weights
-whatInfinity
-whileLoop
-wholePart
-wholeRadix
-wholeRagits
-width
-withPredicates
-wordInGenerators
-wordInStrongGenerators
-wordsForStrongGenerators
-wreath
-writable?
-write
-write!
-writeLine!
-wronskianMatrix
-wrregime
-xCoord
-xn
-xor
-xRange
-Y
-yCoord
-yCoordinates
-yellow
-youngGroup
-yRange
-zag
-zCoord
-zero
-zero?
-zeroDim?
-zeroDimensional?
-zeroDimPrimary?
-zeroDimPrime?
-zeroMatrix
-zeroOf
-zeroSetSplit
-zeroSetSplitIntoTriangularSystems
-zerosOf
-zeroSquareMatrix
-zeroVector
-zoom
-zRange
-AbelianGroup
-AbelianMonoid
-AbelianMonoidRing
-AbelianSemiGroup
-Aggregate
-Algebra
-AlgebraicallyClosedField
-AlgebraicallyClosedFunctionSpace
-ArcHyperbolicFunctionCategory
-ArcTrigonometricFunctionCategory
-AssociationListAggregate
-AttributeRegistry
-BagAggregate
-BasicType
-BiModule
-BinaryRecursiveAggregate
-BinaryTreeCategory
-BitAggregate
-CachableSet
-CancellationAbelianMonoid
-CharacteristicNonZero
-CharacteristicZero
-CoercibleTo
-Collection
-CombinatorialFunctionCategory
-CombinatorialOpsCategory
-CommutativeRing
-ComplexCategory
-ConvertibleTo
-DequeueAggregate
-Dictionary
-DictionaryOperations
-DifferentialExtension
-DifferentialPolynomialCategory
-DifferentialRing
-DifferentialVariableCategory
-DirectProductCategory
-DivisionRing
-DoublyLinkedAggregate
-ElementaryFunctionCategory
-Eltable
-EltableAggregate
-EntireRing
-EuclideanDomain
-Evalable
-ExpressionSpace
-ExtensibleLinearAggregate
-ExtensionField
-Field
-FieldOfPrimeCharacteristic
-FileCategory
-FileNameCategory
-Finite
-FiniteAbelianMonoidRing
-FiniteAlgebraicExtensionField
-FiniteDivisorCategory
-FiniteFieldCategory
-FiniteLinearAggregate
-FiniteRankAlgebra
-FiniteRankNonAssociativeAlgebra
-FiniteSetAggregate
-FloatingPointSystem
-FortranFunctionCategory
-FortranMachineTypeCategory
-FortranMatrixCategory
-FortranMatrixFunctionCategory
-FortranProgramCategory
-FortranVectorCategory
-FortranVectorFunctionCategory
-FramedAlgebra
-FramedNonAssociativeAlgebra
-FreeAbelianMonoidCategory
-FreeLieAlgebra
-FreeModuleCat
-FullyEvalableOver
-FullyLinearlyExplicitRingOver
-FullyPatternMatchable
-FullyRetractableTo
-FunctionFieldCategory
-FunctionSpace
-GcdDomain
-GradedAlgebra
-GradedModule
-Group
-HomogeneousAggregate
-HyperbolicFunctionCategory
-IndexedAggregate
-IndexedDirectProductCategory
-InnerEvalable
-IntegerNumberSystem
-IntegralDomain
-IntervalCategory
-IVLeafNodeCategory
-IVNodeCategory
-KeyedDictionary
-LazyStreamAggregate
-LeftAlgebra
-LeftModule
-LieAlgebra
-LinearAggregate
-LinearlyExplicitRingOver
-LinearOrdinaryDifferentialOperatorCategory
-LiouvillianFunctionCategory
-ListAggregate
-Logic
-MatrixCategory
-Module
-Monad
-MonadWithUnit
-MonogenicAlgebra
-MonogenicLinearOperator
-Monoid
-MultiDictionary
-MultisetAggregate
-MultivariateTaylorSeriesCategory
-NonAssociativeAlgebra
-NonAssociativeRing
-NonAssociativeRng
-NormalizedTriangularSetCategory
-NumericalIntegrationCategory
-NumericalOptimizationCategory
-OctonionCategory
-OneDimensionalArrayAggregate
-OpenMath
-OrderedAbelianGroup
-OrderedAbelianMonoid
-OrderedAbelianMonoidSup
-OrderedAbelianSemiGroup
-OrderedCancellationAbelianMonoid
-OrderedFinite
-OrderedIntegralDomain
-OrderedMonoid
-OrderedMultisetAggregate
-OrderedRing
-OrderedSet
-OrdinaryDifferentialEquationsSolverCategory
-PAdicIntegerCategory
-PartialDifferentialEquationsSolverCategory
-PartialDifferentialRing
-PartialTranscendentalFunctions
-Patternable
-PatternMatchable
-PermutationCategory
-PlottablePlaneCurveCategory
-PlottableSpaceCurveCategory
-PointCategory
-PolynomialCategory
-PolynomialFactorizationExplicit
-PolynomialSetCategory
-PowerSeriesCategory
-PrimitiveFunctionCategory
-PrincipalIdealDomain
-PriorityQueueAggregate
-QuaternionCategory
-QueueAggregate
-QuotientFieldCategory
-RadicalCategory
-RealClosedField
-RealConstant
-RealNumberSystem
-RealRootCharacterizationCategory
-RectangularMatrixCategory
-RecursiveAggregate
-RecursivePolynomialCategory
-RegularTriangularSetCategory
-RetractableTo
-RightModule
-Ring
-Rng
-SegmentCategory
-SegmentExpansionCategory
-SemiGroup
-SetAggregate
-SetCategory
-SExpressionCategory
-SpecialFunctionCategory
-SquareFreeNormalizedTriangularSetCategory
-SquareFreeRegularTriangularSetCategory
-SquareMatrixCategory
-StackAggregate
-StepThrough
-StreamAggregate
-StringAggregate
-StringCategory
-TableAggregate
-ThreeSpaceCategory
-TranscendentalFunctionCategory
-TriangularSetCategory
-TrigonometricFunctionCategory
-TwoDimensionalArrayCategory
-Type
-UnaryRecursiveAggregate
-UniqueFactorizationDomain
-UnivariateLaurentSeriesCategory
-UnivariateLaurentSeriesConstructorCategory
-UnivariatePolynomialCategory
-UnivariatePowerSeriesCategory
-UnivariatePuiseuxSeriesCategory
-UnivariatePuiseuxSeriesConstructorCategory
-UnivariateSkewPolynomialCategory
-UnivariateTaylorSeriesCategory
-VectorCategory
-VectorSpace
-XAlgebra
-XFreeAlgebra
-XPolynomialsCat
-AlgebraGivenByStructuralConstants
-AlgebraicFunctionField
-AlgebraicNumber
-AnonymousFunction
-AntiSymm
-Any
-ArrayStack
-Asp1
-Asp10
-Asp12
-Asp19
-Asp20
-Asp24
-Asp27
-Asp28
-Asp29
-Asp30
-Asp31
-Asp33
-Asp34
-Asp35
-Asp4
-Asp41
-Asp42
-Asp49
-Asp50
-Asp55
-Asp6
-Asp7
-Asp73
-Asp74
-Asp77
-Asp78
-Asp8
-Asp80
-Asp9
-AssociatedJordanAlgebra
-AssociatedLieAlgebra
-AssociationList
-AttributeButtons
-Automorphism
-BalancedBinaryTree
-BalancedPAdicInteger
-BalancedPAdicRational
-BasicFunctions
-BasicOperator
-BinaryExpansion
-BinaryFile
-BinarySearchTree
-BinaryTournament
-BinaryTree
-Bits
-Boolean
-CardinalNumber
-CartesianTensor
-Character
-CharacterClass
-CliffordAlgebra
-Color
-Commutator
-Complex
-ContinuedFraction
-d01ajfAnnaType
-d01akfAnnaType
-d01alfAnnaType
-d01amfAnnaType
-d01anfAnnaType
-d01apfAnnaType
-d01aqfAnnaType
-d01asfAnnaType
-d01fcfAnnaType
-d01gbfAnnaType
-d01TransformFunctionType
-d02bbfAnnaType
-d02bhfAnnaType
-d02cjfAnnaType
-d02ejfAnnaType
-d03eefAnnaType
-d03fafAnnaType
-Database
-DataList
-DecimalExpansion
-DenavitHartenbergMatrix
-Dequeue
-DeRhamComplex
-DifferentialSparseMultivariatePolynomial
-DirectProduct
-DirectProductMatrixModule
-DirectProductModule
-DistributedMultivariatePolynomial
-DoubleFloat
-DrawOption
-e04dgfAnnaType
-e04fdfAnnaType
-e04gcfAnnaType
-e04jafAnnaType
-e04mbfAnnaType
-e04nafAnnaType
-e04ucfAnnaType
-ElementaryFunctionsUnivariateLaurentSeries
-ElementaryFunctionsUnivariatePuiseuxSeries
-Enumeration
-EqTable
-Equation
-EuclideanModularRing
-Exit
-ExponentialExpansion
-ExponentialOfUnivariatePuiseuxSeries
-Expression
-ExtAlgBasis
-Factored
-File
-FileName
-FiniteDivisor
-FiniteField
-FiniteFieldCyclicGroup
-FiniteFieldCyclicGroupExtension
-FiniteFieldCyclicGroupExtensionByPolynomial
-FiniteFieldExtension
-FiniteFieldExtensionByPolynomial
-FiniteFieldNormalBasis
-FiniteFieldNormalBasisExtension
-FiniteFieldNormalBasisExtensionByPolynomial
-FlexibleArray
-Float
-FormalFraction
-FortranCode
-FortranExpression
-FortranProgram
-FortranScalarType
-FortranTemplate
-FortranType
-FourierComponent
-FourierSeries
-Fraction
-FractionalIdeal
-FramedModule
-FreeAbelianGroup
-FreeAbelianMonoid
-FreeGroup
-FreeModule
-FreeModule1
-FreeMonoid
-FreeNilpotentLie
-FullPartialFractionExpansion
-FunctionCalled
-GeneralDistributedMultivariatePolynomial
-GeneralModulePolynomial
-GeneralPolynomialSet
-GeneralSparseTable
-GeneralTriangularSet
-GeneralUnivariatePowerSeries
-GenericNonAssociativeAlgebra
-GraphImage
-HashTable
-Heap
-HexadecimalExpansion
-HomogeneousDirectProduct
-HomogeneousDistributedMultivariatePolynomial
-HyperellipticFiniteDivisor
-IndexCard
-IndexedBits
-IndexedDirectProductAbelianGroup
-IndexedDirectProductAbelianMonoid
-IndexedDirectProductObject
-IndexedDirectProductOrderedAbelianMonoid
-IndexedDirectProductOrderedAbelianMonoidSup
-IndexedExponents
-IndexedFlexibleArray
-IndexedList
-IndexedMatrix
-IndexedOneDimensionalArray
-IndexedString
-IndexedTwoDimensionalArray
-IndexedVector
-InfiniteTuple
-InnerAlgebraicNumber
-InnerFiniteField
-InnerFreeAbelianMonoid
-InnerIndexedTwoDimensionalArray
-InnerPAdicInteger
-InnerPrimeField
-InnerSparseUnivariatePowerSeries
-InnerTable
-InnerTaylorSeries
-InputForm
-Integer
-IntegerMod
-IntegrationFunctionsTable
-IntegrationResult
-Interval
-InventorDataSink
-InventorRenderPackage
-InventorViewPort
-IVBaseColor
-IVBasicNode
-IVCoordinate3
-IVCoordinate4
-IVFaceSet
-IVField
-IVGroup
-IVIndexedLineSet
-IVNodeConnection
-IVNodeObject
-IVPointSet
-IVQuadMesh
-IVSeparator
-IVSimpleInnerNode
-IVUtilities
-IVValue
-Kernel
-KeyedAccessFile
-LaurentPolynomial
-Library
-LieExponentials
-LiePolynomial
-LieSquareMatrix
-LinearOrdinaryDifferentialOperator
-LinearOrdinaryDifferentialOperator1
-LinearOrdinaryDifferentialOperator2
-List
-ListMonoidOps
-ListMultiDictionary
-LocalAlgebra
-Localize
-LyndonWord
-MachineComplex
-MachineFloat
-MachineInteger
-Magma
-MakeCachableSet
-Mapping
-Matrix
-ModMonic
-ModularField
-ModularRing
-ModuleMonomial
-ModuleOperator
-MoebiusTransform
-MonoidRing
-Multiset
-MultivariatePolynomial
-NagDiscreteFourierTransformInterfacePackage
-NagEigenInterfacePackage
-NagOptimisationInterfacePackage
-NagQuadratureInterfacePackage
-NagResultChecks
-NagSpecialFunctionsInterfacePackage
-NewSparseMultivariatePolynomial
-NewSparseUnivariatePolynomial
-None
-NonNegativeInteger
-NumericalIntegrationProblem
-NumericalODEProblem
-NumericalOptimizationProblem
-NumericalPDEProblem
-Octonion
-ODEIntensityFunctionsTable
-OneDimensionalArray
-OnePointCompletion
-OpenMathConnection
-OpenMathDevice
-OpenMathEncoding
-OpenMathError
-OpenMathErrorKind
-Operator
-OppositeMonogenicLinearOperator
-OrderedCompletion
-OrderedDirectProduct
-OrderedFreeMonoid
-OrderedVariableList
-OrderlyDifferentialPolynomial
-OrderlyDifferentialVariable
-OrdinaryDifferentialRing
-OrdinaryWeightedPolynomials
-OrdSetInts
-OutputForm
-PackedHermitianSequence
-PAdicInteger
-PAdicRational
-PAdicRationalConstructor
-Palette
-ParametricPlaneCurve
-ParametricSpaceCurve
-ParametricSurface
-PartialFraction
-Partition
-Pattern
-PatternMatchListResult
-PatternMatchResult
-PendantTree
-Permutation
-PermutationGroup
-Pi
-PlaneAlgebraicCurvePlot
-Plot
-Plot3D
-PoincareBirkhoffWittLyndonBasis
-Point
-Polynomial
-PolynomialIdeals
-PolynomialRing
-PositiveInteger
-PrimeField
-PrimitiveArray
-Product
-QuadraticForm
-QuasiAlgebraicSet
-Quaternion
-QueryEquation
-Queue
-RadicalFunctionField
-RadixExpansion
-RealClosure
-Record
-RectangularMatrix
-Reference
-RegularChain
-RegularTriangularSet
-RenderTools
-ResidueRing
-Result
-RewriteRule
-RightOpenIntervalRootCharacterization
-RomanNumeral
-RoutinesTable
-RuleCalled
-Ruleset
-ScriptFormulaFormat
-Segment
-SegmentBinding
-SequentialDifferentialPolynomial
-SequentialDifferentialVariable
-Set
-SetOfMIntegersInOneToN
-SExpression
-SExpressionOf
-SimpleAlgebraicExtension
-SimpleFortranProgram
-SingleInteger
-SingletonAsOrderedSet
-SparseMultivariatePolynomial
-SparseMultivariateTaylorSeries
-SparseTable
-SparseUnivariateLaurentSeries
-SparseUnivariatePolynomial
-SparseUnivariatePuiseuxSeries
-SparseUnivariateSkewPolynomial
-SparseUnivariateTaylorSeries
-SplitHomogeneousDirectProduct
-SplittingNode
-SplittingTree
-SquareFreeRegularTriangularSet
-SquareMatrix
-Stack
-Stream
-String
-StringTable
-SubSpace
-SubSpaceComponentProperty
-SuchThat
-Switch
-Symbol
-SymbolTable
-SymmetricPolynomial
-Table
-Tableau
-TaylorSeries
-TexFormat
-TextFile
-TheSymbolTable
-ThreeDimensionalMatrix
-ThreeDimensionalViewport
-ThreeSpace
-Timer
-Tree
-TubePlot
-Tuple
-TwoDimensionalArray
-TwoDimensionalViewport
-Union
-UnivariateLaurentSeries
-UnivariateLaurentSeriesConstructor
-UnivariatePolynomial
-UnivariatePuiseuxSeries
-UnivariatePuiseuxSeriesConstructor
-UnivariatePuiseuxSeriesWithExponentialSingularity
-UnivariateSkewPolynomial
-UnivariateTaylorSeries
-UniversalSegment
-Variable
-Vector
-Void
-WeightedPolynomials
-WuWenTsunTriangularSet
-XDistributedPolynomial
-XPBWPolynomial
-XPolynomial
-XPolynomialRing
-XRecursivePolynomial
-AlgebraicFunction
-AlgebraicHermiteIntegration
-AlgebraicIntegrate
-AlgebraicIntegration
-AlgebraicManipulations
-AlgebraicMultFact
-AlgebraPackage
-AlgFactor
-AnnaNumericalIntegrationPackage
-AnnaNumericalOptimizationPackage
-AnnaOrdinaryDifferentialEquationPackage
-AnnaPartialDifferentialEquationPackage
-AnyFunctions1
-ApplyRules
-ApplyUnivariateSkewPolynomial
-AssociatedEquations
-AttachPredicates
-BalancedFactorisation
-BasicOperatorFunctions1
-BezoutMatrix
-BoundIntegerRoots
-BrillhartTests
-CartesianTensorFunctions2
-ChangeOfVariable
-CharacteristicPolynomialInMonogenicalAlgebra
-CharacteristicPolynomialPackage
-ChineseRemainderToolsForIntegralBases
-CoerceVectorMatrixPackage
-CombinatorialFunction
-CommonDenominator
-CommonOperators
-CommuteUnivariatePolynomialCategory
-ComplexFactorization
-ComplexFunctions2
-ComplexIntegerSolveLinearPolynomialEquation
-ComplexPattern
-ComplexPatternMatch
-ComplexRootFindingPackage
-ComplexRootPackage
-ComplexTrigonometricManipulations
-ConstantLODE
-CoordinateSystems
-CRApackage
-CycleIndicators
-CyclicStreamTools
-CyclotomicPolynomialPackage
-d01AgentsPackage
-d01WeightsPackage
-d02AgentsPackage
-d03AgentsPackage
-DefiniteIntegrationTools
-DegreeReductionPackage
-DiophantineSolutionPackage
-DirectProductFunctions2
-DiscreteLogarithmPackage
-DisplayPackage
-DistinctDegreeFactorize
-DoubleFloatSpecialFunctions
-DoubleResultantPackage
-DrawComplex
-DrawNumericHack
-DrawOptionFunctions0
-DrawOptionFunctions1
-e04AgentsPackage
-EigenPackage
-ElementaryFunction
-ElementaryFunctionDefiniteIntegration
-ElementaryFunctionLODESolver
-ElementaryFunctionODESolver
-ElementaryFunctionSign
-ElementaryFunctionStructurePackage
-ElementaryIntegration
-ElementaryRischDE
-ElementaryRischDESystem
-EllipticFunctionsUnivariateTaylorSeries
-EquationFunctions2
-ErrorFunctions
-EuclideanGroebnerBasisPackage
-EvaluateCycleIndicators
-ExpertSystemContinuityPackage
-ExpertSystemContinuityPackage1
-ExpertSystemToolsPackage
-ExpertSystemToolsPackage1
-ExpertSystemToolsPackage2
-ExpressionFunctions2
-ExpressionSpaceFunctions1
-ExpressionSpaceFunctions2
-ExpressionSpaceODESolver
-ExpressionToOpenMath
-ExpressionToUnivariatePowerSeries
-ExpressionTubePlot
-FactoredFunctions
-FactoredFunctions2
-FactoredFunctionUtilities
-FactoringUtilities
-FGLMIfCanPackage
-FindOrderFinite
-FiniteDivisorFunctions2
-FiniteFieldFunctions
-FiniteFieldHomomorphisms
-FiniteFieldPolynomialPackage
-FiniteFieldPolynomialPackage2
-FiniteFieldSolveLinearPolynomialEquation
-FiniteLinearAggregateFunctions2
-FiniteLinearAggregateSort
-FiniteSetAggregateFunctions2
-FloatingComplexPackage
-FloatingRealPackage
-FortranCodePackage1
-FortranOutputStackPackage
-FortranPackage
-FractionalIdealFunctions2
-FractionFunctions2
-FramedNonAssociativeAlgebraFunctions2
-FunctionalSpecialFunction
-FunctionFieldCategoryFunctions2
-FunctionFieldIntegralBasis
-FunctionSpaceAssertions
-FunctionSpaceAttachPredicates
-FunctionSpaceComplexIntegration
-FunctionSpaceFunctions2
-FunctionSpaceIntegration
-FunctionSpacePrimitiveElement
-FunctionSpaceReduce
-FunctionSpaceSum
-FunctionSpaceToExponentialExpansion
-FunctionSpaceToUnivariatePowerSeries
-FunctionSpaceUnivariatePolynomialFactor
-GaloisGroupFactorizationUtilities
-GaloisGroupFactorizer
-GaloisGroupPolynomialUtilities
-GaloisGroupUtilities
-GaussianFactorizationPackage
-GeneralHenselPackage
-GeneralizedMultivariateFactorize
-GeneralPolynomialGcdPackage
-GenerateUnivariatePowerSeries
-GenExEuclid
-GenUFactorize
-GenusZeroIntegration
-GosperSummationMethod
-GraphicsDefaults
-GrayCode
-GroebnerFactorizationPackage
-GroebnerInternalPackage
-GroebnerPackage
-GroebnerSolve
-HallBasis
-HeuGcd
-IdealDecompositionPackage
-IncrementingMaps
-InfiniteProductCharacteristicZero
-InfiniteProductFiniteField
-InfiniteProductPrimeField
-InfiniteTupleFunctions2
-InfiniteTupleFunctions3
-Infinity
-InnerAlgFactor
-InnerCommonDenominator
-InnerMatrixLinearAlgebraFunctions
-InnerMatrixQuotientFieldFunctions
-InnerModularGcd
-InnerMultFact
-InnerNormalBasisFieldFunctions
-InnerNumericEigenPackage
-InnerNumericFloatSolvePackage
-InnerPolySign
-InnerPolySum
-InnerTrigonometricManipulations
-InputFormFunctions1
-IntegerBits
-IntegerCombinatoricFunctions
-IntegerFactorizationPackage
-IntegerLinearDependence
-IntegerNumberTheoryFunctions
-IntegerPrimesPackage
-IntegerRetractions
-IntegerRoots
-IntegerSolveLinearPolynomialEquation
-IntegralBasisPolynomialTools
-IntegralBasisTools
-IntegrationResultFunctions2
-IntegrationResultRFToFunction
-IntegrationResultToFunction
-IntegrationTools
-InternalPrintPackage
-InternalRationalUnivariateRepresentationPackage
-InverseLaplaceTransform
-IrredPolyOverFiniteField
-IrrRepSymNatPackage
-KernelFunctions2
-Kovacic
-LaplaceTransform
-LazardSetSolvingPackage
-LeadingCoefDetermination
-LexTriangularPackage
-LinearDependence
-LinearOrdinaryDifferentialOperatorFactorizer
-LinearOrdinaryDifferentialOperatorsOps
-LinearPolynomialEquationByFractions
-LinearSystemMatrixPackage
-LinearSystemMatrixPackage1
-LinearSystemPolynomialPackage
-LinGroebnerPackage
-LiouvillianFunction
-ListFunctions2
-ListFunctions3
-ListToMap
-MakeBinaryCompiledFunction
-MakeFloatCompiledFunction
-MakeFunction
-MakeRecord
-MakeUnaryCompiledFunction
-MappingPackage1
-MappingPackage2
-MappingPackage3
-MappingPackageInternalHacks1
-MappingPackageInternalHacks2
-MappingPackageInternalHacks3
-MatrixCategoryFunctions2
-MatrixCommonDenominator
-MatrixLinearAlgebraFunctions
-MergeThing
-MeshCreationRoutinesForThreeDimensions
-ModularDistinctDegreeFactorizer
-ModularHermitianRowReduction
-MonoidRingFunctions2
-MonomialExtensionTools
-MoreSystemCommands
-MPolyCatFunctions2
-MPolyCatFunctions3
-MPolyCatPolyFactorizer
-MPolyCatRationalFunctionFactorizer
-MRationalFactorize
-MultFiniteFactorize
-MultipleMap
-MultiVariableCalculusFunctions
-MultivariateFactorize
-MultivariateLifting
-MultivariateSquareFree
-NagEigenPackage
-NagFittingPackage
-NagIntegrationPackage
-NagInterpolationPackage
-NagLapack
-NagLinearEquationSolvingPackage
-NAGLinkSupportPackage
-NagMatrixOperationsPackage
-NagOptimisationPackage
-NagOrdinaryDifferentialEquationsPackage
-NagPartialDifferentialEquationsPackage
-NagPolynomialRootsPackage
-NagRootFindingPackage
-NagSeriesSummationPackage
-NagSpecialFunctionsPackage
-NewSparseUnivariatePolynomialFunctions2
-NonCommutativeOperatorDivision
-NoneFunctions1
-NonLinearFirstOrderODESolver
-NonLinearSolvePackage
-NormalizationPackage
-NormInMonogenicAlgebra
-NormRetractPackage
-NPCoef
-NumberFieldIntegralBasis
-NumberFormats
-NumberTheoreticPolynomialFunctions
-Numeric
-NumericalOrdinaryDifferentialEquations
-NumericalQuadrature
-NumericComplexEigenPackage
-NumericContinuedFraction
-NumericRealEigenPackage
-NumericTubePlot
-OctonionCategoryFunctions2
-ODEIntegration
-ODETools
-OneDimensionalArrayFunctions2
-OnePointCompletionFunctions2
-OpenMathPackage
-OpenMathServerPackage
-OperationsQuery
-OrderedCompletionFunctions2
-OrderingFunctions
-OrthogonalPolynomialFunctions
-OutputPackage
-PadeApproximantPackage
-PadeApproximants
-PAdicWildFunctionFieldIntegralBasis
-ParadoxicalCombinatorsForStreams
-ParametricLinearEquations
-ParametricPlaneCurveFunctions2
-ParametricSpaceCurveFunctions2
-ParametricSurfaceFunctions2
-PartialFractionPackage
-PartitionsAndPermutations
-PatternFunctions1
-PatternFunctions2
-PatternMatch
-PatternMatchAssertions
-PatternMatchFunctionSpace
-PatternMatchIntegerNumberSystem
-PatternMatchIntegration
-PatternMatchKernel
-PatternMatchListAggregate
-PatternMatchPolynomialCategory
-PatternMatchPushDown
-PatternMatchQuotientFieldCategory
-PatternMatchResultFunctions2
-PatternMatchSymbol
-PatternMatchTools
-Permanent
-PermutationGroupExamples
-PiCoercions
-PlotFunctions1
-PlotTools
-PointFunctions2
-PointPackage
-PointsOfFiniteOrder
-PointsOfFiniteOrderRational
-PointsOfFiniteOrderTools
-PolToPol
-PolyGroebner
-PolynomialAN2Expression
-PolynomialCategoryLifting
-PolynomialCategoryQuotientFunctions
-PolynomialComposition
-PolynomialDecomposition
-PolynomialFactorizationByRecursion
-PolynomialFactorizationByRecursionUnivariate
-PolynomialFunctions2
-PolynomialGcdPackage
-PolynomialInterpolation
-PolynomialInterpolationAlgorithms
-PolynomialNumberTheoryFunctions
-PolynomialRoots
-PolynomialSetUtilitiesPackage
-PolynomialSolveByFormulas
-PolynomialSquareFree
-PolynomialToUnivariatePolynomial
-PowerSeriesLimitPackage
-PrecomputedAssociatedEquations
-PrimitiveArrayFunctions2
-PrimitiveElement
-PrimitiveRatDE
-PrimitiveRatRicDE
-PrintPackage
-PseudoLinearNormalForm
-PseudoRemainderSequence
-PureAlgebraicIntegration
-PureAlgebraicLODE
-PushVariables
-QuasiAlgebraicSet2
-QuasiComponentPackage
-QuaternionCategoryFunctions2
-QuotientFieldCategoryFunctions2
-RadicalEigenPackage
-RadicalSolvePackage
-RadixUtilities
-RandomDistributions
-RandomFloatDistributions
-RandomIntegerDistributions
-RandomNumberSource
-RationalFactorize
-RationalFunction
-RationalFunctionDefiniteIntegration
-RationalFunctionFactor
-RationalFunctionFactorizer
-RationalFunctionIntegration
-RationalFunctionLimitPackage
-RationalFunctionSign
-RationalFunctionSum
-RationalIntegration
-RationalLODE
-RationalRetractions
-RationalRicDE
-RationalUnivariateRepresentationPackage
-RealPolynomialUtilitiesPackage
-RealSolvePackage
-RealZeroPackage
-RealZeroPackageQ
-RectangularMatrixCategoryFunctions2
-ReducedDivisor
-ReduceLODE
-ReductionOfOrder
-RegularSetDecompositionPackage
-RegularTriangularSetGcdPackage
-RepeatedDoubling
-RepeatedSquaring
-RepresentationPackage1
-RepresentationPackage2
-ResolveLatticeCompletion
-RetractSolvePackage
-SAERationalFunctionAlgFactor
-ScriptFormulaFormat1
-SegmentBindingFunctions2
-SegmentFunctions2
-SimpleAlgebraicExtensionAlgFactor
-SimplifyAlgebraicNumberConvertPackage
-SmithNormalForm
-SortedCache
-SortPackage
-SparseUnivariatePolynomialFunctions2
-SpecialOutputPackage
-SquareFreeQuasiComponentPackage
-SquareFreeRegularSetDecompositionPackage
-SquareFreeRegularTriangularSetGcdPackage
-StorageEfficientMatrixOperations
-StreamFunctions1
-StreamFunctions2
-StreamFunctions3
-StreamInfiniteProduct
-StreamTaylorSeriesOperations
-StreamTranscendentalFunctions
-StreamTranscendentalFunctionsNonCommutative
-StructuralConstantsPackage
-SturmHabichtPackage
-SubResultantPackage
-SupFractionFactorizer
-SymmetricFunctions
-SymmetricGroupCombinatoricFunctions
-SystemODESolver
-SystemSolvePackage
-TableauxBumpers
-TabulatedComputationPackage
-TangentExpansions
-TemplateUtilities
-TexFormat1
-ToolsForSign
-TopLevelDrawFunctions
-TopLevelDrawFunctionsForAlgebraicCurves
-TopLevelDrawFunctionsForCompiledFunctions
-TopLevelDrawFunctionsForPoints
-TopLevelThreeSpace
-TranscendentalHermiteIntegration
-TranscendentalIntegration
-TranscendentalManipulations
-TranscendentalRischDE
-TranscendentalRischDESystem
-TransSolvePackage
-TransSolvePackageService
-TriangularMatrixOperations
-TrigonometricManipulations
-TubePlotTools
-TwoDimensionalPlotClipping
-TwoFactorize
-UnivariateFactorize
-UnivariateLaurentSeriesFunctions2
-UnivariatePolynomialCategoryFunctions2
-UnivariatePolynomialCommonDenominator
-UnivariatePolynomialDecompositionPackage
-UnivariatePolynomialDivisionPackage
-UnivariatePolynomialFunctions2
-UnivariatePolynomialMultiplicationPackage
-UnivariatePolynomialSquareFree
-UnivariatePuiseuxSeriesFunctions2
-UnivariateSkewPolynomialCategoryOps
-UnivariateTaylorSeriesFunctions2
-UnivariateTaylorSeriesODESolver
-UniversalSegmentFunctions2
-UserDefinedPartialOrdering
-UserDefinedVariableOrdering
-UTSodetools
-VectorFunctions2
-ViewDefaultsPackage
-ViewportPackage
-WeierstrassPreparation
-WildFunctionFieldIntegralBasis
-XExponentialPackage
-ZeroDimensionalSolvePackage
-@
-\begin{thebibliography}{99}
-\bibitem{1} Jenks, R.J. and Sutor, R.S. \\
-``Axiom -- The Scientific Computation System''\\
-Springer-Verlag New York (1992)
-ISBN 0-387-97855-0
-\bibitem{2} Knuth, Donald E., ``Literate Programming''\\
-Center for the Study of Language and Information
-ISBN 0-937073-81-4
-Stanford CA (1992) 
-\bibitem{3} Page, William, ``The Axiom Wiki Website''\\
-{\bf http://wiki.axiom-developer.org}
-\bibitem{4} Watt, Stephen, ``Aldor'',\\
-{\bf http://www.aldor.org}
-\bibitem{5} Lamport, Leslie,\\
-``Latex -- A Document Preparation System'',
-Addison-Wesley, New York ISBN 0-201-52983-1
-\bibitem{6} Ramsey, Norman\\
-``Noweb -- A Simple, Extensible Tool for Literate Programming''\\
-{\bf http://www.eecs.harvard.edu/ $\tilde{}$nr/noweb}
-\bibitem{7} Axiom Book Volume 7 -- Hyperdoc\\
-{\bf file://usr/local/axiom/src/hyper/bookvol7.pamphlet}
-\bibitem{8} Axiom Book Volume 8 -- Graphics\\
-{\bf file://usr/local/axiom/src/graph/bookvol8.pamphlet}
-\bibitem{9} AIX Version 3.2 and 4 Performance Tuning Guide\\
-{\bf 
-http://www.rs6000.ibm.com/doc\_link/en\_US/\\
-{\hbox {\hskip 1.0cm}}a\_doc\_lib/aixbman/prftungd/toc.htm}
-\end{thebibliography}
-\printindex
-\end{document}
