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

    r4689 r5846  
    33int load (int argc, char **argv) {
    44 
    5   int N, n, Nline, ISCEL;
    6   int Ximage, Nimage;
    7   char *c, type[10], string[128];
     5  int i, N, n, ISCEL;
     6  int Ximage, Nimage, Noverlay, NOVERLAY;
     7  char *c, type[10], string[128], line[1024];
    88  double x, y, dx, dy, x1, y1;
    99  double dra, ddec, ra1, dec1, ra, dec;
    1010  FILE *f;
    11   char *buffer, *line;
     11  char *buffer;
    1212  Coords coords;
    1313  Buffer *buf;
     14  KiiOverlay *overlay;
    1415 
    1516  Nimage = -1;
     
    3334  }
    3435 
    35   if (!SelectOverlay (argv[1], &n)) return (FALSE);
    36 
    3736  if (!strcmp (argv[2], "-")) {
    3837    f = stdin;
     
    5049  }
    5150
     51  Noverlay = 0;
     52  NOVERLAY = 1000;
     53  ALLOCATE (overlay, KiiOverlay, NOVERLAY);
     54
    5255  ALLOCATE (buffer, char, 65536);  /* space for 512 lines of 128 bytes */
    5356  bzero (buffer, 65536);
    54   ALLOCATE (line, char, 1024);     /* space to read the file */
    55   Nline = 0;
    5657
    57   SendGraphCommand (Ximage, 4, "LOAD");
    58   SendGraphCommand (Ximage, 16, "OVER %9d ", n);
    59  
    6058  dx = dy = 0;
    6159  for (n = 0; scan_line (f, line) != EOF;) {
     
    8179    case 3:
    8280      if (strcmp (type, "TEXT")) {
    83         fprintf (stderr, "syntactical error in line:\n   %s\n", line);
     81        fprintf (stderr, "syntax error in line:\n   %s\n", line);
    8482        continue;
    8583      }
     
    113111      }
    114112    }
    115     if (!strcmp (type, "TEXT")) {
    116       snprintf (&buffer[Nline*128], 128, "%15s %20.10f %20.10f %s ", type, x, y, string);
     113    overlay[Noverlay].type = KiiOverlayTypeByName (type);
     114    if (overlay[Noverlay].type == KII_OVERLAY_TEXT) {
     115      overlay[Noverlay].text = strcreate (string);
    117116    } else {
    118       snprintf (&buffer[Nline*128], 128, "%15s %20.10f %20.10f %20.10f %20.10f ", type, x, y, dx, dy);
     117      overlay[Noverlay].text = NULL;
    119118    }
    120     n++;
    121     Nline ++;
    122     if (Nline == 512) {
    123       SendGraphCommand (Ximage, 16, "NLINES  %7d ", Nline);
    124       write (Ximage, buffer, Nline*128);
    125       bzero (buffer, 65536);
    126       Nline = 0;
    127     }
     119    overlay[Noverlay].x = x;
     120    overlay[Noverlay].y = y;
     121    overlay[Noverlay].dx = dx;
     122    overlay[Noverlay].dy = dy;
     123    Noverlay++;
     124    CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 1000);
    128125  }
    129126
    130   SendGraphCommand (Ximage, 16, "NLINES  %7d ", Nline);
    131   write (Ximage, buffer, Nline*128);
    132   SendGraphCommand (Ximage, 16, "DONE");
     127  KiiLoadOverlay (Ximage, overlay, Noverlay, argv[1]);
    133128
    134   free (buffer);
    135   free (line);
    136   fprintf (stderr, "loaded %d objects\n", n);
     129  for (i = 0; i < Noverlay; i++) {
     130    if (overlay[i].text == NULL) continue;
     131    free (overlay[i].text);
     132  }
     133  free (overlay);
     134
     135  fprintf (stderr, "loaded %d objects\n", Noverlay);
     136
    137137  if (f != stdin) {
    138138    fclose (f);
Note: See TracChangeset for help on using the changeset viewer.