~ubuntu-branches/ubuntu/karmic/axiom/karmic

« back to all changes in this revision

Viewing changes to src/graph/viewman/viewman.c.pamphlet

  • Committer: Bazaar Package Importer
  • Author(s):
  • Date: 2005-02-21 17:08:37 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050221170837-34vm4j33v4t9hsk4
Tags: 20050201-1
* New upstream release
* Bug fix: "axiom graphics missing?", thanks to Daniel Lakeland (Closes:
  #277692).
* Bug fix: "axiom: Feb 2005 release for sarge would be nice", thanks to
  Balbir Thomas (Closes: #295000).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
\documentclass{article}
 
2
\usepackage{axiom}
 
3
\begin{document}
 
4
\title{\$SPAD/src/graph/viewman viewman.c}
 
5
\author{The Axiom Team}
 
6
\maketitle
 
7
\begin{abstract}
 
8
\end{abstract}
 
9
\eject
 
10
\tableofcontents
 
11
\eject
 
12
\section{License}
 
13
<<license>>=
 
14
/*
 
15
Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
 
16
All rights reserved.
 
17
 
 
18
Redistribution and use in source and binary forms, with or without
 
19
modification, are permitted provided that the following conditions are
 
20
met:
 
21
 
 
22
    - Redistributions of source code must retain the above copyright
 
23
      notice, this list of conditions and the following disclaimer.
 
24
 
 
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
 
28
      distribution.
 
29
 
 
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.
 
33
 
 
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.
 
45
*/
 
46
@
 
47
<<*>>=
 
48
<<license>>
 
49
 
 
50
#define _VIEWMAN_C
 
51
#include "useproto.h"
 
52
 
 
53
#include <unistd.h>
 
54
#include <sys/time.h>
 
55
#include <stdlib.h>
 
56
#include <stdio.h>
 
57
#include <string.h>
 
58
#include <signal.h>
 
59
#ifdef SGIplatform
 
60
#include <bstring.h>
 
61
#endif
 
62
 
 
63
#include "viewman.h"
 
64
#include "mode.h"
 
65
#include "actions.h"
 
66
#include "viewCommand.h"
 
67
#include "bsdsignal.h"
 
68
 
 
69
 
 
70
#include "bsdsignal.H1"
 
71
#include "util.H1"
 
72
#include "sockio-c.H1"
 
73
#include "fun2D.H1"
 
74
#include "fun3D.H1"
 
75
#include "makeGraph.H1"
 
76
#include "readView.H1"
 
77
#include "cleanup.H1"
 
78
#include "sselect.H1"
 
79
 
 
80
/************* global variables **************/
 
81
 
 
82
Display *dsply;
 
83
Window  root;
 
84
XEvent  viewmanEvent;
 
85
viewManager *viewports,
 
86
  *slot,
 
87
  *stepSlot;
 
88
Sock        *spadSock;
 
89
int         viewType, 
 
90
  viewCommand,
 
91
  acknow,
 
92
  graphKey = 1,
 
93
  defDsply,
 
94
  currentGraph,
 
95
  picked = no,
 
96
  viewOkay  = 0,
 
97
  viewError = -1,
 
98
  checkClosedChild = no,
 
99
  foundBrokenPipe = no;
 
100
fd_set      filedes;
 
101
graphStruct *graphList;
 
102
graphStateStruct currentGraphState;
 
103
char        *s1,
 
104
  propertyBuffer[256];/* XProperty buffer */
 
105
 
 
106
 
 
107
int
 
108
#ifdef _NO_PROTO
 
109
main ()
 
110
#else
 
111
main (void)
 
112
#endif
 
113
{
 
114
 
 
115
  graphStruct *aGraph;
 
116
  int keepLooking,code;
 
117
  
 
118
  bsdSignal(SIGPIPE,brokenPipe,DontRestartSystemCalls);
 
119
  bsdSignal(SIGCLD,endChild,RestartSystemCalls);
 
120
  bsdSignal(SIGTERM,goodbye,DontRestartSystemCalls);
 
121
  
 
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");
 
126
    exit(-1);
 
127
  }
 
128
#ifdef DEBUG
 
129
  else
 
130
    fprintf(stderr,"viewman: Connected to AXIOM\n");
 
131
#endif
 
132
  
 
133
  /******** initialize ********/
 
134
  viewports = 0;
 
135
  graphList = 0;
 
136
  
 
137
  /******** getting stuff from spad and viewports ********
 
138
  *********   the viewports have priority over    ****
 
139
  ***   AXIOM.                              ***/
 
140
  while (1) {
 
141
    FD_ZERO(&filedes); /* zero out file descriptor */
 
142
    FD_SET(spadSock->socket,&filedes);
 
143
    slot = viewports;
 
144
    while (slot) {
 
145
      FD_SET(slot->viewIn,&filedes);
 
146
      slot = slot->nextViewport;
 
147
    }
 
148
    
 
149
#ifdef DEBUG
 
150
    fprintf(stderr,"Selection for filedes of %x \n",filedes);
 
151
#endif
 
152
    code = check(superSelect(FD_SETSIZE,(void *) &filedes,0,0,0));
 
153
    for (;code<=0;) 
 
154
      code = check(superSelect(FD_SETSIZE,(void *)&filedes,0,0,0));
 
155
    
 
156
    slot = viewports;
 
157
    keepLooking = 1;
 
158
    while (keepLooking && slot) {
 
159
      if (FD_ISSET(slot->viewIn,&filedes)) {
 
160
        keepLooking = 0;
 
161
#ifdef DEBUG
 
162
        fprintf(stderr,"Reading child viewport...\n");
 
163
#endif
 
164
        readViewport(slot,&viewCommand,intSize);
 
165
        
 
166
        switch (viewCommand) {
 
167
          
 
168
        case pick2D:
 
169
#ifdef DEBUG
 
170
          fprintf(stderr,"viewman: Doing 2D pick\n");
 
171
#endif
 
172
          picked = yes;
 
173
          
 
174
          readViewport(slot,&currentGraph,intSize); /* get the graph to pick */
 
175
          readViewport(slot,&currentGraphState,sizeof(graphStateStruct));
 
176
          break;
 
177
          
 
178
        case drop2D:
 
179
#ifdef DEBUG
 
180
          fprintf(stderr,"viewman: Doing 2D drop\n");
 
181
#endif
 
182
          if (picked) {
 
183
            write(slot->viewOut,&viewOkay,intSize);
 
184
            write(slot->viewOut,&currentGraph,intSize);
 
185
            sendGraphToView2D(0,currentGraph,slot,&currentGraphState);
 
186
          } else {
 
187
            write(slot->viewOut,&viewError,intSize);
 
188
            fprintf(stderr,"The viewport manager cannot drop a graph because nothing has been picked yet.\n");
 
189
          }
 
190
          break;
 
191
          
 
192
        case viewportClosing:
 
193
#ifdef DEBUG
 
194
          fprintf(stderr,"viewman: closing viewport\n");
 
195
#endif
 
196
          closeChildViewport(slot);
 
197
          break;
 
198
 
 
199
        };  /* switch */
 
200
        
 
201
      };  /* if reading slot->viewIn */
 
202
      stepSlot = slot;
 
203
      slot = slot->nextViewport;
 
204
    };  /* while */
 
205
    
 
206
    if (keepLooking) {   /* if  1 => slots not read, read from spad */
 
207
#ifdef DEBUG
 
208
      fprintf(stderr,"viewman: still looking\n");
 
209
#endif
 
210
      viewType = get_int(spadSock);
 
211
      if (viewType == -1) goodbye(-1);
 
212
      viewCommand = get_int(spadSock);
 
213
      
 
214
      switch (viewType) {
 
215
        
 
216
      case view3DType:
 
217
#ifdef DEBUG
 
218
        fprintf(stderr,"viewman: making 3D viewport\n");
 
219
#endif
 
220
        if (viewCommand == makeViewport) 
 
221
          forkView3D(view3DType);
 
222
        else 
 
223
          funView3D(viewCommand);
 
224
        
 
225
        break;
 
226
        
 
227
      case viewTubeType:
 
228
#ifdef DEBUG
 
229
        fprintf(stderr,"viewman: viewing a tube\n");
 
230
#endif
 
231
        if (viewCommand == makeViewport) 
 
232
          forkView3D(viewTubeType);
 
233
        else 
 
234
          funView3D(viewCommand);
 
235
        
 
236
        break;
 
237
        
 
238
      case viewGraphType:
 
239
#ifdef DEBUG
 
240
        fprintf(stderr,"viewman: making a graph\n");
 
241
#endif
 
242
        if (viewCommand == makeGraph) {
 
243
          aGraph            = makeGraphFromSpadData();
 
244
          aGraph->nextGraph = graphList;
 
245
          graphList         = aGraph;
 
246
        }
 
247
        break;
 
248
        
 
249
      case view2DType:
 
250
#ifdef DEBUG
 
251
        fprintf(stderr,"viewman: forking 2D\n");
 
252
#endif
 
253
        if (viewCommand == makeViewport) {
 
254
          forkView2D();
 
255
        } else {
 
256
          funView2D(viewCommand);
 
257
        }
 
258
        break;
 
259
        
 
260
      }   /* switch on viewType */
 
261
    }   /* if (keepLooking) */ 
 
262
  }   /* while (1) */
 
263
}
 
264
 
 
265
 
 
266
 
 
267
@
 
268
\eject
 
269
\begin{thebibliography}{99}
 
270
\bibitem{1} nothing
 
271
\end{thebibliography}
 
272
\end{document}