/********************************/ /* reviewio valdes 8 30 82 */ /* */ /* I/O for doing catalog */ /* reviews */ /********************************/ #include "focas1.h" #include "match1.h" #include "review.h" /*Read object positions in catalog and return number of objects read*/ getpos (cat) int cat; { struct objrec ob; int i, n; char *calloc(); long nobj(); if (cat >= NWNDW) return (0); n = nobjs (cfd); offset[cat] = (long *) calloc (n, sizeof (long)); xpos[cat] = (int *) calloc (n, sizeof (int)); ypos[cat] = (int *) calloc (n, sizeof (int)); if (offset[cat] == 0 || xpos[cat] == 0 || ypos[cat] == 0) focaserr (1, "Memory allocation error", ""); for (i = 0; i < n; i++) { offset[cat][i] = ftell (cfd); if (rdcatob (cfd, 0L, &ob)) break; if (ffilter (&ob)) { xpos[cat][i] = ob.xc; ypos[cat][i] = ob.yc; } else { xpos[cat][i] = -1; ypos[cat][i] = -1; } } return (i); } /*Read object positions in matched catalog and return number of objects read*/ mgetpos (cat) int cat; { int i, n; char *calloc(); long off; off = ftell (cfd); for (i = 0;; i++) { if (rdmcatob (cfd, &mentry, mob)) break; } n = i; offset[cat] = (long *) calloc (n, sizeof (long)); xpos[cat] = (int *) calloc (n, sizeof (int)); ypos[cat] = (int *) calloc (n, sizeof (int)); if (offset[cat] == 0 || xpos[cat] == 0 || ypos[cat] == 0) focaserr (1, "Memory allocation error", ""); fseek (cfd, off, 0); for (i = 0; i < MAXOBJ; i++) { offset[cat][i] = ftell (cfd); if (rdmcatob (cfd, &mentry, mob)) break; if (mob[cat].entnum >= 0) { if (ffilter (&mob[cat])) { xpos[cat][i] = mob[cat].xc; ypos[cat][i] = mob[cat].yc; } else { xpos[cat][i] = -1; ypos[cat][i] = -1; } } else { xpos[cat][i] = -1; ypos[cat][i] = -1; } } return (i); } /*Display field for catalog in window*/ getfld (cat, imiso, wndw, flag) int cat; struct imiso *imiso; int wndw; int flag; /* 0 - write image to iis, 1 - image already in iis */ { if (cat >= NWNDW) return; sp.xs = pthdr.crpix1; sp.ys = pthdr.crpix2; sp.kpts = pthdr.naxis1; sp.kscan = pthdr.naxis2; /* red[cat] = imred (&pthdr) * pthdr.cdelt1; */ red[cat] = imred (&pthdr); p[cat].x0 = p[cat].y0 = 0; /* p[cat].dx = sp.kpts / red[cat]; p[cat].dy = sp.kscan / red[cat]; */ p[cat].dx = sp.kpts; p[cat].dy = sp.kscan; if (flag == 0) { /* Display image */ iiserase (wndw, "frame"); iiserase (wndw, "FRAME"); iiswdw (wndw); imdspfl (wndw, pfd, &pthdr, imred (&pthdr), imiso); fldflag[wndw] = 0; } } /*Initialize review display*/ initrev (dev) int dev; { static struct iiscdf cursor = STDCRS; int screen[4]; iisopen (dev); iisomap (); screen[0] = screen[1] = 0; screen[2] = iisxsize - 1; screen[3] = iisysize - 1; iisdfw (0, screen, 1, ALLBITPL, 07); iismap (0, "w", 0, 255); iiswda[0].cursor = cursor; iisgmap (0, ALLBITPL, 0); iisgmap (0, -01, INSERT + GRED); iisgmap (0, -02, INSERT + GGREEN); iisgmap (0, -03, INSERT + GBLUE); iisgmap (0, -04, INSERT + GRED + GGREEN); iisgmap (0, -05, INSERT + GRED + GBLUE); iisgmap (0, -06, INSERT + GGREEN + GBLUE); iisgmap (0, -07, INSERT + GRED); iisgmap (0, BITPL7, 0174037); switch (nreview) { case 1: iisdfw (1, screen, 2, ALLBITPL, 070); iismap (1, "w", 0, 255); iiswda[1].cursor = cursor; iisgmap (1, ALLBITPL, 0); iisgmap (1, -010, INSERT + GRED); iisgmap (1, -020, INSERT + GGREEN); iisgmap (1, -030, INSERT + GBLUE); iisgmap (1, -040, INSERT + GRED + GGREEN); iisgmap (1, -050, INSERT + GRED + GBLUE); iisgmap (1, -060, INSERT + GGREEN + GBLUE); iisgmap (1, -070, INSERT + GRED); iisgmap (1, BITPL7, 0174037); break; case 2: iisdfw (1, screen, 2, ALLBITPL, 070); iismap (1, "w", 0, 255); iiswda[1].cursor = cursor; iisgmap (1, ALLBITPL, 0); iisgmap (1, -010, INSERT + GRED); iisgmap (1, -020, INSERT + GGREEN); iisgmap (1, -030, INSERT + GBLUE); iisgmap (1, -040, INSERT + GRED + GGREEN); iisgmap (1, -050, INSERT + GRED + GBLUE); iisgmap (1, -060, INSERT + GGREEN + GBLUE); iisgmap (1, -070, INSERT + GRED); iisgmap (1, BITPL7, 0174037); iisdfw (2, screen, 4, ALLBITPL, 0100); iismap (2, "w", 0, 255); iiswda[2].cursor = cursor; iisgmap (2, ALLBITPL, 0); iisgmap (2, -0100, INSERT + GRED); iisgmap (2, BITPL7, 0174037); break; default: iisdfw (1, screen, 2, ALLBITPL, 010); iismap (1, "w", 0, 255); iiswda[1].cursor = cursor; iisgmap (1, ALLBITPL, 0); iisgmap (1, -010, INSERT + GRED); iisgmap (1, BITPL7, 0174037); iisdfw (2, screen, 4, ALLBITPL, 020); iismap (2, "w", 0, 255); iiswda[2].cursor = cursor; iisgmap (2, ALLBITPL, 0); iisgmap (2, -020, INSERT + GRED); iisgmap (2, BITPL7, 0174037); iisdfw (3, screen, 8, ALLBITPL, 040); iismap (3, "w", 0, 255); iiswda[3].cursor = cursor; iisgmap (3, ALLBITPL, 0); iisgmap (3, -040, INSERT + GRED); iisgmap (3, BITPL7, 0174037); break; } } /*Toggle overlays*/ ovrlys (wndw) int wndw; { static oflag[NWNDW]; if (iisdev == 3) { fprintf (stderr, "Option not available with IMTOOL\n"); return; } oflag[wndw] = oflag[wndw] == 0 ? 1 : 0; switch (wndw) { case 0: if (oflag[wndw] == 1) iisgmap (wndw, 07, 0); else { iisgmap (wndw, -01, INSERT + GRED); iisgmap (wndw, -02, INSERT + GGREEN); iisgmap (wndw, -03, INSERT + GBLUE); iisgmap (wndw, -04, INSERT + GRED + GGREEN); iisgmap (wndw, -05, INSERT + GRED + GBLUE); iisgmap (wndw, -06, INSERT + GGREEN + GBLUE); iisgmap (wndw, -07, INSERT + GRED); } break; case 1: if (oflag[wndw] == 1) { if (nreview <= 2) iisgmap (wndw, 070, 0); else iisgmap (wndw, 010, 0); } else { if (nreview <= 2) { iisgmap (wndw, -010, INSERT + GRED); iisgmap (wndw, -020, INSERT + GGREEN); iisgmap (wndw, -030, INSERT + GBLUE); iisgmap (wndw, -040, INSERT + GRED + GGREEN); iisgmap (wndw, -050, INSERT + GRED + GBLUE); iisgmap (wndw, -060, INSERT + GGREEN + GBLUE); iisgmap (wndw, -070, INSERT + GRED); } else iisgmap (wndw, 010, INSERT + GRED); } break; case 2: if (oflag[wndw] == 1) iisgmap (wndw, 020, 0); else iisgmap (wndw, 020, INSERT + GRED); break; case 3: if (oflag[wndw] == 1) iisgmap (wndw, 040, 0); else iisgmap (wndw, 040, INSERT + GRED); break; } iisgmap (wndw, BITPL7, 0176037); iisgrf (wndw); } /*Display object from catalog described by area in window*/ fdisplay (cat, wndw, ob, ar, vdx, vdy, redraw) int cat; int wndw; struct objrec *ob; struct areas *ar; int vdx, vdy; int redraw; { short rct[4]; int rep; if (iiswdn != wndw) iiswdw (wndw); rct[0] = ar->rct[0]; rct[1] = ar->rct[1]; rct[2] = ar->rct[2]; rct[3] = ar->rct[3]; if (rct[2] - rct[0] < vdx - 1) { rct[0] = (rct[0] + rct[2] - vdx) / 2; rct[2] = rct[0] + vdx - 1; } if (rct[3] - rct[1] < vdy - 1) { rct[1] = (rct[1] + rct[3] - vdy) / 2; rct[3] = rct[1] + vdy - 1; } if (rct[0] < 0) rct[0] = 0; if (rct[1] < 0) rct[1] = 0; if (rct[2] >= pthdr.naxis1) rct[2] = pthdr.naxis1 - 1; if (rct[3] >= pthdr.naxis2) rct[3] = pthdr.naxis2 - 1; switch (iisdev) { case 1: case 2: if (rdimg (pffd[cat], rct, &p[wndw]) == 1) return; iiserase (wndw, "f"); iiserase (wndw, "F"); iiswda[wndw].wndw[0] = (iisxsize - 1 - p[wndw].dx) / 2; iiswda[wndw].wndw[1] = (iisysize - 1 - p[wndw].dy) / 2; iiswda[wndw].wndw[2] = iiswda[wndw].wndw[0] + p[wndw].dx; iiswda[wndw].wndw[3] = iiswda[wndw].wndw[1] + p[wndw].dy; imdsp (wndw, &p[wndw], &pthdr, 1); fldflag[wndw] = 1; break; case 3: if (rdimg (pffd[cat], rct, &p[wndw]) == redraw) return; iiserase (wndw, "f"); rep = 1; iiswda[wndw].wndw[0] = (iisxsize - 1 - rep * p[wndw].dx) / 2; iiswda[wndw].wndw[1] = (iisysize - 1 - rep * p[wndw].dy) / 2; iiswda[wndw].wndw[2] = iiswda[wndw].wndw[0] + rep * p[wndw].dx; iiswda[wndw].wndw[3] = iiswda[wndw].wndw[1] + rep * p[wndw].dy; imdsp (wndw, &p[wndw], &pthdr, -rep); fldflag[wndw] = 1; break; } } /*Display splitting in current wndw*/ dspspt (pspt) struct image *pspt; { iiswda[iiswdn].wndw[0] = (iisxsize - 1 - pspt->dx) / 2; iiswda[iiswdn].wndw[1] = (iisysize - 1 - pspt->dy) / 2; iiswda[iiswdn].wndw[2] = iiswda[iiswdn].wndw[0] + pspt->dx; iiswda[iiswdn].wndw[3] = iiswda[iiswdn].wndw[1] + pspt->dy; imdsp (iiswdn, pspt, &pthdr, 1); } /*Locate object nearest to cursor*/ nearcr (cat, wndw) int cat; int wndw; { int i, j; int curs[2], x0, y0, x1, y1; float d, dx, dy, dmin; iiscrm (wndw, 0, curs); x0 = lpcoords ((float)(curs[0] * red[cat]), 1, 1); y0 = lpcoords ((float)(curs[1] * red[cat]), 2, 1); x1 = lpcoords ((float)curs[0], 1, 1); y1 = lpcoords ((float)curs[1], 2, 1); /* if (fldflag[wndw]) printf ("nearcr: cat=%d, wndw=%d, red=%d, x0=%d, y0=%d\n", cat, wndw, red[cat], p[wndw].x0, p[wndw].y0); */ for (i = 0, dmin = 10000.; i < nobs[cat]; i++) { if (xpos[cat][i] < 0) continue; if (fldflag[wndw]) { dx = x1 - (xpos[cat][i] - p[wndw].x0 +.5); dy = y1 - (ypos[cat][i] - p[wndw].y0 +.5); } else { dx = x0 - xpos[cat][i]; dy = y0 - ypos[cat][i]; } d = sqrt (dx * dx + dy * dy); if (d < dmin) { dmin = d; j = i; } } return (j); } /*Toggle flags*/ setflgs (o) struct objrec *o; { char c[2]; static char *cmd1[] = { "a attention", "b boundary", "c classification", "d dark", "e evaluated", "f forced", "l large", "p peak", "q quit", "r reference", "s single", "", 0 }; fillwin (win1, cmd1); for (;;) { chwin (win3, "Command: "); c[0] = wgetch (win3); switch (c[0]) { case 'a': if (o->eflgs & ATTN) o->eflgs &= ~ATTN; else o->eflgs |= ATTN; break; case 'b': if (o->eflgs & EDGE) o->eflgs &= ~EDGE; else o->eflgs |= EDGE; break; case 'c': if (o->eflgs & CLSF) o->eflgs &= ~CLSF; else o->eflgs |= CLSF; break; case 'd': if (o->eflgs & DARK) o->eflgs &= ~DARK; else o->eflgs |= DARK; break; case 'e': if (o->eflgs & EVAL) o->eflgs &= ~EVAL; else o->eflgs |= EVAL; break; case 'f': if (o->eflgs & FRCD) o->eflgs &= ~FRCD; else o->eflgs |= FRCD; break; case 'l': if (o->eflgs & SIZE) o->eflgs &= ~SIZE; else o->eflgs |= SIZE; break; case 'p': if (o->eflgs & PEAK) o->eflgs &= ~PEAK; else o->eflgs |= PEAK; break; case 'r': if (o->eflgs & REFP) o->eflgs &= ~REFP; else o->eflgs |= REFP; break; case 's': if (o->eflgs & SNGL) o->eflgs &= ~SNGL; else o->eflgs |= SNGL; break; case 'q': return; } putstatus (win2, o); } } /*Trackball display control*/ dtrack (wndw) int wndw; { static char *cmds[] = { " DISPLAY ADJUSTMENT ", " ", "Button A - Adjust contrast with trackball ", "Button B - Move center of zoom with trackball ", "Button C - Cycle through zoom factors 1, 2, 4, 8 ", "Button D - Exit display control ", "", 0 }; fillwin (win1, cmds); iistrack (wndw); } /*Overlays*/ setovrlys (cat, wndw, o, ar, vdx, vdy) int cat; int wndw; struct objrec *o; struct areas *ar; int vdx, vdy; { int res, revcolor(); char c[2]; static char *cmds[] = { "a automatic isophotes on/off ", "b erase overlays", "d draw isophote", "e erase isophote", "o overlays off/on", "", 0 }; fillwin (win1, cmds); for (;;) { chwin (win3, "Command: "); c[0] = wgetch (win3); switch (c[0]) { case 'a': drwisp[wndw] = drwisp[wndw] == 0 ? 1 : 0; drwovrlys (cat, wndw, o, ar); break; case 'o': ovrlys (wndw); break; case 'b': if (nisphts[wndw] > 0) { switch (iisdev) { case 1: case 2: iiserase (wndw, "F"); break; case 3: if (fldflag[wndw]) fdisplay (curcat, wndw, o, ar, vdx, vdy, 0); else getfld (curcat, wndw, 0); } nisphts[wndw] = 0; } break; case 'd': if (fldflag[wndw]) { switch (iisdev) { case 1: case 2: res = 1; break; case 3: /* res = -4; */ res = 1; } iisispht (wndw, &p[wndw], o, ar, res, revcolor(wndw, o->class)); } else iisispht (wndw, &p[wndw], o, ar, red[cat], revcolor(wndw, o->class)); nisphts[wndw]++; break; case 'e': switch (iisdev) { case 1: case 2: if (fldflag[wndw]) iisispht (wndw, &p[wndw], o, ar, 1, 0); else iisispht (wndw, &p[wndw], o, ar, red[cat], 0); break; case 3: fprintf (stderr, "Option not available with IMTOOL\n"); } nisphts[wndw]--; break; } break; } } /*Draw overlays*/ drwovrlys (cat, wndw, o, ar) int cat; int wndw; struct objrec *o; struct areas *ar; { int res, revcolor(); if (drwisp[wndw] == 1) { if (fldflag[wndw]) { switch (iisdev) { case 1: case 2: res = 1; break; case 3: /* res = -4; */ res = 1; } iisispht (wndw, &p[wndw], o, ar, res, revcolor(wndw, o->class)); } else iisispht (wndw, &p[wndw], o, ar, red[cat], revcolor(wndw, o->class)); nisphts[wndw]++; } } /*Change catalogs*/ chcat (cat) int cat; { curcat = cat; cfd = cffd[curcat]; afd = arfd[curcat]; pfd = pffd[curcat]; sp = cathdr[curcat]; pthdr = imhdr[curcat]; } int revcolor (wndw, class) int wndw; char *class; { int color; switch (iisdev) { case 1: case 2: color = 255; switch (wndw) { case 0: if (strncmp (class, "g", 1) == 0) color = 01; else if (strncmp (class, "sf", 2) == 0) color = 03; else if (strncmp (class, "s", 1) == 0) color = 02; else if (strncmp (class, "d", 1) == 0) color = 04; else if (strncmp (class, "n", 1) == 0) color = 05; else if (strncmp (class, "u", 1) == 0) color = 06; break; case 1: if (nreview <= 2) { if (strncmp (class, "g", 1) == 0) color = 010; else if (strncmp (class, "sf", 2) == 0) color = 030; else if (strncmp (class, "s", 1) == 0) color = 020; else if (strncmp (class, "d", 1) == 0) color = 040; else if (strncmp (class, "n", 1) == 0) color = 050; else if (strncmp (class, "u", 1) == 0) color = 060; } } break; case 3: if (strncmp (class, "g", 1) == 0) color = 204; /* red */ else if (strncmp (class, "s", 1) == 0) color = 205; /* green */ else if (strncmp (class, "sf", 2) == 0) color = 206; /* blue */ else if (strncmp (class, "u", 1) == 0) color = 207; /* yellow */ else if (strncmp (class, "l", 1) == 0) color = 208; /* cyan-black */ else if (strncmp (class, "n", 1) == 0) color = 209; /* magenta-white */ else if (strncmp (class, "d", 1) == 0) color = 210; /* coral-yellow */ else if (strncmp (class, "m", 1) == 0) color = 212; /* orange-yellow */ else color = 203; /* white */ break; } return (color); }