193 |
|
getevent(); /* main loop */ |
194 |
|
userr: |
195 |
|
fprintf(stderr, |
196 |
< |
"Usage: %s [-display disp][-geometry spec][-b][-m][-d][-f][-c ncolors][-e +/-stops] file\n", |
196 |
> |
"Usage: %s [-di disp][[-ge] spec][-b][-m][-d][-f][-c nclrs][-e +/-stops] pic\n", |
197 |
|
progname); |
198 |
< |
quit(1); |
198 |
> |
exit(1); |
199 |
|
} |
200 |
|
|
201 |
|
|
256 |
|
} |
257 |
|
} |
258 |
|
/* open window */ |
259 |
< |
ourwinattr.border_pixel = ourblack; |
260 |
< |
ourwinattr.background_pixel = ourwhite; |
259 |
> |
ourwinattr.border_pixel = ourwhite; |
260 |
> |
ourwinattr.background_pixel = ourblack; |
261 |
|
ourwinattr.colormap = XCreateColormap(thedisplay, ourroot, |
262 |
|
ourvis.visual, AllocNone); |
263 |
|
wind = XCreateWindow(thedisplay, ourroot, oursizhints.x, oursizhints.y, |
508 |
|
case ButtonPress: |
509 |
|
if (e.b.state & (ShiftMask|ControlMask)) |
510 |
|
moveimage(&e.b); |
511 |
+ |
else if (e.b.button == Button2) |
512 |
+ |
traceray(e.b.x, e.b.y); |
513 |
|
else |
514 |
|
getbox(&e.b); |
515 |
|
break; |
517 |
|
} |
518 |
|
|
519 |
|
|
520 |
< |
docom(ekey) /* execute command */ |
520 |
> |
traceray(xpos, ypos) /* print ray corresponding to pixel */ |
521 |
> |
int xpos, ypos; |
522 |
> |
{ |
523 |
> |
FLOAT hv[2]; |
524 |
> |
FVECT rorg, rdir; |
525 |
> |
|
526 |
> |
if (!gotview) { /* no view, no can do */ |
527 |
> |
XBell(thedisplay, 0); |
528 |
> |
return(-1); |
529 |
> |
} |
530 |
> |
pix2loc(hv, &inpres, xpos-xoff, ypos-yoff); |
531 |
> |
if (viewray(rorg, rdir, &ourview, hv[0], hv[1]) < 0) |
532 |
> |
return(-1); |
533 |
> |
printf("%e %e %e ", rorg[0], rorg[1], rorg[2]); |
534 |
> |
printf("%e %e %e\n", rdir[0], rdir[1], rdir[2]); |
535 |
> |
fflush(stdout); |
536 |
> |
return(0); |
537 |
> |
} |
538 |
> |
|
539 |
> |
|
540 |
> |
docom(ekey) /* execute command */ |
541 |
|
XKeyPressedEvent *ekey; |
542 |
|
{ |
543 |
|
char buf[80]; |
546 |
|
int com, n; |
547 |
|
double comp; |
548 |
|
FLOAT hv[2]; |
527 |
– |
FVECT rorg, rdir; |
549 |
|
|
550 |
|
n = XLookupString(ekey, buf, sizeof(buf), NULL, NULL); |
551 |
|
if (n == 0) |
553 |
|
com = buf[0]; |
554 |
|
switch (com) { /* interpret command */ |
555 |
|
case 'q': |
556 |
+ |
case 'Q': |
557 |
|
case CTRL('D'): /* quit */ |
558 |
< |
quit(0); |
558 |
> |
quiterr(NULL); |
559 |
|
case '\n': |
560 |
|
case '\r': |
561 |
|
case 'l': |
601 |
|
buf, strlen(buf)); |
602 |
|
return(0); |
603 |
|
case 't': /* trace */ |
604 |
< |
if (!gotview) { |
583 |
< |
XBell(thedisplay, 0); |
584 |
< |
return(-1); |
585 |
< |
} |
586 |
< |
pix2loc(hv, &inpres, ekey->x-xoff, ekey->y-yoff); |
587 |
< |
if (viewray(rorg, rdir, &ourview, hv[0], hv[1]) < 0) |
588 |
< |
return(-1); |
589 |
< |
printf("%e %e %e ", rorg[0], rorg[1], rorg[2]); |
590 |
< |
printf("%e %e %e\n", rdir[0], rdir[1], rdir[2]); |
591 |
< |
fflush(stdout); |
592 |
< |
return(0); |
604 |
> |
return(traceray(ekey->x, ekey->y)); |
605 |
|
case '=': /* adjust exposure */ |
606 |
|
if (avgbox(cval) == -1) |
607 |
|
return(-1); |