--- ray/src/px/xshowtrace.c 1990/09/24 12:21:06 1.3 +++ ray/src/px/xshowtrace.c 1991/11/12 16:04:29 2.1 @@ -1,3 +1,5 @@ +/* Copyright (c) 1991 Regents of the University of California */ + #ifndef lint static char SCCSid[] = "$SunId$ LBL"; #endif @@ -14,20 +16,22 @@ static char SCCSid[] = "$SunId$ LBL"; #define MAXDEPTH 32 /* ridiculous ray tree depth */ -char rtcom[] = "rtrace -h -otp -fa -x 1"; -char xicom[] = "x11image -f"; +char rtcom[] = "rtrace -h- -otp -fa -x 1"; +char xicom[] = "ximage"; VIEW ourview = STDVIEW; /* view for picture */ int xres, yres; char *progname; /* program name */ +char *picture; /* picture name */ + FILE *pin; /* input stream */ Display *theDisplay = NULL; /* connection to server */ struct node { /* ray tree node */ - double ipt[2]; + FVECT ipt; struct node *sister; struct node *daughter; }; @@ -43,7 +47,6 @@ char *argv[]; { int i; char combuf[256]; - Cursor curs; progname = argv[0]; for (i = 1; i < argc-2; i++) @@ -53,25 +56,26 @@ char *argv[]; break; if (i > argc-2) { fprintf(stderr, "Usage: %s [-s] [rtrace args] octree picture\n", - argv[0]); + progname); exit(1); } + picture = argv[argc-1]; /* get the viewing parameters */ - if (viewfile(argv[argc-1], &ourview, &xres, &yres) <= 0 || + if (viewfile(picture, &ourview, &xres, &yres) <= 0 || setview(&ourview) != NULL) { fprintf(stderr, "%s: cannot get view from \"%s\"\n", - argv[0], argv[argc-1]); + progname, picture); exit(1); } /* open the display */ if ((theDisplay = XOpenDisplay(NULL)) == NULL) { fprintf(stderr, "%s: cannot open display; DISPLAY variable set?\n", - argv[0]); + progname); exit(1); } /* build input command */ - sprintf(combuf, "%s %s | %s", xicom, argv[argc-1], rtcom); + sprintf(combuf, "%s %s | %s", xicom, picture, rtcom); for ( ; i < argc-1; i++) { strcat(combuf, " "); strcat(combuf, argv[i]); @@ -149,14 +153,14 @@ struct node *tp; strtoipt(ipt, str) /* convert string x y z to image point */ -double ipt[2]; +FVECT ipt; char *str; { FVECT pt; if (sscanf(str, "%lf %lf %lf", &pt[0], &pt[1], &pt[2]) != 3) return(-1); - viewpixel(&ipt[0], &ipt[1], NULL, &ourview, pt); + viewloc(ipt, &ourview, pt); return(0); } @@ -175,14 +179,16 @@ double ipt[2]; XWindowAttributes wa; XColor xc; XGCValues gcv; - int pm, rx, ry, wx, wy, rw, cw; + int rx, ry, wx, wy; + Window rw, cw; + unsigned int pm; /* compute pointer location */ - if (gwind == 0) { - XQueryPointer(theDisplay, rwind, &rw, &gwind, - &rx, &ry, &wx, &wy, &pm); + if (gwind == 0 && + (gwind = xfindwind(theDisplay, rwind, picture, 2)) == 0) { + fprintf(stderr, "%s: cannot find display window!\n", progname); + exit(1); } - XQueryPointer(theDisplay, gwind, &rw, &cw, - &rx, &ry, &wx, &wy, &pm); + XQueryPointer(theDisplay, gwind, &rw, &cw, &rx, &ry, &wx, &wy, &pm); xoff = wx - ipt[0]*xres; yoff = wy - (1.-ipt[1])*yres; /* set graphics context */