| 28 |
|
getframe(s) /* get a new frame */ |
| 29 |
|
char *s; |
| 30 |
|
{ |
| 31 |
< |
int x0, y0, x1, y1; |
| 32 |
< |
|
| 33 |
< |
if (!strcmp("all", s)) { |
| 34 |
< |
pframe.l = pframe.d = 0; |
| 35 |
< |
pframe.r = ourview.hresolu; |
| 36 |
< |
pframe.u = ourview.vresolu; |
| 37 |
< |
pdepth = 0; |
| 31 |
> |
if (getrect(s, &pframe) < 0) |
| 32 |
|
return; |
| 39 |
– |
} |
| 40 |
– |
if (sscanf(s, "%d %d %d %d", &x0, &y0, &x1, &y1) != 4) { |
| 41 |
– |
if (dev->getcur == NULL) |
| 42 |
– |
return; |
| 43 |
– |
(*dev->comout)("Pick first corner\n"); |
| 44 |
– |
if ((*dev->getcur)(&x0, &y0) == ABORT) |
| 45 |
– |
return; |
| 46 |
– |
(*dev->comout)("Pick second corner\n"); |
| 47 |
– |
if ((*dev->getcur)(&x1, &y1) == ABORT) |
| 48 |
– |
return; |
| 49 |
– |
} |
| 50 |
– |
if (x0 < x1) { |
| 51 |
– |
pframe.l = x0; |
| 52 |
– |
pframe.r = x1; |
| 53 |
– |
} else { |
| 54 |
– |
pframe.l = x1; |
| 55 |
– |
pframe.r = x0; |
| 56 |
– |
} |
| 57 |
– |
if (y0 < y1) { |
| 58 |
– |
pframe.d = y0; |
| 59 |
– |
pframe.u = y1; |
| 60 |
– |
} else { |
| 61 |
– |
pframe.d = y1; |
| 62 |
– |
pframe.u = y0; |
| 63 |
– |
} |
| 64 |
– |
if (pframe.l < 0) pframe.l = 0; |
| 65 |
– |
if (pframe.d < 0) pframe.d = 0; |
| 66 |
– |
if (pframe.r > ourview.hresolu) pframe.r = ourview.hresolu; |
| 67 |
– |
if (pframe.u > ourview.vresolu) pframe.u = ourview.vresolu; |
| 68 |
– |
if (pframe.l > pframe.r) pframe.l = pframe.r; |
| 69 |
– |
if (pframe.d > pframe.u) pframe.d = pframe.u; |
| 33 |
|
pdepth = 0; |
| 34 |
|
} |
| 35 |
|
|
| 36 |
|
|
| 37 |
+ |
getrepaint(s) /* get area and repaint */ |
| 38 |
+ |
char *s; |
| 39 |
+ |
{ |
| 40 |
+ |
RECT box; |
| 41 |
+ |
|
| 42 |
+ |
if (getrect(s, &box) < 0) |
| 43 |
+ |
return; |
| 44 |
+ |
paintrect(&ptrunk, 0, 0, hresolu, vresolu, &box); |
| 45 |
+ |
} |
| 46 |
+ |
|
| 47 |
+ |
|
| 48 |
|
getview(s) /* get/show view parameters */ |
| 49 |
|
char *s; |
| 50 |
|
{ |
| 113 |
|
else { |
| 114 |
|
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
| 115 |
|
} |
| 116 |
< |
sprintf(buf, "x and y resolution (%d %d): ", |
| 117 |
< |
ourview.hresolu, ourview.vresolu); |
| 116 |
> |
sprintf(buf, "view shift and lift (%.6g %.6g): ", |
| 117 |
> |
ourview.hoff, ourview.voff); |
| 118 |
|
(*dev->comout)(buf); |
| 119 |
|
(*dev->comin)(buf); |
| 120 |
|
if (buf[0] == CTRL(C)) return; |
| 121 |
< |
if (sscanf(buf, "%d %d", &nv.hresolu, &nv.vresolu) == 2) |
| 121 |
> |
if (sscanf(buf, "%lf %lf", &nv.hoff, &nv.voff) == 2) |
| 122 |
|
change++; |
| 123 |
|
else { |
| 124 |
< |
nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu; |
| 124 |
> |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
| 125 |
|
} |
| 126 |
|
if (change) |
| 127 |
|
newview(&nv); |
| 137 |
|
VIEW nv; |
| 138 |
|
|
| 139 |
|
if (sscanf(s, "%s", buf) == 1) { /* get parameters from a file */ |
| 140 |
< |
bcopy(&stdview, &nv, sizeof(VIEW)); |
| 140 |
> |
copyview(&nv, &stdview); |
| 141 |
|
if ((fname = getpath(buf, NULL, 0)) == NULL || |
| 142 |
< |
(success = viewfile(fname, &nv)) == -1) { |
| 142 |
> |
(success = viewfile(fname, &nv, 0, 0)) == -1) { |
| 143 |
|
sprintf(errmsg, "cannot open \"%s\"", buf); |
| 144 |
|
error(COMMAND, errmsg); |
| 145 |
|
return; |
| 150 |
|
newview(&nv); |
| 151 |
|
return; |
| 152 |
|
} |
| 153 |
< |
if (oldview.hresolu == 0) { /* no old view! */ |
| 153 |
> |
if (oldview.horiz == 0) { /* no old view! */ |
| 154 |
|
error(COMMAND, "no previous view"); |
| 155 |
|
return; |
| 156 |
|
} |
| 157 |
< |
bcopy(&ourview, &nv, sizeof(VIEW)); |
| 158 |
< |
bcopy(&oldview, &ourview, sizeof(VIEW)); |
| 159 |
< |
bcopy(&nv, &oldview, sizeof(VIEW)); |
| 157 |
> |
copyview(&nv, &ourview); |
| 158 |
> |
copyview(&ourview, &oldview); |
| 159 |
> |
copyview(&oldview, &nv); |
| 160 |
|
newimage(); |
| 161 |
|
} |
| 162 |
|
|
| 163 |
|
|
| 190 |
– |
getinterest(s, direc, vec, mp) /* get area of interest */ |
| 191 |
– |
char *s; |
| 192 |
– |
int direc; |
| 193 |
– |
FVECT vec; |
| 194 |
– |
double *mp; |
| 195 |
– |
{ |
| 196 |
– |
int x, y; |
| 197 |
– |
RAY thisray; |
| 198 |
– |
register int i; |
| 199 |
– |
|
| 200 |
– |
if (sscanf(s, "%lf", mp) != 1) |
| 201 |
– |
*mp = 1.0; |
| 202 |
– |
else if (*mp < -FTINY) /* negative zoom is reduction */ |
| 203 |
– |
*mp = -1.0 / *mp; |
| 204 |
– |
else if (*mp <= FTINY) { /* too small */ |
| 205 |
– |
error(COMMAND, "illegal magnification"); |
| 206 |
– |
return(-1); |
| 207 |
– |
} |
| 208 |
– |
if (sscanf(s, "%*lf %lf %lf %lf", &vec[0], &vec[1], &vec[2]) != 3) { |
| 209 |
– |
if (dev->getcur == NULL) |
| 210 |
– |
return(-1); |
| 211 |
– |
(*dev->comout)("Pick view center\n"); |
| 212 |
– |
if ((*dev->getcur)(&x, &y) == ABORT) |
| 213 |
– |
return(-1); |
| 214 |
– |
rayview(thisray.rorg, thisray.rdir, &ourview, x+.5, y+.5); |
| 215 |
– |
if (!direc || ourview.type == VT_PAR) { |
| 216 |
– |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
| 217 |
– |
if (!localhit(&thisray, &thescene)) { |
| 218 |
– |
error(COMMAND, "not a local object"); |
| 219 |
– |
return(-1); |
| 220 |
– |
} |
| 221 |
– |
} |
| 222 |
– |
if (direc) |
| 223 |
– |
if (ourview.type == VT_PAR) |
| 224 |
– |
for (i = 0; i < 3; i++) |
| 225 |
– |
vec[i] = thisray.rop[i] - ourview.vp[i]; |
| 226 |
– |
else |
| 227 |
– |
VCOPY(vec, thisray.rdir); |
| 228 |
– |
else |
| 229 |
– |
VCOPY(vec, thisray.rop); |
| 230 |
– |
} else if (direc) |
| 231 |
– |
for (i = 0; i < 3; i++) |
| 232 |
– |
vec[i] -= ourview.vp[i]; |
| 233 |
– |
return(0); |
| 234 |
– |
} |
| 235 |
– |
|
| 236 |
– |
|
| 164 |
|
getaim(s) /* aim camera */ |
| 165 |
|
char *s; |
| 166 |
|
{ |
| 172 |
|
return; |
| 173 |
|
VCOPY(nv.vp, ourview.vp); |
| 174 |
|
VCOPY(nv.vup, ourview.vup); |
| 175 |
< |
nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu; |
| 175 |
> |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
| 176 |
|
if ((nv.type = ourview.type) == VT_PAR) { |
| 177 |
|
nv.horiz = ourview.horiz / zfact; |
| 178 |
|
nv.vert = ourview.vert / zfact; |
| 213 |
|
} |
| 214 |
|
VCOPY(nv.vp, ourview.vp); |
| 215 |
|
VCOPY(nv.vup, ourview.vup); |
| 216 |
< |
nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu; |
| 216 |
> |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
| 217 |
|
spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.)); |
| 218 |
|
if (elev != 0.0) { |
| 219 |
|
fcross(v1, nv.vdir, ourview.vup); |
| 270 |
|
if ((*dev->getcur)(&x, &y) == ABORT) |
| 271 |
|
return; |
| 272 |
|
r.l = r.d = 0; |
| 273 |
< |
r.r = ourview.hresolu; r.u = ourview.vresolu; |
| 273 |
> |
r.r = hresolu; r.u = vresolu; |
| 274 |
|
p = findrect(x, y, &ptrunk, &r, -1); |
| 275 |
|
e = 1.0; |
| 276 |
|
} else { |
| 540 |
|
if ((*dev->getcur)(&x, &y) == ABORT) |
| 541 |
|
return; |
| 542 |
|
|
| 543 |
< |
rayview(thisray.rorg, thisray.rdir, &ourview, x+.5, y+.5); |
| 543 |
> |
viewray(thisray.rorg, thisray.rdir, &ourview, |
| 544 |
> |
(x+.5)/hresolu, (y+.5)/vresolu); |
| 545 |
|
|
| 546 |
|
} else if (normalize(thisray.rdir) == 0.0) { |
| 547 |
|
error(COMMAND, "zero ray direction"); |
| 604 |
|
/* write header */ |
| 605 |
|
fputs(progname, fp); |
| 606 |
|
fprintview(&ourview, fp); |
| 607 |
< |
fputs("\n", fp); |
| 607 |
> |
putc('\n', fp); |
| 608 |
|
if (exposure != 1.0) |
| 609 |
< |
fprintf(fp, "EXPOSURE=%e\n", exposure); |
| 610 |
< |
fprintf(fp, "\n-Y %d +X %d\n", ourview.vresolu, ourview.hresolu); |
| 609 |
> |
fputexpos(exposure, fp); |
| 610 |
> |
if (dev->pixaspect != 1.0) |
| 611 |
> |
fputaspect(dev->pixaspect, fp); |
| 612 |
> |
putc('\n', fp); |
| 613 |
> |
fputresolu(YMAJOR|YDECR, hresolu, vresolu, fp); |
| 614 |
|
|
| 615 |
< |
scanline = (COLR *)malloc(ourview.hresolu*sizeof(COLR)); |
| 615 |
> |
scanline = (COLR *)malloc(hresolu*sizeof(COLR)); |
| 616 |
|
if (scanline == NULL) |
| 617 |
|
error(SYSTEM, "out of memory in writepict"); |
| 618 |
< |
for (y = ourview.vresolu-1; y >= 0; y--) { |
| 619 |
< |
getpictcolrs(y, scanline, &ptrunk, |
| 620 |
< |
ourview.hresolu, ourview.vresolu); |
| 690 |
< |
if (fwritecolrs(scanline, ourview.hresolu, fp) < 0) |
| 618 |
> |
for (y = vresolu-1; y >= 0; y--) { |
| 619 |
> |
getpictcolrs(y, scanline, &ptrunk, hresolu, vresolu); |
| 620 |
> |
if (fwritecolrs(scanline, hresolu, fp) < 0) |
| 621 |
|
break; |
| 622 |
|
} |
| 623 |
|
if (fclose(fp) < 0) |