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/dvo/cmpload.c

    r4689 r5846  
    66int cmpload (int argc, char **argv) {
    77 
    8   int i, nstar, N, Nin, Nout, Nextra, n, Type, type;
     8  int i, Noverlay, N, Nin, Nextra, n, Objtype, type;
    99  int doneread, done, Nskip, Nbytes, nbytes, Ninstar;
    1010  char *c, *c2;
     
    1515  int Ximage, Nimage;
    1616  Header header;
     17  KiiOverlay *overlay;
    1718 
    1819  Nimage = -1;
     
    2425  if (!GetImage (&Ximage, &Nimage)) return (FALSE);
    2526
    26   Type = 0;
     27  Objtype = 0;
    2728  if ((N = get_argument (argc, argv, "-t"))) {
    2829    remove_argument (N, &argc, argv);
    29     Type = atof (argv[N]);
     30    Objtype = atof (argv[N]);
    3031    remove_argument (N, &argc, argv);
    3132  }
    3233
    3334  if (argc != 3) {
    34     fprintf (stderr, "USAGE: load (overlay) <filename>\n");
     35    fprintf (stderr, "USAGE: cmpload (overlay) <filename>\n");
    3536    return (FALSE);
    3637  }
    37 
    38   if (!SelectOverlay (argv[1], &n))
    39     return (FALSE);
    4038
    4139  if (!fits_read_header (argv[2], &header)) {
     
    6058  fseek (f, header.size, SEEK_SET);
    6159
    62   ALLOCATE (X, double, nstar);
    63   ALLOCATE (Y, double, nstar);
    64   ALLOCATE (M, double, nstar);
    65 
     60  Noverlay = 0;
     61  NOVERLAY = 1000;
     62  ALLOCATE (overlay, KiiOverlay, Noverlay);
     63 
    6664  /* load in stars by blocks of 1000 */
    6765  Nin = 0;
     
    106104    Ninstar = nbytes / BYTES_STAR;
    107105    Nextra = nbytes % BYTES_STAR;
    108     for (i = 0; i < Ninstar; i++, Nin++) {
    109       dparse (&X[Nin],  1, &buffer[i*BYTES_STAR]);
    110       dparse (&Y[Nin],  2, &buffer[i*BYTES_STAR]);
    111       dparse (&M[Nin],  3, &buffer[i*BYTES_STAR]);
    112       if (Type) {
     106    for (i = 0; i < Ninstar; i++) {
     107      if (Objtype) {
    113108        dparse (&dtmp, 5, &buffer[i*BYTES_STAR]);
    114109        type = dtmp;
    115         if (type != Type) {
    116           Nin --;
    117         }
     110        if (type != Objtype) continue;
    118111      }
     112      # if (0)
     113      if (scale) {
     114        dparse (&mag,  3, &buffer[i*BYTES_STAR]);
     115        overlay[Noverlay].dx = mzero + mscale * mag;
     116        overlay[Noverlay].dy = mzero + mscale * mag;
     117      } else {
     118        overlay[Noverlay].dx = 5.0;
     119        overlay[Noverlay].dy = 5.0;
     120      }     
     121      # endif
     122
     123      dparse (&overlay[Noverlay].x,  1, &buffer[i*BYTES_STAR]);
     124      dparse (&overlay[Noverlay].y,  2, &buffer[i*BYTES_STAR]);
     125      overlay[Noverlay].type = KII_OVERLAY_BOX;
     126      overlay[Noverlay].dx = 5.0;
     127      overlay[Noverlay].dy = 5.0;
     128      Noverlay ++;
     129      CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 1000);
    119130    }
    120131  }
    121132  fclose (f);
    122133
    123   SendGraphCommand (Ximage, 4, "LOAD");
    124   SendGraphCommand (Ximage, 16, "OVER %9d ", n);
    125   ALLOCATE (buffer2, char, 66000);
    126   bzero (buffer2, 65536);
    127 
    128   for (Nout = i = 0; i < Nin; i++, Nout++) {
    129     sprintf (&buffer2[Nout*128], "%15s %20.10f %20.10f %20.10f %20.10f ", "BOX", X[i], Y[i], 5.0, 5.0);
    130     if (Nout == 512) {
    131       SendGraphCommand (Ximage, 16, "NLINES  %7d ", Nout);
    132       write (Ximage, buffer2, Nout*128);
    133       bzero (buffer2, 65536);
    134       Nout = -1;
    135     }
    136   }
    137 
    138   if (Nout) {
    139     SendGraphCommand (Ximage, 16, "NLINES  %7d ", Nout);
    140     write (Ximage, buffer2, Nout*128);
    141   }
    142   SendGraphCommand (Ximage, 16, "DONE");
     134  KiiLoadOverlay (Ximage, overlay, Noverlay, argv[1]);
     135  free (overlay);
    143136
    144137  fits_free_header (&header);
    145   free (X);
    146   free (Y);
    147   free (M);
    148138  free (buffer);
    149   free (buffer2);
    150139
    151   fprintf (stderr, "loaded %d objects\n", Nin);
     140  fprintf (stderr, "loaded %d objects\n", Noverlay);
    152141  return (TRUE);
    153142}
Note: See TracChangeset for help on using the changeset viewer.