Changeset 5846 for trunk/Ohana/src/opihi/cmd.astro
- Timestamp:
- Dec 27, 2005, 5:06:32 AM (21 years ago)
- Location:
- trunk/Ohana/src/opihi/cmd.astro
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.astro/gauss.c
r3693 r5846 3 3 int gauss (int argc, char **argv) { 4 4 5 char buffer[20], key;5 char key[20]; 6 6 int i, N, Npix, Nborder, Nspot; 7 7 double X, Y, Z, max; … … 50 50 if ((buf = SelectBuffer (GetImageName(), OLDBUFFER, TRUE)) == NULL) return (FALSE); 51 51 52 fcntl (Ximage, F_SETFL, !O_NONBLOCK); 53 SendGraphCommand (Ximage, 4, "CURS"); 54 52 KiiCursorOn (Ximage); 53 55 54 for (i = 0; (i < Nspot) || (Nspot == 0); i++) { 56 bzero (buffer, 20); 57 read (Ximage, buffer, 16); 58 buffer[16] = 0; 59 sscanf (buffer, "%c %lf %lf", &key, &X, &Y); 60 if ((key == 'q') || (key == 'Q')) { 61 break; 62 } 55 KiiCursorRead (Ximage, &X, &Y, key); 56 57 if (!strcasecmp (key, "Q")) break; 58 63 59 Z = get_aperture_stats (&buf[0].matrix, (int)(X+0.5), (int)(Y+0.5), Npix, Nborder, max); 64 65 60 } 66 SendGraphCommand (Ximage, 4, "NCUR"); 67 61 KiiCursorOff (Ximage); 68 62 return (TRUE); 69 63 } -
trunk/Ohana/src/opihi/cmd.astro/objload.c
r3693 r5846 5 5 int objload (int argc, char **argv) { 6 6 7 int i, nstar, N, Nout, n, Type, type, NSTAR, Nline, status; 8 double *X, *Y; 7 int i, N, Objtype, type, Nline, status; 9 8 FILE *f; 10 9 char *buffer, *line; 11 int Ximage, Nimage; 10 int Ximage, Nimage, Noverlay, NOVERLAY; 11 KiiOverlay *overlay; 12 12 13 13 Nimage = -1; … … 19 19 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 20 20 21 Type = 0;21 Objtype = 0; 22 22 if ((N = get_argument (argc, argv, "-t"))) { 23 23 remove_argument (N, &argc, argv); 24 Type = atof (argv[N]);24 Objtype = atof (argv[N]); 25 25 remove_argument (N, &argc, argv); 26 26 } 27 27 28 28 if (argc != 3) { 29 fprintf (stderr, "USAGE: load (overlay) <filename>\n");29 fprintf (stderr, "USAGE: objload (overlay) <filename>\n"); 30 30 return (FALSE); 31 31 } 32 33 if (!SelectOverlay (argv[1], &n)) return (FALSE);34 32 35 33 f = fopen (argv[2], "r"); … … 43 41 scan_line (f, line); 44 42 45 nstar = 0;46 NSTAR = 1000;47 ALLOCATE (X, double, NSTAR);48 ALLOCATE (Y, double, NSTAR);49 43 ALLOCATE (buffer, char, CHAR_LINE*NBLOCK); 50 44 45 Noverlay = 0; 46 NOVERLAY = 1000; 47 ALLOCATE (overlay, KiiOverlay, Noverlay); 48 51 49 /* read in data from obj file */ 52 50 while ((Nline = fread (buffer, CHAR_LINE, NBLOCK, f)) > 0) { 53 51 for (i = 0; i < Nline; i++) { 54 52 /* we are now using all entries on the *.obj line */ 55 status = sscanf (&buffer[i*CHAR_LINE], "%d %lf %lf", &type, &X[nstar], &Y[nstar]); 56 if (Type && (Type != type)) continue; 57 nstar ++; 58 if (nstar == NSTAR) { 59 NSTAR += 1000; 60 REALLOCATE (X, double, NSTAR); 61 REALLOCATE (Y, double, NSTAR); 62 } 53 status = sscanf (&buffer[i*CHAR_LINE], "%d %f %f", &type, &overlay[Noverlay].x, &overlay[Noverlay].y); 54 if (Objtype && (Objtype != type)) continue; 55 overlay[Noverlay].type = KII_OVERLAY_BOX; 56 overlay[Noverlay].dx = 5.0; 57 overlay[Noverlay].dy = 5.0; 58 Noverlay ++; 59 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 1000); 63 60 } 64 61 } … … 66 63 free (buffer); 67 64 68 SendGraphCommand (Ximage, 4, "LOAD"); 69 SendGraphCommand (Ximage, 16, "OVER %9d ", n); 70 71 /** NOTE: modify to use NBYTE **/ 72 ALLOCATE (buffer, char, 66000); 73 bzero (buffer, 65536); 74 for (Nout = i = 0; i < nstar; i++, Nout++) { 75 snprintf (&buffer[Nout*128], 129, "%15s %20.10f %20.10f %20.10f %20.10f ", "BOX", X[i], Y[i], 5.0, 5.0); 76 if (Nout == 512) { 77 SendGraphCommand (Ximage, 16, "NLINES %7d ", Nout); 78 write (Ximage, buffer, Nout*128); 79 bzero (buffer, 65536); 80 Nout = -1; 81 } 82 } 65 KiiLoadOverlay (Ximage, overlay, Noverlay, argv[1]); 83 66 84 if (Nout) { 85 SendGraphCommand (Ximage, 16, "NLINES %7d ", Nout); 86 write (Ximage, buffer, Nout*128); 87 } 88 SendGraphCommand (Ximage, 16, "DONE"); 89 90 free (X); 91 free (Y); 92 67 free (overlay); 93 68 free (buffer); 94 69 free (line); 95 70 96 fprintf (stderr, "loaded %d objects\n", nstar);71 fprintf (stderr, "loaded %d objects\n", Noverlay); 97 72 return (TRUE); 98 73 } -
trunk/Ohana/src/opihi/cmd.astro/outline.c
r3693 r5846 145 145 /* code to draw dots on Ximage */ 146 146 { 147 char *buffer, *line; 148 int Nline, Nimage, Ximage; 147 int Nimage, Ximage; 149 148 float xp, yp, x, y; 150 149 float dx, dy, theta, t, dt; 150 int Noverlay, NOVERLAY; 151 KiiOverlay *overlay; 151 152 152 153 Nimage = -1; 153 154 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 154 155 155 ALLOCATE (buffer, char, 65536); /* space for 512 lines of 128 bytes */ 156 bzero (buffer, 65536); 157 ALLOCATE (line, char, 1024); /* space to read the file */ 158 Nline = 0; 159 160 SendGraphCommand (Ximage, 4, "LOAD"); 161 SendGraphCommand (Ximage, 16, "OVER %9d ", 0); 162 156 Noverlay = 0; 157 NOVERLAY = 1000; 158 ALLOCATE (overlay, KiiOverlay, Noverlay); 159 163 160 dx = par[2]; 164 161 dy = par[3]; … … 173 170 y = xp * sin (theta * RAD_DEG) + yp * cos (theta * RAD_DEG) + par[1]; 174 171 175 sprintf (&buffer[Nline*128], "%15s %20.10f %20.10f %20.10f %20.10f ", "BOX", x, y, 1.0, 1.0); 176 Nline ++; 177 178 if (Nline >= 510) { 179 SendGraphCommand (Ximage, 16, "NLINES %7d ", Nline); 180 write (Ximage, buffer, Nline*128); 181 bzero (buffer, 65536); 182 Nline = 0; 183 } 184 } 185 186 SendGraphCommand (Ximage, 16, "NLINES %7d ", Nline); 187 write (Ximage, buffer, Nline*128); 188 SendGraphCommand (Ximage, 16, "DONE"); 189 190 free (buffer); 191 free (line); 192 172 overlay[Noverlay].type = KII_OVERLAY_BOX; 173 overlay[Noverlay].x = x; 174 overlay[Noverlay].y = y; 175 overlay[Noverlay].dx = 1.0; 176 overlay[Noverlay].dy = 1.0; 177 178 Noverlay ++; 179 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 1000); 180 } 181 KiiLoadOverlay (Ximage, overlay, Noverlay, "red"); 182 free (overlay); 193 183 } 194 184 -
trunk/Ohana/src/opihi/cmd.astro/outline2.c
r3693 r5846 303 303 int plot_outline () { 304 304 305 char *buffer, *line; 306 int Nline, Nimage, Ximage; 305 int Nimage, Ximage; 307 306 float xp, yp, x, y; 308 307 float dx, dy, theta, t, dt; 308 int Noverlay, NOVERLAY; 309 KiiOverlay *overlay; 309 310 310 311 Nimage = -1; 311 312 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 312 313 313 ALLOCATE (buffer, char, 65536); /* space for 512 lines of 128 bytes */ 314 bzero (buffer, 65536); 315 ALLOCATE (line, char, 1024); /* space to read the file */ 316 Nline = 0; 317 318 SendGraphCommand (Ximage, 4, "LOAD"); 319 SendGraphCommand (Ximage, 16, "OVER %9d ", 0); 314 Noverlay = 0; 315 NOVERLAY = 1000; 316 ALLOCATE (overlay, KiiOverlay, Noverlay); 320 317 321 318 dx = par[2]; … … 331 328 y = xp * sin (theta * RAD_DEG) + yp * cos (theta * RAD_DEG) + par[1]; 332 329 333 sprintf (&buffer[Nline*128], "%15s %20.10f %20.10f %20.10f %20.10f ", "BOX", x, y, 1.0, 1.0); 334 Nline ++; 335 336 if (Nline >= 510) { 337 SendGraphCommand (Ximage, 16, "NLINES %7d ", Nline); 338 write (Ximage, buffer, Nline*128); 339 bzero (buffer, 65536); 340 Nline = 0; 341 } 342 } 343 344 SendGraphCommand (Ximage, 16, "NLINES %7d ", Nline); 345 write (Ximage, buffer, Nline*128); 346 SendGraphCommand (Ximage, 16, "DONE"); 347 348 free (buffer); 349 free (line); 330 overlay[Noverlay].type = KII_OVERLAY_BOX; 331 overlay[Noverlay].x = x; 332 overlay[Noverlay].y = y; 333 overlay[Noverlay].dx = 1.0; 334 overlay[Noverlay].dy = 1.0; 335 336 Noverlay ++; 337 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 1000); 338 } 339 KiiLoadOverlay (Ximage, overlay, Noverlay, "red"); 340 free (overlay); 350 341 return (TRUE); 351 342 }
Note:
See TracChangeset
for help on using the changeset viewer.
