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

Location:
trunk/Ohana/src/opihi/cmd.astro
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.astro/gauss.c

    r3693 r5846  
    33int gauss (int argc, char **argv) {
    44
    5   char buffer[20], key;
     5  char key[20];
    66  int i, N, Npix, Nborder, Nspot;
    77  double X, Y, Z, max;
     
    5050  if ((buf = SelectBuffer (GetImageName(), OLDBUFFER, TRUE)) == NULL) return (FALSE);
    5151
    52   fcntl (Ximage, F_SETFL, !O_NONBLOCK); 
    53   SendGraphCommand (Ximage, 4, "CURS");
    54  
     52  KiiCursorOn (Ximage);
     53
    5554  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
    6359    Z = get_aperture_stats (&buf[0].matrix, (int)(X+0.5), (int)(Y+0.5), Npix, Nborder, max);
    64    
    6560  }
    66   SendGraphCommand (Ximage, 4, "NCUR");
    67 
     61  KiiCursorOff (Ximage);
    6862  return (TRUE);
    6963}
  • 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}
  • trunk/Ohana/src/opihi/cmd.astro/outline.c

    r3693 r5846  
    145145    /* code to draw dots on Ximage */
    146146    {
    147       char *buffer, *line;
    148       int Nline, Nimage, Ximage;
     147      int Nimage, Ximage;
    149148      float xp, yp, x, y;
    150149      float dx, dy, theta, t, dt;
     150      int Noverlay, NOVERLAY;
     151      KiiOverlay *overlay;
    151152     
    152153      Nimage = -1;
    153154      if (!GetImage (&Ximage, &Nimage)) return (FALSE);
    154155     
    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 
    163160      dx = par[2];
    164161      dy = par[3];
     
    173170        y = xp * sin (theta * RAD_DEG) + yp * cos (theta * RAD_DEG) + par[1];
    174171       
    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);
    193183    }
    194184
  • trunk/Ohana/src/opihi/cmd.astro/outline2.c

    r3693 r5846  
    303303int plot_outline () {
    304304 
    305   char *buffer, *line;
    306   int Nline, Nimage, Ximage;
     305  int Nimage, Ximage;
    307306  float xp, yp, x, y;
    308307  float dx, dy, theta, t, dt;
     308  int Noverlay, NOVERLAY;
     309  KiiOverlay *overlay;
    309310 
    310311  Nimage = -1;
    311312  if (!GetImage (&Ximage, &Nimage)) return (FALSE);
    312313 
    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);
    320317 
    321318  dx = par[2];
     
    331328    y = xp * sin (theta * RAD_DEG) + yp * cos (theta * RAD_DEG) + par[1];
    332329   
    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);
    350341  return (TRUE);
    351342}
Note: See TracChangeset for help on using the changeset viewer.