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.12 by gregl, Thu Dec 11 09:37:43 1997 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     2       /* 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 58 | Line 62 | char   *argv[];
62                                  printview();
63                          if (inp & DEV_NEWVIEW)
64                                  new_view(&odev.v);
65 +                        if (inp & DEV_LASTVIEW)
66 +                                new_view(NULL);
67                          if (inp & DEV_SHUTDOWN)
68                                  serv_request(DR_SHUTDOWN, 0, NULL);
69 <                        if (inp & DEV_REDRAW) {
70 <                                imm_mode = 1;   /* preempt updates */
65 <                                beam_sync();
66 <                        }
69 >                        if (inp & DEV_REDRAW)
70 >                                imm_mode = beam_sync() > 0;
71                          if (inp & DEV_WAIT)
72                                  pause = 1;
73                          if (inp & DEV_RESUME) {
# Line 190 | Line 194 | register PACKHEAD      *p;
194  
195  
196   new_view(v)                     /* change view parameters */
197 < VIEW    *v;
197 > register VIEW   *v;
198   {
199 +        static VIEW     viewhist[VIEWHISTLEN];
200 +        static unsigned nhist;
201          char    *err;
202 <
203 <        do {
204 <                if ((err = setview(v)) != NULL) {
205 <                        error(COMMAND, err);
202 >                                /* restore previous view? */
203 >        if (v == NULL) {
204 >                if (nhist < 2) {
205 >                        error(COMMAND, "no previous view");
206                          return;
207                  }
208 <                if (v->type == VT_PAR) {
209 <                        error(COMMAND, "cannot handle parallel views");
210 <                        return;
211 <                }
212 <                dev_view(v);            /* update display driver */
213 <                dev_flush();            /* update screen */
214 <        } while (!beam_view(v));        /* update beam list */
208 >                nhist--;        /* get one before last setting */
209 >                v = viewhist + ((nhist-1)%VIEWHISTLEN);
210 >        } else if ((err = setview(v)) != NULL) {
211 >                error(COMMAND, err);
212 >                return;
213 >        }
214 > again:
215 >        if (v->type == VT_PAR) {
216 >                error(COMMAND, "cannot handle parallel views");
217 >                return;
218 >        }
219 >        if (!dev_view(v))       /* update display driver */
220 >                goto again;
221 >        dev_flush();            /* update screen */
222 >        if (!beam_view(v))      /* update beam list */
223 >                goto again;
224 >                                /* record new view */
225 >        if (v < viewhist || v >= viewhist+VIEWHISTLEN) {
226 >                copystruct(viewhist + (nhist%VIEWHISTLEN), v);
227 >                nhist++;
228 >        }
229   }
230  
231  
# Line 215 | Line 235 | usr_input()                    /* get user input and process it */
235          VIEW    vparams;
236          char    cmd[128];
237          register char   *args;
238 <        register int    cmdno;
238 >        register int    i;
239  
240          if (fgets(cmd, sizeof(cmd), sstdin) == NULL)
241                  return(DC_QUIT);
# Line 225 | Line 245 | usr_input()                    /* get user input and process it */
245                  *args++ = '\0';
246          if (!*cmd)
247                  return(DC_RESUME);
248 <        for (cmdno = 0; cmdno < DC_NCMDS; cmdno++)
249 <                if (!strcmp(cmd, cmdlist[cmdno]))
248 >        if (*args && args[i=strlen(args)-1] == '\n')
249 >                args[i] = '\0';
250 >        for (i = 0; i < DC_NCMDS; i++)
251 >                if (!strcmp(cmd, cmdlist[i]))
252                          break;
253 <        if (cmdno >= DC_NCMDS) {
253 >        if (i >= DC_NCMDS) {
254                  sprintf(errmsg, "unknown command: %s", cmd);
255                  error(COMMAND, errmsg);
256                  return(-1);
257          }
258 <        switch (cmdno) {
258 >        switch (i) {
259          case DC_SETVIEW:                /* set the view */
260                  copystruct(&vparams, &odev.v);
261                  if (!sscanview(&vparams, args))
# Line 244 | Line 266 | usr_input()                    /* get user input and process it */
266          case DC_GETVIEW:                /* print the current view */
267                  printview();
268                  break;
269 +        case DC_LASTVIEW:               /* restore previous view */
270 +                new_view(NULL);
271 +                break;
272          case DC_PAUSE:                  /* pause the current calculation */
273          case DC_RESUME:                 /* resume the calculation */
274                  /* handled in main() */
# Line 254 | Line 279 | usr_input()                    /* get user input and process it */
279          default:
280                  error(CONSISTENCY, "bad command id in usr_input");
281          }
282 <        return(cmdno);
258 <                
282 >        return(i);
283   }
284  
285  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines