IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 27, 2005, 5:06:32 AM (21 years ago)
Author:
eugene
Message:

converting to use libkapa commands instead of raw graph commands

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/tv.c

    r4689 r5846  
    33int tv (int argc, char **argv) {
    44 
    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;
    116  Coords coords;
    127  Buffer *buf;
     8  KiiImage image;
     9  KiiDisplayMode mode;
    1310
    1411  Nimage = -1;
     
    2219  /* shell exits on pipe close, FIX */
    2320  if ((N = get_argument (argc, argv, "-kill"))) {
    24     close (Ximage);
     21    KiiClose (Ximage);
    2522    Ximage = 0;
    2623    return (TRUE);
    2724  }
    2825
    29   min = max = 0.0;
    30   ISLOG = FALSE;
     26  mode.logflux = FALSE;
    3127  if ((N = get_argument (argc, argv, "-log"))) {
    3228    remove_argument (N, &argc, argv);
    33     ISLOG = TRUE;
     29    mode.logflux = TRUE;
    3430  }
    3531
     
    3935  }
    4036
    41   GetImageScale (&zero, &range);
     37  GetImageScale (&mode.zero, &mode.range);
    4238  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);
    4743  }
    4844
    4945  if ((buf = SelectBuffer (argv[1], OLDBUFFER, TRUE)) == NULL) return (FALSE);
    5046  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;
    5153
    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);
    9255
    9356  SetImageName (argv[1]);
Note: See TracChangeset for help on using the changeset viewer.