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.4 by greg, Fri Dec 21 17:24:45 1990 UTC vs.
Revision 2.2 by greg, Tue Apr 21 17:24:51 1992 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 10 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #include "standard.h"
14   #include "view.h"
15 + #include "resolu.h"
16   #include <X11/Xlib.h>
17  
18   #define MAXDEPTH        32              /* ridiculous ray tree depth */
19  
20 < char    rtcom[] = "rtrace -h -otp -fa -x 1";
21 < char    xicom[] = "x11image -f";
20 > #ifdef  SMLFLT
21 > #define  sscanvec(s,v)  (sscanf(s,"%f %f %f",v,v+1,v+2)==3)
22 > #else
23 > #define  sscanvec(s,v)  (sscanf(s,"%lf %lf %lf",v,v+1,v+2)==3)
24 > #endif
25  
26 + char    rtcom[] = "rtrace -h- -otp -fa -x 1";
27 + char    xicom[] = "ximage";
28 +
29   VIEW    ourview = STDVIEW;              /* view for picture */
30 < int     xres, yres;
30 > RESOLU  ourres;                         /* picture resolution */
31  
32   char    *progname;                      /* program name */
33  
34 + char    *picture;                       /* picture name */
35 +
36   FILE    *pin;                           /* input stream */
37  
38   Display *theDisplay = NULL;             /* connection to server */
39  
40   struct node {                           /* ray tree node */
41 <        double  ipt[2];
41 >        int     ipt[2];
42          struct node     *sister;
43          struct node     *daughter;
44   };
# Line 52 | Line 63 | char   *argv[];
63                          break;
64          if (i > argc-2) {
65                  fprintf(stderr, "Usage: %s [-s] [rtrace args] octree picture\n",
66 <                                argv[0]);
66 >                                progname);
67                  exit(1);
68          }
69 +        picture = argv[argc-1];
70                                          /* get the viewing parameters */
71 <        if (viewfile(argv[argc-1], &ourview, &xres, &yres) <= 0 ||
71 >        if (viewfile(picture, &ourview, &ourres) <= 0 ||
72                          setview(&ourview) != NULL) {
73                  fprintf(stderr, "%s: cannot get view from \"%s\"\n",
74 <                                argv[0], argv[argc-1]);
74 >                                progname, picture);
75                  exit(1);
76          }
77                                          /* open the display */
78          if ((theDisplay = XOpenDisplay(NULL)) == NULL) {
79                  fprintf(stderr,
80                  "%s: cannot open display; DISPLAY variable set?\n",
81 <                                argv[0]);
81 >                                progname);
82                  exit(1);
83          }
84                                          /* build input command */
85 <        sprintf(combuf, "%s %s | %s", xicom, argv[argc-1], rtcom);
85 >        sprintf(combuf, "%s %s | %s", xicom, picture, rtcom);
86          for ( ; i < argc-1; i++) {
87                  strcat(combuf, " ");
88                  strcat(combuf, argv[i]);
# Line 148 | Line 160 | struct node    *tp;
160  
161  
162   strtoipt(ipt, str)              /* convert string x y z to image point */
163 < double  ipt[2];
163 > int     ipt[2];
164   char    *str;
165   {
166 <        FVECT   pt;
166 >        FVECT   im_pt, pt;
167  
168 <        if (sscanf(str, "%lf %lf %lf", &pt[0], &pt[1], &pt[2]) != 3)
168 >        if (!sscanvec(str, pt))
169                  return(-1);
170 <        viewpixel(&ipt[0], &ipt[1], NULL, &ourview, pt);
170 >        if (DOT(pt,pt) <= FTINY)                /* origin is really infinity */
171 >                ipt[0] = ipt[1] = -1;                   /* null vector */
172 >        else {
173 >                viewloc(im_pt, &ourview, pt);
174 >                loc2pix(ipt, &ourres, im_pt[0], im_pt[1]);
175 >        }
176          return(0);
177   }
178  
# Line 169 | Line 186 | int    xoff, yoff;
186  
187  
188   setvec(ipt)                     /* set up vector drawing for pick */
189 < double  ipt[2];
189 > int     ipt[2];
190   {
191          XWindowAttributes       wa;
192          XColor  xc;
# Line 178 | Line 195 | double ipt[2];
195          Window  rw, cw;
196          unsigned int    pm;
197                                          /* compute pointer location */
198 <        if (gwind == 0) {
199 <                XQueryPointer(theDisplay, rwind, &rw, &gwind,
200 <                                &rx, &ry, &wx, &wy, &pm);
198 >        if (gwind == 0 &&
199 >                (gwind = xfindwind(theDisplay, rwind, picture, 2)) == 0) {
200 >                fprintf(stderr, "%s: cannot find display window!\n", progname);
201 >                exit(1);
202          }
203 <        XQueryPointer(theDisplay, gwind, &rw, &cw,
204 <                        &rx, &ry, &wx, &wy, &pm);
205 <        xoff = wx - ipt[0]*xres;
188 <        yoff = wy - (1.-ipt[1])*yres;
203 >        XQueryPointer(theDisplay, gwind, &rw, &cw, &rx, &ry, &wx, &wy, &pm);
204 >        xoff = wx - ipt[0];
205 >        yoff = wy - ipt[1];
206                                          /* set graphics context */
207          if (vecGC == 0) {
208                  XGetWindowAttributes(theDisplay, gwind, &wa);
# Line 203 | Line 220 | double ipt[2];
220  
221  
222   vector(ip1, ip2)                /* draw a vector */
223 < double  ip1[2], ip2[2];
223 > int     ip1[2], ip2[2];
224   {
225 +        if (ip2[0] == -1 && ip2[1] == -1)
226 +                return;                 /* null vector */
227          XDrawLine(theDisplay, gwind, vecGC,
228 <                        (int)(ip1[0]*xres)+xoff, (int)((1.-ip1[1])*yres)+yoff,
229 <                        (int)(ip2[0]*xres)+xoff, (int)((1.-ip2[1])*yres)+yoff);
228 >                        ip1[0]+xoff, ip1[1]+yoff,
229 >                        ip2[0]+xoff, ip2[1]+yoff);
230          if (slow) {
231                  XFlush(theDisplay);
232                  sleep(1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines