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

Comparing ray/src/hd/rhd_x11.c (file contents):
Revision 3.8 by gregl, Tue Nov 25 11:21:50 1997 UTC vs.
Revision 3.9 by gregl, Tue Nov 25 16:52:51 1997 UTC

# Line 49 | Line 49 | static unsigned long  *pixval = NULL;  /* allocated pix
49   static unsigned long  ourblack=0, ourwhite=1;
50  
51   static Display  *ourdisplay = NULL;     /* our display */
52
52   static XVisualInfo  ourvinfo;           /* our visual information */
54
53   static Window  gwind = 0;               /* our graphics window */
56
54   static GC  ourgc = 0;                   /* our graphics context for drawing */
58
55   static Colormap ourmap = 0;             /* our color map */
56  
57   static double   pwidth, pheight;        /* pixel dimensions (mm) */
# Line 380 | Line 376 | getevent()                     /* get next event */
376  
377  
378   static
379 + ilclip(dp, wp)                  /* clip world coordinates to device */
380 + int     dp[2][2];
381 + FVECT   wp[2];
382 + {
383 +        static FVECT    vmin = {0.,0.,0.}, vmax = {1.,1.,FHUGE};
384 +        FVECT   ip[2];
385 +                                /* not exactly right, but who cares? */
386 +        viewloc(ip[0], &odev.v, wp[0]);
387 +        viewloc(ip[1], &odev.v, wp[1]);
388 +        if (!clip(ip[0], ip[1], vmin, vmax))
389 +                return(0);
390 +        dp[0][0] = ip[0][0]*odev.hres;
391 +        dp[0][1] = ip[0][1]*odev.vres;
392 +        dp[1][0] = ip[1][0]*odev.hres;
393 +        dp[1][1] = ip[1][1]*odev.vres;
394 +        return(1);
395 + }
396 +
397 +
398 + static
399 + draw3dline(wp)                  /* draw 3d line in world coordinates */
400 + FVECT   wp[2];
401 + {
402 +        int     dp[2][2];
403 +
404 +        if (!ilclip(dp, wp))
405 +                return;
406 +        XDrawLine(ourdisplay, gwind, ourgc,
407 +                        dp[0][0], odev.vres-1 - dp[0][1],
408 +                        dp[1][0], odev.vres-1 - dp[1][1]);
409 + }
410 +
411 +
412 + static
413 + draw_grids()                    /* draw holodeck section grids */
414 + {
415 +        static BYTE     gridrgb[3] = {0x0, 0xff, 0xff};
416 +        unsigned long  pixel;
417 +
418 +        if (!mapped || odev.v.type != VT_PER)
419 +                return;
420 +        if (ncolors > 0)
421 +                pixel = pixval[get_pixel(gridrgb, xnewcolr)];
422 +        else
423 +                pixel = true_pixel(gridrgb);
424 +        XSetForeground(ourdisplay, ourgc, pixel);
425 +                                        /* draw each grid line */
426 +        gridlines(draw3dline);
427 + }
428 +
429 +
430 + static
431   moveview(dx, dy, move)          /* move our view */
432   int     dx, dy, move;
433   {
# Line 432 | Line 480 | XButtonPressedEvent    *ebut;
480          unsigned int    statemask;
481  
482          qtMinNodesiz = 16;              /* for quicker update */
483 +        XNoOp(ourdisplay);
484  
485 <        do {
485 >        while (!XCheckMaskEvent(ourdisplay,
486 >                        ButtonReleaseMask, levptr(XEvent))) {
487 >
488                  if (!XQueryPointer(ourdisplay, gwind, &rootw, &childw,
489                                  &rootx, &rooty, &wx, &wy, &statemask))
490                          break;          /* on another screen */
491  
492 <                if (!moveview(wx, odev.vres-1-wy, MOVDIR(whichbutton)))
492 >                if (!moveview(wx, odev.vres-1-wy, MOVDIR(whichbutton))) {
493                          sleep(1);
494 <                else
495 <                        qtUpdate();
496 <
497 <        } while (!XCheckMaskEvent(ourdisplay,
498 <                        ButtonReleaseMask, levptr(XEvent)));
499 <
494 >                        continue;
495 >                }
496 >                XClearWindow(ourdisplay, gwind);
497 >                qtUpdate();
498 >                draw_grids();
499 >        }
500          if (!(inpresflags & DEV_NEWVIEW)) {     /* do final motion */
501                  whichbutton = levptr(XButtonReleasedEvent)->button;
502                  wx = levptr(XButtonReleasedEvent)->x;
503                  wy = levptr(XButtonReleasedEvent)->y;
504                  moveview(wx, odev.vres-1-wy, MOVDIR(whichbutton));
454                dev_flush();
505          }
506 +        dev_flush();
507  
508          qtMinNodesiz = oldnodesiz;      /* restore quadtree resolution */
509   }
# Line 498 | Line 549 | register XKeyPressedEvent  *ekey;
549                  if (inpresflags & DEV_REDRAW)
550                          return;
551                  XClearWindow(ourdisplay, gwind);
552 +                draw_grids();
553                  XFlush(ourdisplay);
554                  qtCompost(100);                 /* unload the old tree */
555                  if (ncolors > 0)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines