aboutsummaryrefslogtreecommitdiff
path: root/src/graph/view2D
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2007-08-14 05:14:52 +0000
committerdos-reis <gdr@axiomatics.org>2007-08-14 05:14:52 +0000
commitab8cc85adde879fb963c94d15675783f2cf4b183 (patch)
treec202482327f474583b750b2c45dedfc4e4312b1d /src/graph/view2D
downloadopen-axiom-ab8cc85adde879fb963c94d15675783f2cf4b183.tar.gz
Initial population.
Diffstat (limited to 'src/graph/view2D')
-rw-r--r--src/graph/view2D/ChangeLog63
-rw-r--r--src/graph/view2D/Makefile.in68
-rw-r--r--src/graph/view2D/Makefile.pamphlet104
-rw-r--r--src/graph/view2D/buttons2d.c.pamphlet739
-rw-r--r--src/graph/view2D/control2d.c.pamphlet642
-rwxr-xr-xsrc/graph/view2D/globals2.h89
-rw-r--r--src/graph/view2D/graph2d.c.pamphlet189
-rwxr-xr-xsrc/graph/view2D/header2.h283
-rw-r--r--src/graph/view2D/main2d.c.pamphlet524
-rw-r--r--src/graph/view2D/pot2d.c.pamphlet84
-rw-r--r--src/graph/view2D/process2d.c.pamphlet959
-rw-r--r--src/graph/view2D/spadAction2d.c.pamphlet320
-rw-r--r--src/graph/view2D/stuff2d.c.pamphlet146
-rw-r--r--src/graph/view2D/viewport2D.c.pamphlet734
-rw-r--r--src/graph/view2D/write2d.c.pamphlet226
15 files changed, 5170 insertions, 0 deletions
diff --git a/src/graph/view2D/ChangeLog b/src/graph/view2D/ChangeLog
new file mode 100644
index 00000000..6d3a68d7
--- /dev/null
+++ b/src/graph/view2D/ChangeLog
@@ -0,0 +1,63 @@
+2007-07-29 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * Makefile.pamphlet: Propagate libtoolization changes.
+ * Makefile.in: Regenerate.
+
+2006-11-26 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * buttons2d.c.pamphlet: Include axiom-c-macros.h
+ * control2d.c.pamphlet: Likewise.
+ * graph2d.c.pamphlet: Likewise.
+ * main2d.c.pamphlet: Likewise.
+ * pot2d.c.pamphlet: Likewise.
+ * process2d.c.pamphlet: Likewise.
+ * spadAction2d.c.pamphlet: Likewise.
+ * stuff2d.c.pamphlet: Likewise.
+ * viewport2D.c.pamphlet: Likewise.
+ * write2d.c.pamphlet: Likewise.
+
+ * Makefile.pamphlet: Add support for OS that require extension for
+ executable binary files.
+ * Makefile.in: Regenerate.
+
+2006-11-24 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * Makefile.pamphlet (view2D_DEPENDENCIES): Remove direct referene
+ to libspad.a and hash.o
+ ($(build_libdir)/hash.o): Remove rule.
+ ($(abs_top_builddir)/src/graph/Gdraws/Gfun.o): Likewise.
+ (AXIOM_CFLAGS): New variale.
+ (%.$(OBJEXT)): Use it.
+ (all-view2D): New phony target.
+ (stamp): New target. Split from all-ax.
+ * Makefile.in: Regenerate.
+
+2006-10-08 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * Makefile.pamphlet: Remove references to ${MNT} throughout.
+ * Makefile.in: Regenerate.
+
+2006-10-04 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * Makefile.pamphlet (document): Remove.
+ (pamphlets): New.
+
+2006-09-18 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * Makefile.pamphlet: Simplify.
+ (subdir): New.
+ * Makefile.in: Regenerate.
+
+2006-09-11 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * Makefile.pamphlet: Use $(axiom_build_document) to tangle
+ pamphlets. Add support for out-of-source build.
+ * Makefile.in: Regenerate.
+
+2006-09-03 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * Makefile.in: New.
+
+2006-08-06 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * Makefile.pamphlet: Remove explicit mention of X11 and Xpm.
diff --git a/src/graph/view2D/Makefile.in b/src/graph/view2D/Makefile.in
new file mode 100644
index 00000000..2cf338f5
--- /dev/null
+++ b/src/graph/view2D/Makefile.in
@@ -0,0 +1,68 @@
+# local include files shared by graphics
+LINC= $(axiom_src_srcdir)/graph/include
+
+# global include files shared by everyone
+GINC= $(axiom_src_srcdir)/include
+
+build_libdir = $(abs_top_builddir)/src/lib
+
+bin_PROGRAMS = view2D$(EXEEXT)
+
+view2D_sources = buttons2d.c control2d.c graph2d.c main2d.c pot2d.c \
+ process2d.c spadAction2d.c stuff2d.c viewport2D.c write2d.c
+
+view2D_SOURCES = $(addsuffix .pamphlet, $(view2D_sources))
+
+view2D_objects = $(view2D_sources:.c=.lo)
+
+Gfun_objects = ../Gdraws/Gfun.lo
+
+view2D_LDADD = $(axiom_target_libdir)/libspad.la
+
+view2D_DEPENDENCIES = $(Gfun_objects)
+
+subdir = src/graph/view2D/
+
+pamphlets = Makefile.pamphlet $(view2D_SOURCES)
+
+AXIOM_CFLAGS = ${CCF} ${AXIOM_X11_CFLAGS} -I${LINC} -I${GINC} -I$(srcdir) \
+ $(axiom_includes)
+
+GDRAW_OBJS = ../Gdraws/Gfun.lo
+
+HEADERS = $(srcdir)/header2.h $(srcdir)/globals2.h ${LINC}/view2D.h \
+ ${LINC}/actions.h ${LINC}/viewCommand.h ${GINC}/view.h ${LINC}/G.h
+
+.PHONY: all all-ax all-view2D
+
+all: all-ax
+
+all-ax all-view2D: stamp
+ @ echo finished $(builddir)
+
+stamp: $(axiom_target_libdir)/view2D
+ @rm -f stamp
+ $(STAMP) stamp
+
+$(axiom_target_libdir)/view2D$(EXEEXT): $(view2D_objects) $(view2D_DEPENDENCIES)
+ $(LINK) -o $@ $(view2D_objects) $(Gfun_objects) \
+ $(view2D_LDADD) $(AXIOM_X11_LDFLAGS) -lm
+
+.PRECIOUS: %.c
+.PRECIOUS: %.lo
+
+%.$(OBJEXT): $(HEADERS)
+
+%.lo: $(builddir)/%.c $(axiom_c_macros.h)
+ $(COMPILE) -o $@ $(CFLAGS) $(AXIOM_CFLAGS) $<
+
+%.c: $(srcdir)/%.c.pamphlet
+ $(axiom_build_document) --tangle --output=$@ $<
+
+mostlyclean-local:
+
+clean-local: mostlyclean-local
+ @rm -f $(view2D_sources) $(view2D_objects)
+ @rm -f $(axiom_target_libdir)/view2D$(EXEEXT)
+
+distclean-local: clean-local
diff --git a/src/graph/view2D/Makefile.pamphlet b/src/graph/view2D/Makefile.pamphlet
new file mode 100644
index 00000000..80570d24
--- /dev/null
+++ b/src/graph/view2D/Makefile.pamphlet
@@ -0,0 +1,104 @@
+%% Oh Emacs, this is a -*- Makefile -*-, so give me tabs.
+\documentclass{article}
+\usepackage{axiom}
+
+\title{\$SPAD/src/graph/view2D Makefile}
+\author{Timothy Daly \and Gabriel Dos~Reis}
+
+\begin{document}
+\maketitle
+
+\begin{abstract}
+\end{abstract}
+\eject
+
+\tableofcontents
+\eject
+
+\section{environment variables}
+<<environment>>=
+# local include files shared by graphics
+LINC= $(axiom_src_srcdir)/graph/include
+
+# global include files shared by everyone
+GINC= $(axiom_src_srcdir)/include
+
+build_libdir = $(abs_top_builddir)/src/lib
+
+bin_PROGRAMS = view2D$(EXEEXT)
+
+view2D_sources = buttons2d.c control2d.c graph2d.c main2d.c pot2d.c \
+ process2d.c spadAction2d.c stuff2d.c viewport2D.c write2d.c
+
+view2D_SOURCES = $(addsuffix .pamphlet, $(view2D_sources))
+
+view2D_objects = $(view2D_sources:.c=.lo)
+
+Gfun_objects = ../Gdraws/Gfun.lo
+
+view2D_LDADD = $(axiom_target_libdir)/libspad.la
+
+view2D_DEPENDENCIES = $(Gfun_objects)
+@
+
+\section{view2D code}
+
+<<view2D code>>=
+$(axiom_target_libdir)/view2D$(EXEEXT): $(view2D_objects) $(view2D_DEPENDENCIES)
+ $(LINK) -o $@ $(view2D_objects) $(Gfun_objects) \
+ $(view2D_LDADD) $(AXIOM_X11_LDFLAGS) -lm
+
+.PRECIOUS: %.c
+.PRECIOUS: %.lo
+
+%.$(OBJEXT): $(HEADERS)
+
+%.lo: $(builddir)/%.c $(axiom_c_macros.h)
+ $(COMPILE) -o $@ $(CFLAGS) $(AXIOM_CFLAGS) $<
+
+%.c: $(srcdir)/%.c.pamphlet
+ $(axiom_build_document) --tangle --output=$@ $<
+@
+
+<<*>>=
+<<environment>>
+
+subdir = src/graph/view2D/
+
+pamphlets = Makefile.pamphlet $(view2D_SOURCES)
+
+AXIOM_CFLAGS = ${CCF} ${AXIOM_X11_CFLAGS} -I${LINC} -I${GINC} -I$(srcdir) \
+ $(axiom_includes)
+
+GDRAW_OBJS = ../Gdraws/Gfun.lo
+
+HEADERS = $(srcdir)/header2.h $(srcdir)/globals2.h ${LINC}/view2D.h \
+ ${LINC}/actions.h ${LINC}/viewCommand.h ${GINC}/view.h ${LINC}/G.h
+
+.PHONY: all all-ax all-view2D
+
+all: all-ax
+
+all-ax all-view2D: stamp
+ @ echo finished $(builddir)
+
+stamp: $(axiom_target_libdir)/view2D
+ @rm -f stamp
+ $(STAMP) stamp
+
+<<view2D code>>
+
+mostlyclean-local:
+
+clean-local: mostlyclean-local
+ @rm -f $(view2D_sources) $(view2D_objects)
+ @rm -f $(axiom_target_libdir)/view2D$(EXEEXT)
+
+distclean-local: clean-local
+@
+
+\eject
+\begin{thebibliography}{99}
+\bibitem{1} nothing
+\end{thebibliography}
+\end{document}
diff --git a/src/graph/view2D/buttons2d.c.pamphlet b/src/graph/view2D/buttons2d.c.pamphlet
new file mode 100644
index 00000000..103ead1f
--- /dev/null
+++ b/src/graph/view2D/buttons2d.c.pamphlet
@@ -0,0 +1,739 @@
+\documentclass{article}
+\usepackage{axiom}
+\begin{document}
+\title{\$SPAD/src/graph/view2D buttons2d.c}
+\author{The Axiom Team}
+\maketitle
+\begin{abstract}
+\end{abstract}
+\eject
+\tableofcontents
+\eject
+\section{License}
+<<license>>=
+/*
+Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - 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.
+
+ - 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.
+
+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.
+*/
+@
+<<*>>=
+<<license>>
+
+#define _BUTTONS2D_C
+#include "axiom-c-macros.h"
+#include "useproto.h"
+
+#include <string.h>
+
+#include "header2.h"
+#include "buttons2d.H1"
+#include "all_2d.H1"
+
+
+
+
+#define bColor 98
+#define graphColor 138
+
+/*****************************************************
+ * int initButtons(buttons) *
+ * *
+ * Creates the fields for each button window in the *
+ * two dimensional control panel, and returns the *
+ * number of buttons created. *
+ * *
+ *****************************************************/
+
+int
+#ifdef _NO_PROTO
+initButtons (buttons)
+buttonStruct *buttons;
+#else
+initButtons (buttonStruct *buttons)
+#endif
+{
+ int ii, num = 0;
+
+/********** Scale(Zoom) and Translate Potentiometer Buttons **********/
+
+ /* Title: "Scale" */
+ ii = scale2D;
+ buttons[ii].buttonX = 5;
+ buttons[ii].buttonY = 85;
+ buttons[ii].buttonWidth = 110;
+ buttons[ii].buttonHeight = 80;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = yes; /* scale is a potentiometer */
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = potMASK;
+ buttons[ii].textColor = 164;
+ buttons[ii].xHalf = buttons[ii].buttonWidth/2;
+ buttons[ii].yHalf = buttons[ii].buttonHeight/2;
+ ++num;
+
+ /* Title: "Translate" */
+ ii = translate2D;
+ buttons[ii].buttonX = 121;
+ buttons[ii].buttonY = 85;
+ buttons[ii].buttonWidth = 110;
+ buttons[ii].buttonHeight = 80;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = yes; /* translate is a potentiometer */
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = potMASK;
+ buttons[ii].textColor = 21; /* line color of translate arrow */
+ 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;
+ buttons[ii].buttonY = 55;
+ buttons[ii].buttonWidth = 53;
+ buttons[ii].buttonHeight = 25;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no;
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"X On ");
+ buttons[ii].textColor = bColor;
+ 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;
+ buttons[ii].buttonY = 55;
+ buttons[ii].buttonWidth = 53;
+ buttons[ii].buttonHeight = 25;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no;
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"Y On ");
+ buttons[ii].textColor = bColor;
+ 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;
+ buttons[ii].buttonY = 55;
+ buttons[ii].buttonWidth = 53;
+ buttons[ii].buttonHeight = 25;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no;
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"X On ");
+ buttons[ii].textColor = bColor;
+ 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;
+ buttons[ii].buttonY = 55;
+ buttons[ii].buttonWidth = 53;
+ buttons[ii].buttonHeight = 25;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no;
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"Y On ");
+ buttons[ii].textColor = bColor;
+ 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;
+ buttons[ii].buttonY = 292;
+ buttons[ii].buttonWidth = 90;
+ buttons[ii].buttonHeight = 30;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no;
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"Axes On ");
+ buttons[ii].textColor = 75;
+ buttons[ii].textHue = 10;
+ buttons[ii].textShade = 3;
+ 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;
+ buttons[ii].buttonY = 292;
+ buttons[ii].buttonWidth = 90;
+ buttons[ii].buttonHeight = 30;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no;
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"Units Off");
+ buttons[ii].textColor = 75;
+ buttons[ii].textHue = 10;
+ buttons[ii].textShade = 3;
+ 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;
+ buttons[ii].buttonY = 292;
+ buttons[ii].buttonWidth = 36;
+ buttons[ii].buttonHeight = 30;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no;
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"PS");
+ buttons[ii].textColor = 35;
+ buttons[ii].textHue = 5;
+ buttons[ii].textShade = 2;
+ 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;
+ buttons[ii].buttonY = 329;
+ buttons[ii].buttonWidth = 66;
+ buttons[ii].buttonHeight = 30;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no;
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"Box Off");
+ buttons[ii].textColor = 7;
+ buttons[ii].textHue = 26;
+ buttons[ii].textShade = 3;
+ 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;
+ buttons[ii].buttonY = 329;
+ buttons[ii].buttonWidth = 67;
+ buttons[ii].buttonHeight = 30;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no;
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"Pts On ");
+ buttons[ii].textColor = 7;
+ buttons[ii].textHue = 26;
+ buttons[ii].textShade = 3;
+ 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;
+ buttons[ii].buttonY = 329;
+ buttons[ii].buttonWidth = 84;
+ buttons[ii].buttonHeight = 30;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no;
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"Lines On ");
+ buttons[ii].textColor = 7;
+ buttons[ii].textHue = 26;
+ buttons[ii].textShade = 3;
+ 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;
+ buttons[ii].buttonY = 364;
+ buttons[ii].buttonWidth = 60;
+ buttons[ii].buttonHeight = 30;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no;
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"Reset");
+ buttons[ii].textColor = bColor;
+ buttons[ii].textHue = 5;
+ buttons[ii].textShade = 2;
+ buttons[ii].xHalf = buttons[ii].buttonWidth/2;
+ buttons[ii].yHalf = buttons[ii].buttonHeight/2;
+ ++num;
+
+ /* Hide Control Panel */
+ ii = hideControl2D;
+ buttons[ii].buttonX = 70;
+ buttons[ii].buttonY = 364;
+ buttons[ii].buttonWidth = 88;
+ buttons[ii].buttonHeight = 30;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no;
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"Hide Panel");
+ buttons[ii].textColor = bColor;
+ buttons[ii].textHue = 5;
+ buttons[ii].textShade = 2;
+ 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;
+ buttons[ii].buttonY = 370;
+ buttons[ii].buttonWidth = 61;
+ buttons[ii].buttonHeight = 24;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no;
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"Quit");
+ buttons[ii].textColor = 13;
+ buttons[ii].textHue = 29;
+ buttons[ii].textShade = 2;
+ 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;
+ buttons[ii].buttonY = 217;
+ buttons[ii].buttonWidth = 40;
+ buttons[ii].buttonHeight = 24;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no;
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"Pick");
+ buttons[ii].textColor = 123;
+ buttons[ii].textHue = 19;
+ buttons[ii].textShade = 3;
+ 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;
+ buttons[ii].buttonY = 245;
+ buttons[ii].buttonWidth = 40;
+ buttons[ii].buttonHeight = 24;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no;
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"Drop");
+ buttons[ii].textColor = 123;
+ buttons[ii].textHue = 19;
+ buttons[ii].textShade = 3;
+ 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;
+ buttons[ii].buttonX = 5;
+ buttons[ii].buttonY = 217;
+ buttons[ii].buttonWidth = 49;
+ buttons[ii].buttonHeight = 24;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no;
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"Clear");
+ buttons[ii].textColor = 123;
+ buttons[ii].textHue = 19;
+ buttons[ii].textShade = 3;
+ 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;
+ buttons[ii].buttonY = 245;
+ buttons[ii].buttonWidth = 49;
+ buttons[ii].buttonHeight = 24;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no;
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"Query");
+ buttons[ii].textColor = 123;
+ buttons[ii].textHue = 19;
+ buttons[ii].textShade = 3;
+ 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;
+ buttons[ii].buttonWidth = graphBarWidth;
+ buttons[ii].buttonHeight = graphBarHeight;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no;
+ buttons[ii].graphNum = yes;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"1");
+ buttons[ii].textColor = graphColor;
+ 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;
+ buttons[ii].buttonWidth = graphBarWidth;
+ buttons[ii].buttonHeight = graphBarHeight-2;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no; /* this is a regular button */
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = yes;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"^");
+ buttons[ii].textColor = graphColor;
+ 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;
+ buttons[ii].buttonWidth = graphBarWidth;
+ buttons[ii].buttonHeight = graphBarHeight;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no; /* this is a regular button */
+ buttons[ii].graphNum = yes;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"2");
+ buttons[ii].textColor = graphColor;
+ 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;
+ buttons[ii].buttonWidth = graphBarWidth;
+ buttons[ii].buttonHeight = graphBarHeight-2;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no; /* this is a regular button */
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = yes;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"-");
+ buttons[ii].textColor = graphColor;
+ 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;
+ buttons[ii].buttonWidth = graphBarWidth;
+ buttons[ii].buttonHeight = graphBarHeight;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no; /* this is a regular button */
+ buttons[ii].graphNum = yes;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"3");
+ buttons[ii].textColor = graphColor;
+ 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;
+ buttons[ii].buttonWidth = graphBarWidth;
+ buttons[ii].buttonHeight = graphBarHeight-2;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no; /**** blend these three together ***/
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = yes;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"-");
+ buttons[ii].textColor = graphColor;
+ 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;
+ buttons[ii].buttonWidth = graphBarWidth;
+ buttons[ii].buttonHeight = graphBarHeight;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no; /* this is a regular button */
+ buttons[ii].graphNum = yes;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"4");
+ buttons[ii].textColor = graphColor;
+ 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;
+ buttons[ii].buttonWidth = graphBarWidth;
+ buttons[ii].buttonHeight = graphBarHeight-2;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no; /* this is a regular button */
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = yes;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"-");
+ buttons[ii].textColor = graphColor;
+ 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;
+ buttons[ii].buttonWidth = graphBarWidth;
+ buttons[ii].buttonHeight = graphBarHeight;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no; /* this is a regular button */
+ buttons[ii].graphNum = yes;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"5");
+ buttons[ii].textColor = graphColor;
+ 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;
+ buttons[ii].buttonWidth = graphBarWidth;
+ buttons[ii].buttonHeight = graphBarHeight-2;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no; /* this is a regular button */
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = yes;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"-");
+ buttons[ii].textColor = graphColor;
+ 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;
+ buttons[ii].buttonWidth = graphBarWidth;
+ buttons[ii].buttonHeight = graphBarHeight;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no; /* this is a regular button */
+ buttons[ii].graphNum = yes;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"6");
+ buttons[ii].textColor = graphColor;
+ 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;
+ buttons[ii].buttonWidth = graphBarWidth;
+ buttons[ii].buttonHeight = graphBarHeight-2;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no; /* this is a regular button */
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = yes;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"-");
+ buttons[ii].textColor = graphColor;
+ 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;
+ buttons[ii].buttonWidth = graphBarWidth;
+ buttons[ii].buttonHeight = graphBarHeight;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no; /* this is a regular button */
+ buttons[ii].graphNum = yes;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"7");
+ buttons[ii].textColor = graphColor;
+ 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;
+ buttons[ii].buttonWidth = graphBarWidth;
+ buttons[ii].buttonHeight = graphBarHeight-2;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no; /* this is a regular button */
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = yes;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"-");
+ buttons[ii].textColor = graphColor;
+ 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;
+ buttons[ii].buttonWidth = graphBarWidth;
+ buttons[ii].buttonHeight = graphBarHeight;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no; /* this is a regular button */
+ buttons[ii].graphNum = yes;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"8");
+ buttons[ii].textColor = graphColor;
+ 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;
+ buttons[ii].buttonWidth = graphBarWidth;
+ buttons[ii].buttonHeight = graphBarHeight-2;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no; /* this is a regular button */
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = yes;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"-");
+ buttons[ii].textColor = graphColor;
+ 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;
+ buttons[ii].buttonWidth = graphBarWidth;
+ buttons[ii].buttonHeight = graphBarHeight;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no; /* this is a regular button */
+ buttons[ii].graphNum = yes;
+ buttons[ii].graphSelect = no;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"9");
+ buttons[ii].textColor = graphColor;
+ 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;
+ buttons[ii].buttonWidth = graphBarWidth;
+ buttons[ii].buttonHeight = graphBarHeight-2;
+ buttons[ii].buttonKey = ii;
+ buttons[ii].pot = no; /* this is a regular button */
+ buttons[ii].graphNum = no;
+ buttons[ii].graphSelect = yes;
+ buttons[ii].mask = buttonMASK;
+ strcpy(buttons[ii].text,"*");
+ buttons[ii].textColor = graphColor;
+ buttons[ii].xHalf = buttons[ii].buttonWidth/2;
+ buttons[ii].yHalf = buttons[ii].buttonHeight/2;
+ ++num;
+
+ return(num);
+}
+@
+\eject
+\begin{thebibliography}{99}
+\bibitem{1} nothing
+\end{thebibliography}
+\end{document}
diff --git a/src/graph/view2D/control2d.c.pamphlet b/src/graph/view2D/control2d.c.pamphlet
new file mode 100644
index 00000000..e25f61de
--- /dev/null
+++ b/src/graph/view2D/control2d.c.pamphlet
@@ -0,0 +1,642 @@
+\documentclass{article}
+\usepackage{axiom}
+\begin{document}
+\title{\$SPAD/src/graph/view2D control2d.c}
+\author{The Axiom Team}
+\maketitle
+\begin{abstract}
+\end{abstract}
+\eject
+\tableofcontents
+\eject
+\section{License}
+<<license>>=
+/*
+Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - 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.
+
+ - 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.
+
+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.
+*/
+@
+<<*>>=
+<<license>>
+
+#define _CONTROL2D_C
+#include "axiom-c-macros.h"
+#include "useproto.h"
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#include "header2.h"
+#include "buttons2d.H1"
+#include "all_2d.H1"
+#include "Gfun.H1"
+#include "XSpadFill.H1"
+#include "util.H1"
+
+
+#include "mouse11.bitmap"
+#include "mouse11.mask"
+
+/* 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
+#ifdef _NO_PROTO
+writeControlTitle()
+#else
+writeControlTitle(void)
+#endif
+{
+
+ int strlength;
+
+ s = viewport->title;
+ strlength = strlen(s);
+ XClearArea(dsply,control->controlWindow,0,0,controlWidth,potA,False);
+ GSetForeground(anotherGC,(float)controlTitleColor,Xoption);
+ GDrawImageString(anotherGC,control->controlWindow,
+ centerX(anotherGC,s,strlength,controlWidth),
+ 15,s,strlength,Xoption);
+
+} /* writeControlTitle() */
+
+void
+#ifdef _NO_PROTO
+makeMessageFromData(whichGraph)
+int whichGraph;
+#else
+makeMessageFromData(int whichGraph)
+#endif
+{
+ if (viewport->haveControl) {
+ if ((graphStateArray[whichGraph].scaleX) > 99.0) {
+ strcpy(scaleXReport,"big");
+ } else {
+ sprintf(scaleXReport,"%4.1f",graphStateArray[whichGraph].scaleX);
+ }
+ if ((graphStateArray[whichGraph].scaleY) > 99.0) {
+ strcpy(scaleYReport,"big");
+ } else {
+ sprintf(scaleYReport,"%4.1f",graphStateArray[whichGraph].scaleY);
+ }
+ if ((graphStateArray[whichGraph].centerX) > 999.0) {
+ strcpy(deltaXReport,"+big");
+ } else if ((graphStateArray[whichGraph].centerX) < -999.0) {
+ strcpy(deltaXReport,"-big");
+ } else {
+ sprintf(deltaXReport,"%4.0f",
+ -graphStateArray[whichGraph].centerX /
+ graphArray[whichGraph].unitX);
+ }
+ if ((graphStateArray[whichGraph].centerY) > 999.0) {
+ strcpy(deltaYReport,"+big");
+ } else if ((graphStateArray[whichGraph].centerY) < -999.0) {
+ strcpy(deltaYReport,"-big");
+ } else {
+ sprintf(deltaYReport,"%4.0f",
+ -graphStateArray[whichGraph].centerY /
+ graphArray[whichGraph].unitY);
+ }
+ sprintf(viewport->controlPanel->message,"[%s,%s] >%d< [%s,%s]",
+ scaleXReport,scaleYReport,whichGraph+1,deltaXReport,deltaYReport);
+ } /* if haveControl */
+
+} /* makeMessageFromData() */
+
+
+void
+#ifdef _NO_PROTO
+writeControlMessage()
+#else
+writeControlMessage(void)
+#endif
+{
+ 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
+#ifdef _NO_PROTO
+drawControlPanel()
+#else
+drawControlPanel(void)
+#endif
+{
+
+ 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. */
+ GSetForeground(trashGC,(float)foregroundColor,Xoption);
+ GSetLineAttributes(trashGC,3,LineSolid,CapButt,JoinMiter,Xoption);
+ GDrawLine(trashGC, cp->controlWindow, 0, potA, controlWidth, potA, Xoption);
+ GSetLineAttributes(trashGC,2,LineSolid,CapButt,JoinMiter,Xoption);
+ GDrawLine(trashGC, cp->controlWindow, 0, potB, controlWidth, potB, Xoption);
+ 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);
+
+ /* 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);
+
+ s = "Translate";
+ strlength = strlen(s);
+ GDrawString(globGC,cp->controlWindow,
+ centerX(globGC,s,strlength,
+ 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);
+
+ GSetForeground(trashGC,
+ (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);
+ 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);
+ switch (i) {
+ case scale2D:
+ GDrawLines(trashGC,cp->controlWindow,scaleArrow,
+ scaleArrowN,CoordModeOrigin,Xoption);
+ break;
+ case translate2D:
+ GDrawLines(trashGC,cp->controlWindow,translateArrow,
+ translateArrowN,CoordModeOrigin,Xoption);
+ break;
+ } /* switch i */
+ } else if (cp->buttonQueue[i].graphNum) {
+
+ if (mono) {
+ if (graphStateArray[i-graphStart].showing) {
+ GSetForeground(graphGC,(float)backgroundColor,Xoption);
+ GSetBackground(graphGC,(float)foregroundColor,Xoption);
+ } else {
+ GSetForeground(graphGC,(float)foregroundColor,Xoption);
+ GSetBackground(graphGC,(float)backgroundColor,Xoption);
+ }
+ 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);
+ } else {
+ if (graphStateArray[i-graphStart].showing)
+ GSetForeground(graphGC,(float)graphBarShowingColor,Xoption);
+ else
+ 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);
+ }
+ } else if (cp->buttonQueue[i].graphSelect) {
+ /* The select characters are defined as: "^" for on and "-" for off. */
+ if (graphStateArray[i-graphSelectStart].selected) {
+ GSetForeground(graphGC,(float)graphBarSelectColor,Xoption);
+ strcpy((cp->buttonQueue[i]).text,"^");
+ } else {
+ GSetForeground(graphGC,(float)graphBarNotSelectColor,Xoption);
+ *(cp->buttonQueue[i]).text = '-';
+ 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);
+ }
+ else { /* a regular button */
+ int isOn = 1;
+
+ switch(i) {
+ case pointsOnOff:
+ isOn = pointsON = graphStateArray[0].pointsOn;
+ if (graphStateArray[0].pointsOn)
+ strcpy((cp->buttonQueue[i]).text,"Pts On ");
+ else
+ strcpy((cp->buttonQueue[i]).text,"Pts Off");
+ break;
+
+ case spline2D:
+ isOn = splineON = graphStateArray[0].splineOn;
+ if (graphStateArray[0].splineOn)
+ strcpy((cp->buttonQueue[i]).text, "Box On ");
+ else
+ strcpy((cp->buttonQueue[i]).text, "Box Off");
+ break;
+
+ case connectOnOff:
+ isOn = connectON = graphStateArray[0].connectOn;
+ if (graphStateArray[0].connectOn)
+ strcpy((cp->buttonQueue[i]).text, "Lines On ");
+ else
+ strcpy((cp->buttonQueue[i]).text, "Lines Off");
+ break;
+
+ case axesOnOff2D:
+ isOn = axesON = graphStateArray[0].axesOn;
+ if (graphStateArray[0].axesOn)
+ strcpy((cp->buttonQueue[i]).text , "Axes On ");
+ else
+ strcpy((cp->buttonQueue[i]).text , "Axes Off");
+ break;
+
+ case unitsOnOff2D:
+ isOn = unitsON = graphStateArray[0].unitsOn;
+ if (graphStateArray[0].unitsOn)
+ strcpy( (cp->buttonQueue[i]).text , "Units On ");
+ else
+ strcpy( (cp->buttonQueue[i]).text , "Units Off");
+ 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
+#ifdef _NO_PROTO
+getControlXY(whereDoYouWantPanel)
+int whereDoYouWantPanel;
+#else
+getControlXY(int whereDoYouWantPanel)
+#endif
+{
+ XWindowAttributes wAttr, wAttrib;
+ controlXY cXY;
+ int tmp=1;
+ Window rootW, parentW, *childrenWs, tmpW;
+ unsigned int nChildren;
+
+ tmpW = viewport->titleWindow;
+ while(tmp) {
+ XQueryTree(dsply,tmpW,&rootW,&parentW,&childrenWs,&nChildren);
+ XFree(childrenWs);
+ if (parentW == rtWindow) tmp = 0;
+ else tmpW = parentW;
+ }
+ XGetWindowAttributes(dsply,tmpW,&wAttrib);
+
+ XGetWindowAttributes(dsply,viewport->titleWindow,&wAttr);
+ if (whereDoYouWantPanel) {
+ switch (whereDoYouWantPanel) {
+ case 1: /* right */
+ cXY.putX = wAttrib.x + wAttrib.width;
+ cXY.putY = wAttrib.y;
+ break;
+ case 2: /* bottom */
+ cXY.putX = wAttrib.x + (wAttr.width - controlWidth)/2; /* center it */
+ cXY.putY = wAttrib.y + wAttrib.height;
+ break;
+ case 3: /* left */
+ cXY.putX = wAttrib.x - controlWidth - borderWidth;
+ cXY.putY = wAttrib.y;
+ break;
+ case 4: /* top */
+ cXY.putX = wAttrib.x + (wAttr.width - controlWidth)/2;
+ cXY.putY = wAttrib.y - controlHeight - borderHeight;
+ }
+ } else {
+ if ((physicalWidth - (wAttrib.x + wAttr.width)) >= controlWidth) {
+ cXY.putX = wAttrib.x + wAttrib.width;
+ cXY.putY = wAttrib.y;
+ } else if ((physicalHeight - (wAttrib.y + wAttr.height)) >=
+ controlHeight) {
+ cXY.putX = wAttrib.x + (wAttr.width - controlWidth)/2;
+ cXY.putY = wAttrib.y + wAttrib.height;
+ } else if (wAttrib.x >= controlWidth) {
+ cXY.putX = wAttrib.x - controlWidth - borderWidth;
+ cXY.putY = wAttrib.y;
+ } else if (wAttrib.y >= controlHeight) {
+ cXY.putX = wAttrib.x + (wAttr.width - controlWidth)/2;
+ cXY.putY = wAttrib.y - controlHeight - borderHeight;
+ } else { /* put inside of viewport */
+ cXY.putX = wAttrib.x + wAttr.width - controlWidth;
+ cXY.putY = wAttrib.y + wAttr.height - controlHeight;
+ }
+ }
+ return(cXY);
+
+}
+
+/************************************************/
+/*** controlPanelStruct *makeControlPanel() ***/
+/************************************************/
+
+controlPanelStruct *
+#ifdef _NO_PROTO
+makeControlPanel()
+#else
+makeControlPanel(void)
+#endif
+{
+
+ Window cw;
+ int i,num;
+ controlPanelStruct *control;
+ buttonStruct *buttons;
+ controlXY cXY;
+ 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);
+ mousemask = XCreateBitmapFromData(dsply,rtWindow,mouseMask_bits,
+ mouseMask_width,mouseMask_height);
+ cwAttrib.background_pixel = backgroundColor; /* controlBackground; */
+ cwAttrib.border_pixel = foregroundColor;
+ cwAttrib.backing_store = WhenMapped;
+ cwAttrib.event_mask = controlMASK;
+ cwAttrib.colormap = colorMap;
+ cwAttrib.override_redirect = overrideManager;
+ foreColor.pixel = controlCursorForeground;
+ XQueryColor(dsply,colorMap,&foreColor);
+ backColor.pixel = controlCursorBackground;
+ XQueryColor(dsply,colorMap,&backColor);
+ 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,
+ (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));
+ /* 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;
+ }
+ for (i=0; i<translateArrowN; i++) {
+ 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
+#ifdef _NO_PROTO
+putControlPanelSomewhere(whereDoesPanelGo)
+int whereDoesPanelGo;
+#else
+putControlPanelSomewhere(int whereDoesPanelGo)
+#endif
+{
+ controlPanelStruct *control;
+ controlXY whereControl;
+
+ 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);
+ viewport->justMadeControl = no;
+ }
+ XMapWindow(dsply,control->controlWindow);
+}
+
+
+
+
+
+/************************************/
+/*** void clearControlMessage() ***/
+/************************************/
+
+void
+#ifdef _NO_PROTO
+clearControlMessage()
+#else
+clearControlMessage(void)
+#endif
+{
+
+ strcpy(viewport->controlPanel->message,"");
+
+ XClearArea(dsply,viewport->controlPanel->controlWindow,
+ 0,controlMessageY-2,controlWidth,controlMessageHeight,False);
+}
+
+
+@
+\eject
+\begin{thebibliography}{99}
+\bibitem{1} nothing
+\end{thebibliography}
+\end{document}
diff --git a/src/graph/view2D/globals2.h b/src/graph/view2D/globals2.h
new file mode 100755
index 00000000..de0d132a
--- /dev/null
+++ b/src/graph/view2D/globals2.h
@@ -0,0 +1,89 @@
+/*
+Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - 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.
+
+ - 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.
+
+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.
+*/
+
+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;
diff --git a/src/graph/view2D/graph2d.c.pamphlet b/src/graph/view2D/graph2d.c.pamphlet
new file mode 100644
index 00000000..45d4399e
--- /dev/null
+++ b/src/graph/view2D/graph2d.c.pamphlet
@@ -0,0 +1,189 @@
+\documentclass{article}
+\usepackage{axiom}
+\begin{document}
+\title{\$SPAD/src/graph/view2D graph2d.c}
+\author{The Axiom Team}
+\maketitle
+\begin{abstract}
+\end{abstract}
+\eject
+\tableofcontents
+\eject
+\section{License}
+<<license>>=
+/*
+Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - 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.
+
+ - 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.
+
+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.
+*/
+@
+<<*>>=
+<<license>>
+
+#define _GRAPH2D_C
+#include "axiom-c-macros.h"
+#include "useproto.h"
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include "header2.h"
+
+#include "all_2d.H1"
+#include "util.H1"
+
+
+void
+#ifdef _NO_PROTO
+getGraphFromViewman(i)
+int i;
+#else
+getGraphFromViewman(int i)
+#endif
+{
+ /** 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). **/
+
+ int j,k,xPointsNeeded;
+ pointListStruct *llPtr;
+ pointStruct *p;
+
+ readViewman(&(graphArray[i].xmin),floatSize);
+ readViewman(&(graphArray[i].xmax),floatSize);
+ readViewman(&(graphArray[i].ymin),floatSize);
+ readViewman(&(graphArray[i].ymax),floatSize);
+ readViewman(&(graphArray[i].xNorm),floatSize);
+ readViewman(&(graphArray[i].yNorm),floatSize);
+ readViewman(&(graphArray[i].spadUnitX),floatSize);
+ readViewman(&(graphArray[i].spadUnitY),floatSize);
+ readViewman(&(graphArray[i].unitX),floatSize);
+ readViewman(&(graphArray[i].unitY),floatSize);
+ 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");
+ exitWithAck(RootWindow(dsply,scrn),Window,-1);
+ }
+ llPtr->listOfPoints = p; /** point to current point list **/
+ for (k=0; k<llPtr->numberOfPoints; k++) {
+ readViewman(&(p->x),floatSize);
+ readViewman(&(p->y),floatSize);
+ readViewman(&(p->hue),floatSize);
+ readViewman(&(p->shade),floatSize);
+ p++;
+ } /* for k in list of points */
+ 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);
+ readViewman(&(graphStateArray[i].deltaX),floatSize);
+ readViewman(&(graphStateArray[i].deltaY),floatSize);
+ readViewman(&(graphStateArray[i].pointsOn),intSize);
+ readViewman(&(graphStateArray[i].connectOn),intSize);
+ readViewman(&(graphStateArray[i].splineOn),intSize);
+ readViewman(&(graphStateArray[i].axesOn),intSize);
+ readViewman(&(graphStateArray[i].axesColor),intSize);
+ readViewman(&(graphStateArray[i].unitsOn),intSize);
+ readViewman(&(graphStateArray[i].unitsColor),intSize);
+ 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");
+ 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");
+ 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");
+ exitWithAck(RootWindow(dsply,scrn),Window,-1);
+ }
+
+} /* getGraphFromViewman */
+
+
+
+void
+#ifdef _NO_PROTO
+freeGraph(i)
+int i;
+#else
+freeGraph(int i)
+#endif
+{
+ int j;
+ pointListStruct *llPtr;
+
+ if (graphArray[i].key) {
+ graphArray[i].key = 0; /* 0 means no graph */
+ for (j=0,llPtr=graphArray[i].listOfListsOfPoints;
+ j<graphArray[i].numberOfLists; j++,llPtr++)
+ free(llPtr->listOfPoints);
+ free(llPtr);
+ free(xPointsArray[i].xPoint);
+ } else {
+ }
+
+}
+@
+\eject
+\begin{thebibliography}{99}
+\bibitem{1} nothing
+\end{thebibliography}
+\end{document}
diff --git a/src/graph/view2D/header2.h b/src/graph/view2D/header2.h
new file mode 100755
index 00000000..b6b37848
--- /dev/null
+++ b/src/graph/view2D/header2.h
@@ -0,0 +1,283 @@
+/*
+Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - 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.
+
+ - 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.
+
+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.
+*/
+
+#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" /* Gdraw functions header file */
+
+
+
+#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--;
+
+
+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;
+
+typedef struct _controlPanelStruct {
+ int numOfButtons;
+ Window controlWindow,messageWindow,colormapWindow;
+ char message[40];
+ struct _buttonStruct buttonQueue[maxButtons2D];
+} controlPanelStruct;
+
+typedef struct _mouseCoord {
+ float x,y;
+} mouseCoord;
+
+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;
+
+
+typedef struct _controlXY {
+ int putX,putY;
+} controlXY;
+
+
+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)
+
+#include "globals2.h"
+
diff --git a/src/graph/view2D/main2d.c.pamphlet b/src/graph/view2D/main2d.c.pamphlet
new file mode 100644
index 00000000..71a84071
--- /dev/null
+++ b/src/graph/view2D/main2d.c.pamphlet
@@ -0,0 +1,524 @@
+\documentclass{article}
+\usepackage{axiom}
+\begin{document}
+\title{\$SPAD/src/graph/view2D main2d.c}
+\author{The Axiom Team}
+\maketitle
+\begin{abstract}
+\end{abstract}
+\eject
+\tableofcontents
+\eject
+\section{License}
+<<license>>=
+/*
+Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - 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.
+
+ - 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.
+
+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.
+*/
+@
+<<*>>=
+<<license>>
+
+#define _MAIN2D_C
+#include "axiom-c-macros.h"
+#include "useproto.h"
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <signal.h>
+
+#include "header2.h"
+#include "bsdsignal.h"
+#include "globals2.h"
+#include "bsdsignal.H1"
+#include "all_2d.H1"
+#include "Gfun.H1"
+#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 */
+
+int
+#ifdef _NO_PROTO
+main()
+#else
+main(void)
+#endif
+{
+
+ XGCValues controlGCVals;
+ int i,code;
+ view2DStruct viewData;
+
+ char property[256];
+ char *prop = &property[0];
+ char *str_type[20];
+ XrmValue value;
+
+
+ /**** Set up display ****/
+ 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() */
+
+void
+#ifdef _NO_PROTO
+mergeDatabases()
+#else
+mergeDatabases(void)
+#endif
+{
+ /* using global
+ rDB
+ dsply
+ */
+ 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));
+ else {
+ (void) strcpy(filename,getenv("HOME"));
+ (void) strcat(filename,"/.Xdefaults");
+ serverDB = XrmGetFileDatabase(filename);
+ }
+ XrmMergeDatabases(serverDB,&rDB);
+ if ( getenv ("XENVIRONMENT") == NULL) {
+ int len;
+ (void) strcpy(filename,getenv("HOME"));
+ (void) strcat(filename,"/.Xdefaults-");
+ len = strlen(filename);
+ (void) gethostname(filename+len,1024-len);
+ }
+ else
+ (void) strcpy (filename,getenv ("XENVIRONMENT"));
+
+ homeDB = XrmGetFileDatabase(filename);
+ XrmMergeDatabases(homeDB,&rDB);
+}
+
+@
+\eject
+\begin{thebibliography}{99}
+\bibitem{1} nothing
+\end{thebibliography}
+\end{document}
diff --git a/src/graph/view2D/pot2d.c.pamphlet b/src/graph/view2D/pot2d.c.pamphlet
new file mode 100644
index 00000000..8aef8bf1
--- /dev/null
+++ b/src/graph/view2D/pot2d.c.pamphlet
@@ -0,0 +1,84 @@
+\documentclass{article}
+\usepackage{axiom}
+\begin{document}
+\title{\$SPAD/src/graph/view2D pot2d.c}
+\author{The Axiom Team}
+\maketitle
+\begin{abstract}
+\end{abstract}
+\eject
+\tableofcontents
+\eject
+\section{License}
+<<license>>=
+/*
+Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - 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.
+
+ - 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.
+
+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.
+*/
+@
+<<*>>=
+<<license>>
+
+#define _POT2D_C
+#include "axiom-c-macros.h"
+#include "useproto.h"
+
+#include "header2.h"
+
+#include "all_2d.H1"
+
+mouseCoord
+#ifdef _NO_PROTO
+getPotValue(eX,eY,xH,yH)
+ short eX,eY,xH,yH;
+#else
+getPotValue(short eX,short eY,short xH,short yH)
+#endif
+{
+
+ 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() */
+@
+\eject
+\begin{thebibliography}{99}
+\bibitem{1} nothing
+\end{thebibliography}
+\end{document}
diff --git a/src/graph/view2D/process2d.c.pamphlet b/src/graph/view2D/process2d.c.pamphlet
new file mode 100644
index 00000000..c8b91811
--- /dev/null
+++ b/src/graph/view2D/process2d.c.pamphlet
@@ -0,0 +1,959 @@
+\documentclass{article}
+\usepackage{axiom}
+\begin{document}
+\title{\$SPAD/src/graph/view2D process2d.c}
+\author{The Axiom Team}
+\maketitle
+\begin{abstract}
+\end{abstract}
+\eject
+\tableofcontents
+\eject
+\section{License}
+<<license>>=
+/*
+Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - 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.
+
+ - 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.
+
+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.
+*/
+@
+<<*>>=
+<<license>>
+
+#define _PROCESS2D_C
+#include "axiom-c-macros.h"
+#include "useproto.h"
+
+#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
+
+#include "header2.h"
+
+#include "all_2d.H1"
+#include "util.H1"
+#include "Gfun.H1"
+#include "XSpadFill.H1"
+
+
+static int doit=0; /* globish variable for picking/dropping/clearing - all sorts of
+ 2 button sequence events (command & graph #). */
+
+
+void
+#ifdef _NO_PROTO
+doPick (i,bKey)
+ int i,bKey;
+#else
+doPick (int i,int bKey)
+#endif
+{
+ int vCommand=pick2D;
+
+ picking = no;
+ /* reset indicator so that we're not in pick/drop/query mode anymore */
+ doit = 0;
+ if (graphArray[currentGraph].key) {
+ check(write(Socket,&vCommand,intSize));
+ check(write(Socket,&(graphArray[currentGraph].key),intSize));
+ check(write(Socket,&(graphStateArray[currentGraph]),
+ sizeof(graphStateStruct)));
+ sprintf(control->message,"%s%d","Picked up graph ",currentGraph+1);
+ } else
+ sprintf(control->message,"%s","This graph is empty!");
+ writeControlMessage();
+
+
+}
+
+
+void
+#ifdef _NO_PROTO
+doDrop (i,bKey)
+ int i,bKey;
+#else
+doDrop (int i,int bKey)
+#endif
+{
+ int vCommand=drop2D;
+ int viewGoAhead;
+
+ dropping = no;
+ /* reset indicator so that we're not in pick/drop/query mode anymore */
+ doit = 0;
+ check(write(Socket,&(vCommand),intSize));
+ readViewman(&viewGoAhead,intSize);
+ if (viewGoAhead < 0) {
+ sprintf(control->message,"%s%d","Couldn't drop to graph ",currentGraph+1);
+ writeControlMessage();
+ } else {
+ sprintf(control->message,"%s%d","Dropped onto graph ",currentGraph+1);
+ writeControlMessage();
+ freeGraph(currentGraph);
+ readViewman(&(graphArray[currentGraph].key),intSize);
+ getGraphFromViewman(currentGraph);
+ /* simulate a button press to turn display number on and select on */
+ /* need !yes since it will be inverted */
+ graphStateArray[currentGraph].selected = no;
+ graphStateArray[currentGraph].showing =
+ !(graphStateArray[currentGraph].showing);
+ clickedOnGraph(currentGraph,currentGraph+graphStart);
+ clickedOnGraphSelect(currentGraph,currentGraph+graphSelectStart);
+ }
+}
+
+void
+#ifdef _NO_PROTO
+clickedOnGraphSelect (i,bKey)
+ int i,bKey;
+#else
+clickedOnGraphSelect (int i,int bKey)
+#endif
+{
+ int strlength;
+
+ switch (doit) {
+ case pick2D:
+ currentGraph = i;
+ doPick(i,bKey);
+ break;
+ case drop2D:
+ currentGraph = i;
+ doDrop(i,bKey);
+ break;
+ case query2D:
+ queriedGraph = i;
+ makeMessageFromData(queriedGraph);
+ writeControlMessage();
+ /* reset indicator so that we're not in pick/drop/query mode anymore */
+ doit = 0;
+ break;
+ default:
+ graphStateArray[i].selected = !(graphStateArray[i].selected);
+ if (graphStateArray[i].selected) {
+ GSetForeground(graphGC,(float)graphBarSelectColor,Xoption);
+ strcpy(control->buttonQueue[bKey].text,"^");
+ strlength = strlen(control->buttonQueue[bKey].text);
+ } else {
+ GSetForeground(graphGC,(float)graphBarNotSelectColor,Xoption);
+ strcpy(control->buttonQueue[bKey].text,"-");
+ strlength = strlen(control->buttonQueue[bKey].text);
+ }
+ /* just to make sure the background is reset from clickedOnGraph */
+ if (mono) {
+ GSetForeground(graphGC,(float)foregroundColor,Xoption);
+ GSetBackground(graphGC,(float)backgroundColor,Xoption);
+ }
+
+ GDrawImageString(graphGC,control->controlWindow,
+ control->buttonQueue[bKey].buttonX +
+ centerX(graphGC,
+ control->buttonQueue[bKey].text,strlength,
+ control->buttonQueue[bKey].buttonWidth),
+ control->buttonQueue[bKey].buttonY +
+ centerY(graphGC,
+ control->buttonQueue[bKey].buttonHeight),
+ control->buttonQueue[bKey].text,strlength,Xoption);
+ GSetForeground(trashGC,(float)foregroundColor,Xoption);
+ GSetLineAttributes(trashGC,2,LineSolid,CapButt,JoinMiter,Xoption);
+ GDrawLine(trashGC,control->controlWindow,0,286,controlWidth,286,Xoption);
+ break;
+ } /* switch doit */
+
+}
+
+
+static void
+#ifndef _NO_PROTO
+drawControlPushButton(int isOn, int index)
+#else
+ drawControlPushButton(isOn,index)
+ int isOn;
+ int index;
+#endif
+{
+ GDrawPushButton(dsply, processGC, processGC, processGC,
+ control->controlWindow,
+ (control->buttonQueue[index]).buttonX,
+ (control->buttonQueue[index]).buttonY,
+ (control->buttonQueue[index]).buttonWidth,
+ (control->buttonQueue[index]).buttonHeight,
+ isOn,
+ (control->buttonQueue[index]).text,
+ buttonColor,
+ monoColor((control->buttonQueue[index]).textColor), Xoption);
+ XSync(dsply,False);
+}
+
+
+
+void
+#ifdef _NO_PROTO
+buttonAction (bKey)
+ int bKey;
+#else
+buttonAction (int bKey)
+#endif
+{
+ int i;
+
+ switch (bKey) {
+
+ case pick2D:
+ if (viewAloned) {
+ sprintf(control->message,"%s","Cannot pick without AXIOM!");
+ writeControlMessage();
+ XSync(dsply,False);
+ }
+ else {
+ doit = pick2D;
+ sprintf(control->message,"%s","Click on the graph to pick");
+ writeControlMessage();
+ XSync(dsply,False);
+ }
+ break;
+
+ case drop2D:
+ if (viewAloned) {
+ sprintf(control->message,"%s","Cannot drop without AXIOM!");
+ writeControlMessage();
+ XSync(dsply,False);
+ } else {
+ doit = drop2D;
+ sprintf(control->message,"%s","Click on the graph to drop");
+ writeControlMessage();
+ 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");
+ else
+ 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");
+ else strcpy((control->buttonQueue[zoom2Dy]).text ,
+ "Y On ");
+ zoomYON = !zoomYON;
+ 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 ");
+ transXON = !transXON;
+ drawControlPushButton(transXON, translate2Dx);
+ XSync(dsply,False);
+ break;
+
+ case translate2Dy:
+ if (transYON) strcpy((control->buttonQueue[translate2Dy]).text,
+ "Y Off");
+ else strcpy( (control->buttonQueue[translate2Dy]).text,
+ "Y On");
+ transYON = !transYON;
+ drawControlPushButton(transYON, translate2Dy);
+ XSync(dsply,False);
+ break;
+
+ case pointsOnOff:
+ if (pointsON) strcpy((control->buttonQueue[pointsOnOff]).text,
+ "Pts Off");
+ else strcpy( (control->buttonQueue[pointsOnOff]).text,
+ "Pts On ");
+ pointsON = !pointsON;
+ 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 ");
+ 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 ");
+ 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");
+ else
+ 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");
+ else
+ 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();
+ drawControlPushButton(0, ps2D);
+ 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,
+ viewport->title) == psError) {
+ strcpy(control->message,"Aborted: PSCreateFile error.");
+ writeControlMessage();
+ drawControlPushButton(0, ps2D);
+ XSync(dsply,False);
+ return;
+ }
+
+ clearControlMessage();
+ strcpy(control->message,PSfilename);
+ strcat(control->message," in working dir ");
+ writeControlMessage();
+ drawControlPushButton(0, ps2D);
+ XSync(dsply,False);
+ break;
+
+ case hideControl2D:
+ if (viewport->haveControl) {
+ viewport->haveControl = no;
+ XUnmapWindow(dsply,control->controlWindow);
+ 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++)
+ if (graphStateArray[i].showing && graphStateArray[i].selected)
+ graphStateArray[i].splineOn = splineON;
+ drawControlPushButton(splineON, spline2D);
+ drawViewport(Xoption);
+
+ break;
+
+ case closeAll2D:
+ strcpy(control->message," Click again to confirm ");
+ writeControlMessage();
+ drawControlPushButton(1, closeAll2D);
+ XSync(dsply,False);
+ viewport->closing = yes;
+ break;
+
+ case clear2D:
+ for (i=0; i<maxGraphs; i++) graphStateArray[i].selected = 1;
+ clickedOnGraphSelect(0,graphSelect1);
+ clickedOnGraphSelect(1,graphSelect2);
+ clickedOnGraphSelect(2,graphSelect3);
+ clickedOnGraphSelect(3,graphSelect4);
+ clickedOnGraphSelect(4,graphSelect5);
+ clickedOnGraphSelect(5,graphSelect6);
+ clickedOnGraphSelect(6,graphSelect7);
+ clickedOnGraphSelect(7,graphSelect8);
+ clickedOnGraphSelect(8,graphSelect9);
+ XSync(dsply,False);
+ break;
+
+ case graph1:
+ case graph2:
+ case graph3:
+ case graph4:
+ case graph5:
+ case graph6:
+ case graph7:
+ case graph8:
+ case graph9:
+ clickedOnGraph(bKey-graphStart,bKey);
+ XSync(dsply,False);
+ break;
+
+ case graphSelect1:
+ case graphSelect2:
+ case graphSelect3:
+ case graphSelect4:
+ case graphSelect5:
+ case graphSelect6:
+ case graphSelect7:
+ case graphSelect8:
+ case graphSelect9:
+ clickedOnGraphSelect(bKey-graphSelectStart,bKey);
+ XSync(dsply,False);
+ break;
+
+ } /* switch (action) */
+}
+
+/*********************** X Event Processing ***************************/
+void
+#ifdef _NO_PROTO
+processEvents()
+#else
+processEvents(void)
+#endif
+{
+
+ XEvent *event,
+ tempEvent;
+ Window whichWindow;
+ XWindowAttributes graphWindowAttrib;
+ buttonStruct *controlButton;
+ mouseCoord mouseXY;
+ int i,
+ someInt,
+ mouseW4,
+ mouseH4,
+ toggleReady,
+ gotToggle = no,
+ checkButton = no,
+ firstTime = yes,
+ gotEvent = 0,
+ buttonTablePtr,
+ Xcon,
+ 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;
+ }
+ if (!followMouse)
+ len=select(FD_SETSIZE,(void *) &rd,0,0,0);
+ else
+ len=1;
+ }
+ if (FD_ISSET(Xcon,&rd)||
+ XEventsQueued(dsply, QueuedAfterFlush) ||
+ followMouse) {
+
+ if (followMouse) {
+ if (XPending(dsply))
+ XNextEvent(dsply,event);
+ gotEvent++;
+ } else {
+ 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);
+ }
+ else {
+ fprintf(stderr,"Unknown Client Message ...\n");
+ }
+ break;
+ case Expose:
+ if (whichWindow == viewport->titleWindow) {
+ /* get rid of redundant events */
+ XCheckWindowEvent(dsply,
+ viewport->titleWindow,
+ ExposureMask,
+ &tempEvent);
+ writeTitle();
+ XGetWindowAttributes(dsply,
+ whichWindow,
+ &graphWindowAttrib);
+ XResizeWindow(dsply,
+ viewport->viewWindow,
+ graphWindowAttrib.width,
+ graphWindowAttrib.height-titleHeight);
+ XSync(dsply,False);
+ break;
+ } else if (whichWindow == viewport->viewWindow) {
+ XCheckWindowEvent(dsply,
+ viewport->viewWindow,
+ ExposureMask,
+ &tempEvent);
+ XGetWindowAttributes(dsply,
+ viewport->titleWindow,
+ &graphWindowAttrib);
+ XResizeWindow(dsply,
+ viewport->viewWindow,
+ graphWindowAttrib.width,
+ graphWindowAttrib.height-titleHeight);
+ drawViewport(Xoption);
+ XMapWindow(dsply,whichWindow);
+ XSync(dsply,False);
+ break;
+ } else { /* it's gotta be the control panel */
+ XGetWindowAttributes(dsply,
+ control->controlWindow,
+ &graphWindowAttrib);
+ /* do not allow resizing of control panel */
+ if ((graphWindowAttrib.width != controlWidth) ||
+ (graphWindowAttrib.height != controlHeight)) {
+ XResizeWindow(dsply,
+ control->controlWindow,
+ controlWidth,
+ controlHeight);
+ }
+ drawControlPanel();
+ XSync(dsply,False);
+ break;
+ }
+ break;
+
+ case MotionNotify:
+ if (followMouse) {
+ while (XCheckMaskEvent(dsply,
+ ButtonMotionMask,
+ event));
+ mouseXY = getPotValue(((XButtonEvent *)event)->x,
+ ((XButtonEvent *)event)->y,
+ controlButton->xHalf,
+ controlButton->yHalf);
+ }
+ if (controlButton->pot) {
+ gotToggle = no;
+ checkButton = yes;
+ }
+ break;
+
+ case ButtonRelease:
+ if (followMouse==yes) {
+ followMouse = no;
+ toggleReady = yes;
+ checkButton = no;
+ drawViewport(Xoption);
+ } else {
+ followMouse = no;
+ toggleReady = yes;
+ checkButton = no;
+ }
+ break;
+
+ case LeaveNotify:
+ /*
+ We still follow the mouse when we leave the pots.
+ */
+ /*
+ followMouse = no;
+ 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);
+ sprintf(viewport->controlPanel->message,
+ " >%d<: [%6.2f,%6.2f] ",
+ queriedGraph+1,
+ projX((((XButtonEvent *)event)->x),
+ graphWindowAttrib.width,queriedGraph),
+ projY((((XButtonEvent *)event)->y),
+ graphWindowAttrib.height,queriedGraph));
+ writeControlMessage();
+ XFlush(dsply);
+ break;
+ default:
+
+ /* Find where mouse is on the viewport => where to put the CP */
+
+ XGetWindowAttributes(dsply,
+ whichWindow,
+ &graphWindowAttrib);
+ mouseW4 = graphWindowAttrib.width/4;
+ if (((XButtonEvent *)event)->x >
+ (graphWindowAttrib.width - mouseW4))
+ someInt = 1;
+ else {
+ mouseH4 = graphWindowAttrib.height/4;
+ if (((XButtonEvent *)event)->y >
+ (graphWindowAttrib.height - mouseH4))
+ someInt = 2;
+ else if (((XButtonEvent *)event)->x < mouseW4)
+ someInt = 3;
+ else if (((XButtonEvent *)event)->y < mouseH4)
+ someInt = 4;
+ else someInt = 0;
+ }
+ if (viewport->haveControl) {
+ XUnmapWindow(dsply,control->controlWindow);
+ }
+ putControlPanelSomewhere(someInt);
+ XMapWindow(dsply,control->controlWindow);
+ XSync(dsply,False);
+ 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,
+ ((XButtonEvent *)event)->y,
+ controlButton->xHalf,
+ controlButton->yHalf);
+ followMouse = yes;
+ gotToggle = no;
+ } else {
+ followMouse = no;
+ gotToggle = yes; /* auto-repeat on toggle buttons not allowed */
+ if (toggleReady) {
+ toggleReady = no;
+ }
+ }
+ checkButton = yes;
+ 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;
+ }
+ if (checkButton) {
+ if (viewport->closing && (controlButton->buttonKey == closeAll2D)) {
+ goodbye(-1);
+ } else {
+ clearControlMessage();
+ viewport->closing = no;
+ drawControlPushButton(0, closeAll2D);
+ if ((doit) &&
+ ((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) {
+ if (transXON) {
+ graphStateArray[i].centerX -= mouseXY.x * 0.1;
+ if (graphStateArray[i].centerX > maxDelta)
+ graphStateArray[i].centerX = maxDelta;
+ else if (graphStateArray[i].centerX < -maxDelta)
+ graphStateArray[i].centerX = maxDelta;
+ }
+ if (transYON) {
+ graphStateArray[i].centerY -= mouseXY.y * 0.1;
+ if (graphStateArray[i].centerY > maxDelta)
+ graphStateArray[i].centerY = maxDelta;
+ else if (graphStateArray[i].centerY < -maxDelta)
+ graphStateArray[i].centerY = maxDelta;
+ }
+ } /* graph showing or selected */
+ } /* for graphs */
+ drawViewport(Xoption);
+ break;
+
+ case scale2D:
+ for (i=0; i<maxGraphs; i++) {
+ if (graphStateArray[i].showing && graphStateArray[i].selected) {
+ if (zoomXON) {
+ graphStateArray[i].scaleX *= (1 - mouseXY.y * 0.3);
+ if (graphStateArray[i].scaleX > maxScale)
+ graphStateArray[i].scaleX = maxScale;
+ else if (graphStateArray[i].scaleX < minScale)
+ graphStateArray[i].scaleX = minScale;
+ }
+ if (zoomYON) {
+ graphStateArray[i].scaleY *= (1 - mouseXY.y * 0.3);
+ if (graphStateArray[i].scaleY > maxScale)
+ graphStateArray[i].scaleY = maxScale;
+ else if (graphStateArray[i].scaleY < minScale)
+ graphStateArray[i].scaleY = minScale;
+ }
+ } /* graph showing or selected */
+ } /* for graphs */
+ drawViewport(Xoption);
+ break;
+
+ default:
+ buttonAction(controlButton->buttonKey);
+ } /* switch on buttonKey */
+ } /* else - not closing */
+ } /* if checkButton */
+ } /* if FD_ISSET(Xcon.... */
+ else if FD_ISSET(0,&rd) {
+ externalControl=spadAction(); /* returns (-1) if broken ,0 if success */
+ if (spadDraw && (externalControl==0)) drawViewport(Xoption);
+ }
+ } /* while */
+} /* processEvents() */
+
+
+
+
+
+
+void
+#ifdef _NO_PROTO
+clickedOnGraph (i,bKey)
+ int i,bKey;
+#else
+clickedOnGraph (int i,int bKey)
+#endif
+{
+
+ switch (doit) {
+ case pick2D:
+ currentGraph = queriedGraph = i;
+ doPick(i,bKey);
+ break;
+ case drop2D:
+ currentGraph = queriedGraph = i;
+ doDrop(i,bKey);
+ break;
+ case query2D:
+ queriedGraph = i;
+ makeMessageFromData(queriedGraph);
+ writeControlMessage();
+ /* reset indicator so that we're not in pick/drop/query mode anymore */
+ doit = 0;
+ break;
+ default:
+ graphStateArray[i].showing = !(graphStateArray[i].showing);
+ if (mono) {
+ if (graphStateArray[i].showing) {
+ GSetForeground(graphGC,(float)backgroundColor,Xoption);
+ GSetBackground(graphGC,(float)foregroundColor,Xoption);
+ } else {
+ GSetForeground(graphGC,(float)foregroundColor,Xoption);
+ 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);
+ } else {
+ if (graphStateArray[i].showing)
+ GSetForeground(graphGC,(float)graphBarShowingColor,Xoption);
+ else
+ GSetForeground(graphGC,(float)graphBarHiddenColor,Xoption);
+ GDrawString(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);
+ }
+ drawViewport(Xoption);
+ break;
+ } /* switch doit */
+
+}
+
+
+
+
+
+
+
+
+
+@
+\eject
+\begin{thebibliography}{99}
+\bibitem{1} nothing
+\end{thebibliography}
+\end{document}
diff --git a/src/graph/view2D/spadAction2d.c.pamphlet b/src/graph/view2D/spadAction2d.c.pamphlet
new file mode 100644
index 00000000..28f3e749
--- /dev/null
+++ b/src/graph/view2D/spadAction2d.c.pamphlet
@@ -0,0 +1,320 @@
+\documentclass{article}
+\usepackage{axiom}
+\begin{document}
+\title{\$SPAD/src/graph/view2D spadAction2d.c}
+\author{The Axiom Team}
+\maketitle
+\begin{abstract}
+\end{abstract}
+\eject
+\tableofcontents
+\eject
+\section{License}
+<<license>>=
+/*
+Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - 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.
+
+ - 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.
+
+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.
+*/
+@
+<<*>>=
+<<license>>
+
+#define _SPADACTION2D_C
+#include "axiom-c-macros.h"
+#include "useproto.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "header2.h"
+
+#include "all_2d.H1"
+#include "util.H1"
+
+
+/******************************
+ * int readViewman(info,size) *
+ ******************************/
+
+int
+#ifdef _NO_PROTO
+readViewman(info,size)
+ void *info;
+ int size;
+#else
+readViewman(void * info,int size)
+#endif
+{
+ 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
+#ifdef _NO_PROTO
+spadAction()
+#else
+spadAction(void)
+#endif
+{
+ 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 */
+ if (viewport->haveControl) XUnmapWindow(dsply,control->controlWindow);
+ putControlPanelSomewhere(someInt);
+ } else { /* turn off control panel */
+ if (viewport->haveControl) {
+ viewport->haveControl = no;
+ XUnmapWindow(dsply,control->controlWindow);
+ }
+ }
+ break;
+
+ case changeTitle:
+ readViewman(&i1,intSize);
+ readViewman(viewport->title,i1);
+ viewport->title[i1] = '\0';
+ writeTitle();
+ writeControlTitle();
+ XFlush(dsply);
+ spadDraw=no;
+ break;
+
+ case writeView:
+ readViewman(&i1,intSize);
+ readViewman(filename,i1);
+ filename[i1] = '\0';
+ sprintf(errorStr,"writing of viewport data");
+ i3 = 0;
+ readViewman(&i2,intSize);
+ while (i2) {
+ i3 = i3 | (1<<i2);
+ readViewman(&i2,intSize);
+ }
+ 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--;
+ readViewman(&i2,intSize);
+ graphStateArray[i1].axesOn = i2;
+ if (graphStateArray[i1].showing) spadDraw=yes;
+ break;
+
+ case axesColor2D:
+ readViewman(&i1,intSize);
+ i1--;
+ readViewman(&i2,intSize);
+ graphStateArray[i1].axesColor = i2;
+ if (graphStateArray[i1].showing) spadDraw=yes;
+ break;
+
+ case unitsOnOff2D:
+ readViewman(&i1,intSize);
+ i1--;
+ readViewman(&i2,intSize);
+ graphStateArray[i1].unitsOn = i2;
+ if (graphStateArray[i1].showing) spadDraw=yes;
+ break;
+
+ case unitsColor2D:
+ readViewman(&i1,intSize);
+ i1--;
+ readViewman(&i2,intSize);
+ graphStateArray[i1].unitsColor = i2;
+ if (graphStateArray[i1].showing) spadDraw=yes;
+ break;
+
+ case connectOnOff:
+ readViewman(&i1,intSize);
+ i1--;
+ readViewman(&i2,intSize);
+ graphStateArray[i1].connectOn = i2;
+ if (graphStateArray[i1].showing) spadDraw=yes;
+ break;
+
+ case pointsOnOff:
+ readViewman(&i1,intSize);
+ i1--;
+ readViewman(&i2,intSize);
+ graphStateArray[i1].pointsOn = i2;
+ if (graphStateArray[i1].showing) spadDraw=yes;
+ break;
+
+ case spline2D:
+ readViewman(&i1,intSize);
+ i1--;
+ readViewman(&i2,intSize);
+ graphStateArray[i1].splineOn = i2;
+ if (graphStateArray[i1].showing) spadDraw=yes;
+ break;
+
+ case showing2D:
+ readViewman(&i1,intSize);
+ i1--;
+ readViewman(&i2,intSize);
+ /* simulate a button press to turn display number on/off */
+ 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] */
+ readViewman(&f1,floatSize);
+ readViewman(&f2,floatSize);
+ graphStateArray[i1].scaleX = f1;
+ graphStateArray[i1].scaleY = f2;
+ if (graphStateArray[i1].scaleX > maxScale)
+ graphStateArray[i1].scaleX = maxScale;
+ else
+ if (graphStateArray[i1].scaleX < minScale)
+ graphStateArray[i1].scaleX = minScale;
+ if (graphStateArray[i1].scaleY > maxScale)
+ graphStateArray[i1].scaleY = maxScale;
+ else
+ if (graphStateArray[i1].scaleY < minScale)
+ 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] */
+ readViewman(&f1,floatSize);
+ readViewman(&f2,floatSize);
+ graphStateArray[i1].centerX = f1;
+ graphStateArray[i1].centerY = f2;
+ if (graphStateArray[i1].centerX > maxDelta)
+ graphStateArray[i1].centerX = maxDelta;
+ else if (graphStateArray[i1].centerX < -maxDelta)
+ graphStateArray[i1].centerX = maxDelta;
+ if (graphStateArray[i1].centerY > maxDelta)
+ graphStateArray[i1].centerY = maxDelta;
+ else if (graphStateArray[i1].centerY < -maxDelta)
+ 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);
+ XResizeWindow(dsply,viewport->titleWindow,i1,i2+titleHeight);
+ 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*/
+ readViewman(&viewGoAhead,intSize);
+ if (viewGoAhead < 0) {
+ sprintf(control->message,"%s%d","Couldn't put into graph ",i2+1);
+ writeControlMessage();
+ } else {
+ sprintf(control->message,"%s%d","Dropped onto graph ",i2+1);
+ writeControlMessage();
+ freeGraph(i2);
+ graphArray[i2].key = i1;
+ getGraphFromViewman(i2);
+ /* simulate a button press to turn display number on and select on */
+ /* need !yes since it will be inverted */
+ graphStateArray[i2].selected = no;
+ graphStateArray[i2].connectOn = yes;
+ graphStateArray[i2].showing = !(graphStateArray[i2].showing);
+ clickedOnGraph(i2,i2+graphStart);
+ 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);
+
+}
+
+@
+\eject
+\begin{thebibliography}{99}
+\bibitem{1} nothing
+\end{thebibliography}
+\end{document}
diff --git a/src/graph/view2D/stuff2d.c.pamphlet b/src/graph/view2D/stuff2d.c.pamphlet
new file mode 100644
index 00000000..f4796fa4
--- /dev/null
+++ b/src/graph/view2D/stuff2d.c.pamphlet
@@ -0,0 +1,146 @@
+\documentclass{article}
+\usepackage{axiom}
+\begin{document}
+\title{\$SPAD/src/graph/view2D stuff2d.c}
+\author{The Axiom Team}
+\maketitle
+\begin{abstract}
+\end{abstract}
+\eject
+\tableofcontents
+\eject
+\section{License}
+<<license>>=
+/*
+Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - 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.
+
+ - 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.
+
+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.
+*/
+@
+<<*>>=
+<<license>>
+
+#define _STUFF2D_C
+#include "axiom-c-macros.h"
+#include "useproto.h"
+
+#include <unistd.h>
+#include <stdlib.h>
+
+#include "header2.h"
+
+#include "all_2d.H1"
+#include "Gfun.H1"
+#include "util.H1"
+
+
+/**************************/
+/*** float absolute(x) ***/
+/**************************/
+
+float
+#ifdef _NO_PROTO
+absolute(x)
+ float x;
+#else
+absolute(float x)
+#endif
+{
+ if (x<0.0) {
+ return(-x);
+ } else {
+ return(x);
+ }
+}
+
+
+
+/************************/
+/*** void goodbye() ***/
+/************************/
+
+void
+#ifdef _NO_PROTO
+goodbye(sig)
+int sig;
+#else
+goodbye(int sig)
+#endif
+{
+ 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);
+ XFreeGC(dsply,trashGC);
+ XFreeGC(dsply,anotherGC);
+ 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);
+
+}
+
+
+
+
+
+
+@
+\eject
+\begin{thebibliography}{99}
+\bibitem{1} nothing
+\end{thebibliography}
+\end{document}
diff --git a/src/graph/view2D/viewport2D.c.pamphlet b/src/graph/view2D/viewport2D.c.pamphlet
new file mode 100644
index 00000000..20273fb9
--- /dev/null
+++ b/src/graph/view2D/viewport2D.c.pamphlet
@@ -0,0 +1,734 @@
+\documentclass{article}
+\usepackage{axiom}
+\begin{document}
+\title{\$SPAD/src/graph/view2D viewport2D}
+\author{The Axiom Team}
+\maketitle
+\begin{abstract}
+\end{abstract}
+\eject
+\tableofcontents
+\eject
+\section{License}
+<<license>>=
+/*
+Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - 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.
+
+ - 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.
+
+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.
+*/
+@
+<<*>>=
+<<license>>
+
+#define _VIEWPORT2D_C
+#include "axiom-c-macros.h"
+#include "useproto.h"
+
+#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)
+
+#include "header2.h"
+
+#include "all_2d.H1"
+#include "Gfun.H1"
+#include "util.H1"
+#include "XSpadFill.H1"
+
+#include "spadBitmap.bitmap"
+#include "spadMask.mask"
+
+#define rint(z) ((int)(z))
+
+Atom wm_delete_window;
+
+
+/***************************
+ *** void writeTitle() ***
+ ***************************/
+
+void
+#ifdef _NO_PROTO
+writeTitle()
+#else
+writeTitle(void)
+#endif
+{
+
+ int strlength;
+ XWindowAttributes attribInfo;
+
+ XGetWindowAttributes(dsply,viewport->titleWindow,&attribInfo);
+ if (mono) GSetForeground(anotherGC,(float)foregroundColor,Xoption);
+ else GSetForeground(anotherGC,(float)titleColor,Xoption);
+ XClearWindow(dsply,viewport->titleWindow); /* it's behind the viewWindow */
+ strlength = strlen(viewport->title);
+ GDrawImageString(anotherGC,viewport->titleWindow,
+ centerX(anotherGC,viewport->title,strlength,attribInfo.width),
+ 15,viewport->title,strlength,Xoption);
+
+}
+
+
+/********************************/
+/*** void drawTheViewport() ***/
+/********************************/
+
+void
+#ifdef _NO_PROTO
+drawTheViewport(dFlag)
+int dFlag; /* display flag: X, PS,... */
+#else
+drawTheViewport(int dFlag)
+#endif
+{
+
+ Window vw;
+ XWindowAttributes vwInfo;
+ pointListStruct *aList;
+ pointStruct *aPoint;
+ XPoint *anXPoint,*tempXpt;
+ XArc *anXarc;
+ Vertex *anX10Point;
+ float jj,diffX, diffY, tickStart,oneTickUnit;
+ int i,j,k,ii,halfSize;
+ int charlength,strlength,halflength,halfheight;
+ int ptX,ptY,ptX1,ptY1,clipped, clipped1;
+ int xAxis,yAxis,dummyInt, ascent, descent;
+ 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));
+ yAxis= rint(vwInfo.height * aspectR *
+ (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,
+ vwInfo.width,yAxis,
+ dFlag);
+ if ((xAxis >=0) && (xAxis <= vwInfo.width))
+ GDrawLine(globalGC1,vw,
+ xAxis,0,
+ 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)
+ graphStateArray[0].scaleY = 99.0;
+ if (i > 0) {
+ if (isNaN(aPoint->x)) {
+ anXPoint->x = anX10Point->x = NotPoint;
+ }
+ else {
+ diffX = graphArray[i].xmax-graphArray[i].xmin;
+ anXPoint->x = anX10Point->x = vwInfo.width *
+ ((aPoint->x * diffX/(graphArray[0].xmax-graphArray[0].xmin)
+ + (graphArray[0].originX - graphArray[i].originX*diffX /
+ (graphArray[0].xmax-graphArray[0].xmin))
+ - graphStateArray[0].centerX)*graphStateArray[i].scaleX+0.5);
+ }
+ if (isNaN(aPoint->y)) {
+ anXPoint->y = anX10Point->y = NotPoint;
+ }
+ else {
+ diffY = graphArray[i].ymax-graphArray[i].ymin;
+ anXPoint->y = anX10Point->y = vwInfo.height * aspectR *
+ (1 - ((aPoint->y * diffY/(graphArray[0].ymax-graphArray[0].ymin)
+ + (graphArray[0].originY - graphArray[i].originY* diffY/
+ (graphArray[0].ymax-graphArray[0].ymin))*aspectR
+ - graphStateArray[0].centerY) *
+ graphStateArray[i].scaleY + 0.5*aspectR));
+ }
+ } else {
+ if (isNaN(aPoint->x)) {
+ anXPoint->x = anX10Point->x = NotPoint;
+ }
+ else {
+ anXPoint->x = anX10Point->x = vwInfo.width *
+ ((aPoint->x - graphStateArray[i].centerX) *
+ graphStateArray[i].scaleX + 0.5);
+ }
+ if (isNaN(aPoint->y)) {
+ anXPoint->y = anX10Point->y = NotPoint;
+ }
+ else {
+ anXPoint->y = anX10Point->y = vwInfo.height * aspectR *
+ (1 - ((aPoint->y - graphStateArray[i].centerY) *
+ graphStateArray[i].scaleY + 0.5*aspectR));
+ }
+ }
+
+ /* first or last point */
+ if (k == 0 || k == (aList->numberOfPoints - 1)) {
+ anX10Point->flags = 0;
+ } else {
+ anX10Point->flags = VertexCurved;
+ }
+
+ anXPoint++;
+ anX10Point++;
+ anXarc++;
+ } /* for aPoint in pointList */
+
+ aPoint--; /* make it legal, the last one*/
+ if (graphStateArray[i].connectOn || graphStateArray[i].pointsOn) {
+ halfSize = aList->pointSize/2;
+ ptX = tempXpt->x;
+ ptY = tempXpt->y;
+ clipped = ptX > vwInfo.x && ptX < vwInfo.width &&
+ ptY > 0 && ptY < vwInfo.height;
+ if (graphStateArray[i].pointsOn) {
+ if (dFlag==Xoption) {
+ if (mono) {
+ GSetForeground(globalGC1,
+ (float)monoColor((int)(aPoint->hue)),
+ dFlag);
+ } else {
+ GSetForeground(globalGC1,
+ (float)XSolidColor((int)(aPoint->hue),
+ (int)(aPoint->shade)),
+ dFlag);
+ }
+ }
+ if (clipped && !eqNANQ(ptX) && !eqNANQ(ptY))
+ GFillArc(globalGC1,vw,ptX-halfSize,
+ ptY-halfSize,aList->pointSize,aList->pointSize,
+ 0,360*64, dFlag);
+
+ } /* if points on */
+ for (ii=0, aPoint=aList->listOfPoints;
+ ii<aList->numberOfPoints;
+ ++ii, ++tempXpt, ++aPoint) {
+ ptX1 = tempXpt->x;
+ ptY1 = tempXpt->y;
+ clipped1 = ptX1 > vwInfo.x && ptX1 < vwInfo.width &&
+ ptY1 > 0 && ptY1 < vwInfo.height;
+ if (graphStateArray[i].connectOn) {
+ if (dFlag==Xoption) {
+ if (mono) {
+ GSetForeground(globalGC1,
+ (float)monoColor((int)(aList->lineColor-1)/5),
+ dFlag);
+ } else {
+ GSetForeground(globalGC1,
+ (float)XSolidColor((int)(aList->lineColor-1)/5,
+ (int)((aList->lineColor-1)%5)/2),
+ dFlag);
+ }
+ } /* if X */
+ if ((clipped || clipped1) && !eqNANQ(ptX) && !eqNANQ(ptY) &&
+ !eqNANQ(ptX1) && !eqNANQ(ptY1))
+ GDrawLine(globalGC1,vw,
+ ptX,ptY,ptX1,ptY1,
+ dFlag);
+ } /* if lines on */
+ if (graphStateArray[i].pointsOn) {
+ if (dFlag==Xoption) {
+ if (mono) {
+ GSetForeground(globalGC1,
+ (float)monoColor((int)(aPoint->hue)),
+ dFlag);
+ } else {
+ GSetForeground(globalGC1,
+ (float)XSolidColor((int)(aPoint->hue),
+ (int)(aPoint->shade)),
+ dFlag);
+ }
+ }
+ if (clipped1 && !eqNANQ(ptX1) && !eqNANQ(ptY1))
+ GFillArc(globalGC1,vw,ptX1-halfSize,
+ ptY1-halfSize,aList->pointSize,aList->pointSize,
+ 0,360*64, dFlag);
+ } /* if points on */
+ ptX = ptX1; ptY = ptY1; clipped = clipped1;
+ } /* for all points */
+ } /* if points or lines on */
+
+ if (graphStateArray[i].splineOn) { /* need spline color as well */
+ if (dFlag==Xoption) /* do only for X, ps uses default of black */
+ GSetForeground(globalGC1,
+ (float)monoColor(148),
+ dFlag);
+ boxX = vwInfo.width *
+ ((-0.5 - graphStateArray[i].centerX)*
+ graphStateArray[i].scaleX + 0.5);
+ 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) {
+ /* do only for X, ps uses default of black */
+ if (dFlag==Xoption)
+ 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 */
+ k = floor(unitWidth/oneTickUnit) +1; /* get skipping integer */
+ for (ii=0, jj = tickStart;
+ jj < vwInfo.width;
+ ii=ii+k,jj =jj+k* oneTickUnit) {
+ if (jj >= 0) {
+
+ /* ticks stuck to viewport*/
+ 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);
+ /* 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);
+
+ 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);
+ /* 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 */
+ 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 */
+ /*
+ GDrawLine(unitGC,vw,
+ vwInfo.width-6,(int)rint(jj),
+ vwInfo.width-2,(int)rint(jj),dFlag);
+ */
+ /* on the left */
+ GDrawLine(unitGC,vw,
+ 2,(int)rint(jj),
+ 6,(int)rint(jj),
+ dFlag);
+ sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitY);
+ strlength=strlen(aunit);
+ XTextExtents(unitFont,aunit,strlength,&dummyInt,
+ &ascent,&descent,&overall);
+ halflength=overall.width; /* let's reuse that variable */
+
+ if(dFlag == Xoption){
+ /* on the right */
+ /*
+ GDrawImageString(unitGC, vw,
+ vwInfo.width-halflength -6-descent,
+ (int)rint(jj)+ascent/2 ,
+ aunit, strlength, dFlag);
+ */
+ /* on the left */
+ GDrawImageString(unitGC, vw,
+ 8 + charlength/2,
+ (int)rint(jj)+ascent/2 ,
+ aunit, strlength, dFlag);
+ }
+ if(dFlag == PSoption){
+ /* on the right */
+ /*
+ GDrawImageString(unitGC, vw,
+ vwInfo.width - 6 - (strlength*6),
+ (int)rint(jj)+4,
+ aunit, strlength, dFlag);
+ */
+ /* on the left */
+ GDrawImageString(unitGC, vw,
+ 8,(int)rint(jj)+4,
+ aunit, strlength, dFlag);
+ /* these are "eyeball" parameters for the given PS font */
+ }
+ }
+ }
+
+ /* ticks along the negative Y axis */
+
+ for (ii=(-k),jj = tickStart - k*oneTickUnit;
+ jj < vwInfo.height;
+ ii=ii-k,jj =jj-k*oneTickUnit) {
+ if (jj > 0) {
+
+ /* ticks stuck to viewport*/
+ /* on the right */
+ /*
+ GDrawLine(unitGC,vw,
+ vwInfo.width-6,(int)rint(jj),
+ vwInfo.width-2,(int)rint(jj),
+ dFlag);
+ */
+ /* on the left */
+ GDrawLine(unitGC,vw,
+ 2,(int)rint(jj),
+ 6,(int)rint(jj),
+ dFlag);
+
+ sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitY);
+ strlength=strlen(aunit);
+ XTextExtents(unitFont,aunit,strlength,&dummyInt,
+ &ascent,&descent,&overall);
+ halflength=overall.width; /* let's reuse that variable */
+
+ if(dFlag == Xoption){
+ /* on the right */
+ /*
+ GDrawImageString(unitGC, vw,
+ vwInfo.width-halflength -6-descent,
+ (int)rint(jj)+ascent/2 ,
+ aunit, strlength, dFlag);
+ */
+ /* on the left */
+ GDrawImageString(unitGC, vw,
+ 8 + charlength/2,
+ (int)rint(jj)+ascent/2 ,
+ aunit, strlength, dFlag);
+ }
+ if(dFlag == PSoption){
+ /* on the right */
+ /*
+ GDrawImageString(unitGC, vw,
+ vwInfo.width -6 -(strlength*6),
+ (int)rint(jj)+4 ,
+ aunit, strlength, dFlag);
+ */
+ /* on the left */
+ GDrawImageString(unitGC, vw,
+ 8,
+ (int)rint(jj)+4 ,
+ aunit, strlength, dFlag);
+ /* these are "eyeball" parameters for the given PS font */
+ }
+ }
+ }
+
+ } /* 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 */
+ makeMessageFromData(queriedGraph);
+ writeControlMessage();
+ }
+ XFlush(dsply);
+ }
+
+} /* drawViewport() */
+
+
+
+/************************************
+ *** viewPoints *makeViewport() ***
+ ************************************/
+
+viewPoints *
+#ifdef _NO_PROTO
+makeViewport(title,vX,vY,vW,vH,showCP)
+ char *title;
+ int vX,vY,vW,vH,showCP;
+#else
+makeViewport(char *title,int vX,int vY,int vW,int vH,int showCP)
+#endif
+{
+ 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);
+ }
+
+#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;
+ viewport->unitsOn = unitsON;
+ viewport->pointsOn = pointsON;
+ viewport->linesOn = connectON;
+ viewport->splineOn = splineON;
+
+ /**** 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;
+ 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;
+ titleSizeHints.x = vX;
+ titleSizeHints.y = vY;
+ titleSizeHints.width = vW;
+ titleSizeHints.height = vH;
+ } else {
+ titleSizeHints.flags = PSize;
+ 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;
+ viewSizeHints.x = -viewBorderWidth;
+ 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,
+ CopyFromParent,InputOutput,CopyFromParent,
+ viewportCreateMASK,&viewAttrib);
+ 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 *
+#ifdef _NO_PROTO
+makeView2D(viewdata)
+ view2DStruct *viewdata;
+#else
+makeView2D(view2DStruct *viewdata)
+#endif
+{
+ 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) */
+ return(vPoints);
+
+} /* makeView2D */
+
+@
+\eject
+\begin{thebibliography}{99}
+\bibitem{1} nothing
+\end{thebibliography}
+\end{document}
diff --git a/src/graph/view2D/write2d.c.pamphlet b/src/graph/view2D/write2d.c.pamphlet
new file mode 100644
index 00000000..3d91a517
--- /dev/null
+++ b/src/graph/view2D/write2d.c.pamphlet
@@ -0,0 +1,226 @@
+\documentclass{article}
+\usepackage{axiom}
+\begin{document}
+\title{\$SPAD/src/graph/view2D write2d.c}
+\author{The Axiom Team}
+\maketitle
+\begin{abstract}
+\end{abstract}
+\eject
+\tableofcontents
+\eject
+\section{License}
+<<license>>=
+/*
+Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - 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.
+
+ - 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.
+
+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.
+*/
+@
+<<*>>=
+<<license>>
+
+#define _WRITE2D_C
+#include "axiom-c-macros.h"
+#include "useproto.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "header2.h"
+#include "write.h"
+
+#include "all_2d.H1"
+#include "pixmap.H1"
+#include "Gfun.H1"
+
+
+#define numBits (8*sizeof(int))
+
+int
+#ifdef _NO_PROTO
+writeViewport(thingsToWrite)
+ int thingsToWrite;
+#else
+writeViewport(int thingsToWrite)
+#endif
+{
+
+ FILE *viewDataFile;
+ char viewDirName[80],
+ viewBitmapFilename[80],viewDataFilename[80],command[80];
+ int i,j,k,code,ii;
+ 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");
+ code = system(command);
+ sprintf(command,"%s%s%s","mkdir ",viewDirName," > /dev/null 2>&1");
+ if (system(command)) {
+ 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) {
+ fprintf(stderr," Error: Cannot create %s\n",viewDataFilename);
+ perror("fopen");
+ return(-1);
+ } else {
+ /*** write out the view2DStruct stuff ***/
+ fprintf(viewDataFile,"%d\n",view2DType);
+ fprintf(viewDataFile,"%s\n",viewport->title);
+ fprintf(viewDataFile,"%d %d %d %d\n",vwInfo.x,vwInfo.y,
+ vwInfo.width,vwInfo.height);
+ for (i=0; i<maxGraphs; i++) {
+ fprintf(viewDataFile,"%d\n",graphArray[i].key);
+ fprintf(viewDataFile,"%g %g\n",
+ graphStateArray[i].scaleX,graphStateArray[i].scaleY);
+ fprintf(viewDataFile,"%g %g\n",
+ graphStateArray[i].deltaX,graphStateArray[i].deltaY);
+ fprintf(viewDataFile,"%g %g\n",
+ graphStateArray[i].centerX,graphStateArray[i].centerY);
+ fprintf(viewDataFile,"%d %d %d %d %d %d %d\n",
+ graphStateArray[i].pointsOn,graphStateArray[i].connectOn,
+ graphStateArray[i].splineOn,
+ graphStateArray[i].axesOn, graphStateArray[i].axesColor,
+ graphStateArray[i].unitsOn, graphStateArray[i].unitsColor);
+ fprintf(viewDataFile,"%d %d\n",
+ graphStateArray[i].showing,graphStateArray[i].selected);
+ }
+ fclose(viewDataFile);
+ for (i=0; i<maxGraphs; i++) {
+ if (graphArray[i].key) {
+ sprintf(viewDataFilename,"%s%s%d",viewDirName,"/graph",i);
+ if ((viewDataFile = fopen(viewDataFilename,"w")) == NULL) {
+ fprintf(stderr," Error: Cannot create %s\n",viewDataFilename);
+ perror("fopen");
+ return(-1);
+ } else {
+ fprintf(viewDataFile,"%g %g %g %g\n",
+ graphArray[i].xmin,graphArray[i].ymin,
+ graphArray[i].xmax,graphArray[i].ymax);
+ fprintf(viewDataFile,"%g %g\n",
+ graphArray[i].xNorm,graphArray[i].yNorm);
+ fprintf(viewDataFile,"%g %g\n",
+ graphArray[i].originX,graphArray[i].originY);
+ fprintf(viewDataFile,"%g %g\n",
+ graphArray[i].spadUnitX,graphArray[i].spadUnitY);
+ fprintf(viewDataFile,"%g %g\n",
+ graphArray[i].unitX,graphArray[i].unitY);
+ fprintf(viewDataFile,"%d\n",graphArray[i].numberOfLists);
+ for (j=0,aList=graphArray[i].listOfListsOfPoints;
+ j<graphArray[i].numberOfLists;
+ j++, aList++) {
+ fprintf(viewDataFile,"%d\n",aList->numberOfPoints);
+ fprintf(viewDataFile,"%d %d %d\n",
+ aList->pointColor,aList->lineColor,aList->pointSize);
+ for (k=0,aPoint=aList->listOfPoints;
+ k<aList->numberOfPoints;
+ k++,aPoint++)
+ fprintf(viewDataFile,"%g %g %g %g\n",
+ aPoint->x,aPoint->y,aPoint->hue,aPoint->shade);
+ } /* for j, aList */
+ fclose(viewDataFile);
+ } /* else graph i */
+ } /* 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:
+ /*** Create the pixmap (bitmaps need leaf name) ***/
+ sprintf(viewBitmapFilename,"%s%s",viewDirName,"/image.xpm");
+ XGetWindowAttributes(dsply,viewport->viewWindow,&vwInfo);
+ write_pixmap_file(dsply,scrn,viewBitmapFilename,
+ viewport->titleWindow,0,0,vwInfo.width,
+ vwInfo.height+titleHeight);
+ break;
+ case Bitmap:
+ /*** Create the bitmap (bitmaps need leaf name) ***/
+ sprintf(viewBitmapFilename,"%s%s",viewDirName,"/image.bm");
+ XGetWindowAttributes(dsply,viewport->viewWindow,&vwInfo);
+ code = XWriteBitmapFile(dsply,viewBitmapFilename,
+ viewport->titleWindow,vwInfo.width,
+ vwInfo.height+vwInfo.border_width+20,-1,-1);
+ break;
+ case Image:
+ /*** Create the pixmap (bitmaps need leaf name) ***/
+ sprintf(viewBitmapFilename,"%s%s",viewDirName,"/image.xpm");
+ XResizeWindow(dsply,viewport->titleWindow,300,300+titleHeight);
+ XResizeWindow(dsply,viewport->viewWindow,300,300);
+ XGetWindowAttributes(dsply,viewport->viewWindow,&vwInfo);
+ drawViewport(Xoption);
+ writeTitle();
+ write_pixmap_file(dsply,scrn,viewBitmapFilename,
+ viewport->titleWindow,0,0,vwInfo.width,
+ vwInfo.height+titleHeight);
+ /*** Create the bitmap (bitmaps need leaf name) ***/
+ mono = 1;
+ drawViewport(Xoption);
+ writeTitle();
+ sprintf(viewBitmapFilename,"%s%s%s",viewDirName,"/","image.bm");
+ code = XWriteBitmapFile(dsply,viewBitmapFilename,
+ viewport->titleWindow,vwInfo.width,
+ vwInfo.height+vwInfo.border_width+20,-1,-1);
+ mono = 0;
+ break;
+
+ case Postscript:
+ /*** Create postscript output for viewport (in axiom2D.ps) ***/
+ sprintf(PSfilename,"%s%s",viewDirName,"/axiom2D.ps");
+ if (PSInit(viewport->viewWindow,viewport->titleWindow) == psError)
+ return (-1);
+ drawViewport(PSoption); /* write new script file in /tmp */
+ if (PSCreateFile(viewBorderWidth,viewport->viewWindow,
+ viewport->titleWindow, viewport->title) == psError)
+ return(-1); /* concat script & proc into axiom2D.ps */
+ break;
+
+ } /* switch on ii */
+ } /* if thingsToWrite >> ii */
+ } /* for ii */
+
+ return(0);
+ } /* else create directory okay */
+
+}
+@
+\eject
+\begin{thebibliography}{99}
+\bibitem{1} nothing
+\end{thebibliography}
+\end{document}