49 |
|
static unsigned long ourblack=0, ourwhite=1; |
50 |
|
|
51 |
|
static Display *ourdisplay = NULL; /* our display */ |
52 |
– |
|
52 |
|
static XVisualInfo ourvinfo; /* our visual information */ |
54 |
– |
|
53 |
|
static Window gwind = 0; /* our graphics window */ |
56 |
– |
|
54 |
|
static GC ourgc = 0; /* our graphics context for drawing */ |
58 |
– |
|
55 |
|
static Colormap ourmap = 0; /* our color map */ |
56 |
|
|
57 |
|
static double pwidth, pheight; /* pixel dimensions (mm) */ |
208 |
|
dev_input() /* get X11 input */ |
209 |
|
{ |
210 |
|
inpresflags = 0; |
211 |
+ |
|
212 |
|
do |
213 |
|
getevent(); |
214 |
|
|
376 |
|
|
377 |
|
|
378 |
|
static |
379 |
+ |
ilclip(dp, wp) /* clip world coordinates to device */ |
380 |
+ |
int dp[2][2]; |
381 |
+ |
FVECT wp[2]; |
382 |
+ |
{ |
383 |
+ |
static FVECT vmin = {0.,0.,0.}, vmax = {1.,1.,FHUGE}; |
384 |
+ |
FVECT ip[2]; |
385 |
+ |
/* not exactly right, but who cares? */ |
386 |
+ |
viewloc(ip[0], &odev.v, wp[0]); |
387 |
+ |
viewloc(ip[1], &odev.v, wp[1]); |
388 |
+ |
if (!clip(ip[0], ip[1], vmin, vmax)) |
389 |
+ |
return(0); |
390 |
+ |
dp[0][0] = ip[0][0]*odev.hres; |
391 |
+ |
dp[0][1] = ip[0][1]*odev.vres; |
392 |
+ |
dp[1][0] = ip[1][0]*odev.hres; |
393 |
+ |
dp[1][1] = ip[1][1]*odev.vres; |
394 |
+ |
return(1); |
395 |
+ |
} |
396 |
+ |
|
397 |
+ |
|
398 |
+ |
static |
399 |
+ |
draw3dline(wp) /* draw 3d line in world coordinates */ |
400 |
+ |
FVECT wp[2]; |
401 |
+ |
{ |
402 |
+ |
int dp[2][2]; |
403 |
+ |
|
404 |
+ |
if (!ilclip(dp, wp)) |
405 |
+ |
return; |
406 |
+ |
XDrawLine(ourdisplay, gwind, ourgc, |
407 |
+ |
dp[0][0], odev.vres-1 - dp[0][1], |
408 |
+ |
dp[1][0], odev.vres-1 - dp[1][1]); |
409 |
+ |
} |
410 |
+ |
|
411 |
+ |
|
412 |
+ |
static |
413 |
+ |
draw_grids() /* draw holodeck section grids */ |
414 |
+ |
{ |
415 |
+ |
static BYTE gridrgb[3] = {0x0, 0xff, 0xff}; |
416 |
+ |
unsigned long pixel; |
417 |
+ |
|
418 |
+ |
if (!mapped || odev.v.type != VT_PER) |
419 |
+ |
return; |
420 |
+ |
if (ncolors > 0) |
421 |
+ |
pixel = pixval[get_pixel(gridrgb, xnewcolr)]; |
422 |
+ |
else |
423 |
+ |
pixel = true_pixel(gridrgb); |
424 |
+ |
XSetForeground(ourdisplay, ourgc, pixel); |
425 |
+ |
/* draw each grid line */ |
426 |
+ |
gridlines(draw3dline); |
427 |
+ |
} |
428 |
+ |
|
429 |
+ |
|
430 |
+ |
static |
431 |
|
moveview(dx, dy, move) /* move our view */ |
432 |
|
int dx, dy, move; |
433 |
|
{ |
480 |
|
unsigned int statemask; |
481 |
|
|
482 |
|
qtMinNodesiz = 16; /* for quicker update */ |
483 |
< |
qtCompost(50); |
483 |
> |
XNoOp(ourdisplay); |
484 |
|
|
485 |
< |
do { |
485 |
> |
while (!XCheckMaskEvent(ourdisplay, |
486 |
> |
ButtonReleaseMask, levptr(XEvent))) { |
487 |
> |
|
488 |
|
if (!XQueryPointer(ourdisplay, gwind, &rootw, &childw, |
489 |
|
&rootx, &rooty, &wx, &wy, &statemask)) |
490 |
|
break; /* on another screen */ |
491 |
|
|
492 |
< |
if (!moveview(wx, odev.vres-1-wy, MOVDIR(whichbutton))) |
492 |
> |
if (!moveview(wx, odev.vres-1-wy, MOVDIR(whichbutton))) { |
493 |
|
sleep(1); |
494 |
< |
else |
495 |
< |
qtUpdate(); |
496 |
< |
|
497 |
< |
} while (!XCheckMaskEvent(ourdisplay, |
498 |
< |
ButtonReleaseMask, levptr(XEvent))); |
499 |
< |
|
494 |
> |
continue; |
495 |
> |
} |
496 |
> |
XClearWindow(ourdisplay, gwind); |
497 |
> |
qtUpdate(); |
498 |
> |
draw_grids(); |
499 |
> |
} |
500 |
|
if (!(inpresflags & DEV_NEWVIEW)) { /* do final motion */ |
501 |
|
whichbutton = levptr(XButtonReleasedEvent)->button; |
502 |
|
wx = levptr(XButtonReleasedEvent)->x; |
503 |
|
wy = levptr(XButtonReleasedEvent)->y; |
504 |
|
moveview(wx, odev.vres-1-wy, MOVDIR(whichbutton)); |
505 |
|
} |
506 |
+ |
dev_flush(); |
507 |
|
|
508 |
|
qtMinNodesiz = oldnodesiz; /* restore quadtree resolution */ |
509 |
|
} |
526 |
|
case 'H': /* turn off height motion lock */ |
527 |
|
headlocked = 0; |
528 |
|
return; |
529 |
< |
case CTRL('Z'): |
529 |
> |
case CTRL('S'): |
530 |
|
case 'p': /* pause computation */ |
531 |
|
inpresflags |= DEV_WAIT; |
532 |
|
return; |
533 |
+ |
case 'v': /* spit out view */ |
534 |
+ |
fputs(VIEWSTR, stderr); |
535 |
+ |
fprintview(&odev.v, stderr); |
536 |
+ |
fputc('\n', stderr); |
537 |
+ |
return; |
538 |
+ |
case CTRL('Q'): |
539 |
|
case '\n': |
540 |
< |
case '\r': /* release */ |
540 |
> |
case '\r': /* resume computation */ |
541 |
> |
inpresflags |= DEV_RESUME; |
542 |
|
return; |
543 |
< |
case CTRL('R'): /* redraw */ |
543 |
> |
case CTRL('R'): /* redraw screen */ |
544 |
|
if (ncolors > 0) |
545 |
|
new_ctab(ncolors); |
546 |
|
qtRedraw(0, 0, odev.hres, odev.vres); |
547 |
+ |
return; |
548 |
+ |
case CTRL('L'): /* refresh from server */ |
549 |
+ |
if (inpresflags & DEV_REDRAW) |
550 |
+ |
return; |
551 |
+ |
XClearWindow(ourdisplay, gwind); |
552 |
+ |
draw_grids(); |
553 |
+ |
XFlush(ourdisplay); |
554 |
+ |
qtCompost(100); /* unload the old tree */ |
555 |
+ |
if (ncolors > 0) |
556 |
+ |
new_ctab(ncolors); |
557 |
+ |
inpresflags |= DEV_REDRAW; /* resend values from server */ |
558 |
|
return; |
559 |
|
case CTRL('D'): |
560 |
|
case 'Q': |