ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rhdisp.c
(Generate patch)

Comparing ray/src/hd/rhdisp.c (file contents):
Revision 3.10 by gregl, Mon Dec 8 18:51:15 1997 UTC vs.
Revision 3.19 by gregl, Sun Jan 4 12:28:09 1998 UTC

# Line 14 | Line 14 | static char SCCSid[] = "$SunId$ SGI";
14   #include "selcall.h"
15   #include <ctype.h>
16  
17 + #ifndef VIEWHISTLEN
18 + #define VIEWHISTLEN     4       /* number of remembered views */
19 + #endif
20 +
21   HOLO    *hdlist[HDMAX+1];       /* global holodeck list */
22  
23   char    cmdlist[DC_NCMDS][8] = DC_INIT;
# Line 52 | Line 56 | char   *argv[];
56                                          /* enter main loop */
57          do {
58                  rdy = disp_wait();
59 +                if (rdy & RDY_SRV) {            /* process server result */
60 +                        res = serv_result();
61 +                        if (pause && res != DS_SHUTDOWN) {
62 +                                serv_request(DR_ATTEN, 0, NULL);
63 +                                while ((res = serv_result()) != DS_ACKNOW &&
64 +                                                res != DS_SHUTDOWN)
65 +                                        ;
66 +                        }
67 +                }
68                  if (rdy & RDY_DEV) {            /* user input from driver */
69                          inp = dev_input();
70 <                        if (inp & DEV_PUTVIEW)
58 <                                printview();
59 <                        if (inp & DEV_NEWVIEW)
70 >                        if (inp & DFL(DC_SETVIEW))
71                                  new_view(&odev.v);
72 <                        if (inp & DEV_SHUTDOWN)
73 <                                serv_request(DR_SHUTDOWN, 0, NULL);
74 <                        if (inp & DEV_REDRAW) {
75 <                                imm_mode = 1;   /* preempt updates */
76 <                                beam_sync();
72 >                        if (inp & DFL(DC_GETVIEW))
73 >                                printview();
74 >                        if (inp & DFL(DC_LASTVIEW))
75 >                                new_view(NULL);
76 >                        if (inp & DFL(DC_RESUME)) {
77 >                                serv_request(DR_NOOP, 0, NULL);
78 >                                pause = 0;
79                          }
80 <                        if (inp & DEV_WAIT)
80 >                        if (inp & DFL(DC_PAUSE))
81                                  pause = 1;
82 <                        if (inp & DEV_RESUME) {
83 <                                serv_request(DR_NOOP, 0, NULL);
82 >                        if (inp & DFL(DC_REDRAW))
83 >                                imm_mode = beam_sync() > 0;
84 >                        if (inp & DFL(DC_KILL)) {
85 >                                serv_request(DR_KILL, 0, NULL);
86                                  pause = 0;
87                          }
88 +                        if (inp & DFL(DC_CLOBBER))
89 +                                serv_request(DR_CLOBBER, 0, NULL);
90 +                        if (inp & DFL(DC_RESTART)) {
91 +                                serv_request(DR_RESTART, 0, NULL);
92 +                                pause = 0;
93 +                        }
94 +                        if (inp & DFL(DC_QUIT))
95 +                                serv_request(DR_SHUTDOWN, 0, NULL);
96                  }
97                  if (rdy & RDY_SIN)              /* user input from sstdin */
98                          switch (usr_input()) {
# Line 78 | Line 101 | char   *argv[];
101                                  break;
102                          case DC_RESUME:
103                                  serv_request(DR_NOOP, 0, NULL);
104 +                                /* fall through */
105 +                        case DC_KILL:
106 +                        case DC_RESTART:
107                                  pause = 0;
108                                  break;
109                          }
84                if (rdy & RDY_SRV) {            /* process server result */
85                        res = serv_result();
86                        if (pause && res != DS_SHUTDOWN) {
87                                serv_request(DR_ATTEN, 0, NULL);
88                                while ((res = serv_result()) != DS_ACKNOW &&
89                                                res != DS_SHUTDOWN)
90                                        ;
91                        }
92                }
110          } while (res != DS_SHUTDOWN);
111                                          /* all done */
112          quit(0);
# Line 190 | Line 207 | register PACKHEAD      *p;
207  
208  
209   new_view(v)                     /* change view parameters */
210 < VIEW    *v;
210 > register VIEW   *v;
211   {
212 +        static VIEW     viewhist[VIEWHISTLEN];
213 +        static unsigned nhist;
214          char    *err;
215 <
216 <        do {
217 <                if ((err = setview(v)) != NULL) {
218 <                        error(COMMAND, err);
219 <                        return;
220 <                }
221 <                if (v->type == VT_PAR) {
222 <                        error(COMMAND, "cannot handle parallel views");
223 <                        return;
224 <                }
225 <                dev_view(v);            /* update display driver */
226 <                dev_flush();            /* update screen */
227 <        } while (!beam_view(v));        /* update beam list */
215 >                                /* restore previous view? */
216 >        if (v == NULL) {
217 >                if (nhist > 1)          /* get one before last setting */
218 >                        nhist--;
219 >                else                    /* else go to end of list */
220 >                        while (nhist < VIEWHISTLEN && viewhist[nhist].type)
221 >                                nhist++;
222 >                v = viewhist + ((nhist-1)%VIEWHISTLEN);
223 >        } else
224 > again:
225 >        if ((err = setview(v)) != NULL) {
226 >                error(COMMAND, err);
227 >                return;
228 >        }
229 >        if (v->type == VT_PAR) {
230 >                error(COMMAND, "cannot handle parallel views");
231 >                return;
232 >        }
233 >        if (!dev_view(v))       /* update display driver */
234 >                goto again;
235 >        dev_flush();            /* update screen */
236 >        if (!beam_view(v))      /* update beam list */
237 >                goto again;
238 >                                /* record new view */
239 >        if (v < viewhist || v >= viewhist+VIEWHISTLEN) {
240 >                copystruct(viewhist + (nhist%VIEWHISTLEN), v);
241 >                nhist++;
242 >        }
243   }
244  
245  
# Line 215 | Line 249 | usr_input()                    /* get user input and process it */
249          VIEW    vparams;
250          char    cmd[128];
251          register char   *args;
252 <        register int    cmdno;
252 >        register int    i;
253  
254          if (fgets(cmd, sizeof(cmd), sstdin) == NULL)
255                  return(DC_QUIT);
# Line 225 | Line 259 | usr_input()                    /* get user input and process it */
259                  *args++ = '\0';
260          if (!*cmd)
261                  return(DC_RESUME);
262 <        for (cmdno = 0; cmdno < DC_NCMDS; cmdno++)
263 <                if (!strcmp(cmd, cmdlist[cmdno]))
262 >        if (*args && args[i=strlen(args)-1] == '\n')
263 >                args[i] = '\0';
264 >        for (i = 0; i < DC_NCMDS; i++)
265 >                if (!strcmp(cmd, cmdlist[i]))
266                          break;
267 <        if (cmdno >= DC_NCMDS) {
267 >        if (i >= DC_NCMDS) {
268                  sprintf(errmsg, "unknown command: %s", cmd);
269                  error(COMMAND, errmsg);
270                  return(-1);
271          }
272 <        switch (cmdno) {
272 >        switch (i) {
273          case DC_SETVIEW:                /* set the view */
274                  copystruct(&vparams, &odev.v);
275                  if (!sscanview(&vparams, args))
# Line 244 | Line 280 | usr_input()                    /* get user input and process it */
280          case DC_GETVIEW:                /* print the current view */
281                  printview();
282                  break;
283 +        case DC_LASTVIEW:               /* restore previous view */
284 +                new_view(NULL);
285 +                break;
286          case DC_PAUSE:                  /* pause the current calculation */
287          case DC_RESUME:                 /* resume the calculation */
288                  /* handled in main() */
289                  break;
290 +        case DC_REDRAW:                 /* redraw from server */
291 +                imm_mode = beam_sync() > 0;
292 +                break;
293 +        case DC_KILL:                   /* kill rtrace process(es) */
294 +                serv_request(DR_KILL, 0, NULL);
295 +                break;
296 +        case DC_CLOBBER:                /* clobber holodeck */
297 +                serv_request(DR_CLOBBER, 0, NULL);
298 +                break;
299 +        case DC_RESTART:                /* restart rtrace */
300 +                serv_request(DR_RESTART, 0, NULL);
301 +                break;
302          case DC_QUIT:                   /* quit request */
303                  serv_request(DR_SHUTDOWN, 0, NULL);
304                  break;
305          default:
306                  error(CONSISTENCY, "bad command id in usr_input");
307          }
308 <        return(cmdno);
258 <                
308 >        return(i);
309   }
310  
311  
# Line 305 | Line 355 | serv_result()                  /* get next server result and process
355          case DS_STARTIMM:
356          case DS_ENDIMM:
357                  imm_mode = msg.type==DS_STARTIMM;
308                if (msg.type == DS_ENDIMM)
309                        dev_flush();            /* update display NOW */
358                  /* fall through */
359          case DS_ACKNOW:
360          case DS_SHUTDOWN:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines