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

Comparing ray/src/px/xshowtrace.c (file contents):
Revision 1.1 by greg, Sat Sep 22 10:53:57 1990 UTC vs.
Revision 2.1 by greg, Tue Nov 12 16:04:29 1991 UTC

# Line 1 | Line 1
1 + /* Copyright (c) 1991 Regents of the University of California */
2 +
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
5   #endif
# Line 14 | Line 16 | static char SCCSid[] = "$SunId$ LBL";
16  
17   #define MAXDEPTH        32              /* ridiculous ray tree depth */
18  
19 < char    rtcom[] = "rtrace -h -otp -fa -x 1";
20 < char    xicom[] = "x11image";
19 > char    rtcom[] = "rtrace -h- -otp -fa -x 1";
20 > char    xicom[] = "ximage";
21  
22   VIEW    ourview = STDVIEW;              /* view for picture */
23   int     xres, yres;
24  
25   char    *progname;                      /* program name */
26  
27 + char    *picture;                       /* picture name */
28 +
29   FILE    *pin;                           /* input stream */
30  
31   Display *theDisplay = NULL;             /* connection to server */
32  
33   struct node {                           /* ray tree node */
34 <        double  ipt[2];
34 >        FVECT   ipt;
35          struct node     *sister;
36          struct node     *daughter;
37   };
38  
39   #define newnode()       (struct node *)calloc(1, sizeof(struct node))
40  
41 + int     slow = 0;               /* slow trace? */
42  
43 +
44   main(argc, argv)                /* takes both the octree and the image */
45   int     argc;
46   char    *argv[];
47   {
48          int     i;
49          char    combuf[256];
44        Cursor  curs;
50  
51          progname = argv[0];
52 <        if (argc < 3) {
53 <                fprintf(stderr, "Usage: %s [rtrace args] octree picture\n",
54 <                                argv[0]);
52 >        for (i = 1; i < argc-2; i++)
53 >                if (!strcmp(argv[i], "-s"))
54 >                        slow++;
55 >                else
56 >                        break;
57 >        if (i > argc-2) {
58 >                fprintf(stderr, "Usage: %s [-s] [rtrace args] octree picture\n",
59 >                                progname);
60                  exit(1);
61          }
62 +        picture = argv[argc-1];
63                                          /* get the viewing parameters */
64 <        if (viewfile(argv[argc-1], &ourview, &xres, &yres) <= 0 ||
64 >        if (viewfile(picture, &ourview, &xres, &yres) <= 0 ||
65                          setview(&ourview) != NULL) {
66                  fprintf(stderr, "%s: cannot get view from \"%s\"\n",
67 <                                argv[0], argv[argc-1]);
67 >                                progname, picture);
68                  exit(1);
69          }
70                                          /* open the display */
71          if ((theDisplay = XOpenDisplay(NULL)) == NULL) {
72                  fprintf(stderr,
73                  "%s: cannot open display; DISPLAY variable set?\n",
74 <                                argv[0]);
74 >                                progname);
75                  exit(1);
76          }
77                                          /* build input command */
78 <        sprintf(combuf, "%s %s | %s", xicom, argv[argc-1], rtcom);
79 <        for (i = 1; i < argc-1; i++) {
78 >        sprintf(combuf, "%s %s | %s", xicom, picture, rtcom);
79 >        for ( ; i < argc-1; i++) {
80                  strcat(combuf, " ");
81                  strcat(combuf, argv[i]);
82          }
# Line 109 | Line 120 | mainloop()                             /* get and process input */
120                  if (i == 0) {
121                          setvec(sis[0]->ipt);
122                          tracerays(sis[0]);
112                        XFlush(theDisplay);
123                          freetree(sis[0]);
124                          sis[0] = NULL;
125 +                        if (!slow)
126 +                                XFlush(theDisplay);
127                  }
128          }
129   }
# Line 134 | Line 146 | struct node    *tp;
146          register struct node    *kid;
147  
148          for (kid = tp->daughter; kid != NULL; kid = kid->sister) {
137                tracerays(kid);
149                  vector(tp->ipt, kid->ipt);
150 +                tracerays(kid);
151          }
152   }
153  
154  
155   strtoipt(ipt, str)              /* convert string x y z to image point */
156 < double  ipt[2];
156 > FVECT   ipt;
157   char    *str;
158   {
159          FVECT   pt;
160  
161          if (sscanf(str, "%lf %lf %lf", &pt[0], &pt[1], &pt[2]) != 3)
162                  return(-1);
163 <        viewpixel(&ipt[0], &ipt[1], NULL, &ourview, pt);
163 >        viewloc(ipt, &ourview, pt);
164          return(0);
165   }
166  
# Line 167 | Line 179 | double ipt[2];
179          XWindowAttributes       wa;
180          XColor  xc;
181          XGCValues       gcv;
182 <        int     pm, rx, ry, wx, wy, rw, cw;
182 >        int     rx, ry, wx, wy;
183 >        Window  rw, cw;
184 >        unsigned int    pm;
185                                          /* compute pointer location */
186 <        if (gwind == 0) {
187 <                XQueryPointer(theDisplay, rwind, &rw, &gwind,
188 <                                &rx, &ry, &wx, &wy, &pm);
186 >        if (gwind == 0 &&
187 >                (gwind = xfindwind(theDisplay, rwind, picture, 2)) == 0) {
188 >                fprintf(stderr, "%s: cannot find display window!\n", progname);
189 >                exit(1);
190          }
191 <        XQueryPointer(theDisplay, gwind, &rw, &cw,
177 <                        &rx, &ry, &wx, &wy, &pm);
191 >        XQueryPointer(theDisplay, gwind, &rw, &cw, &rx, &ry, &wx, &wy, &pm);
192          xoff = wx - ipt[0]*xres;
193          yoff = wy - (1.-ipt[1])*yres;
194                                          /* set graphics context */
# Line 199 | Line 213 | double ip1[2], ip2[2];
213          XDrawLine(theDisplay, gwind, vecGC,
214                          (int)(ip1[0]*xres)+xoff, (int)((1.-ip1[1])*yres)+yoff,
215                          (int)(ip2[0]*xres)+xoff, (int)((1.-ip2[1])*yres)+yoff);
216 +        if (slow) {
217 +                XFlush(theDisplay);
218 +                sleep(1);
219 +        }
220   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines