Changeset 5846 for trunk/Ohana/src/opihi/cmd.data
- Timestamp:
- Dec 27, 2005, 5:06:32 AM (21 years ago)
- Location:
- trunk/Ohana/src/opihi/cmd.data
- Files:
-
- 14 edited
-
center.c (modified) (1 diff)
-
cursor.c (modified) (3 diffs)
-
erase.c (modified) (2 diffs)
-
jpeg.c (modified) (1 diff)
-
load.c (modified) (5 diffs)
-
point.c (modified) (3 diffs)
-
ps.c (modified) (2 diffs)
-
resize.c (modified) (2 diffs)
-
save.c (modified) (3 diffs)
-
tv.c (modified) (3 diffs)
-
tvcontour.c (modified) (11 diffs)
-
tvgrid.c (modified) (8 diffs)
-
vcontour.c (modified) (10 diffs)
-
vload.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/center.c
r4689 r5846 23 23 y = atof (argv[2]); 24 24 zoom = 0; 25 if (argc == 4) { 26 zoom = atof (argv[3]); 27 } 25 if (argc == 4) zoom = atof (argv[3]); 28 26 29 SendGraphCommand (Ximage, 4, "CENT"); 30 SendGraphMessage (Ximage, "%8.3f %8.3f %8d ", x, y, zoom); 27 KiiCenter (Ximage, x, y, zoom); 31 28 return (TRUE); 32 29 } -
trunk/Ohana/src/opihi/cmd.data/cursor.c
r5349 r5846 3 3 int cursor (int argc, char **argv) { 4 4 5 char buffer[40], string[20], key[20], keyname[20];5 char string[20], key[20]; 6 6 int i, N, Nsource, Source, IsImage; 7 7 double X, Y, R, D, Z; … … 42 42 if (IsImage) buf = SelectBuffer (GetImageName(), OLDBUFFER, FALSE); 43 43 44 sprintf (string, "CURS"); 45 write (Source, string, 4); /* ask Source to look for the keystrokes */ 44 KiiCursorOn (Source); 46 45 47 46 oldsignal = signal (SIGINT, handle_interrupt); … … 49 48 Z = -1.0; 50 49 for (i = 0; ((i < N) || (N == 0)) && !interrupt; i++) { 51 bzero (buffer, 40); 52 read (Source, buffer, 40); 53 buffer[39] = 0; 54 sscanf (buffer, "%s %lf %lf", key, &X, &Y); 55 if (ispunct(key[0])) { 56 strcpy (keyname, "_"); 57 } else { 58 strcpy (keyname, key); 59 } 60 sprintf (string, "X%s", keyname); 50 KiiCursorRead (Source, &X, &Y, key); 51 52 sprintf (string, "X%s", key); 61 53 set_variable (string, X); 62 sprintf (string, "Y%s", key name);54 sprintf (string, "Y%s", key); 63 55 set_variable (string, Y); 64 56 set_str_variable ("KEY", key); 65 57 66 if (IsImage && (buf != NULL))67 Z = fits_get_matrix_value (&buf[0].matrix, (int)X, (int)Y);68 69 if (!IsImage) {70 XY_to_RD (&R, &D, X, Y, &graphmode.coords);71 sprintf (string, "R%s", keyname);72 set_variable (string, R);73 sprintf (string, "D%s", keyname);74 set_variable (string, D);75 }76 77 /* I still don't like this, but I have to decide which to print... */78 58 if (IsImage) { 59 if (buf != NULL) { 60 Z = fits_get_matrix_value (&buf[0].matrix, (int) X, (int) Y); 61 } 79 62 fprintf (GetOutfile(), "%s %f %f %f\n", key, X, Y, Z); 80 63 } else { 64 XY_to_RD (&R, &D, X, Y, &graphmode.coords); 65 sprintf (string, "R%s", key); 66 set_variable (string, R); 67 sprintf (string, "D%s", key); 68 set_variable (string, D); 81 69 fprintf (GetOutfile(), "%s %f %f\n", key, X, Y); 82 70 } 83 84 if (!strcasecmp (key, "Q")) { 85 signal (SIGINT, (void *) oldsignal); 86 write (Source, "NCUR", 4); /* ask Source to stop looking for the keystrokes */ 87 return (TRUE); 88 } 89 71 if (!strcasecmp (key, "Q")) break; 90 72 } 91 73 92 74 signal (SIGINT, oldsignal); 93 write (Source, "NCUR", 4); /* ask Source to look for the keystrokes */75 KiiCursorOff (Source); 94 76 return (TRUE); 95 96 77 } -
trunk/Ohana/src/opihi/cmd.data/erase.c
r4689 r5846 3 3 int erase (int argc, char **argv) { 4 4 5 int i, n,N;5 int i, N; 6 6 int Ximage, Nimage; 7 7 … … 21 21 22 22 for (i = 1; i < argc; i++) { 23 if (strcmp (argv[i], "0") && strcmp (argv[i], "1") && strcmp (argv[i], "2") && strcmp (argv[i], "3") && 24 strcmp (argv[i], "red") && strcmp (argv[i], "green") && strcmp (argv[i], "blue") && strcmp (argv[i], "yellow") && 25 strcmp (argv[i], "all") && strcmp (argv[i], "tick") ) { 23 if (!(strcasecmp (argv[i], "all"))) { 24 KiiEraseOverlay (Ximage, "red"); 25 KiiEraseOverlay (Ximage, "green"); 26 KiiEraseOverlay (Ximage, "blue"); 27 KiiEraseOverlay (Ximage, "yellow"); 28 continue; 29 } 30 if (!KiiSelectOverlay (argv[i], &N)) { 26 31 fprintf (stderr, "%s is not a valid overlay\n", argv[i]); 27 32 return (FALSE); 28 33 } 29 n = atof (argv[i]); 30 if (!(strcmp (argv[i], "all"))) { 31 for (n = 0; n < 4; n++) { 32 SendGraphCommand (Ximage, 4, "ERAS"); 33 SendGraphCommand (Ximage, 16, "OVERLAY %7d ", n); 34 } 35 return (TRUE); 36 } 37 38 if (!(strcmp (argv[i], "red"))) n = 0; 39 if (!(strcmp (argv[i], "green"))) n = 1; 40 if (!(strcmp (argv[i], "blue"))) n = 2; 41 if (!(strcmp (argv[i], "yellow"))) n = 3; 42 if (!(strcmp (argv[i], "tick"))) n = 4; 43 44 SendGraphCommand (Ximage, 4, "ERAS"); 45 SendGraphCommand (Ximage, 16, "OVERLAY %7d ", n); 34 KiiEraseOverlay (Ximage, argv[i]); 46 35 } 47 36 return (TRUE); -
trunk/Ohana/src/opihi/cmd.data/jpeg.c
r3693 r5846 46 46 if (!filename[0]) strcpy (filename, "Ximage.jpg"); 47 47 strcpy (type, "JPEG"); 48 KiiJpeg (Source, filename); 48 49 } else { 49 50 if (!GetGraph (NULL, &Source, &Nsource)) return (FALSE); 50 51 if (!filename[0]) strcpy (filename, "Xgraph.png"); 52 SendGraphCommand (Source, 4, type); 53 SendGraphCommand (Source, 16, "LEN: %11d", strlen(filename)); 54 write (Source, filename, strlen(filename)); 55 read (Source, buffer, 4); 51 56 } 52 53 SendGraphCommand (Source, 4, type);54 SendGraphCommand (Source, 16, "LEN: %11d", strlen(filename));55 write (Source, filename, strlen(filename));56 read (Source, buffer, 4);57 58 57 return (TRUE); 59 58 } -
trunk/Ohana/src/opihi/cmd.data/load.c
r4689 r5846 3 3 int load (int argc, char **argv) { 4 4 5 int N, n, Nline, ISCEL;6 int Ximage, Nimage ;7 char *c, type[10], string[128] ;5 int i, N, n, ISCEL; 6 int Ximage, Nimage, Noverlay, NOVERLAY; 7 char *c, type[10], string[128], line[1024]; 8 8 double x, y, dx, dy, x1, y1; 9 9 double dra, ddec, ra1, dec1, ra, dec; 10 10 FILE *f; 11 char *buffer , *line;11 char *buffer; 12 12 Coords coords; 13 13 Buffer *buf; 14 KiiOverlay *overlay; 14 15 15 16 Nimage = -1; … … 33 34 } 34 35 35 if (!SelectOverlay (argv[1], &n)) return (FALSE);36 37 36 if (!strcmp (argv[2], "-")) { 38 37 f = stdin; … … 50 49 } 51 50 51 Noverlay = 0; 52 NOVERLAY = 1000; 53 ALLOCATE (overlay, KiiOverlay, NOVERLAY); 54 52 55 ALLOCATE (buffer, char, 65536); /* space for 512 lines of 128 bytes */ 53 56 bzero (buffer, 65536); 54 ALLOCATE (line, char, 1024); /* space to read the file */55 Nline = 0;56 57 57 SendGraphCommand (Ximage, 4, "LOAD");58 SendGraphCommand (Ximage, 16, "OVER %9d ", n);59 60 58 dx = dy = 0; 61 59 for (n = 0; scan_line (f, line) != EOF;) { … … 81 79 case 3: 82 80 if (strcmp (type, "TEXT")) { 83 fprintf (stderr, "synta cticalerror in line:\n %s\n", line);81 fprintf (stderr, "syntax error in line:\n %s\n", line); 84 82 continue; 85 83 } … … 113 111 } 114 112 } 115 if (!strcmp (type, "TEXT")) { 116 snprintf (&buffer[Nline*128], 128, "%15s %20.10f %20.10f %s ", type, x, y, string); 113 overlay[Noverlay].type = KiiOverlayTypeByName (type); 114 if (overlay[Noverlay].type == KII_OVERLAY_TEXT) { 115 overlay[Noverlay].text = strcreate (string); 117 116 } else { 118 snprintf (&buffer[Nline*128], 128, "%15s %20.10f %20.10f %20.10f %20.10f ", type, x, y, dx, dy);117 overlay[Noverlay].text = NULL; 119 118 } 120 n++; 121 Nline ++; 122 if (Nline == 512) { 123 SendGraphCommand (Ximage, 16, "NLINES %7d ", Nline); 124 write (Ximage, buffer, Nline*128); 125 bzero (buffer, 65536); 126 Nline = 0; 127 } 119 overlay[Noverlay].x = x; 120 overlay[Noverlay].y = y; 121 overlay[Noverlay].dx = dx; 122 overlay[Noverlay].dy = dy; 123 Noverlay++; 124 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 1000); 128 125 } 129 126 130 SendGraphCommand (Ximage, 16, "NLINES %7d ", Nline); 131 write (Ximage, buffer, Nline*128); 132 SendGraphCommand (Ximage, 16, "DONE"); 127 KiiLoadOverlay (Ximage, overlay, Noverlay, argv[1]); 133 128 134 free (buffer); 135 free (line); 136 fprintf (stderr, "loaded %d objects\n", n); 129 for (i = 0; i < Noverlay; i++) { 130 if (overlay[i].text == NULL) continue; 131 free (overlay[i].text); 132 } 133 free (overlay); 134 135 fprintf (stderr, "loaded %d objects\n", Noverlay); 136 137 137 if (f != stdin) { 138 138 fclose (f); -
trunk/Ohana/src/opihi/cmd.data/point.c
r4689 r5846 3 3 int point (int argc, char **argv) { 4 4 5 int N, n, ISCEL, ISPIX;5 int N, celestial, pixscale; 6 6 int Ximage, Nimage; 7 double x, y, dx, dy, x1, y1;8 double dra, ddec, ra1, dec1, ra, dec;7 double ra, dec, dra, ddec; 8 double x1, y1, ra1, dec1; 9 9 Coords coords; 10 10 Buffer *buf; 11 KiiOverlay overlay; 11 12 12 13 Nimage = -1; … … 18 19 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 19 20 20 ISCEL= FALSE;21 celestial = FALSE; 21 22 if ((N = get_argument (argc, argv, "-c"))) { 22 23 remove_argument (N, &argc, argv); 23 ISCEL= TRUE;24 celestial = TRUE; 24 25 } 25 26 26 ISPIX= FALSE;27 if ((N = get_argument (argc, argv, "-p "))) {27 pixscale = FALSE; 28 if ((N = get_argument (argc, argv, "-pixscale"))) { 28 29 remove_argument (N, &argc, argv); 29 ISPIX= TRUE;30 pixscale = TRUE; 30 31 } 31 32 … … 35 36 } 36 37 37 if (!SelectOverlay (argv[1], &n)) 38 return (FALSE); 39 40 if (ISCEL) { 38 if (celestial) { 41 39 if ((buf = SelectBuffer (GetImageName(), OLDBUFFER, TRUE)) == NULL) return (FALSE); 42 40 GetCoords (&coords, &buf[0].header); 43 41 } 44 42 45 ra = atof(argv[3]); 46 dec = atof(argv[4]); 47 dra = atof(argv[5]); 48 ddec = atof(argv[6]); 49 if (ISCEL) { 50 RD_to_XY (&x, &y, ra, dec, &coords); 51 if (!ISPIX) { 43 if (celestial) { 44 ra = atof(argv[3]); 45 dec = atof(argv[4]); 46 dra = atof(argv[5]); 47 ddec = atof(argv[6]); 48 49 fRD_to_XY (&overlay.x, &overlay.y, ra, dec, &coords); 50 if (pixscale) { 51 overlay.dx = atof(argv[5]); 52 overlay.dy = atof(argv[6]); 53 } else { 52 54 ra1 = ra + dra; 53 55 dec1 = dec + ddec; 54 56 RD_to_XY (&x1, &y1, ra1, dec1, &coords); 55 dx = x1 - x; 56 dy = y1 - y; 57 } else { 58 dx = atof(argv[5]); 59 dy = atof(argv[6]); 57 overlay.dx = x1 - overlay.x; 58 overlay.dy = y1 - overlay.y; 60 59 } 61 60 } 62 61 else { 63 x = ra;64 y = dec;65 dx = dra;66 dy = ddec;62 overlay.x = atof(argv[3]); 63 overlay.y = atof(argv[4]); 64 overlay.dx = atof(argv[5]); 65 overlay.dy = atof(argv[6]); 67 66 } 68 69 SendGraphCommand (Ximage, 4, "LOAD"); 70 SendGraphCommand (Ximage, 16, "OVERLAY %6d ", n); 71 SendGraphCommand (Ximage, 16, "NLINES %7d ", 1); 72 SendGraphCommand (Ximage, 128, "%15s %20.10f %20.10f %20.10f %20.10f ", argv[2], x, y, dx, dy); 73 SendGraphCommand (Ximage, 16, "DONE"); 67 overlay.type = KiiOverlayTypeByName (argv[2]); 68 KiiLoadOverlay (Ximage, &overlay, 1, argv[1]); 74 69 return (TRUE); 75 70 } 76 -
trunk/Ohana/src/opihi/cmd.data/ps.c
r3693 r5846 3 3 int ps (int argc, char **argv) { 4 4 5 char filename[1024] , buffer[64];5 char filename[1024]; 6 6 int N, Source, Nsource, RawImage, NoScale, IsImage; 7 7 … … 56 56 57 57 /* tell Ximage/Xgraph to ps the image */ 58 if (RawImage) SendGraphCommand (Source, 4, "PSRW"); 59 if (NoScale) SendGraphCommand (Source, 4, "PSNS"); 60 if (!RawImage && !NoScale) SendGraphCommand (Source, 4, "PSIT"); 61 62 /* I need to fix kapa and kii to read NBYTES, etc like other messages */ 63 SendGraphCommand (Source, 16, "LEN: %11d", strlen(filename)); 64 write (Source, filename, strlen(filename)); 65 read (Source, buffer, 4); 66 58 KiiPS (Source, NoScale, RawImage, filename); 67 59 return (TRUE); 68 60 } -
trunk/Ohana/src/opihi/cmd.data/resize.c
r2843 r5846 3 3 int resize (int argc, char **argv) { 4 4 5 char buffer[128], buffer2[128],*end;5 char *end; 6 6 double NX, NY; 7 7 int N, Source, Nsource, IsImage; … … 49 49 if (!strcmp (end, "cm")) { NY *= 38; } 50 50 51 write (Source, "RSIZ", 4); /* tell Source to resize the image */ 52 53 sprintf (buffer, "%d %d", (int) NX, (int) NY); 54 sprintf (buffer2, "NBYTES: %6d ", strlen (buffer)); 55 write (Source, buffer2, 16); 56 write (Source, buffer, strlen (buffer)); 57 51 KiiResize (Source, NX, NY); 58 52 return (TRUE); 59 60 53 } 61 54 -
trunk/Ohana/src/opihi/cmd.data/save.c
r4689 r5846 3 3 int save (int argc, char **argv) { 4 4 5 int N, n, ISCEL;5 int N, celestial; 6 6 int Ximage, Nimage; 7 7 … … 14 14 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 15 15 16 ISCEL= FALSE;16 celestial = FALSE; 17 17 if ((N = get_argument (argc, argv, "-c"))) { 18 18 remove_argument (N, &argc, argv); 19 ISCEL= TRUE;19 celestial = TRUE; 20 20 } 21 21 … … 26 26 } 27 27 28 if (!SelectOverlay (argv[1], &n)) return (FALSE); 29 30 if (ISCEL) 31 SendGraphCommand (Ximage, 4, "CSVE"); 32 else 33 SendGraphCommand (Ximage, 4, "SAVE"); 34 35 SendGraphMessage (Ximage, "FILE: %d %s", n, argv[2]); 28 KiiSaveOverlay (Ximage, celestial, argv[1], argv[2]); 36 29 return (TRUE); 37 30 } -
trunk/Ohana/src/opihi/cmd.data/tv.c
r4689 r5846 3 3 int tv (int argc, char **argv) { 4 4 5 int N, j, Npix, Ncolors, size, ISLOG, NNcol; 6 char buffer[1024]; 7 double a1, a2, max, min, zero, range; 8 float *in; 9 char *out, *outbuffer, *root; 10 int Ximage, Nimage; 5 int N, Ximage, Nimage; 11 6 Coords coords; 12 7 Buffer *buf; 8 KiiImage image; 9 KiiDisplayMode mode; 13 10 14 11 Nimage = -1; … … 22 19 /* shell exits on pipe close, FIX */ 23 20 if ((N = get_argument (argc, argv, "-kill"))) { 24 close (Ximage);21 KiiClose (Ximage); 25 22 Ximage = 0; 26 23 return (TRUE); 27 24 } 28 25 29 min = max = 0.0; 30 ISLOG = FALSE; 26 mode.logflux = FALSE; 31 27 if ((N = get_argument (argc, argv, "-log"))) { 32 28 remove_argument (N, &argc, argv); 33 ISLOG= TRUE;29 mode.logflux = TRUE; 34 30 } 35 31 … … 39 35 } 40 36 41 GetImageScale (& zero, &range);37 GetImageScale (&mode.zero, &mode.range); 42 38 if (argc == 4) { 43 zero = atof (argv[2]);44 range = atof (argv[3]);45 if ( range == 0.0)range = 0.001;46 SetImageScale ( zero,range);39 mode.zero = atof (argv[2]); 40 mode.range = atof (argv[3]); 41 if (mode.range == 0.0) mode.range = 0.001; 42 SetImageScale (mode.zero, mode.range); 47 43 } 48 44 49 45 if ((buf = SelectBuffer (argv[1], OLDBUFFER, TRUE)) == NULL) return (FALSE); 50 46 GetCoords (&coords, &buf[0].header); 47 48 image.data1d = (float *) buf[0].matrix.buffer; 49 image.Nx = buf[0].matrix.Naxis[0]; 50 image.Ny = buf[0].matrix.Naxis[1]; 51 image.file = buf[0].file; 52 image.name = buf[0].name; 51 53 52 Npix = buf[0].matrix.Naxis[0]*buf[0].matrix.Naxis[1]; 53 size = Npix * sizeof (char); 54 in = (float *) (buf[0].matrix.buffer); 55 ALLOCATE (outbuffer, char, Npix); 56 out = outbuffer; 57 58 SendGraphCommand (Ximage, 4, "READ"); /* tell Ximage to look for the incoming image */ 59 60 /* convert from (float) internal rep to 1 byte chars -- depends on how many colors Kii owns*/ 61 read (Ximage, buffer, 16); 62 sscanf (buffer, "%*s %d", &Ncolors); 63 64 /* need to invert the logic if range < 0 */ 65 /* define color table, */ 66 NNcol = Ncolors - 1; 67 if (ISLOG) { 68 range = MAX (2, range); 69 a1 = Ncolors / log10 (range); 70 for (j = 0; j < Npix; j++, in++, out++) { 71 *out = (char) MIN (a1 * log10 (MAX (*in - zero, 1.0)), NNcol); 72 } 73 } 74 if (!ISLOG) { 75 a1 = Ncolors / range; 76 a2 = Ncolors * zero / range; 77 for (j = 0; j < Npix; j++, in++, out++) { 78 *out = (char) MIN (MAX (a1 * *in - a2, 0), NNcol); 79 } 80 } 81 82 /* done with the conversion, now send Ximage the converted picture */ 83 SendGraphMessage (Ximage, "%8d %8d 8 1 %f %f", buf[0].matrix.Naxis[0], buf[0].matrix.Naxis[1], 0.0, 1.0); 84 SendGraphMessage (Ximage, "%f %f %f %f %d ", zero, range, min, max, size); 85 SendGraphMessage (Ximage, "%f %f %g %g %g ", coords.crval1, coords.crpix1, coords.cdelt1, coords.pc1_1, coords.pc1_2); 86 SendGraphMessage (Ximage, "%f %f %g %g %g ", coords.crval2, coords.crpix2, coords.cdelt2, coords.pc2_1, coords.pc2_2); 87 88 root = filerootname (buf[0].file); 89 SendGraphMessage (Ximage, "%s %s %s ", coords.ctype, root, buf[0].name); 90 write (Ximage, outbuffer, size); 91 free (outbuffer); 54 KiiNewPicture1D (Ximage, &image, &mode, &coords); 92 55 93 56 SetImageName (argv[1]); -
trunk/Ohana/src/opihi/cmd.data/tvcontour.c
r4689 r5846 42 42 43 43 # define DUMP { \ 44 sprintf (&buffer[Nline*128], "%14s %20.10f %20.10f %20.10f %20.10f ", "LINE", Npix*x, Npix*y, Npix*dx, Npix*dy); \ 45 Nline ++; \ 46 if (Nline == 512) { \ 47 SendGraphCommand (Ximage, 16, "NLINES %7d ", Nline); \ 48 write (Ximage, buffer, Nline*128); \ 49 bzero (buffer, 65536); \ 50 Nline = 0; \ 51 } \ 52 continue; } 53 54 # define NUMP { \ 55 sprintf (&buffer[Nline*128], "%14s %20.10f %20.10f %20.10f %20.10f ", "LINE", Npix*x, Npix*y, Npix*dx, Npix*dy); \ 56 Nline ++; \ 57 if (Nline == 512) { \ 58 SendGraphCommand (Ximage, 16, "NLINES %7d ", Nline); \ 59 write (Ximage, buffer, Nline*128); \ 60 bzero (buffer, 65536); \ 61 Nline = 0; \ 62 } } 44 overlay[Noverlay].type = KII_OVERLAY_LINE; \ 45 overlay[Noverlay].x = Npix*x; \ 46 overlay[Noverlay].y = Npix*y; \ 47 overlay[Noverlay].dx = Npix*dx; \ 48 overlay[Noverlay].dy = Npix*dy; \ 49 Noverlay ++; \ 50 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 1000); \ 51 } 63 52 64 53 int tvcontour (int argc, char **argv) { 65 54 66 int i, j, ii, jj, n, Npix, Nx, Ny, Nline;55 int i, j, ii, jj, Npix, Nx, Ny; 67 56 float level, d00, d01, d10, d11, tmp; 68 57 float x, y, dx, dy; 69 58 float *v00, *v01, *v10, *v11; 70 59 float *Vout, *Vin, *matrix; 71 char *buffer; 72 int Ximage, Nimage, N; 60 int Ximage, Nimage, N, Noverlay, NOVERLAY; 73 61 Buffer *buf; 62 KiiOverlay *overlay; 74 63 75 64 Nimage = -1; … … 87 76 88 77 if ((buf = SelectBuffer (argv[1], OLDBUFFER, TRUE)) == NULL) return (FALSE); 89 if (!SelectOverlay (argv[2], &n)) return (FALSE);90 78 91 79 level = atof (argv[3]); … … 115 103 } 116 104 } 117 } 118 else { 105 } else { 119 106 fprintf (stderr, "using scale of 1\n"); 120 107 matrix = (float *)(buf[0].matrix.buffer); 121 108 } 122 109 123 SendGraphCommand (Ximage, 4, "LOAD"); /* force Ximage to look for the incoming image */ 124 SendGraphCommand (Ximage, 16, "OVERLAY %7d ", n); 125 ALLOCATE (buffer, char, 65536); /* space for 512 lines of 128 bytes */ 126 bzero (buffer, 65536); 127 Nline = 0; 110 Noverlay = 0; 111 NOVERLAY = 1000; 112 ALLOCATE (overlay, KiiOverlay, NOVERLAY); 128 113 129 114 v00 = matrix; … … 150 135 LL; 151 136 DUMP; 137 continue; 152 138 } 153 139 if ((d01 > 0) && (d11 <= 0)) { /* - */ 154 140 HZ; 155 141 DUMP; 142 continue; 156 143 } 157 144 if ((d01 > 0) && (d11 > 0)) { /* / */ 158 145 UL; 159 146 DUMP; 147 continue; 160 148 } 161 149 if ((d01 <= 0) && (d11 > 0)) { /* \\ */ 162 150 LL; 163 NUMP;151 DUMP; 164 152 UR; 165 153 DUMP; 154 continue; 166 155 } 167 156 } … … 171 160 LL; 172 161 DUMP; 162 continue; 173 163 } 174 164 if ((d01 <= 0) && (d11 > 0)) { /* - */ 175 165 HZ; 176 166 DUMP; 167 continue; 177 168 } 178 169 if ((d01 <= 0) && (d11 <= 0)) { /* / */ 179 170 UL; 180 171 DUMP; 172 continue; 181 173 } 182 174 if ((d01 > 0) && (d11 <= 0)) { /* // */ 183 175 UL; 184 NUMP;176 DUMP; 185 177 LR; 186 178 DUMP; 179 continue; 187 180 } 188 181 } … … 193 186 LR; 194 187 DUMP; 188 continue; 195 189 } 196 190 if ((d01 <= 0) && (d11 > 0)) { 197 191 UR; 198 192 DUMP; 193 continue; 199 194 } 200 195 if ((d01 > 0) && (d11 > 0)) { 201 196 VT; 202 197 DUMP; 198 continue; 203 199 } 204 200 } … … 208 204 LR; 209 205 DUMP; 206 continue; 210 207 } 211 208 if ((d01 > 0) && (d11 <= 0)) { 212 209 UR; 213 210 DUMP; 211 continue; 214 212 } 215 213 if ((d01 <= 0) && (d11 <= 0)) { 216 214 VT; 217 215 DUMP; 216 continue; 218 217 } 219 218 } … … 235 234 if (((*v00 > level) && (*v01 <= level)) || ((*v00 <= level) && (*v01 > level))) { 236 235 x = i + (level - *v01)/(*v01 - *v00); 237 NUMP;236 DUMP; 238 237 } 239 238 } … … 248 247 if (((*v00 > level) && (*v01 <= level)) || ((*v00 <= level) && (*v01 > level))) { 249 248 x = i + (level - *v01)/(*v01 - *v00); 250 NUMP;249 DUMP; 251 250 } 252 251 } … … 261 260 if (((*v00 > level) && (*v01 <= level)) || ((*v00 <= level) && (*v01 > level))) { 262 261 y = j + (level - *v01)/(*v01 - *v00); 263 NUMP;262 DUMP; 264 263 } 265 264 } … … 274 273 if (((*v00 > level) && (*v01 <= level)) || ((*v00 <= level) && (*v01 > level))) { 275 274 y = j + (level - *v01)/(*v01 - *v00); 276 NUMP;275 DUMP; 277 276 } 278 277 } 279 278 280 if (Nline > 0) { 281 SendGraphCommand (Ximage, 16, "NLINES %7d ", Nline); 282 write (Ximage, buffer, Nline*128); 283 } 284 285 free (buffer); 286 SendGraphCommand (Ximage, 16, "DONE"); 279 KiiLoadOverlay (Ximage, overlay, Noverlay, argv[2]); 280 free (overlay); 287 281 288 282 if (Npix != 1) free (matrix); -
trunk/Ohana/src/opihi/cmd.data/tvgrid.c
r4689 r5846 4 4 int tvgrid (int argc, char **argv) { 5 5 6 int n color, ndig1, ndig2, NX, NY, connect;6 int ndig1, ndig2, NX, NY, connect; 7 7 int tDEC, tRA; 8 8 double ra, dec, ra0, dec0, ra1, dec1; … … 11 11 char format[16]; 12 12 Coords coords; 13 int Ximage, Nimage, N ;13 int Ximage, Nimage, N, Noverlay, NOVERLAY; 14 14 Buffer *buf; 15 KiiOverlay *overlay; 15 16 16 17 Nimage = -1; … … 23 24 24 25 if (argc != 3) { 25 fprintf (stderr, "USAGE: load (overlay) (buffer)\n");26 fprintf (stderr, "USAGE: tvgrid (overlay) (buffer)\n"); 26 27 fprintf (stderr, " (overlay) may be: red, green, blue, yellow\n"); 27 28 return (FALSE); 28 29 } 29 if (strcmp (argv[1], "0") && strcmp (argv[1], "1") && strcmp (argv[1], "2") && strcmp (argv[1], "3") &&30 strcmp (argv[1], "red") && strcmp (argv[1], "green") && strcmp (argv[1], "blue") && strcmp (argv[1], "yellow")) {31 fprintf (stderr, "valid overlays may be: 0, red, 1, green, 2, blue, 3, yellow\n");32 return (FALSE);33 }34 35 ncolor = atof (argv[1]);36 if (!(strcmp (argv[1], "red")))37 ncolor = 0;38 if (!(strcmp (argv[1], "green")))39 ncolor = 1;40 if (!(strcmp (argv[1], "blue")))41 ncolor = 2;42 if (!(strcmp (argv[1], "yellow")))43 ncolor = 3;44 30 45 31 if ((buf = SelectBuffer (argv[2], OLDBUFFER, TRUE)) == NULL) return (FALSE); … … 50 36 fprintf (stderr, "%f %f %f %f\n", ra0, dec0, ra1, dec1); 51 37 52 /* tell KII to expect overlay data */53 SendGraphCommand (Ximage, 4, "LOAD");54 SendGraphCommand (Ximage, 16, "OVERLAY: %7d", ncolor);55 38 Noverlay = 0; 39 NOVERLAY = 1000; 40 ALLOCATE (overlay, KiiOverlay, NOVERLAY); 41 56 42 dDEC = fabs(dec1 - dec0); 57 43 tDEC = log10(dDEC) - log10(5.0); … … 90 76 RD_to_XY (&x1, &y1, ra, dec, &coords); 91 77 if ((x1 >= 0) && (x1 < NX) && (y1 >= 0) && (y1 < NY)) { 92 if (connect) SendGraphCommand (Ximage, 128, "%15s %20.10f %20.10f %20.10f %20.10f ", "LINE", x0, y0, (x1 - x0), (y1 - y0)); 78 if (connect) { 79 overlay[Noverlay].type = KII_OVERLAY_LINE; 80 overlay[Noverlay].x = x0; 81 overlay[Noverlay].y = y0; 82 overlay[Noverlay].dx = x1 - x0; 83 overlay[Noverlay].dy = y1 - y0; 84 Noverlay ++; 85 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 1000); 86 } 93 87 x0 = x1; 94 88 y0 = y1; … … 132 126 RD_to_XY (&x1, &y1, ra, dec, &coords); 133 127 if ((x1 >= 0) && (x1 < NX) && (y1 >= 0) && (y1 < NY)) { 134 if (connect) SendGraphCommand (Ximage, 128, "%15s %20.10f %20.10f %20.10f %20.10f ", "LINE", x0, y0, (x1 - x0), (y1 - y0)); 128 if (connect) { 129 overlay[Noverlay].type = KII_OVERLAY_LINE; 130 overlay[Noverlay].x = x0; 131 overlay[Noverlay].y = y0; 132 overlay[Noverlay].dx = x1 - x0; 133 overlay[Noverlay].dy = y1 - y0; 134 Noverlay ++; 135 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 1000); 136 } 135 137 x0 = x1; 136 138 y0 = y1; … … 142 144 } 143 145 144 /* 146 # if (0) 147 /* write the labels on the axes */ 145 148 dDEC = fabs(dec1 - dec0) / 100; 146 149 for (ra = dRA * ((int)(MIN(ra0, ra1)/dRA) + 1); ra < MAX(ra0, ra1); ra += dRA) { … … 159 162 } 160 163 } 161 */164 # endif 162 165 163 SendGraphCommand (Ximage, 128, "DONE"); 166 KiiLoadOverlay (Ximage, overlay, Noverlay, argv[1]); 167 free (overlay); 168 164 169 return (TRUE); 165 170 } 166 167 /*168 write (Ximage, "LOAD", 4);169 sprintf (buffer, "OVERLAY: %7d", n);170 write (Ximage, buffer, 16);171 172 for (n = 0; scan_line (f, buffer) != EOF; n++) {173 c = strchr (buffer, '#');174 if (c != (char *) NULL)175 *c = 0;176 while ((c = strchr (buffer, '(')) != (char *) NULL)177 *c = ' ';178 while ((c = strchr (buffer, ')')) != (char *) NULL)179 *c = ' ';180 while ((c = strchr (buffer, ',')) != (char *) NULL)181 *c = ' ';182 N = sscanf (buffer, "%s %lf %lf %lf %lf", type, &x, &y, &dx, &dy);183 if (N > 3) {184 if (N == 4)185 dy = dx;186 sprintf (buffer, "%15s %20.10f %20.10f %20.10f %20.10f ", type, x, y, dx, dy);187 write (Ximage, buffer, 128);188 }189 }190 fprintf (stderr, "loaded %d objects\n", n);191 sprintf (buffer, "DONE");192 write (Ximage, buffer, 128);193 if (f != stdin) {194 fclose (f);195 }196 */ -
trunk/Ohana/src/opihi/cmd.data/vcontour.c
r3693 r5846 42 42 43 43 # define DUMP { \ 44 sprintf (&buffer[Nline*128], "%14s %20.10f %20.10f %20.10f %20.10f \0", "LINE", Npix*x, Npix*y, Npix*dx, Npix*dy); \ 45 Nline ++; \ 46 if (Nline == 512) { \ 47 SendGraphCommand (Ximage, 16, "NLINES %7d \0", Nline); \ 48 write (Ximage, buffer, Nline*128); \ 49 bzero (buffer, 65536); \ 50 Nline = 0; \ 51 } \ 52 continue; } 53 54 # define NUMP { \ 55 sprintf (&buffer[Nline*128], "%14s %20.10f %20.10f %20.10f %20.10f \0", "LINE", Npix*x, Npix*y, Npix*dx, Npix*dy); \ 56 Nline ++; \ 57 if (Nline == 512) { \ 58 SendGraphCommand (Ximage, 16, "NLINES %7d \0", Nline); \ 59 write (Ximage, buffer, Nline*128); \ 60 bzero (buffer, 65536); \ 61 Nline = 0; \ 62 } } 44 overlay[Noverlay].type = KII_OVERLAY_LINE; \ 45 overlay[Noverlay].x = Npix*x; \ 46 overlay[Noverlay].y = Npix*y; \ 47 overlay[Noverlay].dx = Npix*dx; \ 48 overlay[Noverlay].dy = Npix*dy; \ 49 Noverlay ++; \ 50 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 1000); \ 51 } 63 52 64 53 int vcontour (int argc, char **argv) { … … 110 99 /* not really finished */ 111 100 101 Noverlay = 0; 102 NOVERLAY = 1000; 103 ALLOCATE (overlay, KiiOverlay, NOVERLAY); 104 112 105 v01 = matrix + 1; 113 106 v10 = matrix + Nx; … … 132 125 LL; 133 126 DUMP; 127 continue; 134 128 } 135 129 if ((d01 > 0) && (d11 <= 0)) { /* - */ 136 130 HZ; 137 131 DUMP; 132 continue; 138 133 } 139 134 if ((d01 > 0) && (d11 > 0)) { /* / */ 140 135 UL; 141 136 DUMP; 137 continue; 142 138 } 143 139 if ((d01 <= 0) && (d11 > 0)) { /* \\ */ 144 140 LL; 145 NUMP;141 DUMP; 146 142 UR; 147 143 DUMP; 144 continue; 148 145 } 149 146 } … … 153 150 LL; 154 151 DUMP; 152 continue; 155 153 } 156 154 if ((d01 <= 0) && (d11 > 0)) { /* - */ 157 155 HZ; 158 156 DUMP; 157 continue; 159 158 } 160 159 if ((d01 <= 0) && (d11 <= 0)) { /* / */ 161 160 UL; 162 161 DUMP; 162 continue; 163 163 } 164 164 if ((d01 > 0) && (d11 <= 0)) { /* // */ 165 165 UL; 166 NUMP;166 DUMP; 167 167 LR; 168 168 DUMP; 169 continue; 169 170 } 170 171 } … … 175 176 LR; 176 177 DUMP; 178 continue; 177 179 } 178 180 if ((d01 <= 0) && (d11 > 0)) { 179 181 UR; 180 182 DUMP; 183 continue; 181 184 } 182 185 if ((d01 > 0) && (d11 > 0)) { 183 186 VT; 184 187 DUMP; 188 continue; 185 189 } 186 190 } … … 190 194 LR; 191 195 DUMP; 196 continue; 192 197 } 193 198 if ((d01 > 0) && (d11 <= 0)) { 194 199 UR; 195 200 DUMP; 201 continue; 196 202 } 197 203 if ((d01 <= 0) && (d11 <= 0)) { 198 204 VT; 199 205 DUMP; 206 continue; 200 207 } 201 208 } … … 217 224 if (((*v00 > level) && (*v01 <= level)) || ((*v00 <= level) && (*v01 > level))) { 218 225 x = i + (level - *v01)/(*v01 - *v00); 219 NUMP; 226 DUMP; 227 continue; 220 228 } 221 229 } … … 230 238 if (((*v00 > level) && (*v01 <= level)) || ((*v00 <= level) && (*v01 > level))) { 231 239 x = i + (level - *v01)/(*v01 - *v00); 232 NUMP; 240 DUMP; 241 continue; 233 242 } 234 243 } … … 243 252 if (((*v00 > level) && (*v01 <= level)) || ((*v00 <= level) && (*v01 > level))) { 244 253 y = j + (level - *v01)/(*v01 - *v00); 245 NUMP; 254 DUMP; 255 continue; 246 256 } 247 257 } … … 256 266 if (((*v00 > level) && (*v01 <= level)) || ((*v00 <= level) && (*v01 > level))) { 257 267 y = j + (level - *v01)/(*v01 - *v00); 258 NUMP; 268 DUMP; 269 continue; 259 270 } 260 271 } 261 272 262 if (Nline > 0) { 263 SendGraphCommand (Ximage, 16, "NLINES %7d \0", Nline); 264 write (Ximage, buffer, Nline*128); 265 } 266 267 free (buffer); 268 SendGraphCommand (Ximage, 16, "DONE"); 273 KiiLoadOverlay (Ximage, overlay, Noverlay, argv[2]); 274 free (overlay); 275 269 276 if (Npix != 1) free (matrix); 270 277 fprintf (stderr, "\n"); -
trunk/Ohana/src/opihi/cmd.data/vload.c
r5702 r5846 1 1 # include "data.h" 2 3 # define NPTYPE 34 static char ptype[NPTYPE][8] = {"BOX", "LINE", "CIRCLE"};5 2 6 3 int vload (int argc, char **argv) { 7 4 8 int i, N, n, Nline;9 int Ximage, Nimage ;5 int i, N, Noverlay; 6 int Ximage, Nimage, type; 10 7 double dx, dy, size; 11 char *buffer, *type;8 KiiOverlay *overlay; 12 9 Vector *vecx, *vecy; 13 10 … … 20 17 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 21 18 22 type = ptype[0];19 type = KII_OVERLAY_BOX; 23 20 if ((N = get_argument (argc, argv, "-type"))) { 24 21 remove_argument (N, &argc, argv); 25 for (i = 0; i < NPTYPE; i++) { 26 if (!strcasecmp (argv[N], ptype[i])) { 27 type = ptype[i]; 28 break; 29 } 30 } 31 if (i == NPTYPE) { 22 type = KiiOverlayTypeByName (argv[N]); 23 remove_argument (N, &argc, argv); 24 if (!type) { 32 25 fprintf (stderr, "unknown Kii point type %s\n", argv[N]); 33 26 return (FALSE); 34 27 } 35 remove_argument (N, &argc, argv);36 28 } 37 29 … … 48 40 } 49 41 50 if (!SelectOverlay (argv[1], &n)) return (FALSE); 42 if (type == KII_OVERLAY_CIRCLE) { 43 dx = dy = size / 2; 44 } else { 45 dx = dy = size; 46 } 51 47 52 48 if ((vecx = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) return (FALSE); … … 57 53 } 58 54 59 ALLOCATE (buffer, char, 65536); /* space for 512 lines of 128 bytes */ 60 bzero (buffer, 65536); 61 Nline = 0; 55 Noverlay = vecx[0].Nelements; 56 ALLOCATE (overlay, KiiOverlay, Noverlay); 62 57 63 SendGraphCommand (Ximage, 4, "LOAD"); 64 SendGraphCommand (Ximage, 16, "OVER %9d ", n); 65 66 if (type == ptype[2]) { 67 dx = dy = size / 2; 68 } else { 69 dx = dy = size; 70 } 71 for (i = 0; i < vecx[0].Nelements; i++) { 72 snprintf (&buffer[Nline*128], 128, "%15s %20.10f %20.10f %20.10f %20.10f ", type, 73 vecx[0].elements[i]+0.5, vecy[0].elements[i]+0.5, dx, dy); 74 Nline ++; 75 if (Nline == 512) { 76 SendGraphCommand (Ximage, 16, "NLINES %7d ", Nline); 77 write (Ximage, buffer, Nline*128); 78 bzero (buffer, 65536); 79 Nline = 0; 80 } 58 for (i = 0; i < Noverlay; i++) { 59 overlay[i].type = type; 60 overlay[i].text = NULL; 61 overlay[i].x = vecx[0].elements[i]+0.5; 62 overlay[i].y = vecy[0].elements[i]+0.5; 63 overlay[i].dx = dx; 64 overlay[i].dy = dy; 81 65 } 82 66 83 SendGraphCommand (Ximage, 16, "NLINES %7d ", Nline); 84 write (Ximage, buffer, Nline*128); 85 SendGraphCommand (Ximage, 16, "DONE"); 86 87 free (buffer); 67 KiiLoadOverlay (Ximage, overlay, Noverlay, argv[1]); 68 free (overlay); 88 69 return (TRUE); 89 70 }
Note:
See TracChangeset
for help on using the changeset viewer.
