12 |
|
|
13 |
|
#include "standard.h" |
14 |
|
#include "view.h" |
15 |
+ |
#include "resolu.h" |
16 |
+ |
#include "vfork.h" |
17 |
|
#include <signal.h> |
18 |
|
#include <X11/Xlib.h> |
19 |
|
#include <X11/Xutil.h> |
20 |
|
|
19 |
– |
#ifndef BSD |
20 |
– |
#define vfork fork |
21 |
– |
#endif |
22 |
– |
|
21 |
|
#define XIM "ximage" |
22 |
|
|
23 |
|
#define NSEG 30 /* number of segments per circle */ |
27 |
|
float col[3] = {1.,0.,0.}; /* color */ |
28 |
|
|
29 |
|
VIEW ourview = STDVIEW; /* view for picture */ |
30 |
< |
int xres, yres; /* picture resolution */ |
30 |
> |
RESOLU pres; /* picture resolution */ |
31 |
|
|
32 |
|
char *progname; /* program name */ |
33 |
|
|
44 |
|
int argc; |
45 |
|
char *argv[]; |
46 |
|
{ |
49 |
– |
extern double atof(); |
47 |
|
char *windowname = NULL; |
48 |
|
FILE *fp; |
49 |
|
|
89 |
|
XColor xc; |
90 |
|
XGCValues gcv; |
91 |
|
/* get the viewing parameters */ |
92 |
< |
if (viewfile(pname, &ourview, &xres, &yres) <= 0 || |
92 |
> |
if (viewfile(pname, &ourview, &pres) <= 0 || |
93 |
|
setview(&ourview) != NULL) { |
94 |
|
fprintf(stderr, "%s: cannot get view from \"%s\"\n", |
95 |
|
progname, pname); |
105 |
|
/* find our window */ |
106 |
|
if (wname == NULL) |
107 |
|
wname = pname; |
108 |
< |
gwind = xfindwind(theDisplay, rwind, wname, 2); |
108 |
> |
gwind = xfindwind(theDisplay, rwind, wname, 4); |
109 |
|
if (gwind == None) { |
110 |
|
if (wname != pname) { |
111 |
|
fprintf(stderr, "%s: cannot find \"%s\" window\n", |
114 |
|
} |
115 |
|
/* start ximage */ |
116 |
|
if (vfork() == 0) { |
117 |
< |
execlp(XIM, XIM, pname, 0); |
117 |
> |
execlp(XIM, XIM, "-c", "256", pname, 0); |
118 |
|
perror(XIM); |
119 |
|
fprintf(stderr, "%s: cannot start %s\n", |
120 |
|
progname, XIM); |
123 |
|
} |
124 |
|
do |
125 |
|
sleep(8); |
126 |
< |
while ((gwind=xfindwind(theDisplay,rwind,pname,2)) == None); |
126 |
> |
while ((gwind=xfindwind(theDisplay,rwind,pname,4)) == None); |
127 |
|
} else |
128 |
|
XMapRaised(theDisplay, gwind); |
129 |
|
do { |
130 |
|
XGetWindowAttributes(theDisplay, gwind, &wa); |
131 |
|
sleep(6); |
132 |
|
} while (wa.map_state != IsViewable); |
133 |
< |
if (wa.width != xres || wa.height != yres) { |
133 |
> |
if (wa.width != scanlen(&pres) || wa.height != numscans(&pres)) { |
134 |
|
fprintf(stderr, |
135 |
|
"%s: warning -- window seems to be the wrong size!\n", |
136 |
|
progname); |
137 |
< |
xres = wa.width; |
138 |
< |
yres = wa.height; |
137 |
> |
if (pres.or & YMAJOR) { |
138 |
> |
pres.xr = wa.width; |
139 |
> |
pres.yr = wa.height; |
140 |
> |
} else { |
141 |
> |
pres.xr = wa.height; |
142 |
> |
pres.yr = wa.width; |
143 |
> |
} |
144 |
|
} |
145 |
|
/* set graphics context */ |
146 |
|
gcv.font = XLoadFont(theDisplay, FONTNAME); |
207 |
|
{ |
208 |
|
FVECT start, cur; |
209 |
|
XPoint pt[NSEG+1]; |
210 |
< |
double px, py, pz; |
210 |
> |
FVECT pp; |
211 |
> |
int ip[2]; |
212 |
|
register int i; |
213 |
|
|
214 |
|
fcross(cur, dir, ourview.vup); |
220 |
|
cur[0] += ourview.vp[0]; |
221 |
|
cur[1] += ourview.vp[1]; |
222 |
|
cur[2] += ourview.vp[2]; |
223 |
< |
viewpixel(&px, &py, &pz, &ourview, cur); |
224 |
< |
if (pz <= 0.0) |
223 |
> |
viewloc(pp, &ourview, cur); |
224 |
> |
if (pp[2] <= 0.0) |
225 |
|
goto fail; |
226 |
< |
pt[i].x = px*xres; |
227 |
< |
pt[i].y = yres-1 - (int)(py*yres); |
226 |
> |
loc2pix(ip, &pres, pp[0], pp[1]); |
227 |
> |
pt[i].x = ip[0]; |
228 |
> |
pt[i].y = ip[1]; |
229 |
|
} |
230 |
|
XDrawLines(theDisplay, gwind, vecGC, pt, NSEG+1, CoordModeOrigin); |
231 |
|
return; |
240 |
|
double v; |
241 |
|
{ |
242 |
|
FVECT pos; |
243 |
< |
double px, py, pz; |
243 |
> |
FVECT pp; |
244 |
> |
int ip[2]; |
245 |
|
char buf[32]; |
246 |
|
|
247 |
|
pos[0] = ourview.vp[0] + dir[0]; |
248 |
|
pos[1] = ourview.vp[1] + dir[1]; |
249 |
|
pos[2] = ourview.vp[2] + dir[2]; |
250 |
< |
viewpixel(&px, &py, &pz, &ourview, pos); |
251 |
< |
if (pz <= 0.0) |
250 |
> |
viewloc(pp, &ourview, pos); |
251 |
> |
if (pp[2] <= 0.0) |
252 |
|
return; |
253 |
+ |
loc2pix(ip, &pres, pp[0], pp[1]); |
254 |
|
sprintf(buf, "%.0f", v); |
255 |
|
XDrawImageString(theDisplay, gwind, strGC, |
256 |
< |
(int)(px*xres), yres-1-(int)(py*yres), |
251 |
< |
buf, strlen(buf)); |
256 |
> |
ip[0], ip[1], buf, strlen(buf)); |
257 |
|
} |