1 |
< |
/* Copyright (c) 1997 Silicon Graphics, Inc. */ |
1 |
> |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ SGI"; |
10 |
|
*/ |
11 |
|
|
12 |
|
#include "standard.h" |
13 |
– |
#include "rhd_qtree.h" |
14 |
– |
|
13 |
|
#include <X11/Xlib.h> |
14 |
|
#include <X11/cursorfont.h> |
15 |
|
#include <X11/Xutil.h> |
16 |
< |
|
16 |
> |
#include "rhd_qtree.h" |
17 |
|
#include "x11icon.h" |
18 |
|
|
19 |
< |
#define CTRL(c) ((c)-'@') |
19 |
> |
#ifndef RAYQLEN |
20 |
> |
#define RAYQLEN 50000 /* max. rays to queue before flush */ |
21 |
> |
#endif |
22 |
|
|
23 |
+ |
#ifndef FEQ |
24 |
+ |
#define FEQ(a,b) ((a)-(b) <= FTINY && (a)-(b) >= -FTINY) |
25 |
+ |
#endif |
26 |
+ |
|
27 |
|
#define GAMMA 2.2 /* default gamma correction */ |
28 |
|
|
29 |
< |
#define MOVPCT 10 /* percent distance to move */ |
29 |
> |
#define FRAMESTATE(s) (((s)&(ShiftMask|ControlMask))==(ShiftMask|ControlMask)) |
30 |
> |
|
31 |
> |
#define MOVPCT 7 /* percent distance to move /frame */ |
32 |
|
#define MOVDIR(b) ((b)==Button1 ? 1 : (b)==Button2 ? 0 : -1) |
33 |
+ |
#define MOVDEG (-5) /* degrees to orbit CW/down /frame */ |
34 |
+ |
#define MOVORB(s) ((s)&ShiftMask ? 1 : (s)&ControlMask ? -1 : 0) |
35 |
|
|
36 |
|
#define MINWIDTH 480 /* minimum graphics window width */ |
37 |
|
#define MINHEIGHT 400 /* minimum graphics window height */ |
49 |
|
|
50 |
|
struct driver odev; /* global device driver structure */ |
51 |
|
|
52 |
+ |
char odev_args[64]; /* command arguments */ |
53 |
+ |
|
54 |
|
static XEvent currentevent; /* current event */ |
55 |
|
|
56 |
|
static int ncolors = 0; /* color table size */ |
59 |
|
static unsigned long ourblack=0, ourwhite=1; |
60 |
|
|
61 |
|
static Display *ourdisplay = NULL; /* our display */ |
52 |
– |
|
62 |
|
static XVisualInfo ourvinfo; /* our visual information */ |
54 |
– |
|
63 |
|
static Window gwind = 0; /* our graphics window */ |
56 |
– |
|
64 |
|
static GC ourgc = 0; /* our graphics context for drawing */ |
58 |
– |
|
65 |
|
static Colormap ourmap = 0; /* our color map */ |
66 |
|
|
67 |
|
static double pwidth, pheight; /* pixel dimensions (mm) */ |
70 |
|
|
71 |
|
static int headlocked = 0; /* lock vertical motion */ |
72 |
|
|
73 |
< |
static int getpixels(), xnewcolr(), freepixels(), resizewindow(), |
73 |
> |
static int getpixels(), xnewcolr(), freepixels(), resizewindow(), getframe(), |
74 |
|
getevent(), getkey(), moveview(), getmove(), fixwindow(); |
75 |
|
static unsigned long true_pixel(); |
76 |
|
|
87 |
|
for (cp = tail; *cp && *cp != '.'; cp++) |
88 |
|
; |
89 |
|
if (cp-tail == 3 && !strncmp(tail, "x11", 3)) |
90 |
< |
return(TM_F_CAMERA); |
90 |
> |
return(TM_F_CAMERA|TM_F_NOSTDERR); |
91 |
|
if (cp-tail == 4 && !strncmp(tail, "x11h", 4)) |
92 |
< |
return(TM_F_HUMAN); |
92 |
> |
return(TM_F_HUMAN|TM_F_NOSTDERR); |
93 |
|
error(USER, "illegal driver name"); |
94 |
|
} |
95 |
|
|
98 |
|
char *id; |
99 |
|
{ |
100 |
|
extern char *getenv(); |
101 |
< |
char *gv; |
101 |
> |
static RGBPRIMS myprims = STDPRIMS; |
102 |
> |
char *ev; |
103 |
|
double gamval = GAMMA; |
104 |
+ |
RGBPRIMP dpri = stdprims; |
105 |
|
int nplanes; |
106 |
|
XSetWindowAttributes ourwinattr; |
107 |
|
XWMHints ourxwmhints; |
108 |
|
XSizeHints oursizhints; |
109 |
|
/* set quadtree globals */ |
102 |
– |
qtDepthEps = 0.02; |
110 |
|
qtMinNodesiz = 2; |
111 |
|
/* open display server */ |
112 |
|
ourdisplay = XOpenDisplay(NULL); |
134 |
|
ourwhite = WhitePixel(ourdisplay,ourscreen); |
135 |
|
} |
136 |
|
/* set gamma and tone mapping */ |
137 |
< |
if ((gv = XGetDefault(ourdisplay, "radiance", "gamma")) != NULL |
138 |
< |
|| (gv = getenv("DISPLAY_GAMMA")) != NULL) |
139 |
< |
gamval = atof(gv); |
140 |
< |
if (tmInit(mytmflags(), stdprims, gamval) == NULL) |
137 |
> |
if ((ev = XGetDefault(ourdisplay, "radiance", "gamma")) != NULL |
138 |
> |
|| (ev = getenv("DISPLAY_GAMMA")) != NULL) |
139 |
> |
gamval = atof(ev); |
140 |
> |
if ((ev = getenv("DISPLAY_PRIMARIES")) != NULL && |
141 |
> |
sscanf(ev, "%f %f %f %f %f %f %f %f", |
142 |
> |
&myprims[RED][CIEX],&myprims[RED][CIEY], |
143 |
> |
&myprims[GRN][CIEX],&myprims[GRN][CIEY], |
144 |
> |
&myprims[BLU][CIEX],&myprims[BLU][CIEY], |
145 |
> |
&myprims[WHT][CIEX],&myprims[WHT][CIEY]) >= 6) |
146 |
> |
dpri = myprims; |
147 |
> |
if (tmInit(mytmflags(), dpri, gamval) == NULL) |
148 |
|
error(SYSTEM, "not enough memory in dev_open"); |
149 |
|
/* open window */ |
150 |
|
ourwinattr.background_pixel = ourblack; |
173 |
|
oursizhints.min_height = MINHEIGHT; |
174 |
|
oursizhints.flags = PMinSize; |
175 |
|
XSetNormalHints(ourdisplay, gwind, &oursizhints); |
162 |
– |
/* map the window and get its size */ |
163 |
– |
XMapWindow(ourdisplay, gwind); |
164 |
– |
dev_input(); |
165 |
– |
/* allocate our leaf pile */ |
166 |
– |
if (!qtAllocLeaves(DisplayWidth(ourdisplay,ourscreen) * |
167 |
– |
DisplayHeight(ourdisplay,ourscreen) / |
168 |
– |
(qtMinNodesiz*qtMinNodesiz))) |
169 |
– |
error(SYSTEM, "insufficient memory for leaf storage"); |
170 |
– |
|
176 |
|
/* figure out sensible view */ |
177 |
|
pwidth = (double)DisplayWidthMM(ourdisplay, ourscreen) / |
178 |
|
DisplayWidth(ourdisplay, ourscreen); |
179 |
|
pheight = (double)DisplayHeightMM(ourdisplay, ourscreen) / |
180 |
|
DisplayHeight(ourdisplay, ourscreen); |
181 |
|
copystruct(&odev.v, &stdview); |
177 |
– |
odev.name = id; |
182 |
|
odev.v.type = VT_PER; |
183 |
< |
odev.v.horiz = 2.*180./PI * atan(0.5/VIEWDIST*pwidth*odev.hres); |
184 |
< |
odev.v.vert = 2.*180./PI * atan(0.5/VIEWDIST*pheight*odev.vres); |
183 |
> |
/* map the window and get its size */ |
184 |
> |
XMapWindow(ourdisplay, gwind); |
185 |
> |
dev_input(); /* sets size and view angles */ |
186 |
> |
/* allocate our leaf pile */ |
187 |
> |
if (!qtAllocLeaves(DisplayWidth(ourdisplay,ourscreen) * |
188 |
> |
DisplayHeight(ourdisplay,ourscreen) * 3 / |
189 |
> |
(qtMinNodesiz*qtMinNodesiz*2))) |
190 |
> |
error(SYSTEM, "insufficient memory for leaf storage"); |
191 |
> |
odev.name = id; |
192 |
|
odev.ifd = ConnectionNumber(ourdisplay); |
193 |
|
} |
194 |
|
|
210 |
|
} |
211 |
|
|
212 |
|
|
213 |
+ |
|
214 |
+ |
dev_clear() /* clear our quadtree */ |
215 |
+ |
{ |
216 |
+ |
qtCompost(100); |
217 |
+ |
if (ncolors > 0) |
218 |
+ |
new_ctab(ncolors); |
219 |
+ |
rayqleft = 0; /* hold off update */ |
220 |
+ |
} |
221 |
+ |
|
222 |
+ |
|
223 |
+ |
int |
224 |
|
dev_view(nv) /* assign new driver view */ |
225 |
|
VIEW *nv; |
226 |
|
{ |
227 |
< |
if (nv != &odev.v) |
227 |
> |
if (nv->type == VT_PAR || /* check view legality */ |
228 |
> |
nv->horiz > 160. || nv->vert > 160.) { |
229 |
> |
error(COMMAND, "illegal view type/angle"); |
230 |
> |
nv->type = VT_PER; |
231 |
> |
nv->horiz = odev.v.horiz; |
232 |
> |
nv->vert = odev.v.vert; |
233 |
> |
return(0); |
234 |
> |
} |
235 |
> |
if (nv->vfore > FTINY) { |
236 |
> |
error(COMMAND, "cannot handle fore clipping"); |
237 |
> |
nv->vfore = 0.; |
238 |
> |
return(0); |
239 |
> |
} |
240 |
> |
if (nv != &odev.v) { |
241 |
> |
if (!FEQ(nv->horiz,odev.v.horiz) || /* resize window? */ |
242 |
> |
!FEQ(nv->vert,odev.v.vert)) { |
243 |
> |
int dw = DisplayWidth(ourdisplay,ourscreen); |
244 |
> |
int dh = DisplayHeight(ourdisplay,ourscreen); |
245 |
> |
|
246 |
> |
dw -= 25; /* for window frame */ |
247 |
> |
dh -= 50; |
248 |
> |
odev.hres = 2.*VIEWDIST/pwidth * |
249 |
> |
tan(PI/180./2.*nv->horiz); |
250 |
> |
odev.vres = 2.*VIEWDIST/pheight * |
251 |
> |
tan(PI/180./2.*nv->vert); |
252 |
> |
if (odev.hres > dw) { |
253 |
> |
odev.vres = dw * odev.vres / odev.hres; |
254 |
> |
odev.hres = dw; |
255 |
> |
} |
256 |
> |
if (odev.vres > dh) { |
257 |
> |
odev.hres = dh * odev.hres / odev.vres; |
258 |
> |
odev.vres = dh; |
259 |
> |
} |
260 |
> |
XResizeWindow(ourdisplay, gwind, odev.hres, odev.vres); |
261 |
> |
dev_input(); /* wait for resize event */ |
262 |
> |
} |
263 |
|
copystruct(&odev.v, nv); |
264 |
+ |
} |
265 |
|
qtReplant(); |
266 |
+ |
return(1); |
267 |
|
} |
268 |
|
|
269 |
|
|
270 |
+ |
dev_auxcom(cmd, args) /* process an auxiliary command */ |
271 |
+ |
char *cmd, *args; |
272 |
+ |
{ |
273 |
+ |
sprintf(errmsg, "%s: unknown command", cmd); |
274 |
+ |
error(COMMAND, errmsg); |
275 |
+ |
} |
276 |
+ |
|
277 |
+ |
|
278 |
+ |
VIEW * |
279 |
+ |
dev_auxview(n, hvres) /* return nth auxiliary view */ |
280 |
+ |
int n; |
281 |
+ |
int hvres[2]; |
282 |
+ |
{ |
283 |
+ |
if (n) |
284 |
+ |
return(NULL); |
285 |
+ |
hvres[0] = odev.hres; hvres[1] = odev.vres; |
286 |
+ |
return(&odev.v); |
287 |
+ |
} |
288 |
+ |
|
289 |
+ |
|
290 |
|
int |
291 |
|
dev_input() /* get X11 input */ |
292 |
|
{ |
295 |
|
do |
296 |
|
getevent(); |
297 |
|
|
298 |
< |
while (XQLength(ourdisplay) > 0); |
298 |
> |
while (XPending(ourdisplay) > 0); |
299 |
|
|
300 |
+ |
odev.inpready = 0; |
301 |
+ |
|
302 |
|
return(inpresflags); |
303 |
|
} |
304 |
|
|
325 |
|
dev_flush() /* flush output */ |
326 |
|
{ |
327 |
|
qtUpdate(); |
328 |
< |
return(XPending(ourdisplay)); |
328 |
> |
rayqleft = RAYQLEN; |
329 |
> |
return(odev.inpready = XPending(ourdisplay)); |
330 |
|
} |
331 |
|
|
332 |
|
|
455 |
|
getkey(levptr(XKeyPressedEvent)); |
456 |
|
break; |
457 |
|
case ButtonPress: |
458 |
< |
getmove(levptr(XButtonPressedEvent)); |
458 |
> |
if (FRAMESTATE(levptr(XButtonPressedEvent)->state)) |
459 |
> |
getframe(levptr(XButtonPressedEvent)); |
460 |
> |
else |
461 |
> |
getmove(levptr(XButtonPressedEvent)); |
462 |
|
break; |
463 |
|
} |
464 |
|
} |
465 |
|
|
466 |
|
|
467 |
|
static |
468 |
< |
moveview(dx, dy, move) /* move our view */ |
469 |
< |
int dx, dy, move; |
468 |
> |
ilclip(dp, wp) /* clip world coordinates to device */ |
469 |
> |
int dp[2][2]; |
470 |
> |
FVECT wp[2]; |
471 |
|
{ |
472 |
+ |
static FVECT vmin = {0.,0.,0.}, vmax = {1.-FTINY,1.-FTINY,FHUGE}; |
473 |
+ |
FVECT wpc[2], ip[2]; |
474 |
+ |
double d, d0, d1; |
475 |
+ |
/* check for points behind view */ |
476 |
+ |
d = DOT(odev.v.vp, odev.v.vdir); |
477 |
+ |
d0 = DOT(wp[0], odev.v.vdir) - d; |
478 |
+ |
d1 = DOT(wp[1], odev.v.vdir) - d; |
479 |
+ |
/* work on copy of world points */ |
480 |
+ |
if (d0 <= d1) { |
481 |
+ |
VCOPY(wpc[0], wp[0]); VCOPY(wpc[1], wp[1]); |
482 |
+ |
} else { |
483 |
+ |
d = d0; d0 = d1; d1 = d; |
484 |
+ |
VCOPY(wpc[1], wp[0]); VCOPY(wpc[0], wp[1]); |
485 |
+ |
} |
486 |
+ |
if (d0 <= FTINY) { |
487 |
+ |
if (d1 <= FTINY) return(0); |
488 |
+ |
VSUB(wpc[0], wpc[0], wpc[1]); |
489 |
+ |
d = .99*d1/(d1-d0); |
490 |
+ |
VSUM(wpc[0], wpc[1], wpc[0], d); |
491 |
+ |
} |
492 |
+ |
/* get view coordinates and clip to window */ |
493 |
+ |
viewloc(ip[0], &odev.v, wpc[0]); |
494 |
+ |
viewloc(ip[1], &odev.v, wpc[1]); |
495 |
+ |
if (!clip(ip[0], ip[1], vmin, vmax)) |
496 |
+ |
return(0); |
497 |
+ |
dp[0][0] = ip[0][0]*odev.hres; |
498 |
+ |
dp[0][1] = ip[0][1]*odev.vres; |
499 |
+ |
dp[1][0] = ip[1][0]*odev.hres; |
500 |
+ |
dp[1][1] = ip[1][1]*odev.vres; |
501 |
+ |
return(1); |
502 |
+ |
} |
503 |
+ |
|
504 |
+ |
|
505 |
+ |
static |
506 |
+ |
draw3dline(wp) /* draw 3d line in world coordinates */ |
507 |
+ |
FVECT wp[2]; |
508 |
+ |
{ |
509 |
+ |
int dp[2][2]; |
510 |
+ |
|
511 |
+ |
if (!ilclip(dp, wp)) |
512 |
+ |
return; |
513 |
+ |
XDrawLine(ourdisplay, gwind, ourgc, |
514 |
+ |
dp[0][0], odev.vres-1 - dp[0][1], |
515 |
+ |
dp[1][0], odev.vres-1 - dp[1][1]); |
516 |
+ |
} |
517 |
+ |
|
518 |
+ |
|
519 |
+ |
static |
520 |
+ |
draw_grids() /* draw holodeck section grids */ |
521 |
+ |
{ |
522 |
+ |
static BYTE gridrgb[3] = {0x0, 0xff, 0xff}; |
523 |
+ |
unsigned long pixel; |
524 |
+ |
|
525 |
+ |
if (ncolors > 0) |
526 |
+ |
pixel = pixval[get_pixel(gridrgb, xnewcolr)]; |
527 |
+ |
else |
528 |
+ |
pixel = true_pixel(gridrgb); |
529 |
+ |
XSetForeground(ourdisplay, ourgc, pixel); |
530 |
+ |
/* draw each grid line */ |
531 |
+ |
gridlines(draw3dline); |
532 |
+ |
} |
533 |
+ |
|
534 |
+ |
|
535 |
+ |
static |
536 |
+ |
moveview(dx, dy, mov, orb) /* move our view */ |
537 |
+ |
int dx, dy, mov, orb; |
538 |
+ |
{ |
539 |
|
VIEW nv; |
540 |
+ |
FVECT odir, v1; |
541 |
|
double d; |
542 |
< |
register int i, li; |
542 |
> |
register int li; |
543 |
|
/* start with old view */ |
544 |
|
copystruct(&nv, &odev.v); |
545 |
|
/* change view direction */ |
546 |
< |
if (move) { |
546 |
> |
if (mov | orb) { |
547 |
|
if ((li = qtFindLeaf(dx, dy)) < 0) |
548 |
|
return(0); /* not on window */ |
549 |
< |
for (i = 0; i < 3; i++) |
396 |
< |
nv.vdir[i] = qtL.wp[li][i] - nv.vp[i]; |
549 |
> |
VSUM(odir, qtL.wp[li], nv.vp, -1.); |
550 |
|
} else { |
551 |
|
if (viewray(nv.vp, nv.vdir, &odev.v, |
552 |
|
(dx+.5)/odev.hres, (dy+.5)/odev.vres) < -FTINY) |
553 |
|
return(0); /* outside view */ |
554 |
|
} |
555 |
< |
/* move viewpoint */ |
556 |
< |
if (move > 0) |
557 |
< |
for (i = 0; i < 3; i++) |
558 |
< |
nv.vp[i] += MOVPCT/100. * nv.vdir[i]; |
559 |
< |
else if (move < 0) |
560 |
< |
for (i = 0; i < 3; i++) |
561 |
< |
nv.vp[i] -= MOVPCT/100. * nv.vdir[i]; |
562 |
< |
if (move && headlocked) { |
563 |
< |
d = 0; /* bring head back to same height */ |
564 |
< |
for (i = 0; i < 3; i++) |
565 |
< |
d += odev.v.vup[i] * (odev.v.vp[i] - nv.vp[i]); |
566 |
< |
for (i = 0; i < 3; i++) |
567 |
< |
nv.vp[i] += d * odev.v.vup[i]; |
555 |
> |
if (orb && mov) { /* orbit left/right */ |
556 |
> |
spinvector(odir, odir, nv.vup, d=MOVDEG*PI/180.*mov); |
557 |
> |
VSUM(nv.vp, qtL.wp[li], odir, -1.); |
558 |
> |
spinvector(nv.vdir, nv.vdir, nv.vup, d); |
559 |
> |
} else if (orb) { /* orbit up/down */ |
560 |
> |
fcross(v1, odir, nv.vup); |
561 |
> |
if (normalize(v1) == 0.) |
562 |
> |
return(0); |
563 |
> |
spinvector(odir, odir, v1, d=MOVDEG*PI/180.*orb); |
564 |
> |
VSUM(nv.vp, qtL.wp[li], odir, -1.); |
565 |
> |
spinvector(nv.vdir, nv.vdir, v1, d); |
566 |
> |
} else if (mov) { /* move forward/backward */ |
567 |
> |
d = MOVPCT/100. * mov; |
568 |
> |
VSUM(nv.vp, nv.vp, odir, d); |
569 |
|
} |
570 |
+ |
if (!mov ^ !orb && headlocked) { /* restore head height */ |
571 |
+ |
VSUM(v1, odev.v.vp, nv.vp, -1.); |
572 |
+ |
d = DOT(v1, odev.v.vup); |
573 |
+ |
VSUM(nv.vp, nv.vp, odev.v.vup, d); |
574 |
+ |
} |
575 |
|
if (setview(&nv) != NULL) |
576 |
|
return(0); /* illegal view */ |
577 |
|
dev_view(&nv); |
578 |
< |
inpresflags |= DEV_NEWVIEW; |
578 |
> |
inpresflags |= DFL(DC_SETVIEW); |
579 |
|
return(1); |
580 |
|
} |
581 |
|
|
582 |
|
|
583 |
|
static |
584 |
+ |
getframe(ebut) /* get focus frame */ |
585 |
+ |
XButtonPressedEvent *ebut; |
586 |
+ |
{ |
587 |
+ |
int startx = ebut->x, starty = ebut->y; |
588 |
+ |
int endx, endy; |
589 |
+ |
|
590 |
+ |
XMaskEvent(ourdisplay, ButtonReleaseMask, levptr(XEvent)); |
591 |
+ |
endx = levptr(XButtonReleasedEvent)->x; |
592 |
+ |
endy = levptr(XButtonReleasedEvent)->y; |
593 |
+ |
if (endx == startx | endy == starty) { |
594 |
+ |
XBell(ourdisplay, 0); |
595 |
+ |
return; |
596 |
+ |
} |
597 |
+ |
if (endx < startx) {register int c = endx; endx = startx; startx = c;} |
598 |
+ |
if (endy < starty) {register int c = endy; endy = starty; starty = c;} |
599 |
+ |
sprintf(odev_args, "%.3f %.3f %.3f %.3f", |
600 |
+ |
(startx+.5)/odev.hres, 1.-(endy+.5)/odev.vres, |
601 |
+ |
(endx+.5)/odev.hres, 1.-(starty+.5)/odev.vres); |
602 |
+ |
inpresflags |= DFL(DC_FOCUS); |
603 |
+ |
} |
604 |
+ |
|
605 |
+ |
|
606 |
+ |
static |
607 |
|
getmove(ebut) /* get view change */ |
608 |
|
XButtonPressedEvent *ebut; |
609 |
|
{ |
610 |
< |
int whichbutton = ebut->button; |
610 |
> |
int movdir = MOVDIR(ebut->button); |
611 |
> |
int movorb = MOVORB(ebut->state); |
612 |
|
int oldnodesiz = qtMinNodesiz; |
613 |
|
Window rootw, childw; |
614 |
|
int rootx, rooty, wx, wy; |
615 |
|
unsigned int statemask; |
616 |
|
|
617 |
|
qtMinNodesiz = 16; /* for quicker update */ |
618 |
< |
qtCompost(50); |
618 |
> |
XNoOp(ourdisplay); |
619 |
|
|
620 |
< |
do { |
620 |
> |
while (!XCheckMaskEvent(ourdisplay, |
621 |
> |
ButtonReleaseMask, levptr(XEvent))) { |
622 |
> |
|
623 |
|
if (!XQueryPointer(ourdisplay, gwind, &rootw, &childw, |
624 |
|
&rootx, &rooty, &wx, &wy, &statemask)) |
625 |
|
break; /* on another screen */ |
626 |
|
|
627 |
< |
if (!moveview(wx, odev.vres-1-wy, MOVDIR(whichbutton))) |
627 |
> |
if (!moveview(wx, odev.vres-1-wy, movdir, movorb)) { |
628 |
|
sleep(1); |
629 |
< |
else |
630 |
< |
qtUpdate(); |
631 |
< |
|
632 |
< |
} while (!XCheckMaskEvent(ourdisplay, |
633 |
< |
ButtonReleaseMask, levptr(XEvent))); |
634 |
< |
|
635 |
< |
if (!(inpresflags & DEV_NEWVIEW)) { /* do final motion */ |
636 |
< |
whichbutton = levptr(XButtonReleasedEvent)->button; |
629 |
> |
continue; |
630 |
> |
} |
631 |
> |
XClearWindow(ourdisplay, gwind); |
632 |
> |
qtUpdate(); |
633 |
> |
draw_grids(); |
634 |
> |
} |
635 |
> |
if (!(inpresflags & DFL(DC_SETVIEW))) { /* do final motion */ |
636 |
> |
movdir = MOVDIR(levptr(XButtonReleasedEvent)->button); |
637 |
|
wx = levptr(XButtonReleasedEvent)->x; |
638 |
|
wy = levptr(XButtonReleasedEvent)->y; |
639 |
< |
moveview(wx, odev.vres-1-wy, MOVDIR(whichbutton)); |
639 |
> |
moveview(wx, odev.vres-1-wy, movdir, movorb); |
640 |
|
} |
641 |
+ |
dev_flush(); |
642 |
|
|
643 |
|
qtMinNodesiz = oldnodesiz; /* restore quadtree resolution */ |
644 |
|
} |
648 |
|
getkey(ekey) /* get input key */ |
649 |
|
register XKeyPressedEvent *ekey; |
650 |
|
{ |
651 |
+ |
Window rootw, childw; |
652 |
+ |
int rootx, rooty, wx, wy; |
653 |
+ |
unsigned int statemask; |
654 |
|
int n; |
655 |
|
char buf[8]; |
656 |
|
|
664 |
|
case 'H': /* turn off height motion lock */ |
665 |
|
headlocked = 0; |
666 |
|
return; |
667 |
< |
case CTRL('S'): |
667 |
> |
case 'l': /* retrieve last view */ |
668 |
> |
inpresflags |= DFL(DC_LASTVIEW); |
669 |
> |
return; |
670 |
> |
case 'f': /* frame view position */ |
671 |
> |
if (!XQueryPointer(ourdisplay, gwind, &rootw, &childw, |
672 |
> |
&rootx, &rooty, &wx, &wy, &statemask)) |
673 |
> |
return; /* on another screen */ |
674 |
> |
sprintf(odev_args, "%.4f %.4f", (wx+.5)/odev.hres, |
675 |
> |
1.-(wy+.5)/odev.vres); |
676 |
> |
inpresflags |= DFL(DC_FOCUS); |
677 |
> |
return; |
678 |
> |
case 'F': /* unfocus */ |
679 |
> |
odev_args[0] = '\0'; |
680 |
> |
inpresflags |= DFL(DC_FOCUS); |
681 |
> |
return; |
682 |
|
case 'p': /* pause computation */ |
683 |
< |
inpresflags |= DEV_WAIT; |
683 |
> |
inpresflags |= DFL(DC_PAUSE); |
684 |
|
return; |
685 |
< |
case CTRL('Q'): |
685 |
> |
case 'v': /* spit out view */ |
686 |
> |
inpresflags |= DFL(DC_GETVIEW); |
687 |
> |
return; |
688 |
|
case '\n': |
689 |
|
case '\r': /* resume computation */ |
690 |
< |
inpresflags |= DEV_RESUME; |
690 |
> |
inpresflags |= DFL(DC_RESUME); |
691 |
|
return; |
692 |
< |
case CTRL('R'): /* redraw */ |
692 |
> |
case CTRL('R'): /* redraw screen */ |
693 |
|
if (ncolors > 0) |
694 |
|
new_ctab(ncolors); |
695 |
|
qtRedraw(0, 0, odev.hres, odev.vres); |
696 |
|
return; |
697 |
< |
case CTRL('D'): |
698 |
< |
case 'Q': |
697 |
> |
case CTRL('L'): /* refresh from server */ |
698 |
> |
if (inpresflags & DFL(DC_REDRAW)) |
699 |
> |
return; |
700 |
> |
XClearWindow(ourdisplay, gwind); |
701 |
> |
draw_grids(); |
702 |
> |
XFlush(ourdisplay); |
703 |
> |
qtCompost(100); /* unload the old tree */ |
704 |
> |
if (ncolors > 0) |
705 |
> |
new_ctab(ncolors); |
706 |
> |
inpresflags |= DFL(DC_REDRAW); /* resend values from server */ |
707 |
> |
rayqleft = 0; /* hold off update */ |
708 |
> |
return; |
709 |
> |
case 'K': /* kill rtrace process(es) */ |
710 |
> |
inpresflags |= DFL(DC_KILL); |
711 |
> |
break; |
712 |
> |
case 'R': /* restart rtrace */ |
713 |
> |
inpresflags |= DFL(DC_RESTART); |
714 |
> |
break; |
715 |
> |
case 'C': /* clobber holodeck */ |
716 |
> |
inpresflags |= DFL(DC_CLOBBER); |
717 |
> |
break; |
718 |
|
case 'q': /* quit the program */ |
719 |
< |
inpresflags |= DEV_SHUTDOWN; |
719 |
> |
inpresflags |= DFL(DC_QUIT); |
720 |
|
return; |
721 |
|
default: |
722 |
|
XBell(ourdisplay, 0); |
732 |
|
if (odev.hres == 0 || odev.vres == 0) { /* first exposure */ |
733 |
|
odev.hres = eexp->width; |
734 |
|
odev.vres = eexp->height; |
511 |
– |
inpresflags |= DEV_NEWSIZE; |
735 |
|
} |
736 |
|
qtRedraw(eexp->x, odev.vres - eexp->y - eexp->height, |
737 |
|
eexp->x + eexp->width, odev.vres - eexp->y); |
745 |
|
if (ersz->width == odev.hres && ersz->height == odev.vres) |
746 |
|
return; |
747 |
|
|
525 |
– |
if (odev.hres != 0 && odev.vres != 0) { |
526 |
– |
odev.v.horiz = 2.*180./PI * atan( |
527 |
– |
tan(PI/180./2.*odev.v.horiz) * ersz->width/odev.hres ); |
528 |
– |
odev.v.vert = 2.*180./PI * atan( |
529 |
– |
tan(PI/180./2.*odev.v.vert) * ersz->height/odev.vres ); |
530 |
– |
inpresflags |= DEV_NEWVIEW; |
531 |
– |
} |
748 |
|
odev.hres = ersz->width; |
749 |
|
odev.vres = ersz->height; |
750 |
|
|
751 |
< |
inpresflags |= DEV_NEWSIZE; |
751 |
> |
odev.v.horiz = 2.*180./PI * atan(0.5/VIEWDIST*pwidth*odev.hres); |
752 |
> |
odev.v.vert = 2.*180./PI * atan(0.5/VIEWDIST*pheight*odev.vres); |
753 |
> |
|
754 |
> |
inpresflags |= DFL(DC_SETVIEW); |
755 |
|
} |