1 |
– |
/* Copyright (c) 1991 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Display an image and watch the rays get traced. |
6 |
|
* |
7 |
|
* 9/21/90 Greg Ward |
8 |
|
*/ |
9 |
|
|
10 |
+ |
#include <X11/Xlib.h> |
11 |
+ |
|
12 |
|
#include "standard.h" |
13 |
+ |
#include "paths.h" |
14 |
|
#include "view.h" |
15 |
– |
#include "resolu.h" |
16 |
– |
#include <X11/Xlib.h> |
15 |
|
|
16 |
|
#define MAXDEPTH 32 /* ridiculous ray tree depth */ |
17 |
|
|
22 |
|
#endif |
23 |
|
|
24 |
|
char rtcom[] = "rtrace -h- -otp -fa -x 1"; |
25 |
< |
char xicom[] = "ximage"; |
25 |
> |
char xicom[] = "ximage -c 256"; |
26 |
|
|
27 |
|
VIEW ourview = STDVIEW; /* view for picture */ |
28 |
|
RESOLU ourres; /* picture resolution */ |
51 |
|
char *argv[]; |
52 |
|
{ |
53 |
|
int i; |
54 |
< |
char combuf[256]; |
54 |
> |
char combuf[PATH_MAX]; |
55 |
|
|
56 |
|
progname = argv[0]; |
57 |
|
for (i = 1; i < argc-2; i++) |
80 |
|
exit(1); |
81 |
|
} |
82 |
|
/* build input command */ |
83 |
< |
sprintf(combuf, "%s %s | %s", xicom, picture, rtcom); |
83 |
> |
sprintf(combuf, "%s \"%s\" | %s", xicom, picture, rtcom); |
84 |
|
for ( ; i < argc-1; i++) { |
85 |
|
strcat(combuf, " "); |
86 |
|
strcat(combuf, argv[i]); |
90 |
|
exit(1); |
91 |
|
/* loop on input */ |
92 |
|
mainloop(); |
93 |
< |
|
93 |
> |
/* close pipe and exit */ |
94 |
> |
pclose(pin); |
95 |
|
exit(0); |
96 |
|
} |
97 |
|
|
138 |
|
freetree(tp) /* free a trace tree */ |
139 |
|
struct node *tp; |
140 |
|
{ |
141 |
< |
register struct node *kid; |
141 |
> |
register struct node *kid, *k2; |
142 |
|
|
143 |
< |
for (kid = tp->daughter; kid != NULL; kid = kid->sister) |
143 |
> |
for (kid = tp->daughter; kid != NULL; kid = k2) { |
144 |
> |
k2 = kid->sister; |
145 |
|
freetree(kid); |
146 |
< |
free((char *)tp); |
146 |
> |
} |
147 |
> |
free((void *)tp); |
148 |
|
} |
149 |
|
|
150 |
|
|
189 |
|
setvec(ipt) /* set up vector drawing for pick */ |
190 |
|
int ipt[2]; |
191 |
|
{ |
192 |
+ |
extern Window xfindwind(); |
193 |
|
XWindowAttributes wa; |
194 |
|
XColor xc; |
195 |
|
XGCValues gcv; |
197 |
|
Window rw, cw; |
198 |
|
unsigned int pm; |
199 |
|
/* compute pointer location */ |
200 |
< |
if (gwind == 0 && |
201 |
< |
(gwind = xfindwind(theDisplay, rwind, picture, 2)) == 0) { |
202 |
< |
fprintf(stderr, "%s: cannot find display window!\n", progname); |
203 |
< |
exit(1); |
200 |
> |
if (gwind == 0) { |
201 |
> |
register char *wn; |
202 |
> |
for (wn = picture; *wn; wn++); |
203 |
> |
while (wn > picture && wn[-1] != '/') wn--; |
204 |
> |
if ((gwind = xfindwind(theDisplay, rwind, wn, 4)) == 0) { |
205 |
> |
fprintf(stderr, "%s: cannot find display window!\n", |
206 |
> |
progname); |
207 |
> |
exit(1); |
208 |
> |
} |
209 |
|
} |
210 |
|
XQueryPointer(theDisplay, gwind, &rw, &cw, &rx, &ry, &wx, &wy, &pm); |
211 |
|
xoff = wx - ipt[0]; |