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.astro/objload.c

    r3693 r5846  
    55int objload (int argc, char **argv) {
    66 
    7   int i, nstar, N, Nout, n, Type, type, NSTAR, Nline, status;
    8   double *X, *Y;
     7  int i, N, Objtype, type, Nline, status;
    98  FILE *f;
    109  char *buffer, *line;
    11   int Ximage, Nimage;
     10  int Ximage, Nimage, Noverlay, NOVERLAY;
     11  KiiOverlay *overlay;
    1212 
    1313  Nimage = -1;
     
    1919  if (!GetImage (&Ximage, &Nimage)) return (FALSE);
    2020
    21   Type = 0;
     21  Objtype = 0;
    2222  if ((N = get_argument (argc, argv, "-t"))) {
    2323    remove_argument (N, &argc, argv);
    24     Type = atof (argv[N]);
     24    Objtype = atof (argv[N]);
    2525    remove_argument (N, &argc, argv);
    2626  }
    2727
    2828  if (argc != 3) {
    29     fprintf (stderr, "USAGE: load (overlay) <filename>\n");
     29    fprintf (stderr, "USAGE: objload (overlay) <filename>\n");
    3030    return (FALSE);
    3131  }
    32 
    33   if (!SelectOverlay (argv[1], &n)) return (FALSE);
    3432
    3533  f = fopen (argv[2], "r");
     
    4341  scan_line (f, line);
    4442
    45   nstar = 0;
    46   NSTAR = 1000;
    47   ALLOCATE (X, double, NSTAR);
    48   ALLOCATE (Y, double, NSTAR);
    4943  ALLOCATE (buffer, char, CHAR_LINE*NBLOCK);
    5044
     45  Noverlay = 0;
     46  NOVERLAY = 1000;
     47  ALLOCATE (overlay, KiiOverlay, Noverlay);
     48 
    5149  /* read in data from obj file */
    5250  while ((Nline = fread (buffer, CHAR_LINE, NBLOCK, f)) > 0) {
    5351    for (i = 0; i < Nline; i++) {
    5452      /* 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);
    6360    }
    6461  }
     
    6663  free (buffer);
    6764
    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]);
    8366
    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);
    9368  free (buffer);
    9469  free (line);
    9570
    96   fprintf (stderr, "loaded %d objects\n", nstar);
     71  fprintf (stderr, "loaded %d objects\n", Noverlay);
    9772  return (TRUE);
    9873}
Note: See TracChangeset for help on using the changeset viewer.