#include "focas1.h" #include "match1.h" #include "review.h" #define IISDEV 3 /* Display: 1=IISM70, 2=IISM75, 3=IMTOOL*/ #define NEXT 1 #define CONT 2 #define LAST 3 #define PREV 4 #define NEAR 5 #define SAME 6 #define MTCH 7 static char *cmd2[] = { "1 entry 1", "2 entry 2", "3 entry 3", ". cursor select", "c continue", "l last", "n next", "p previous", "", 0 }; static char *cmds[] = { "1 entry 1", "2 entry 2", "3 entry 3", ". cursor select", "a set class", "b set flags", "c continue", "d set display", "e evaluate", "f set filter", "h locate objects", "i remove", "j field display", "k object display", "l last", "n next", "o set overlays", "p previous", "q quit", "r resolution", "v set view size", "u set ref point", "x cursor on/off", "y redraw terminal", "z zoom", "", 0 }; struct objrec ob[ARMAX]; struct areas area[ARMAX]; static nextpos = 0; static struct image q; static int chflag = 0; static int vdx = 0, vdy = 0; /* MREVIEW -- Review FOCAS matched catalogs */ mreview (mcatalog) char mcatalog[]; { struct objrec *o; struct areas *ar; long bkcat (); int i, j, k, curs[2]; char ca[120], str[120]; float grow; static float ref1 = 0, ref2 = 0; static int ftype = 2, center = 0, fldflg = 0; printf ("Review %s", mcatalog); fflush (stdout); sprintf (cfile[0], "%s", mcatalog); cfd = mcatopen (cfile[0], 2); nreview = ncats; if (nreview > NWNDW) nreview = NWNDW; k = nreview; if (k == NWNDW) k = nreview - 1; p[k].pic = NULL; initrev (IISDEV); for (i = 0; i < nreview; i++) { rdcathdr (cfd, 1); afd = fndar (sp.arfl, 0); arfd[i] = afd; pfd = fndfld (sp.ptfl, 2); pffd[i] = pfd; imhdr[i] = pthdr; printf (": Display %s", sp.ptfl); fflush (stdout); window[i] = i; p[i].pic = NULL; getfld (i, 0, window[i], 0); cffd[i] = cfd; cathdr[i] = sp; } printf ("\n"); for (i = nreview; i < ncats; i++) rdcathdr (cfd, 1); nextpos = ftell (cfd); for (i = 0; i < nreview; i++) { fseek (cfd, nextpos, 0); printf ("Read %d : ", i); fflush (stdout); nobs[i] = mgetpos (i); iobs[i] = 0; } nextpos = 0; terminit (); mvaddstr (0, 20, "FOCAS IMAGE REVIEW"); refresh (); curcat = 0; chcat (curcat); iiswdw (window[curcat]); werase (win0); mvwaddstr (win0, 0, 0, mcatalog); mvwaddstr (win0, 1, 0, sp.pltnm); wrefresh (win0); fillwin (win1, cmds); chwin (win5, "Filter: "); fseek (cfd, offset[curcat][iobs[curcat]], 0); for (j = SAME;;) { if (mgetnext (j, &ob[1]) == 0) { chwin (win2, "Object not found"); fillwin (win1, cmd2); for (;;) { chwin (win3, "Command: "); ca[0] = wgetch (win3); switch (ca[0]) { case '1': chflag = 1; j = MTCH; break; case '2': chflag = 2; j = MTCH; break; case '3': chflag = 3; j = MTCH; break; case '4': chflag = 4; j = MTCH; break; case 'l': j = LAST; break; case 'n': j = NEXT; break; case 'p': j = PREV; break; case 'c': j = CONT; break; case '.': j = NEAR; break; default: continue; } if (chflag) { if (chflag <= nreview) curcat = chflag - 1; chcat (curcat); werase (win0); mvwaddstr (win0, 0, 0, mcatalog); mvwaddstr (win0, 1, 0, sp.pltnm); wrefresh (win0); chwin (win5, "Filter: "); waddstr (win5, fltstr[curcat]); wrefresh (win5); stflt (fltstr[curcat]); iiswdw (window[curcat]); chflag = 0; } break; } fillwin (win1, cmds); continue; } else ob[0] = ob[1]; o = &ob[0]; ar = &area[0]; rdarea (afd, o->entnum, o->subent, o->arpos, ar); putstatus (win2, o); VIEW: if (fldflg) { fdisplay (curcat, window[curcat], o, ar, vdx, vdy, 1); curs[0] = lpcoords (o->xc, 1, 2) - p[window[curcat]].x0 + 0.5; curs[1] = lpcoords (o->yc, 2, 2) - p[window[curcat]].y0 + 0.5; } else { if (fldflag[window[curcat]]) { pfd = pffd[curcat]; pthdr = imhdr[curcat]; sp = cathdr[curcat]; getfld (curcat, 0, window[curcat], 0); } curs[0] = lpcoords (o->xc, 1, 2) / red[curcat] + 0.5; curs[1] = lpcoords (o->yc, 2, 2) / red[curcat] + 0.5; } iiscrm (window[curcat], 1, curs); drwovrlys (curcat, window[curcat], o, ar); for (j = 0; j == 0;) { putstatus (win2, o); chwin (win3, "Command: "); ca[0] = wgetch (win3); switch (ca[0]) { case 'u': sprintf (str, "\nReference coordinates (%g %g): ", ref1, ref2); waddstr (win3, str); wrefresh (win3); wgetstr (win3, ca); if (strlen (ca)) sscanf (ca, "%hf%hf", &ref1, &ref2); ob->ra = ref1; ob->dec = ref2; ob->eflgs |= REFP; break; case '1': chflag = 1; j = MTCH; break; case '2': chflag = 2; j = MTCH; break; case '3': chflag = 3; j = MTCH; break; case '4': chflag = 4; j = MTCH; break; case 'j': fldflg = 0; for (i = 0; i < nreview; i++) window[i] = i; iiswdw (window[curcat]); goto VIEW; case 'k': fldflg = 1; if (window[curcat] == k) { if (window[curcat] == NWNDW - 1) k = k - 1; else k = k + 1; } for (i = 0; i < nreview; i++) window[i] = nreview; iiswdw (window[curcat]); goto VIEW; case 'a': sprintf (str, "\nClass: "); waddstr (win3, str); wrefresh (win3); wgetstr (win3, ca); o->eflgs |= FRCD | SNGL; strcpy (o->class, ca); break; case 'b': setflgs (o); fillwin (win1, cmds); break; case '.': j = NEAR; break; case 'l': j = LAST; break; case 'n': j = NEXT; break; case 'p': j = PREV; break; case 'c': j = CONT; break; case 'e': chwin (win6, ""); if (sp.pflags & LNR) { if (o->subent == 0) o->sbr = 0.; if (evlobj (o, ar, 1, stdout)) { sprintf (str, "Evaluation unsuccessful"); waddstr (win6, str); wrefresh (win6); } } else { /* There is a problem with the film curve */ chwin (win6, "Option not available"); } break; case 'f': mchflt (); j = SAME; break; case 'd': dtrack (window[curcat]); fillwin (win1, cmds); break; case 'h': mlocate (o, ar); break; case 'o': setovrlys (curcat, window[curcat], o, ar, vdx, vdy); fillwin (win1, cmds); break; case 'q': fseek (cfd, offset[curcat][iobs[curcat]], 0); mob[curcat] = *o; wtmcat (cfd, &mentry, mob); chwin (win1, ""); for (i = 0; i < nreview; i++) { free (offset[i]); free (xpos[i]); free (ypos[i]); fclose (arfd[i]); } fclose (cfd); termclose (); return; case 'i': j = NEXT; strcpy (o->class, "ignre"); break; case 'v': sprintf ("\nMinimum display size: "); waddstr (win3, str); wrefresh (win3); wgetstr (win3, ca); if (strlen (ca)) sscanf (ca, "%d%d", &vdx, &vdy); rdarea (afd, o->entnum, o->subent, o->arpos, ar); j = SAME; break; case 'r': chwin (win6, ""); if (sp.pflags & LNR) { fit (o, ar, ftype, center, 0., 1.); classes (o); } else { /* There is a problem with the film curve */ chwin (win6, "Option not available"); } break; case 'x': iiswitch (window[curcat], 1); break; case 'z': iiszmsc (window[curcat]); break; case 'y': wrefresh (curscr); break; default: sprintf (str, "\nUnknown command %c", ca[0]); waddstr (win3, str); wrefresh (win3); } } fseek (cfd, offset[curcat][iobs[curcat]], 0); mob[curcat] = *o; wtmcat (cfd, &mentry, mob); if (chflag) { if (chflag <= nreview) curcat = chflag - 1; chcat (curcat); werase (win0); mvwaddstr (win0, 0, 0, mcatalog); mvwaddstr (win0, 1, 0, sp.pltnm); wrefresh (win0); chwin (win5, "Filter: "); waddstr (win5, fltstr[curcat]); wrefresh (win5); stflt (fltstr[curcat]); iiswdw (window[curcat]); chflag = 0; } } } mgetnext (mode, o) int mode; struct objrec *o; { int i, iob, start; iob = start = iobs[curcat]; if (nextpos > 0) fseek (cfd, nextpos, 0); switch (mode) { case NEXT: do { iob++; if (iob > nobs[curcat] - 1) { iob = 0; fseek (cfd, offset[curcat][iob], 0); } rdmcatob (cfd, &mentry, mob); } while (mob[curcat].entnum < 0); break; case MTCH: if (mob[curcat].entnum < 0) return (0); break; case SAME: fseek (cfd, offset[curcat][iob], 0); iob--; start--; if (iob < 0) iob = start = nobs[curcat] - 1; case CONT: do { iob++; if (iob > nobs[curcat] - 1) { iob = 0; fseek (cfd, offset[curcat][iob], 0); } rdmcatob (cfd, &mentry, mob); if (iob == start) return (0); } while (xpos[curcat][iob] < 0); break; case PREV: do { iob--; if (iob < 0) iob = nobs[curcat] - 1; fseek (cfd, offset[curcat][iob], 0); rdmcatob (cfd, &mentry, mob); if (iob == start) return (0); } while (xpos[curcat][iob] < 0); break; case LAST: do { iob--; if (iob < 0) iob = nobs[curcat] - 1; fseek (cfd, offset[curcat][iob], 0); rdmcatob (cfd, &mentry, mob); if (iob == start) return (0); } while (mob[curcat].entnum < 0); break; case NEAR: iob = nearcr (curcat, window[curcat]); fseek (cfd, offset[curcat][iob], 0); rdmcatob (cfd, &mentry, mob); break; } for (i = 0; i < nreview; i++) iobs[i] = iob; nextpos = 0; *o = mob[curcat]; return (1); } mlocate (o, ar) struct objrec *o; struct areas *ar; { struct imiso imiso; struct liso *liso; char *calloc(), *malloc(), *realloc(); int i, j, k, n, nbytes, start, color, revcolor(); if (nisphts[window[curcat]] > 0) { switch (iisdev) { case 1: case 2: iiserase (window[curcat], "F"); break; } nisphts[window[curcat]] = 0; } imiso.x0 = 0; imiso.y0 = 0; imiso.nx = pthdr.naxis1; imiso.ny = pthdr.naxis2; imiso.liso = (struct liso *) calloc (imiso.ny, sizeof (struct liso)); if (imiso.liso == 0) focaserr (1, "Memory allocation error", ""); mgetnext (SAME, o); start = iobs[curcat]; for (;;) { if (o->class[0] != 'm') { rdarea (afd, o->entnum, o->subent, o->arpos, ar); color = revcolor (window[curcat], o->class); for (i=0, j=ar->i.ychst, k=0; i < ar->i.nlines; i++, j--) { liso = &imiso.liso[j]; if (liso->nalloc < liso->nused + ar->i.nx[i]) { liso->nalloc = liso->nused + ar->i.nx[i] + 512; nbytes = liso->nalloc * sizeof (short); if (liso->xla == 0) { liso->xla = (short *) malloc (nbytes); liso->xra = (short *) malloc (nbytes); liso->color = (short *) malloc (nbytes); } else { liso->xla = (short *) realloc (liso->xla, nbytes); liso->xra = (short *) realloc (liso->xra, nbytes); liso->color = (short *) realloc (liso->color, nbytes); } if (liso->xla==0 || liso->xra==0 || liso->color==0) focaserr (1, "Memory allocation error", ""); } n = liso->nused; for (; k < ar->i.nx[i]; k++) { liso->xla[n] = ar->i.xla[k]; liso->xra[n] = ar->i.xra[k]; liso->color[n] = color; n++; } liso->nused = n; } nisphts[window[curcat]]++; } mgetnext (CONT, o); if (iobs[curcat] == start) break; } getfld (curcat, &imiso, window[curcat], 0); for (i=0; i