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/tvgrid.c

    r4689 r5846  
    44int tvgrid (int argc, char **argv) {
    55 
    6   int ncolor, ndig1, ndig2, NX, NY, connect;
     6  int ndig1, ndig2, NX, NY, connect;
    77  int tDEC, tRA;
    88  double ra, dec, ra0, dec0, ra1, dec1;
     
    1111  char format[16];
    1212  Coords coords;
    13   int Ximage, Nimage, N;
     13  int Ximage, Nimage, N, Noverlay, NOVERLAY;
    1414  Buffer *buf;
     15  KiiOverlay *overlay;
    1516
    1617  Nimage = -1;
     
    2324 
    2425  if (argc != 3) {
    25     fprintf (stderr, "USAGE: load (overlay) (buffer)\n");
     26    fprintf (stderr, "USAGE: tvgrid (overlay) (buffer)\n");
    2627    fprintf (stderr, " (overlay) may be: red, green, blue, yellow\n");
    2728    return (FALSE);
    2829  }
    29   if (strcmp (argv[1], "0")   && strcmp (argv[1], "1")     && strcmp (argv[1], "2")   && strcmp (argv[1], "3") &&
    30       strcmp (argv[1], "red") && strcmp (argv[1], "green") && strcmp (argv[1], "blue") && strcmp (argv[1], "yellow")) {
    31     fprintf (stderr, "valid overlays may be: 0, red, 1, green, 2, blue, 3, yellow\n");
    32     return (FALSE);
    33   }
    34 
    35   ncolor = atof (argv[1]);
    36   if (!(strcmp (argv[1], "red")))
    37     ncolor = 0;
    38   if (!(strcmp (argv[1], "green")))
    39     ncolor = 1;
    40   if (!(strcmp (argv[1], "blue")))
    41     ncolor = 2;
    42   if (!(strcmp (argv[1], "yellow")))
    43     ncolor = 3;
    4430
    4531  if ((buf = SelectBuffer (argv[2], OLDBUFFER, TRUE)) == NULL) return (FALSE);
     
    5036  fprintf (stderr, "%f %f  %f %f\n", ra0, dec0, ra1, dec1);
    5137 
    52   /* tell KII to expect overlay data */
    53   SendGraphCommand (Ximage, 4, "LOAD");
    54   SendGraphCommand (Ximage, 16, "OVERLAY: %7d", ncolor);
    55  
     38  Noverlay = 0;
     39  NOVERLAY = 1000;
     40  ALLOCATE (overlay, KiiOverlay, NOVERLAY);
     41
    5642  dDEC = fabs(dec1 - dec0);
    5743  tDEC = log10(dDEC) - log10(5.0);
     
    9076      RD_to_XY (&x1, &y1, ra, dec, &coords);
    9177      if ((x1 >= 0) && (x1 < NX) && (y1 >= 0) && (y1 < NY)) {
    92         if (connect) SendGraphCommand (Ximage, 128, "%15s %20.10f %20.10f %20.10f %20.10f ", "LINE", x0, y0, (x1 - x0), (y1 - y0));
     78        if (connect) {
     79          overlay[Noverlay].type = KII_OVERLAY_LINE;
     80          overlay[Noverlay].x = x0;
     81          overlay[Noverlay].y = y0;
     82          overlay[Noverlay].dx = x1 - x0;
     83          overlay[Noverlay].dy = y1 - y0;
     84          Noverlay ++;
     85          CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 1000);
     86        }
    9387        x0 = x1;
    9488        y0 = y1;
     
    132126      RD_to_XY (&x1, &y1, ra, dec, &coords);
    133127      if ((x1 >= 0) && (x1 < NX) && (y1 >= 0) && (y1 < NY)) {
    134         if (connect) SendGraphCommand (Ximage, 128, "%15s %20.10f %20.10f %20.10f %20.10f ", "LINE", x0, y0, (x1 - x0), (y1 - y0));
     128        if (connect) {
     129          overlay[Noverlay].type = KII_OVERLAY_LINE;
     130          overlay[Noverlay].x = x0;
     131          overlay[Noverlay].y = y0;
     132          overlay[Noverlay].dx = x1 - x0;
     133          overlay[Noverlay].dy = y1 - y0;
     134          Noverlay ++;
     135          CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 1000);
     136        }
    135137        x0 = x1;
    136138        y0 = y1;
     
    142144  }
    143145
    144   /*
     146  # if (0)
     147  /* write the labels on the axes */
    145148  dDEC = fabs(dec1 - dec0) / 100;
    146149  for (ra = dRA * ((int)(MIN(ra0, ra1)/dRA) + 1); ra < MAX(ra0, ra1); ra += dRA) {
     
    159162    }
    160163  }
    161   */
     164  # endif
    162165
    163   SendGraphCommand (Ximage, 128, "DONE");
     166  KiiLoadOverlay (Ximage, overlay, Noverlay, argv[1]);
     167  free (overlay);
     168
    164169  return (TRUE);
    165170}
    166 
    167 /*
    168   write (Ximage, "LOAD", 4);
    169   sprintf (buffer, "OVERLAY: %7d", n);
    170   write (Ximage, buffer, 16);
    171  
    172   for (n = 0; scan_line (f, buffer) != EOF; n++) {
    173     c = strchr (buffer, '#');
    174     if (c != (char *) NULL)
    175       *c = 0; 
    176     while ((c = strchr (buffer, '(')) != (char *) NULL)
    177       *c = ' ';
    178     while ((c = strchr (buffer, ')')) != (char *) NULL)
    179       *c = ' ';
    180     while ((c = strchr (buffer, ',')) != (char *) NULL)
    181       *c = ' ';
    182     N = sscanf (buffer, "%s %lf %lf %lf %lf", type, &x, &y, &dx, &dy);
    183     if (N > 3) {
    184       if (N == 4)
    185         dy = dx;
    186       sprintf (buffer, "%15s %20.10f %20.10f %20.10f %20.10f ", type, x, y, dx, dy);
    187       write (Ximage, buffer, 128);
    188     }
    189   }
    190   fprintf (stderr, "loaded %d objects\n", n);
    191   sprintf (buffer, "DONE");
    192   write (Ximage, buffer, 128);
    193   if (f != stdin) {
    194     fclose (f);
    195   }
    196 */
Note: See TracChangeset for help on using the changeset viewer.