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 2.1 by greg, Tue Nov 12 16:04:29 1991 UTC vs.
Revision 2.2 by greg, Tue Apr 21 17:24:51 1992 UTC

# Line 12 | 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 + #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  
# Line 31 | Line 38 | FILE   *pin;                           /* input stream */
38   Display *theDisplay = NULL;             /* connection to server */
39  
40   struct node {                           /* ray tree node */
41 <        FVECT   ipt;
41 >        int     ipt[2];
42          struct node     *sister;
43          struct node     *daughter;
44   };
# Line 61 | Line 68 | char   *argv[];
68          }
69          picture = argv[argc-1];
70                                          /* get the viewing parameters */
71 <        if (viewfile(picture, &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                                  progname, picture);
# Line 153 | Line 160 | struct node    *tp;
160  
161  
162   strtoipt(ipt, str)              /* convert string x y z to image point */
163 < FVECT   ipt;
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 <        viewloc(ipt, &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 174 | 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 189 | Line 201 | double ipt[2];
201                  exit(1);
202          }
203          XQueryPointer(theDisplay, gwind, &rw, &cw, &rx, &ry, &wx, &wy, &pm);
204 <        xoff = wx - ipt[0]*xres;
205 <        yoff = wy - (1.-ipt[1])*yres;
204 >        xoff = wx - ipt[0];
205 >        yoff = wy - ipt[1];
206                                          /* set graphics context */
207          if (vecGC == 0) {
208                  XGetWindowAttributes(theDisplay, gwind, &wa);
# Line 208 | 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