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

    r5702 r5846  
    11# include "data.h"
    2 
    3 # define NPTYPE 3
    4 static char ptype[NPTYPE][8] = {"BOX", "LINE", "CIRCLE"};
    52
    63int vload (int argc, char **argv) {
    74 
    8   int i, N, n, Nline;
    9   int Ximage, Nimage;
     5  int i, N, Noverlay;
     6  int Ximage, Nimage, type;
    107  double dx, dy, size;
    11   char *buffer, *type;
     8  KiiOverlay *overlay;
    129  Vector *vecx, *vecy;
    1310 
     
    2017  if (!GetImage (&Ximage, &Nimage)) return (FALSE);
    2118
    22   type = ptype[0];
     19  type = KII_OVERLAY_BOX;
    2320  if ((N = get_argument (argc, argv, "-type"))) {
    2421    remove_argument (N, &argc, argv);
    25     for (i = 0; i < NPTYPE; i++) {
    26       if (!strcasecmp (argv[N], ptype[i])) {
    27         type = ptype[i];
    28         break;
    29       }
    30     }
    31     if (i == NPTYPE) {
     22    type = KiiOverlayTypeByName (argv[N]);
     23    remove_argument (N, &argc, argv);
     24    if (!type) {
    3225      fprintf (stderr, "unknown Kii point type %s\n", argv[N]);
    3326      return (FALSE);
    3427    }
    35     remove_argument (N, &argc, argv);
    3628  }
    3729
     
    4840  }
    4941 
    50   if (!SelectOverlay (argv[1], &n)) return (FALSE);
     42  if (type == KII_OVERLAY_CIRCLE) {
     43    dx = dy = size / 2;
     44  } else {
     45    dx = dy = size;
     46  }   
    5147
    5248  if ((vecx = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) return (FALSE);
     
    5753  }
    5854
    59   ALLOCATE (buffer, char, 65536);  /* space for 512 lines of 128 bytes */
    60   bzero (buffer, 65536);
    61   Nline = 0;
     55  Noverlay = vecx[0].Nelements;
     56  ALLOCATE (overlay, KiiOverlay, Noverlay);
    6257
    63   SendGraphCommand (Ximage, 4, "LOAD");
    64   SendGraphCommand (Ximage, 16, "OVER %9d ", n);
    65 
    66   if (type == ptype[2]) {
    67     dx = dy = size / 2;
    68   } else {
    69     dx = dy = size;
    70   }   
    71   for (i = 0; i < vecx[0].Nelements; i++) {
    72     snprintf (&buffer[Nline*128], 128, "%15s %20.10f %20.10f %20.10f %20.10f ", type,
    73               vecx[0].elements[i]+0.5, vecy[0].elements[i]+0.5, dx, dy);
    74     Nline ++;
    75     if (Nline == 512) {
    76       SendGraphCommand (Ximage, 16, "NLINES  %7d ", Nline);
    77       write (Ximage, buffer, Nline*128);
    78       bzero (buffer, 65536);
    79       Nline = 0;
    80     }
     58  for (i = 0; i < Noverlay; i++) {
     59    overlay[i].type = type;
     60    overlay[i].text = NULL;
     61    overlay[i].x = vecx[0].elements[i]+0.5;
     62    overlay[i].y = vecy[0].elements[i]+0.5;
     63    overlay[i].dx = dx;
     64    overlay[i].dy = dy;
    8165  }
    8266
    83   SendGraphCommand (Ximage, 16, "NLINES  %7d ", Nline);
    84   write (Ximage, buffer, Nline*128);
    85   SendGraphCommand (Ximage, 16, "DONE");
    86 
    87   free (buffer);
     67  KiiLoadOverlay (Ximage, overlay, Noverlay, argv[1]);
     68  free (overlay);
    8869  return (TRUE);
    8970}
Note: See TracChangeset for help on using the changeset viewer.