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 1.6 by greg, Fri Jul 26 14:14:03 1991 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines