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.28 by gwlarson, Thu Aug 27 19:32:27 1998 UTC vs.
Revision 3.33 by greg, Mon Apr 14 16:56:19 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1998 Silicon Graphics, Inc. */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * X11 driver for holodeck display.
6   * Based on rview driver.
7   */
8  
9   #include "standard.h"
13 #include "rhd_qtree.h"
14
10   #include  <X11/Xlib.h>
11   #include  <X11/cursorfont.h>
12   #include  <X11/Xutil.h>
13 <
13 > #include  <time.h>
14 > #include "rhd_qtree.h"
15   #include  "x11icon.h"
16  
17   #ifndef RAYQLEN
# Line 28 | Line 24 | static char SCCSid[] = "$SunId$ SGI";
24  
25   #define GAMMA           2.2             /* default gamma correction */
26  
27 + #define FRAMESTATE(s)   (((s)&(ShiftMask|ControlMask))==(ShiftMask|ControlMask))
28 +
29   #define MOVPCT          7               /* percent distance to move /frame */
30   #define MOVDIR(b)       ((b)==Button1 ? 1 : (b)==Button2 ? 0 : -1)
31   #define MOVDEG          (-5)            /* degrees to orbit CW/down /frame */
# Line 49 | Line 47 | static char SCCSid[] = "$SunId$ SGI";
47  
48   struct driver   odev;                   /* global device driver structure */
49  
50 + char odev_args[64];                     /* command arguments */
51 +
52   static XEvent  currentevent;            /* current event */
53  
54   static int  ncolors = 0;                /* color table size */
# Line 68 | Line 68 | static int     inpresflags;            /* input result flags */
68  
69   static int      headlocked = 0;         /* lock vertical motion */
70  
71 < static int  getpixels(), xnewcolr(), freepixels(), resizewindow(),
71 > static int  getpixels(), xnewcolr(), freepixels(), resizewindow(), getframe(),
72                  getevent(), getkey(), moveview(), getmove(), fixwindow();
73   static unsigned long  true_pixel();
74  
# Line 265 | Line 265 | VIEW   *nv;
265   }
266  
267  
268 + dev_section(ofn)                /* add octree for geometry rendering */
269 + char    *ofn;
270 + {
271 +        /* unimplemented */
272 + }
273 +
274 +
275   dev_auxcom(cmd, args)           /* process an auxiliary command */
276   char    *cmd, *args;
277   {
# Line 368 | Line 375 | loop:
375                          return(ncolors = 0);
376                  if (XAllocColorCells(ourdisplay,ourmap,0,NULL,0,pixval,ncolors))
377                          break;
378 <                free((char *)pixval);
378 >                free((void *)pixval);
379                  pixval = NULL;
380          }
381          if (pixval == NULL) {
# Line 403 | Line 410 | freepixels()                           /* free our pixels */
410          if (ncolors == 0)
411                  return;
412          XFreeColors(ourdisplay,ourmap,pixval,ncolors,0L);
413 <        free((char *)pixval);
413 >        free((void *)pixval);
414          pixval = NULL;
415          ncolors = 0;
416          if (ourmap != DefaultColormap(ourdisplay,ourscreen))
# Line 453 | Line 460 | getevent()                     /* get next event */
460                  getkey(levptr(XKeyPressedEvent));
461                  break;
462          case ButtonPress:
463 <                getmove(levptr(XButtonPressedEvent));
463 >                if (FRAMESTATE(levptr(XButtonPressedEvent)->state))
464 >                        getframe(levptr(XButtonPressedEvent));
465 >                else
466 >                        getmove(levptr(XButtonPressedEvent));
467                  break;
468          }
469   }
# Line 576 | Line 586 | int    dx, dy, mov, orb;
586  
587  
588   static
589 + getframe(ebut)                          /* get focus frame */
590 + XButtonPressedEvent     *ebut;
591 + {
592 +        int     startx = ebut->x, starty = ebut->y;
593 +        int     endx, endy;
594 +
595 +        XMaskEvent(ourdisplay, ButtonReleaseMask, levptr(XEvent));
596 +        endx = levptr(XButtonReleasedEvent)->x;
597 +        endy = levptr(XButtonReleasedEvent)->y;
598 +        if (endx == startx | endy == starty) {
599 +                XBell(ourdisplay, 0);
600 +                return;
601 +        }
602 +        if (endx < startx) {register int c = endx; endx = startx; startx = c;}
603 +        if (endy < starty) {register int c = endy; endy = starty; starty = c;}
604 +        sprintf(odev_args, "%.3f %.3f %.3f %.3f",
605 +                        (startx+.5)/odev.hres, 1.-(endy+.5)/odev.vres,
606 +                        (endx+.5)/odev.hres, 1.-(starty+.5)/odev.vres);
607 +        inpresflags |= DFL(DC_FOCUS);
608 + }
609 +
610 +
611 + static
612 + waitabit()                              /* pause a moment */
613 + {
614 +        struct timespec ts;
615 +        ts.tv_sec = 0;
616 +        ts.tv_nsec = 50000000;
617 +        nanosleep(&ts, NULL);
618 + }
619 +
620 +
621 + static
622   getmove(ebut)                           /* get view change */
623   XButtonPressedEvent     *ebut;
624   {
# Line 591 | Line 634 | XButtonPressedEvent    *ebut;
634  
635          while (!XCheckMaskEvent(ourdisplay,
636                          ButtonReleaseMask, levptr(XEvent))) {
637 <
637 >                waitabit();
638                  if (!XQueryPointer(ourdisplay, gwind, &rootw, &childw,
639                                  &rootx, &rooty, &wx, &wy, &statemask))
640                          break;          /* on another screen */
# Line 620 | Line 663 | static
663   getkey(ekey)                            /* get input key */
664   register XKeyPressedEvent  *ekey;
665   {
666 +        Window  rootw, childw;
667 +        int     rootx, rooty, wx, wy;
668 +        unsigned int    statemask;
669          int  n;
670          char    buf[8];
671  
# Line 635 | Line 681 | register XKeyPressedEvent  *ekey;
681                  return;
682          case 'l':                       /* retrieve last view */
683                  inpresflags |= DFL(DC_LASTVIEW);
684 +                return;
685 +        case 'f':                       /* frame view position */
686 +                if (!XQueryPointer(ourdisplay, gwind, &rootw, &childw,
687 +                                &rootx, &rooty, &wx, &wy, &statemask))
688 +                        return;         /* on another screen */
689 +                sprintf(odev_args, "%.4f %.4f", (wx+.5)/odev.hres,
690 +                                1.-(wy+.5)/odev.vres);
691 +                inpresflags |= DFL(DC_FOCUS);
692 +                return;
693 +        case 'F':                       /* unfocus */
694 +                odev_args[0] = '\0';
695 +                inpresflags |= DFL(DC_FOCUS);
696                  return;
697          case 'p':                       /* pause computation */
698                  inpresflags |= DFL(DC_PAUSE);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines