From ab8cc85adde879fb963c94d15675783f2cf4b183 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Tue, 14 Aug 2007 05:14:52 +0000 Subject: Initial population. --- src/graph/viewman/ChangeLog | 64 +++++ src/graph/viewman/Makefile.in | 68 ++++++ src/graph/viewman/Makefile.pamphlet | 97 ++++++++ src/graph/viewman/cleanup.c.pamphlet | 255 ++++++++++++++++++++ src/graph/viewman/fun2D.c.pamphlet | 413 +++++++++++++++++++++++++++++++++ src/graph/viewman/fun3D.c.pamphlet | 396 +++++++++++++++++++++++++++++++ src/graph/viewman/globalsM.h | 53 +++++ src/graph/viewman/make2D.c.pamphlet | 106 +++++++++ src/graph/viewman/make3D.c.pamphlet | 186 +++++++++++++++ src/graph/viewman/makeGraph.c.pamphlet | 165 +++++++++++++ src/graph/viewman/readView.c.pamphlet | 87 +++++++ src/graph/viewman/sselect.c.pamphlet | 124 ++++++++++ src/graph/viewman/viewman.c.pamphlet | 277 ++++++++++++++++++++++ src/graph/viewman/viewman.h | 50 ++++ 14 files changed, 2341 insertions(+) create mode 100644 src/graph/viewman/ChangeLog create mode 100644 src/graph/viewman/Makefile.in create mode 100644 src/graph/viewman/Makefile.pamphlet create mode 100644 src/graph/viewman/cleanup.c.pamphlet create mode 100644 src/graph/viewman/fun2D.c.pamphlet create mode 100644 src/graph/viewman/fun3D.c.pamphlet create mode 100755 src/graph/viewman/globalsM.h create mode 100644 src/graph/viewman/make2D.c.pamphlet create mode 100644 src/graph/viewman/make3D.c.pamphlet create mode 100644 src/graph/viewman/makeGraph.c.pamphlet create mode 100644 src/graph/viewman/readView.c.pamphlet create mode 100644 src/graph/viewman/sselect.c.pamphlet create mode 100644 src/graph/viewman/viewman.c.pamphlet create mode 100755 src/graph/viewman/viewman.h (limited to 'src/graph/viewman') diff --git a/src/graph/viewman/ChangeLog b/src/graph/viewman/ChangeLog new file mode 100644 index 00000000..9ead4e92 --- /dev/null +++ b/src/graph/viewman/ChangeLog @@ -0,0 +1,64 @@ +2007-07-29 Gabriel Dos Reis + + * Makefile.pamphlet: Propagate libtoolization changes. + * Makefile.in: Regenerate. + +2006-11-26 Gabriel Dos Reis + + * cleanup.c.pamphlet: Include axiom-c-macros.h. + * fun2D.c.pamphlet: Likewise. + * fun3D.c.pamphlet: Likewise. + * make2D.c.pamphlet: Likewise. + * make3D.c.pamphlet: Likewise. + * makeGraph.c.pamphlet: Likewise. + * readView.c.pamphlet: Likewise. + * sselect.c.pamphlet: Likewise. + * viewman.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 + + * Makefile.pamphlet (viewman_DEPENDENCIES): Clear. + ($(build_libdir)/libspad.a): Remove rule. + (AXIOM_CFLAGS): New variable. + (%.$(OBJEXT)): Use it. + * Makefile.in: Regenerate. + +2006-11-09 Humberto Ortiz-Zuazaga + + * viewman.c.pamphlet (main): Use SIGHLD on MAC OS X too. + +2006-11-05 Gabriel Dos Reis + + * sselect.c.pamphlet: Sync with silver (revision 247). + +2006-10-08 Gabriel Dos Reis + + * Makefile.pamphlet: Remove references to ${MNT} throughout. + * Makefile.in: Regenerate. + +2006-10-04 Gabriel Dos Reis + + * Makefile.pamphlet (pamphlets): New. + +2006-09-18 Gabriel Dos Reis + + * Makefile.pamphlet: Simplify. + * Makefile.in: Regenerate. + +2006-09-11 Gabriel Dos Reis + + * 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 + + * Makefile.in: New. + +2006-08-06 Gabriel Dos Reis + + * Makefile.pamphlet: Remove explicit mention of X11 and Xpm. diff --git a/src/graph/viewman/Makefile.in b/src/graph/viewman/Makefile.in new file mode 100644 index 00000000..7d02bbed --- /dev/null +++ b/src/graph/viewman/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 = viewman$(EXEEXT) + +viewman_sources = cleanup.c fun2D.c fun3D.c make2D.c make3D.c \ + makeGraph.c readView.c sselect.c viewman.c + +viewman_SOURCES = $(addsuffix .pamphlet, $(viewman_sources)) + +viewman_objects = $(viewman_sources:.c=.lo) + +viewman_headers = $(srcdir)/viewman.h \ + $(addprefix $(axiom_src_srcdir)/graph/include/,\ + component.h view2D.h view3D.h tube.h \ + actions.h viewCommand.h) \ + $(axiom_src_srcdir)/include/com.h + + +viewman_DEPENDENCIES = +viewman_LDFLAGS = $(axiom_target_libdir)/libspad.la + +pamphlets = Makefile.pamphlet $(viewman_SOURCES) + +subdir = src/graph/viewman/ + +AXIOM_CFLAGS = ${CCF} ${AXIOM_X11_CFLAGS} -I${LINC} -I${GINC} -I$(srcdir) \ + $(axiom_includes) + +.PHONY: all all-ax all-viewman +all: all-ax + +all-ax all-viewman: stamp + @ echo 30 finished $(srcdir) + +stamp: $(axiom_target_libdir)/viewman$(EXEEXT) + @rm -f stamp + $(STAMP) stamp + + +.PRECIOUS: %.c +.PRECIOUS: %.lo + +%.lo: $(viewman_HEADERS) + +%.lo: %.c $(axiom_c_macros_h) + $(COMPILE) -o $@ $(CFLAGS) $(AXIOM_CFLAGS) $< + +%.c: $(srcdir)/%.c.pamphlet + $(axiom_build_document) --tangle --output=$@ $< + +$(axiom_target_libdir)/viewman$(EXEEXT): $(viewman_objects) $(viewman_DEPENDENCIES) + $(LINK) -o $@ $(viewman_objects) $(viewman_LDFLAGS) \ + $(AXIOM_X11_LDFLAGS) + +mostlyclean-local: + +clean-local: mostlyclean-local + @rm -f $(viewman_sources) $(viewman_objects) + @rm -f $(axiom_target_libdir)/viewman$(EXEEXT) + +distclean-local: clean-local + diff --git a/src/graph/viewman/Makefile.pamphlet b/src/graph/viewman/Makefile.pamphlet new file mode 100644 index 00000000..ec05317e --- /dev/null +++ b/src/graph/viewman/Makefile.pamphlet @@ -0,0 +1,97 @@ +%% Oh Emacs, this is a -*- Makefile -*-, so give me tabs. +\documentclass{article} +\usepackage{axiom} +\begin{document} +\title{src/graph/viewman Makefile} +\author{The Axiom Team} +\maketitle +\begin{abstract} +\end{abstract} +\eject +\tableofcontents +\eject +\section{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 = viewman$(EXEEXT) + +viewman_sources = cleanup.c fun2D.c fun3D.c make2D.c make3D.c \ + makeGraph.c readView.c sselect.c viewman.c + +viewman_SOURCES = $(addsuffix .pamphlet, $(viewman_sources)) + +viewman_objects = $(viewman_sources:.c=.lo) + +viewman_headers = $(srcdir)/viewman.h \ + $(addprefix $(axiom_src_srcdir)/graph/include/,\ + component.h view2D.h view3D.h tube.h \ + actions.h viewCommand.h) \ + $(axiom_src_srcdir)/include/com.h + + +viewman_DEPENDENCIES = +viewman_LDFLAGS = $(axiom_target_libdir)/libspad.la + +pamphlets = Makefile.pamphlet $(viewman_SOURCES) +@ + +\section{viewman} +<>= +$(axiom_target_libdir)/viewman$(EXEEXT): $(viewman_objects) $(viewman_DEPENDENCIES) + $(LINK) -o $@ $(viewman_objects) $(viewman_LDFLAGS) \ + $(AXIOM_X11_LDFLAGS) +@ + +<<*>>= +<> + +subdir = src/graph/viewman/ + +AXIOM_CFLAGS = ${CCF} ${AXIOM_X11_CFLAGS} -I${LINC} -I${GINC} -I$(srcdir) \ + $(axiom_includes) + +.PHONY: all all-ax all-viewman +all: all-ax + +all-ax all-viewman: stamp + @ echo 30 finished $(srcdir) + +stamp: $(axiom_target_libdir)/viewman$(EXEEXT) + @rm -f stamp + $(STAMP) stamp + + +.PRECIOUS: %.c +.PRECIOUS: %.lo + +%.lo: $(viewman_HEADERS) + +%.lo: %.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 $(viewman_sources) $(viewman_objects) + @rm -f $(axiom_target_libdir)/viewman$(EXEEXT) + +distclean-local: clean-local + +@ +\eject +\begin{thebibliography}{99} +\bibitem{1} nothing +\end{thebibliography} +\end{document} diff --git a/src/graph/viewman/cleanup.c.pamphlet b/src/graph/viewman/cleanup.c.pamphlet new file mode 100644 index 00000000..7400e79a --- /dev/null +++ b/src/graph/viewman/cleanup.c.pamphlet @@ -0,0 +1,255 @@ +\documentclass{article} +\usepackage{axiom} +\begin{document} +\title{\$SPAD/src/graph/viewman cleanup.c} +\author{The Axiom Team} +\maketitle +\begin{abstract} +\end{abstract} +\eject +\tableofcontents +\eject +\section{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. +*/ +@ +<<*>>= +<> + +#define _CLEANUP_C +#include "axiom-c-macros.h" +#include "useproto.h" + +#include +#include +#include +#if !defined(BSDplatform) +#include +#endif +#include +#include +#include + +#include "viewman.h" +#include "actions.h" + +#include "util.H1" +#include "cleanup.H1" +#include "makeGraph.H1" +#include "readView.H1" + +void +#ifdef _NO_PROTO +brokenPipe(sig) +int sig; +#else +brokenPipe(int sig) +#endif +{ + fprintf(stderr, + "The viewport manager tried to write to a non-existing pipe.\n"); +} + + +void +#ifdef _NO_PROTO +endChild(sig) +int sig; +#else +endChild(int sig) +#endif +{ + + checkClosedChild = yes; +} + + +/**************************** + * void rmViewMgr(slotPtr) * + * * + * given a pointer to a * + * viewManager, this * + * procedure removes it * + * from the viewport list * +*****************************/ + +void +#ifdef _NO_PROTO +rmViewMgr(slotPtr) + viewManager *slotPtr; +#else +rmViewMgr(viewManager *slotPtr) +#endif +{ + + int i,throwAway,code; + viewManager *somePort, *someOtherPort; + graphStruct *someGraph,*someOtherGraph; /* used in discarding graphs */ + viewsWithThisGraph *someView,*someOtherView; + + for (somePort=someOtherPort=viewports; + (somePort != 0) && (somePort != slotPtr); + somePort=(someOtherPort=somePort)->nextViewport) + {} + assert ((somePort == 0) || + (somePort == viewports) || + (somePort == someOtherPort->nextViewport)); + + if (somePort) { + if (somePort == viewports) viewports=viewports->nextViewport; + else someOtherPort->nextViewport = somePort->nextViewport; + } + /*** if view2D, then clean up after the graphs as well ***/ + if (slotPtr->viewType == view2DType) { + for (i=0; ikey != throwAway); + someGraph=(someOtherGraph=someGraph)->nextGraph) + { + } + /* someGraph is 0 if not found */ + /* someGraph == graphList if found at first */ + /* otherwise someGraph == someOtherGraph->nextGraph */ + assert( (someGraph == 0) || + (someGraph == graphList) || + (someGraph == someOtherGraph->nextGraph)); + + if (someGraph) { /* if found (should always be true) */ + + for(someView=someOtherView=someGraph->views; + (someView !=0 ) && (someView->viewGr != slotPtr); + someView=(someOtherView=someView)->nextViewthing) + { + } + /* similarly */ + assert( (someView == 0) || + (someView == someGraph->views) || + (someView == someOtherView->nextViewthing)); + + if (someView) { /* if found (should always be true) */ + if (someView == someGraph->views) + /* first */ + someGraph->views = someGraph->views->nextViewthing; + else + someOtherView->nextViewthing = someView->nextViewthing; + free(someView); /* remove this viewport + from list */ + } + /* if now nothing is pointing to this graph , remove the graph from the list*/ + if (someGraph->views == 0) { + if (someGraph == graphList) + graphList = graphList->nextGraph; + else + someOtherGraph->nextGraph = someGraph->nextGraph; + discardGraph(someGraph); /* free the graph */ + } + } /* if someGraph */ + } /* if throwAway */ + } /* for i */ + } /* if type is view2D */ + close(slotPtr->viewIn); + close(slotPtr->viewOut); + free(slotPtr); +} /* rmViewMgr() */ + + +/*********************************** + * int closeChildViewport(slotPtr) * + * * + * given a pointer to a viewport * + * structure (viewManager) this * + * procedure first waits for the * + * actual process to die and then * + * removes it from the list of * + * viewports via rmViewMgr(). * + ***********************************/ + +void +#ifdef _NO_PROTO +closeChildViewport(slotPtr) + viewManager *slotPtr; +#else +closeChildViewport(viewManager *slotPtr) +#endif +{ + + int status; + rmViewMgr(slotPtr); + wait(&status); + +} /* closeChildViewport */ + + +/********************* + * int goodbye() * + * * + * kill all children * + * (how mean) and * + * then kill self. * + *********************/ + +void +#ifdef _NO_PROTO +goodbye(sig) +int sig; +#else +goodbye(int sig) +#endif +{ + + viewManager *v; + + v = viewports; + while (v) { + kill(v->PID,SIGTERM); + while (wait(NULL) == -1); + v = v->nextViewport; + } + exit(0); + +} + + + + +@ +\eject +\begin{thebibliography}{99} +\bibitem{1} nothing +\end{thebibliography} +\end{document} diff --git a/src/graph/viewman/fun2D.c.pamphlet b/src/graph/viewman/fun2D.c.pamphlet new file mode 100644 index 00000000..6556ac17 --- /dev/null +++ b/src/graph/viewman/fun2D.c.pamphlet @@ -0,0 +1,413 @@ +\documentclass{article} +\usepackage{axiom} +\begin{document} +\title{\$SPAD/src/graph/viewman fun2D.c} +\author{The Axiom Team} +\maketitle +\begin{abstract} +\end{abstract} +\eject +\tableofcontents +\eject +\section{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. +*/ +@ +<<*>>= +<> + +#define _FUN2D_C +#include "axiom-c-macros.h" +#include "useproto.h" + +#include +#include +#include +#include + + + +#include "viewman.h" +#include "actions.h" + +#include "util.H1" +#include "sockio-c.H1" +#include "fun2D.H1" +#include "readView.H1" +#include "make2D.H1" + +#define writeEach + +void +#ifdef _NO_PROTO +funView2D(viewCommand) + int viewCommand; +#else +funView2D(int viewCommand) +#endif +{ + + int code; + int viewPID; + float f1,f2; + int i1,i2,i3; + viewManager *viewport; + + viewPID = get_int(spadSock); + + + viewport = viewports; + while ((viewport) && (viewport->PID != viewPID)) { + viewport = viewport->nextViewport; + } + + if (viewport) { + send_int(spadSock,1); /* acknowledge to spad */ + code = write(viewport->viewOut,&viewCommand,intSize); + + + switch (viewCommand) { + + case putGraph: + i1 = get_int(spadSock); /* graph key */ + i2 = get_int(spadSock); /* viewport slot 1..9 */ + i2--; /* 0..8*/ + code = write(viewport->viewOut,&i1,intSize); + code = write(viewport->viewOut,&i2,intSize); + i3 = 1; /* continue*/ + code = write(viewport->viewOut,&i3,intSize); + sendGraphToView2D(0,i1,viewport,¤tGraphState); + + break; + + case translate2D: + i1 = get_int(spadSock); /* graph index */ + f1 = get_float(spadSock); /* translate in the x direction */ + f2 = get_float(spadSock); /* translate in the y direction */ + code = write(viewport->viewOut,&i1,intSize); + code = write(viewport->viewOut,&f1,floatSize); + code = write(viewport->viewOut,&f2,floatSize); + break; + + case scale2D: + i1 = get_int(spadSock); /* graph index */ + f1 = get_float(spadSock); /* scale in the x direction */ + f2 = get_float(spadSock); /* scale in the y direction */ + code = write(viewport->viewOut,&i1,intSize); + code = write(viewport->viewOut,&f1,floatSize); + code = write(viewport->viewOut,&f2,floatSize); + break; + + case hideControl2D: + i1 = get_int(spadSock); + code = write(viewport->viewOut,&i1,intSize); + break; + + case axesOnOff2D: + case unitsOnOff2D: + case connectOnOff: + case pointsOnOff: + case spline2D: + case showing2D: + i1 = get_int(spadSock); /* graph index */ + i2 = get_int(spadSock); /* axes status */ + code = write(viewport->viewOut,&i1,intSize); + code = write(viewport->viewOut,&i2,intSize); + break; + + case moveViewport: + case resizeViewport: + i1 = get_int(spadSock); + i2 = get_int(spadSock); + code = write(viewport->viewOut,&i1,intSize); + code = write(viewport->viewOut,&i2,intSize); + break; + + case changeTitle: + s1 = get_string(spadSock); + i1 = strlen(s1); + code = write(viewport->viewOut,&i1,intSize); + code = write(viewport->viewOut,s1,i1); + break; + + case writeView: + s1 = get_string(spadSock); + i1 = strlen(s1); + code = write(viewport->viewOut,&i1,intSize); + code = write(viewport->viewOut,s1,i1); + /* write out the types of things to be written */ + i2 = get_int(spadSock); + code = write(viewport->viewOut,&i2,intSize); + while (i2) { + i2 = get_int(spadSock); + code = write(viewport->viewOut,&i2,intSize); + } + break; + + case spadPressedAButton: + i1 = get_int(spadSock); + code = write(viewport->viewOut,&i1,intSize); + break; + + } /* switch */ + /*** get acknowledge from viewport */ + code = readViewport(viewport,&acknow,intSize); + send_int(spadSock,1); /* acknowledge to spad */ + } else { + send_int(spadSock,-1); /* send error value in acknowledge to spad */ + } + +} + +void +#ifdef _NO_PROTO +forkView2D() +#else +forkView2D(void) +#endif +{ + + viewManager *viewport; + int childPID, code; + int i; + view2DStruct doView2D; + graphStateStruct doGraphStateArray[maxGraphs]; + int there; + int pipe0[2], pipe1[2]; + + char envAXIOM[100],runView[100]; + +#ifdef DEBUG + fprintf(stderr,"fun2D:Pipe calls for 2D\n"); +#endif + check(pipe(pipe0)); + check(pipe(pipe1)); + +#ifdef DEBUG + fprintf(stderr,"Fork routine for 2D\n"); +#endif + childPID = check(fork()); + + switch(childPID) { + + case -1: + fprintf(stderr, + "The viewport manager cannot open a viewport window.\nTry closing some viewports.\n"); + return; + + case 0: + /***************************** + * child process * + *****************************/ + /* map pipes from viewport manager to standard input and output */ +#ifdef DEBUG + fprintf(stderr,"Mapping pipes to standard I/O in 2D\n"); +#endif + check(dup2(pipe0[0],0)); + check(dup2(pipe1[1],1)); + close(pipe0[0]); + close(pipe0[1]); + close(pipe1[0]); + close(pipe1[1]); + +#ifdef DEBUG + fprintf(stderr,"Executing TwoDimensionalViewport process\n"); +#endif + sprintf(envAXIOM,"%s",getenv("AXIOM")); + sprintf(runView,"%s%s",envAXIOM,"/lib/view2D"); + check(execl(runView,runView,NULL)); + fprintf(stderr,"The viewport manager could not execute view2D.\nCheck that view2D is on your PATH.\n"); + exit(-1); + + default: + /****************************** + * parent process * + ******************************/ + if (!(viewport = (viewManager *)malloc(sizeof(viewManager)))) { + fprintf(stderr,"The viewport manager ran out of memory trying to create a new viewport window (viewManager).\n"); + return; + } + viewport->viewType = view2DType; + viewport->PID = childPID; + + /* set up pipes to child process */ + close(pipe0[0]); + close(pipe1[1]); + viewport->viewIn = pipe1[0]; + viewport->viewOut = pipe0[1]; + + /* add new viewport to global list */ + viewport->nextViewport = viewports; + viewports = viewport; + + if (viewport->viewIn <0) { + fprintf(stderr, + "viewman could not create connection to a 2D viewport window. Try again.\n"); + return; + } else { + + code = readViewport(viewport,&acknow,intSize); + + if (code < 0) { + fprintf(stderr, + "viewman could not read from a 2D viewport window\ncode=%d\nack=%d\n", + code,acknow); + return; + } + } + + makeView2DFromSpadData(&doView2D,doGraphStateArray); + + /* tell the child that mother is a viewport manager */ + i = no; + write(viewport->viewOut,&i,sizeof(int)); + + write(viewport->viewOut,&doView2D,sizeof(view2DStruct)); + i = strlen(doView2D.title)+1; + write(viewport->viewOut,&i,intSize); /* send length of the title child */ + write(viewport->viewOut,doView2D.title,i); /* send title to the child */ + for (i=0; iviewOut,&there,intSize); + sendGraphToView2D(i,there,viewport,doGraphStateArray); + }; /* for i in graphs */ + + /*** get acknowledge from viewport */ + + code = readViewport(viewport,&(viewport->viewWindow),sizeof(Window)); + sleep(1); /* wait a second...*/ + send_int(spadSock,viewport->PID); /* acknowledge to spad */ + + } /* switch */ + +} /* forkView2D() */ + + + +void +#ifdef _NO_PROTO +sendGraphToView2D(i,there,viewport,doGraphStateArray) + int i,there; + viewManager *viewport; + graphStateStruct *doGraphStateArray; +#else +sendGraphToView2D(int i,int there,viewManager *viewport,graphStateStruct *doGraphStateArray) +#endif +{ + + graphStruct *gPtr; + pointListStruct *llPtr; + pointStruct *p; + viewsWithThisGraph *oneView; + int j,k; + + if (there) { + gPtr = graphList; + while ( gPtr != NULL && gPtr->key != there) /** find the right graph (same key) in graph list **/ + gPtr = gPtr->nextGraph; + if ((gPtr==NULL) ||(gPtr->key != there) ){ + fprintf(stderr, + "The viewport manager cannot find the requested graph and will quit and restart.\n"); + exit(-1); + } + + +/*** Before sending off the data, insert a pointer to viewport from graph ***/ + if (!(oneView = (viewsWithThisGraph *)malloc(sizeof(viewsWithThisGraph)))) { + fprintf(stderr,"The viewport manager ran out of memory trying to create a new graph (viewsWithThisGraph).\n"); + return; + } + oneView->viewGr = viewport; + oneView->nextViewthing = gPtr->views; + gPtr->views = oneView; + +#ifdef writeEach + write(viewport->viewOut,&(gPtr->xmin),floatSize); + write(viewport->viewOut,&(gPtr->xmax),floatSize); + write(viewport->viewOut,&(gPtr->ymin),floatSize); + write(viewport->viewOut,&(gPtr->ymax),floatSize); + write(viewport->viewOut,&(gPtr->xNorm),floatSize); + write(viewport->viewOut,&(gPtr->yNorm),floatSize); + write(viewport->viewOut,&(gPtr->spadUnitX),floatSize); + write(viewport->viewOut,&(gPtr->spadUnitY),floatSize); + write(viewport->viewOut,&(gPtr->unitX),floatSize); + write(viewport->viewOut,&(gPtr->unitY),floatSize); + write(viewport->viewOut,&(gPtr->originX),floatSize); + write(viewport->viewOut,&(gPtr->originY),floatSize); + write(viewport->viewOut,&(gPtr->numberOfLists),intSize); +#else + write(viewport->viewOut,gPtr,sizeof(graphStruct)); +#endif + + llPtr = gPtr->listOfListsOfPoints; + for (j=0; j<(gPtr->numberOfLists); j++) { + write(viewport->viewOut,&(llPtr->numberOfPoints),intSize); + p = llPtr->listOfPoints; + for (k=0; k<(llPtr->numberOfPoints); k++) { + write(viewport->viewOut,&(p->x),floatSize); + write(viewport->viewOut,&(p->y),floatSize); + write(viewport->viewOut,&(p->hue),floatSize); + write(viewport->viewOut,&(p->shade),floatSize); + p++; + } /* for k in list of points */ + write(viewport->viewOut,&(llPtr->pointColor),intSize); + write(viewport->viewOut,&(llPtr->lineColor),intSize); + write(viewport->viewOut,&(llPtr->pointSize),intSize); + llPtr++; + } /* for j in list of lists of points */ + + /* a graph state is defined for a graph if graph is there */ + write(viewport->viewOut,&(doGraphStateArray[i].scaleX),floatSize); + write(viewport->viewOut,&(doGraphStateArray[i].scaleY),floatSize); + write(viewport->viewOut,&(doGraphStateArray[i].deltaX),floatSize); + write(viewport->viewOut,&(doGraphStateArray[i].deltaY),floatSize); + write(viewport->viewOut,&(doGraphStateArray[i].pointsOn),intSize); + write(viewport->viewOut,&(doGraphStateArray[i].connectOn),intSize); + write(viewport->viewOut,&(doGraphStateArray[i].splineOn),intSize); + write(viewport->viewOut,&(doGraphStateArray[i].axesOn),intSize); + write(viewport->viewOut,&(doGraphStateArray[i].axesColor),intSize); + write(viewport->viewOut,&(doGraphStateArray[i].unitsOn),intSize); + write(viewport->viewOut,&(doGraphStateArray[i].unitsColor),intSize); + write(viewport->viewOut,&(doGraphStateArray[i].showing),intSize); + + } /* if graph is there */ + +} + +@ +\eject +\begin{thebibliography}{99} +\bibitem{1} nothing +\end{thebibliography} +\end{document} diff --git a/src/graph/viewman/fun3D.c.pamphlet b/src/graph/viewman/fun3D.c.pamphlet new file mode 100644 index 00000000..bb88e710 --- /dev/null +++ b/src/graph/viewman/fun3D.c.pamphlet @@ -0,0 +1,396 @@ +\documentclass{article} +\usepackage{axiom} +\begin{document} +\title{\$SPAD/src/graph/viewman fun3D.c} +\author{The Axiom Team} +\maketitle +\begin{abstract} +\end{abstract} +\eject +\tableofcontents +\eject +\section{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. +*/ +@ +<<*>>= +<> + +#define _FUN3D_C +#include "axiom-c-macros.h" +#include "useproto.h" + +#include +#include +#include +#include + +#include "viewman.h" +#include "mode.h" +#include "actions.h" + +#include "util.H1" +#include "sockio-c.H1" +#include "fun3D.H1" +#include "make3D.H1" +#include "readView.H1" + +void +#ifdef _NO_PROTO +funView3D(viewCommand) + int viewCommand; +#else +funView3D(int viewCommand) +#endif +{ + + int code; + int viewPID; + float f1,f2,f3,f4; + int i1,i2; + viewManager *viewport; + + viewPID = get_int(spadSock); + + viewport = viewports; + while ((viewport) && (viewport->PID != viewPID)) + viewport = viewport->nextViewport; + + if (viewport) { + send_int(spadSock,1); /* acknowledge to spad */ + + viewmanEvent.xclient.window = viewport->viewWindow; + + code = write(viewport->viewOut,&viewCommand,intSize); + switch (viewCommand) { + case rotate: + f1 = get_float(spadSock); + f2 = get_float(spadSock); + code = write(viewport->viewOut,&f1,floatSize); + code = write(viewport->viewOut,&f2,floatSize); + break; + + case zoom: + f1 = get_float(spadSock); + code = write(viewport->viewOut,&f1,floatSize); + break; + + case zoomx: + f1 = get_float(spadSock); + f2 = get_float(spadSock); + f3 = get_float(spadSock); + code = write(viewport->viewOut,&f1,floatSize); + code = write(viewport->viewOut,&f2,floatSize); + code = write(viewport->viewOut,&f3,floatSize); + break; + + case translate: + f1 = get_float(spadSock); + f2 = get_float(spadSock); + code = write(viewport->viewOut,&f1,floatSize); + code = write(viewport->viewOut,&f2,floatSize); + break; + + case modifyPOINT: + i1 = get_int(spadSock); + f1 = get_float(spadSock); + f2 = get_float(spadSock); + f3 = get_float(spadSock); + f4 = get_float(spadSock); + code = write(viewport->viewOut,&i1,intSize); + code = write(viewport->viewOut,&f1,floatSize); + code = write(viewport->viewOut,&f2,floatSize); + code = write(viewport->viewOut,&f3,floatSize); + code = write(viewport->viewOut,&f4,floatSize); + break; + + case hideControl: + i1 = get_int(spadSock); + code = write(viewport->viewOut,&i1,intSize); + break; + + case axesOnOff: + case perspectiveOnOff: + case region3D: + case clipRegionOnOff: + case clipSurfaceOnOff: + i1 = get_int(spadSock); + code = write(viewport->viewOut,&i1,intSize); + break; + + case eyeDistanceData: + case hitherPlaneData: + f1 = get_float(spadSock); + code = write(viewport->viewOut,&f1,floatSize); + break; + + case colorDef: + i1 = get_int(spadSock); + i2 = get_int(spadSock); + code = write(viewport->viewOut,&i1,intSize); + code = write(viewport->viewOut,&i2,intSize); + break; + + case moveViewport: + i1 = get_int(spadSock); + i2 = get_int(spadSock); + code = write(viewport->viewOut,&i1,intSize); + code = write(viewport->viewOut,&i2,intSize); + break; + + case resizeViewport: + i1 = get_int(spadSock); + i2 = get_int(spadSock); + code = write(viewport->viewOut,&i1,intSize); + code = write(viewport->viewOut,&i2,intSize); + break; + + case transparent: + case opaqueMesh: + case render: + break; + + case lightDef: + f1 = get_float(spadSock); + f2 = get_float(spadSock); + f3 = get_float(spadSock); + code = write(viewport->viewOut,&f1,floatSize); + code = write(viewport->viewOut,&f2,floatSize); + code = write(viewport->viewOut,&f3,floatSize); + break; + + case translucenceDef: + f1 = get_float(spadSock); + code = write(viewport->viewOut,&f1,floatSize); + break; + + + case changeTitle: + s1 = get_string(spadSock); + i1 = strlen(s1); + code = write(viewport->viewOut,&i1,intSize); + code = write(viewport->viewOut,s1,i1); + break; + + case writeView: + s1 = get_string(spadSock); + i1 = strlen(s1); + code = write(viewport->viewOut,&i1,intSize); + code = write(viewport->viewOut,s1,i1); + /* write out the types of things to be written */ + i2 = get_int(spadSock); + code = write(viewport->viewOut,&i2,intSize); + while (i2) { + i2 = get_int(spadSock); + code = write(viewport->viewOut,&i2,intSize); + } + break; + + case diagOnOff: + i1 = get_int(spadSock); + code = write(viewport->viewOut,&i1,intSize); + break; + + case outlineOnOff: + i1 = get_int(spadSock); + code = write(viewport->viewOut,&i1,intSize); + break; + + case spadPressedAButton: + i1 = get_int(spadSock); + code = write(viewport->viewOut,&i1,intSize); + break; + } /* switch */ + /*** get acknowledge from viewport */ + + code = readViewport(viewport,&acknow,intSize); + send_int(spadSock,1); /* acknowledge to spad */ + } else { /* if (viewport) */ + send_int(spadSock,-1); /* send error value in acknowledge to spad */ + } + +} +void +#ifdef _NO_PROTO +forkView3D(typeOfViewport) + int typeOfViewport; +#else +forkView3D(int typeOfViewport) +#endif +{ + + viewManager *viewport; + int childPID, code; + int i; + + view3DStruct doView3D; + int pipe0[2],pipe1[2]; + int *anIndex; + + char envAXIOM[100],runView[100]; + int j,k; + LLPoint *anLLPoint; + LPoint *anLPoint; + +#ifdef DEBUG + fprintf(stderr,"Pipe calls for 3D\n"); +#endif + check(pipe(pipe0)); + check(pipe(pipe1)); + +#ifdef DEBUG + fprintf(stderr,"Fork routine for 3D\n"); +#endif + switch(childPID = check(fork())) { + + case -1: + printf("Cannot create a new process - you probably have too many things running already.\n"); + return; + + case 0: + /***************************** + * child process * + *****************************/ + /* map pipes from viewport manager to standard input and output */ +#ifdef DEBUG + fprintf(stderr,"Mapping pipes to standard I/O in 3D\n"); +#endif + check(dup2(pipe0[0],0)); + check(dup2(pipe1[1],1)); + close(pipe0[0]); + close(pipe0[1]); + close(pipe1[0]); + close(pipe1[1]); + +#ifdef DEBUG + fprintf(stderr,"Executing ThreeDimensionalViewport process\n"); +#endif + sprintf(envAXIOM,"%s",getenv("AXIOM")); + sprintf(runView,"%s%s",envAXIOM,"/lib/view3D"); + check(execl(runView,runView,NULL)); + fprintf(stderr,"The viewport manager could not execute view3D.\nCheck that view3D is on your PATH.\n"); + exit(-1); + + default: + /****************************** + * parent process * + ******************************/ + if (!(viewport = (viewManager *)malloc(sizeof(viewManager)))) { + printf("Ran out of memory trying to create a new viewport process.\n"); + return; + } + viewport->viewType = typeOfViewport; + viewport->PID = childPID; + + /* set up pipes to child process */ + close(pipe0[0]); + close(pipe1[1]); + viewport->viewIn = pipe1[0]; + viewport->viewOut = pipe0[1]; + + /* add new viewport to global list */ + viewport->nextViewport = viewports; + viewports = viewport; + + if (viewport->viewIn <0) { + fprintf(stderr, + "The viewport manager could not create connection to a 3D viewport window. Try again.\n"); + return; + } else { + + code = readViewport(viewport,&acknow,intSize); + + if (code < 0) { + fprintf(stderr, + "The viewport manager could not read from a 3D viewport window\ncode=%d\nack=%d\n",code,acknow); + return; + } + } + + makeView3DFromSpadData(&doView3D,typeOfViewport); + + /* tell the child that parent is a viewport manager */ + i = no; + write(viewport->viewOut,&i,sizeof(int)); + + write(viewport->viewOut,&doView3D,sizeof(view3DStruct)); + + i = strlen(doView3D.title)+1; + write(viewport->viewOut,&i,intSize); /* tell the length of the title to child */ + write(viewport->viewOut,doView3D.title,i); /* tell the title to the child */ + write(viewport->viewOut,&(doView3D.lightVec[0]),floatSize); + write(viewport->viewOut,&(doView3D.lightVec[1]),floatSize); + write(viewport->viewOut,&(doView3D.lightVec[2]),floatSize); + + /* send generalized 3D components */ + write(viewport->viewOut,&(doView3D.numOfPoints),intSize); + for (i=0; iviewOut,&(refPt(doView3D,i)->x),floatSize); + write(viewport->viewOut,&(refPt(doView3D,i)->y),floatSize); + write(viewport->viewOut,&(refPt(doView3D,i)->z),floatSize); + write(viewport->viewOut,&(refPt(doView3D,i)->c),floatSize); + } + write(viewport->viewOut,&(doView3D.lllp.numOfComponents),intSize); + anLLPoint = doView3D.lllp.llp; + for (i=0; iviewOut,&(anLLPoint->prop.closed),intSize); + write(viewport->viewOut,&(anLLPoint->prop.solid),intSize); + write(viewport->viewOut,&(anLLPoint->numOfLists),intSize); + anLPoint = anLLPoint->lp; + for (j=0; jnumOfLists; j++,anLPoint++) { + write(viewport->viewOut,&(anLPoint->prop.closed),intSize); + write(viewport->viewOut,&(anLPoint->prop.solid),intSize); + write(viewport->viewOut,&(anLPoint->numOfPoints),intSize); + anIndex = anLPoint->indices; + for (k=0; knumOfPoints; k++,anIndex++) + write(viewport->viewOut,anIndex,intSize); + } /* for LPoints in LLPoints (j) */ + } /* for LLPoints in LLLPoints (i) */ + + /*** get acknowledge from viewport */ + code = readViewport(viewport,&(viewport->viewWindow),sizeof(Window)); + sleep(1); /* wait a second...*/ + send_int(spadSock,viewport->PID); /* acknowledge to spad */ + + } /* switch */ + +} /* forkView3D() */ + + +@ +\eject +\begin{thebibliography}{99} +\bibitem{1} nothing +\end{thebibliography} +\end{document} diff --git a/src/graph/viewman/globalsM.h b/src/graph/viewman/globalsM.h new file mode 100755 index 00000000..019ecc3a --- /dev/null +++ b/src/graph/viewman/globalsM.h @@ -0,0 +1,53 @@ +/* +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 viewManager *viewports,*slot,*stepSlot; +extern Sock *spadSock; +extern int viewType, viewCommand; +extern fd_set filedes; +extern int acknow; +extern int graphKey; +extern graphStruct *graphList; +extern char *s1; +extern Display *dsply; +extern int defDsply; +extern Window root; +extern XEvent viewmanEvent; +extern int currentGraph; +extern graphStateStruct currentGraphState; +extern int picked; +extern int viewOkay; +extern int viewError; +extern int checkClosedChild, + foundBrokenPipe; +extern char propertyBuffer[]; diff --git a/src/graph/viewman/make2D.c.pamphlet b/src/graph/viewman/make2D.c.pamphlet new file mode 100644 index 00000000..668a0aae --- /dev/null +++ b/src/graph/viewman/make2D.c.pamphlet @@ -0,0 +1,106 @@ +\documentclass{article} +\usepackage{axiom} +\begin{document} +\title{\$SPAD/src/graph/viewman make2D.c} +\author{The Axiom Team} +\maketitle +\begin{abstract} +\end{abstract} +\eject +\tableofcontents +\eject +\section{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. +*/ +@ +<<*>>= +<> + +#define _MAKE2D_C +#include "axiom-c-macros.h" +#include "useproto.h" + +#include "viewman.h" + +#include "sockio-c.H1" +#include "make2D.H1" + +void +#ifdef _NO_PROTO +makeView2DFromSpadData(viewdata,graphState) + view2DStruct *viewdata; + graphStateStruct graphState[]; +#else +makeView2DFromSpadData(view2DStruct *viewdata,graphStateStruct graphState[]) +#endif +{ + + int i; + + viewdata->title = get_string(spadSock); + + viewdata->vX = get_int(spadSock); + viewdata->vY = get_int(spadSock); + viewdata->vW = get_int(spadSock); + viewdata->vH = get_int(spadSock); + + viewdata->showCP = get_int(spadSock); + + for (i=0; igraphKeyArray[i] = get_int(spadSock); + if (viewdata->graphKeyArray[i]) { + + graphState[i].scaleX = get_float(spadSock); + graphState[i].scaleY = get_float(spadSock); + graphState[i].deltaX = get_float(spadSock); + graphState[i].deltaY = get_float(spadSock); + graphState[i].pointsOn = get_int(spadSock); + graphState[i].connectOn = get_int(spadSock); + graphState[i].splineOn = get_int(spadSock); + graphState[i].axesOn = get_int(spadSock); + graphState[i].axesColor = get_int(spadSock); + graphState[i].unitsOn = get_int(spadSock); + graphState[i].unitsColor = get_int(spadSock); + graphState[i].showing = get_int(spadSock); + graphState[i].selected = 1; /* always default to selected? */ + + } + } +} +@ +\eject +\begin{thebibliography}{99} +\bibitem{1} nothing +\end{thebibliography} +\end{document} diff --git a/src/graph/viewman/make3D.c.pamphlet b/src/graph/viewman/make3D.c.pamphlet new file mode 100644 index 00000000..b2eb99ed --- /dev/null +++ b/src/graph/viewman/make3D.c.pamphlet @@ -0,0 +1,186 @@ +\documentclass{article} +\usepackage{axiom} +\begin{document} +\title{\$SPAD/src/graph/viewman make3D.c} +\author{The Axiom Team} +\maketitle +\begin{abstract} +\end{abstract} +\eject +\tableofcontents +\eject +\section{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. +*/ +@ +<<*>>= +<> + +#define _MAKE3D_C +#include "axiom-c-macros.h" +#include "useproto.h" + +#include + +#include "viewman.h" +#include "mode.h" + +#include "sockio-c.H1" +#include "make3D.H1" + +void +#ifdef _NO_PROTO +makeView3DFromSpadData(viewdata,typeOfViewport) + view3DStruct *viewdata; + int typeOfViewport; +#else +makeView3DFromSpadData(view3DStruct *viewdata,int typeOfViewport) +#endif +{ + + int i,j,k; + LLPoint *anLLPoint; + LPoint *anLPoint; + int *anIndex; + int firstPieceOfData = yes; + int constantColor; + double cMin = 0; + double cMax = 0; + double cNorm = 0; + + viewdata->typeOf3D = typeOfViewport; + + viewdata->title = get_string(spadSock); + + viewdata->deltaX = get_float(spadSock); + viewdata->deltaY = get_float(spadSock); + viewdata->scale = get_float(spadSock); + viewdata->scaleX = get_float(spadSock); + viewdata->scaleY = get_float(spadSock); + viewdata->scaleZ = get_float(spadSock); + viewdata->theta = get_float(spadSock); + viewdata->phi = get_float(spadSock); + + viewdata->vX = get_int(spadSock); + viewdata->vY = get_int(spadSock); + viewdata->vW = get_int(spadSock); + viewdata->vH = get_int(spadSock); + + viewdata->showCP = get_int(spadSock); + viewdata->style = get_int(spadSock); + viewdata->AxesOn = get_int(spadSock); + viewdata->diagonals = get_int(spadSock); + viewdata->outlineRenderOn = get_int(spadSock); + viewdata->box = get_int(spadSock); + viewdata->clipbox = get_int(spadSock); + viewdata->clipStuff = get_int(spadSock); + + viewdata->hueOff = get_int(spadSock); + viewdata->numOfHues = get_int(spadSock); + + viewdata->lightVec[0] = get_float(spadSock); + viewdata->lightVec[1] = get_float(spadSock); + viewdata->lightVec[2] = get_float(spadSock); + viewdata->translucency = get_float(spadSock); + + viewdata->perspective = get_int(spadSock); + viewdata->eyeDistance = get_float(spadSock); + + viewdata->numOfPoints = get_int(spadSock); + viewdata->points = (viewTriple *)malloc(viewdata->numOfPoints * sizeof(viewTriple)); + for (i=0; inumOfPoints; i++) { + refPt(*viewdata,i)->x = get_float(spadSock); + refPt(*viewdata,i)->y = get_float(spadSock); + refPt(*viewdata,i)->z = get_float(spadSock); + refPt(*viewdata,i)->c = get_float(spadSock); + /* set min/max values */ + if (firstPieceOfData) { + firstPieceOfData = no; + viewdata->xmin = viewdata->xmax = refPt(*viewdata,i)->x; + viewdata->ymin = viewdata->ymax = refPt(*viewdata,i)->y; + viewdata->zmin = viewdata->zmax = refPt(*viewdata,i)->z; + cMin = cMax = refPt(*viewdata,i)->c; + } else { + if (refPt(*viewdata,i)->x < viewdata->xmin) viewdata->xmin = refPt(*viewdata,i)->x; + else if (refPt(*viewdata,i)->x > viewdata->xmax) viewdata->xmax = refPt(*viewdata,i)->x; + if (refPt(*viewdata,i)->y < viewdata->ymin) viewdata->ymin = refPt(*viewdata,i)->y; + else if (refPt(*viewdata,i)->y > viewdata->ymax) viewdata->ymax = refPt(*viewdata,i)->y; + if (refPt(*viewdata,i)->z < viewdata->zmin) viewdata->zmin = refPt(*viewdata,i)->z; + else if (refPt(*viewdata,i)->z > viewdata->zmax) viewdata->zmax = refPt(*viewdata,i)->z; + if (refPt(*viewdata,i)->c < cMin) cMin = refPt(*viewdata,i)->c; + else if (refPt(*viewdata,i)->c > cMax) cMax = refPt(*viewdata,i)->c; + } /* if (firstPieceOfData) else */ + } /* for i (point data) */ + + viewdata->lllp.numOfComponents = get_int(spadSock); + anLLPoint = viewdata->lllp.llp = + (LLPoint *)malloc(viewdata->lllp.numOfComponents*sizeof(LLPoint)); + for (i=0; illlp.numOfComponents; i++,anLLPoint++) { + anLLPoint->prop.closed = get_int(spadSock); + anLLPoint->prop.solid = get_int(spadSock); + anLLPoint->numOfLists = get_int(spadSock); + anLPoint = anLLPoint->lp = + (LPoint *)malloc(anLLPoint->numOfLists*sizeof(LPoint)); + for (j=0; jnumOfLists; j++,anLPoint++) { + anLPoint->prop.closed = get_int(spadSock); + anLPoint->prop.solid = get_int(spadSock); + anLPoint->numOfPoints = get_int(spadSock); + anIndex = anLPoint->indices = + (int *)malloc(anLPoint->numOfPoints*sizeof(int)); + for (k=0; knumOfPoints; k++,anIndex++) + *anIndex = get_int(spadSock); + } /* for LPoints in LLPoints (j) */ + } /* for LLPoints in LLLPoints (i) */ + + /* now normalize the colors */ + cNorm = cMax - cMin; + /*** new fields - cmin, cmax ***/ + viewdata->cmin = cMin; + viewdata->cmax = cMax; + + constantColor = (cNorm < 0.0001); + for (i=0; inumOfPoints; i++) + if (constantColor) refPt(*viewdata,i)->c = 0.5; + else refPt(*viewdata,i)->c = (refPt(*viewdata,i)->c - cMin)/cNorm; + + viewdata->scaleDown = yes; + +} + +@ +\eject +\begin{thebibliography}{99} +\bibitem{1} nothing +\end{thebibliography} +\end{document} diff --git a/src/graph/viewman/makeGraph.c.pamphlet b/src/graph/viewman/makeGraph.c.pamphlet new file mode 100644 index 00000000..14ab47f4 --- /dev/null +++ b/src/graph/viewman/makeGraph.c.pamphlet @@ -0,0 +1,165 @@ +\documentclass{article} +\usepackage{axiom} +\begin{document} +\title{\$SPAD/src/graph/viewman makeGraph.c} +\author{The Axiom Team} +\maketitle +\begin{abstract} +\end{abstract} +\eject +\tableofcontents +\eject +\section{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. +*/ +@ +<<*>>= +<> + +#define _MAKEGRAPH_C +#include "axiom-c-macros.h" +#include "useproto.h" + +#include +#include + +#include "viewman.h" + +#include "sockio-c.H1" +#include "makeGraph.H1" + +graphStruct * +#ifdef _NO_PROTO +makeGraphFromSpadData() +#else +makeGraphFromSpadData(void) +#endif +{ + + graphStruct *graphData; + pointListStruct *pL; + pointStruct *p; + int i,j; + + if (!(graphData = (graphStruct *)malloc(sizeof(graphStruct)))) { + fprintf(stderr,"The viewport manager ran out of memory trying to create a new graph (graphStruct).\n"); + exit(-1); + } + + graphData->xmin = get_float(spadSock); /* after everything is normalized */ + graphData->xmax = get_float(spadSock); + graphData->ymin = get_float(spadSock); /* view2D */ + graphData->ymax = get_float(spadSock); + + graphData->xNorm = 1/(graphData->xmax - graphData->xmin); + graphData->yNorm = 1/(graphData->ymax - graphData->ymin); + + graphData->spadUnitX = get_float(spadSock); + graphData->spadUnitY = get_float(spadSock); + + graphData->unitX = graphData->spadUnitX * graphData->xNorm; + graphData->unitY = graphData->spadUnitY * graphData->yNorm; + + graphData->originX = -graphData->xmin * graphData->xNorm - 0.5; + graphData->originY = -graphData->ymin * graphData->yNorm - 0.5; + + + graphData->numberOfLists = get_int(spadSock); + if (!(pL = (pointListStruct *)malloc(graphData->numberOfLists * sizeof(pointListStruct)))) { + fprintf(stderr,"The viewport manager ran out of memory trying to create a new graph (pointListStruct).\n"); + exit(-1); + } + graphData->listOfListsOfPoints = pL; + + for (i=0; inumberOfLists; i++) { + + pL->numberOfPoints = get_int(spadSock); + if (!(p = (pointStruct *)malloc(pL->numberOfPoints * sizeof(pointStruct)))) { + fprintf(stderr,"The viewport manager ran out of memory trying to create a new graph (pointStruct).\n"); + exit(-1); + } + pL->listOfPoints = p; /** point to current point list **/ + + for (j=0; jnumberOfPoints; j++) { + p->x = get_float(spadSock); /* get numbers from AXIOM */ + p->y = get_float(spadSock); + p->hue = get_float(spadSock) - 1; /* make zero based */ + p->shade = get_float(spadSock) - 1; + /* normalize to range [-0.5..0.5] */ + p->x = (p->x - graphData->xmin) * graphData->xNorm - 0.5; + p->y = (p->y - graphData->ymin) * graphData->yNorm - 0.5; + p++; + } + /* for now, getting hue, shade - do hue * totalHues + shade */ + pL->pointColor = get_int(spadSock); + pL->lineColor = get_int(spadSock); + pL->pointSize = get_int(spadSock); + pL++; /** advance to next point list **/ + } + + + graphData->key = graphKey++; + + send_int(spadSock,(graphKey-1)); /* acknowledge to spad */ + + + return(graphData); + +} + + +void +#ifdef _NO_PROTO +discardGraph (theGraph) + graphStruct *theGraph; +#else +discardGraph (graphStruct *theGraph) +#endif +{ + + pointListStruct *pL; + int j; + + for (j=0, pL=theGraph->listOfListsOfPoints; jnumberOfLists; j++,pL++) + free(pL->listOfPoints); + free(pL); + free(theGraph); + +} +@ +\eject +\begin{thebibliography}{99} +\bibitem{1} nothing +\end{thebibliography} +\end{document} diff --git a/src/graph/viewman/readView.c.pamphlet b/src/graph/viewman/readView.c.pamphlet new file mode 100644 index 00000000..cccc323d --- /dev/null +++ b/src/graph/viewman/readView.c.pamphlet @@ -0,0 +1,87 @@ +\documentclass{article} +\usepackage{axiom} +\begin{document} +\title{\$SPAD/src/graph/viewman readView.c} +\author{The Axiom Team} +\maketitle +\begin{abstract} +\end{abstract} +\eject +\tableofcontents +\eject +\section{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. +*/ +@ +<<*>>= +<> + +#define _READVIEW_C +#include "axiom-c-macros.h" +#include "useproto.h" + +#include +#include +#include + +#include "viewman.h" + +#include "cleanup.H1" + +int +#ifdef _NO_PROTO +readViewport (viewPort,info,size) + viewManager *viewPort; + void *info; + int size; +#else +readViewport (viewManager *viewPort,void *info,int size) +#endif +{ + + int canRead; + +again: + if ((canRead=read(viewPort->viewIn,info,size)) > 0) return(canRead); + if (errno==EINTR || errno==EAGAIN) goto again; + return(-1); +} + + +@ +\eject +\begin{thebibliography}{99} +\bibitem{1} nothing +\end{thebibliography} +\end{document} diff --git a/src/graph/viewman/sselect.c.pamphlet b/src/graph/viewman/sselect.c.pamphlet new file mode 100644 index 00000000..6236fa01 --- /dev/null +++ b/src/graph/viewman/sselect.c.pamphlet @@ -0,0 +1,124 @@ +\documentclass{article} +\usepackage{axiom} +\begin{document} +\title{\$SPAD/src/graph/viewman sselect.c} +\author{The Axiom Team} +\maketitle +\begin{abstract} +\end{abstract} +\eject +\tableofcontents +\eject +\section{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. +*/ +@ +<<*>>= +<> + +#define _SSELECT_C +#include "axiom-c-macros.h" +#include "useproto.h" + +#include +#include +#include +#include +#include + +#include "viewman.h" +#include "bsdsignal.h" + +#include "sockio-c.H1" +#include "bsdsignal.H1" +#include "cleanup.H1" +#include "sselect.H1" + +/******************************************* + * int superSelect(n, rd, wr, ex, timeout) * + * * + * superselect! if select returns a -1 * + * due to an interrupt (EINTR), this * + * routine checks to see if it's a * + * child viewport that has closed. * + * Expected global variables: * + * int checkClosedChild * + *******************************************/ + +int +#ifdef _NO_PROTO +superSelect(n, rd, wr, ex, timeout) + int n; + int *rd, *wr, *ex; + char *timeout; +#else +superSelect(int n, int *rd, int *wr, int *ex, char *timeout) +#endif +{ + + int waiting; + viewManager *viewport; + int ret_val; + + ret_val = select(n, (void *)rd, (void *)wr, (void *)ex, (void *)timeout); + while (ret_val == -1 && errno == EINTR) { + /* checkClosedChild gets set by the SIGCHLD handler */ + if (checkClosedChild) { + while ((waiting = wait(0)) == -1 ); + viewport = viewports; + while ((viewport) && (viewport->PID != waiting)) + viewport = viewport->nextViewport; + if (viewport) { + /* we shouldn't really be doing this since child is dead */ + /* rmViewMgr(viewport); */ + /* flush(spadSock); */ + /* send_int(spadSock,1); acknowledge to spad */ + checkClosedChild = no; +#if defined(BSDplatform) || defined(MACOSXplatform) + bsdSignal(SIGCHLD,endChild,DontRestartSystemCalls); +#else + bsdSignal(SIGCLD,endChild,DontRestartSystemCalls); +#endif + } + } + ret_val = select(n, (void *)rd, (void *)wr, (void *)ex, (void *)timeout); + } + return ret_val; +} +@ +\eject +\begin{thebibliography}{99} +\bibitem{1} nothing +\end{thebibliography} +\end{document} diff --git a/src/graph/viewman/viewman.c.pamphlet b/src/graph/viewman/viewman.c.pamphlet new file mode 100644 index 00000000..6398a0b4 --- /dev/null +++ b/src/graph/viewman/viewman.c.pamphlet @@ -0,0 +1,277 @@ +\documentclass{article} +\usepackage{axiom} +\begin{document} +\title{\$SPAD/src/graph/viewman viewman.c} +\author{The Axiom Team} +\maketitle +\begin{abstract} +\end{abstract} +\eject +\tableofcontents +\eject +\section{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. +*/ +@ +<<*>>= +<> + +#define _VIEWMAN_C +#include "axiom-c-macros.h" +#include "useproto.h" + +#include +#include +#include +#include +#include +#include +#ifdef SGIplatform +#include +#endif + +#include "viewman.h" +#include "mode.h" +#include "actions.h" +#include "viewCommand.h" +#include "bsdsignal.h" + + +#include "bsdsignal.H1" +#include "util.H1" +#include "sockio-c.H1" +#include "fun2D.H1" +#include "fun3D.H1" +#include "makeGraph.H1" +#include "readView.H1" +#include "cleanup.H1" +#include "sselect.H1" + +/************* global variables **************/ + +Display *dsply; +Window root; +XEvent viewmanEvent; +viewManager *viewports, + *slot, + *stepSlot; +Sock *spadSock; +int viewType, + viewCommand, + acknow, + graphKey = 1, + defDsply, + currentGraph, + picked = no, + viewOkay = 0, + viewError = -1, + checkClosedChild = no, + foundBrokenPipe = no; +fd_set filedes; +graphStruct *graphList; +graphStateStruct currentGraphState; +char *s1, + propertyBuffer[256];/* XProperty buffer */ + + +int +#ifdef _NO_PROTO +main () +#else +main (void) +#endif +{ + + graphStruct *aGraph; + int keepLooking,code; + + bsdSignal(SIGPIPE,brokenPipe,DontRestartSystemCalls); +#if defined(BSDplatform) || defined (MACOSXplatform) + bsdSignal(SIGCHLD,endChild,RestartSystemCalls); +#else + bsdSignal(SIGCLD,endChild,RestartSystemCalls); +#endif + bsdSignal(SIGTERM,goodbye,DontRestartSystemCalls); + + /* Connect up to AXIOM server */ + spadSock = connect_to_local_server(SpadServer,ViewportServer,Forever); + if (spadSock == NULL) { + fprintf(stderr,"The viewport manager couldn't connect to AXIOM\n"); + exit(-1); + } +#ifdef DEBUG + else + fprintf(stderr,"viewman: Connected to AXIOM\n"); +#endif + + /******** initialize ********/ + viewports = 0; + graphList = 0; + + /******** getting stuff from spad and viewports ******** + ********* the viewports have priority over **** + *** AXIOM. ***/ + while (1) { + FD_ZERO(&filedes); /* zero out file descriptor */ + FD_SET(spadSock->socket,&filedes); + slot = viewports; + while (slot) { + FD_SET(slot->viewIn,&filedes); + slot = slot->nextViewport; + } + +#ifdef DEBUG + fprintf(stderr,"Selection for filedes of %x \n",filedes); +#endif + code = check(superSelect(FD_SETSIZE,(void *) &filedes,0,0,0)); + for (;code<=0;) + code = check(superSelect(FD_SETSIZE,(void *)&filedes,0,0,0)); + + slot = viewports; + keepLooking = 1; + while (keepLooking && slot) { + if (FD_ISSET(slot->viewIn,&filedes)) { + keepLooking = 0; +#ifdef DEBUG + fprintf(stderr,"Reading child viewport...\n"); +#endif + readViewport(slot,&viewCommand,intSize); + + switch (viewCommand) { + + case pick2D: +#ifdef DEBUG + fprintf(stderr,"viewman: Doing 2D pick\n"); +#endif + picked = yes; + + readViewport(slot,¤tGraph,intSize); /* get the graph to pick */ + readViewport(slot,¤tGraphState,sizeof(graphStateStruct)); + break; + + case drop2D: +#ifdef DEBUG + fprintf(stderr,"viewman: Doing 2D drop\n"); +#endif + if (picked) { + write(slot->viewOut,&viewOkay,intSize); + write(slot->viewOut,¤tGraph,intSize); + sendGraphToView2D(0,currentGraph,slot,¤tGraphState); + } else { + write(slot->viewOut,&viewError,intSize); + fprintf(stderr,"The viewport manager cannot drop a graph because nothing has been picked yet.\n"); + } + break; + + case viewportClosing: +#ifdef DEBUG + fprintf(stderr,"viewman: closing viewport\n"); +#endif + closeChildViewport(slot); + break; + + }; /* switch */ + + }; /* if reading slot->viewIn */ + stepSlot = slot; + slot = slot->nextViewport; + }; /* while */ + + if (keepLooking) { /* if 1 => slots not read, read from spad */ +#ifdef DEBUG + fprintf(stderr,"viewman: still looking\n"); +#endif + viewType = get_int(spadSock); + if (viewType == -1) goodbye(-1); + viewCommand = get_int(spadSock); + + switch (viewType) { + + case view3DType: +#ifdef DEBUG + fprintf(stderr,"viewman: making 3D viewport\n"); +#endif + if (viewCommand == makeViewport) + forkView3D(view3DType); + else + funView3D(viewCommand); + + break; + + case viewTubeType: +#ifdef DEBUG + fprintf(stderr,"viewman: viewing a tube\n"); +#endif + if (viewCommand == makeViewport) + forkView3D(viewTubeType); + else + funView3D(viewCommand); + + break; + + case viewGraphType: +#ifdef DEBUG + fprintf(stderr,"viewman: making a graph\n"); +#endif + if (viewCommand == makeGraph) { + aGraph = makeGraphFromSpadData(); + aGraph->nextGraph = graphList; + graphList = aGraph; + } + break; + + case view2DType: +#ifdef DEBUG + fprintf(stderr,"viewman: forking 2D\n"); +#endif + if (viewCommand == makeViewport) { + forkView2D(); + } else { + funView2D(viewCommand); + } + break; + + } /* switch on viewType */ + } /* if (keepLooking) */ + } /* while (1) */ +} + + + +@ +\eject +\begin{thebibliography}{99} +\bibitem{1} nothing +\end{thebibliography} +\end{document} diff --git a/src/graph/viewman/viewman.h b/src/graph/viewman/viewman.h new file mode 100755 index 00000000..3c54c576 --- /dev/null +++ b/src/graph/viewman/viewman.h @@ -0,0 +1,50 @@ +/* +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 "view2D.h" +#include "view3D.h" + + /* Viewport Commands */ +#define makeViewport -1 +#define makeGraph -1 + +#define check(code) checker(code,__LINE__,"") +#define maxConnect 40 +#define intSize sizeof(int) +#define floatSize sizeof(float) +#define yes 1 +#define no 0 + + +#include "com.h" +#include "globalsM.h" -- cgit v1.2.3