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.32 by gwlarson, Wed Aug 26 13:06:09 1998 UTC vs.
Revision 3.36 by gwlarson, Thu Dec 10 10:45:54 1998 UTC

# Line 18 | Line 18 | static char SCCSid[] = "$SunId$ SGI";
18   #define VIEWHISTLEN     4       /* number of remembered views */
19   #endif
20  
21 + #ifndef FSIZDEF
22 + #define FSIZDEF         0.125   /* default focus frame size */
23 + #endif
24 +
25   HOLO    *hdlist[HDMAX+1];       /* global holodeck list */
26  
27   char    cmdlist[DC_NCMDS][8] = DC_INIT;
# Line 88 | Line 92 | char   *argv[];
92                                  printview();
93                          if (inp & DFL(DC_LASTVIEW))
94                                  new_view(NULL);
95 +                        if (inp & DFL(DC_FOCUS))
96 +                                set_focus(odev_args);
97                          if (inp & DFL(DC_KILL)) {
98                                  serv_request(DR_KILL, 0, NULL);
99                                  pause = 0;
# Line 109 | Line 115 | char   *argv[];
115                          if (inp & DFL(DC_QUIT))
116                                  serv_request(DR_SHUTDOWN, 0, NULL);
117                  }
118 <                if (rdy & RDY_SIN)              /* user input from sstdin */
118 >                if (rdy & RDY_SIN && !imm_mode) /* user input from sstdin */
119                          switch (usr_input()) {
120                          case DC_PAUSE:
121                                  pause = 1;
# Line 289 | Line 295 | again:
295                          }
296                          copystruct(v, viewhist + ((nhist-1)%VIEWHISTLEN));
297                          goto again;
298 <                }
299 <        beam_sync(0);           /* update server */
298 >                }      
299 >                                /* update server */
300 >        imm_mode = beam_sync(0) > 0;
301                                  /* record new view */
302          if (v < viewhist || v >= viewhist+VIEWHISTLEN) {
303                  copystruct(viewhist + (nhist%VIEWHISTLEN), v);
# Line 299 | Line 306 | again:
306   }
307  
308  
309 + set_focus(args)                 /* set focus frame */
310 + char    *args;
311 + {
312 +        double  hcent, vcent, hsiz, vsiz;
313 +        VIEW    *dv, vwfocus;
314 +        int     i, res[2];
315 +
316 +        i = sscanf(args, "%lf %lf %lf %lf", &hcent, &vcent, &hsiz, &vsiz);
317 +        if (i < 2 || hcent < 0 || hcent > 1 || vcent < 0 || vcent > 1) {
318 +                beam_init(0);                           /* restore view */
319 +                for (i = 0; (dv = dev_auxview(i, res)) != NULL; i++)
320 +                        beam_view(dv, res[0], res[1]);
321 +                beam_sync(0);                           /* update server */
322 +                return;
323 +        }
324 +        if (i < 4 || hsiz <= hcent || hsiz > 1 || vsiz <= vcent || vsiz > 1)
325 +                hsiz = vsiz = FSIZDEF;                  /* gave center only */
326 +        else {
327 +                hsiz -= hcent; hcent += 0.5*hsiz;       /* gave min and max */
328 +                vsiz -= vcent; vcent += 0.5*vsiz;
329 +        }
330 +        beam_init(0);                                   /* add basic views */
331 +        for (i = 0; (dv = dev_auxview(i, res)) != NULL; i++)
332 +                beam_view(dv, res[0]>>4, res[1]>>4);
333 +        copystruct(&vwfocus, &odev.v);                  /* add focus view */
334 +        switch (odev.v.type) {
335 +        case VT_PER:
336 +                vwfocus.horiz = 2.*180./PI*atan(
337 +                                hsiz * tan(PI/180./2.*odev.v.horiz) );
338 +                vwfocus.vert = 2.*180./PI*atan(
339 +                                vsiz * tan(PI/180./2.*odev.v.vert) );
340 +                break;
341 +        case VT_PAR:
342 +        case VT_ANG:
343 +                vwfocus.horiz = hsiz * odev.v.horiz;
344 +                vwfocus.vert = vsiz * odev.v.vert;
345 +                break;
346 +        case VT_HEM:
347 +                vwfocus.horiz = 2.*180./PI*asin(
348 +                                hsiz * sin(PI/180./2.*odev.v.horiz) );
349 +                vwfocus.vert = 2.*180./PI*asin(
350 +                                vsiz * sin(PI/180./2.*odev.v.vert) );
351 +                break;
352 +        case VT_CYL:
353 +                vwfocus.horiz = hsiz * odev.v.horiz;
354 +                vwfocus.vert = 2.*180./PI*atan(
355 +                                vsiz * tan(PI/180./2.*odev.v.vert) );
356 +                break;
357 +        default:
358 +                error(INTERNAL, "bad view type in set_focus");
359 +        }
360 +        vwfocus.hoff = (odev.v.hoff + hcent - 0.5)/hsiz;
361 +        vwfocus.voff = (odev.v.voff + vcent - 0.5)/vsiz;
362 +        setview(&vwfocus);
363 +        beam_view(&vwfocus, (int)(3*odev.hres*hsiz)+100,
364 +                        (int)(3*odev.vres*vsiz)+100);
365 +        beam_sync(0);                                   /* update server */
366 + }
367 +
368 +
369   int
370   usr_input()                     /* get user input and process it */
371   {
# Line 341 | Line 408 | usr_input()                    /* get user input and process it */
408          case DC_LASTVIEW:               /* restore previous view */
409                  new_view(NULL);
410                  break;
411 +        case DC_FOCUS:                  /* set focus frame */
412 +                set_focus(args);
413 +                break;
414          case DC_PAUSE:                  /* pause the current calculation */
415          case DC_RESUME:                 /* resume the calculation */
416                  /* handled in main() */
# Line 421 | Line 491 | serv_result()                  /* get next server result and process
491          case DS_STARTIMM:
492          case DS_ENDIMM:
493   #ifdef DEBUG
494 <                if (imm_mode != (msg.type==DS_STARTIMM)) {
494 >                {
495                          time_t  tnow = time(NULL);
496 <                        if (imm_mode) timm += tnow - tmodesw;
497 <                        else tadd += tnow - tmodesw;
496 >                        if (msg.type==DS_STARTIMM) tadd += tnow - tmodesw;
497 >                        else timm += tnow - tmodesw;
498                          tmodesw = tnow;
499                  }
500   #endif
501 <                imm_mode = msg.type==DS_STARTIMM;
501 >                if (!(imm_mode = msg.type==DS_STARTIMM))
502 >                        dev_flush();
503                  goto noargs;
504          case DS_ACKNOW:
505          case DS_SHUTDOWN:
# Line 457 | Line 528 | char   *p;
528   {
529          MSGHEAD msg;
530          int     m;
531 +                                /* consistency checks */
532 + #ifdef DEBUG
533 +        if (nbytes < 0 || nbytes > 0 & p == NULL)
534 +                error(CONSISTENCY, "bad buffer handed to serv_request");
535 + #endif
536                                  /* get server's attention for big request */
537          if (nbytes >= BIGREQSIZ-sizeof(MSGHEAD)) {
538                  serv_request(DR_ATTEN, 0, NULL);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines