1
\documentclass{article}
4
\title{\$SPAD/src/graph/viewman viewman.c}
5
\author{The Axiom Team}
15
Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
18
Redistribution and use in source and binary forms, with or without
19
modification, are permitted provided that the following conditions are
22
- Redistributions of source code must retain the above copyright
23
notice, this list of conditions and the following disclaimer.
25
- Redistributions in binary form must reproduce the above copyright
26
notice, this list of conditions and the following disclaimer in
27
the documentation and/or other materials provided with the
30
- Neither the name of The Numerical ALgorithms Group Ltd. nor the
31
names of its contributors may be used to endorse or promote products
32
derived from this software without specific prior written permission.
34
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
35
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
36
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
37
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
38
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
39
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
40
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
41
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
42
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
43
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
44
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
66
#include "viewCommand.h"
67
#include "bsdsignal.h"
70
#include "bsdsignal.H1"
72
#include "sockio-c.H1"
75
#include "makeGraph.H1"
76
#include "readView.H1"
80
/************* global variables **************/
85
viewManager *viewports,
98
checkClosedChild = no,
101
graphStruct *graphList;
102
graphStateStruct currentGraphState;
104
propertyBuffer[256];/* XProperty buffer */
116
int keepLooking,code;
118
bsdSignal(SIGPIPE,brokenPipe,DontRestartSystemCalls);
119
bsdSignal(SIGCLD,endChild,RestartSystemCalls);
120
bsdSignal(SIGTERM,goodbye,DontRestartSystemCalls);
122
/* Connect up to AXIOM server */
123
spadSock = connect_to_local_server(SpadServer,ViewportServer,Forever);
124
if (spadSock == NULL) {
125
fprintf(stderr,"The viewport manager couldn't connect to AXIOM\n");
130
fprintf(stderr,"viewman: Connected to AXIOM\n");
133
/******** initialize ********/
137
/******** getting stuff from spad and viewports ********
138
********* the viewports have priority over ****
141
FD_ZERO(&filedes); /* zero out file descriptor */
142
FD_SET(spadSock->socket,&filedes);
145
FD_SET(slot->viewIn,&filedes);
146
slot = slot->nextViewport;
150
fprintf(stderr,"Selection for filedes of %x \n",filedes);
152
code = check(superSelect(FD_SETSIZE,(void *) &filedes,0,0,0));
154
code = check(superSelect(FD_SETSIZE,(void *)&filedes,0,0,0));
158
while (keepLooking && slot) {
159
if (FD_ISSET(slot->viewIn,&filedes)) {
162
fprintf(stderr,"Reading child viewport...\n");
164
readViewport(slot,&viewCommand,intSize);
166
switch (viewCommand) {
170
fprintf(stderr,"viewman: Doing 2D pick\n");
174
readViewport(slot,¤tGraph,intSize); /* get the graph to pick */
175
readViewport(slot,¤tGraphState,sizeof(graphStateStruct));
180
fprintf(stderr,"viewman: Doing 2D drop\n");
183
write(slot->viewOut,&viewOkay,intSize);
184
write(slot->viewOut,¤tGraph,intSize);
185
sendGraphToView2D(0,currentGraph,slot,¤tGraphState);
187
write(slot->viewOut,&viewError,intSize);
188
fprintf(stderr,"The viewport manager cannot drop a graph because nothing has been picked yet.\n");
192
case viewportClosing:
194
fprintf(stderr,"viewman: closing viewport\n");
196
closeChildViewport(slot);
201
}; /* if reading slot->viewIn */
203
slot = slot->nextViewport;
206
if (keepLooking) { /* if 1 => slots not read, read from spad */
208
fprintf(stderr,"viewman: still looking\n");
210
viewType = get_int(spadSock);
211
if (viewType == -1) goodbye(-1);
212
viewCommand = get_int(spadSock);
218
fprintf(stderr,"viewman: making 3D viewport\n");
220
if (viewCommand == makeViewport)
221
forkView3D(view3DType);
223
funView3D(viewCommand);
229
fprintf(stderr,"viewman: viewing a tube\n");
231
if (viewCommand == makeViewport)
232
forkView3D(viewTubeType);
234
funView3D(viewCommand);
240
fprintf(stderr,"viewman: making a graph\n");
242
if (viewCommand == makeGraph) {
243
aGraph = makeGraphFromSpadData();
244
aGraph->nextGraph = graphList;
251
fprintf(stderr,"viewman: forking 2D\n");
253
if (viewCommand == makeViewport) {
256
funView2D(viewCommand);
260
} /* switch on viewType */
261
} /* if (keepLooking) */
269
\begin{thebibliography}{99}
271
\end{thebibliography}