IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13434


Ignore:
Timestamp:
May 18, 2007, 10:10:41 AM (19 years ago)
Author:
eugene
Message:

image/graph metadata stored/retrieved from kapa

Location:
branches/kapa-mods-2007-05/Ohana/src
Files:
2 added
35 edited

Legend:

Unmodified
Added
Removed
  • branches/kapa-mods-2007-05/Ohana/src/kapa2/Makefile

    r13432 r13434  
    6565$(SRC)/CreatePicture.$(ARCH).o            $(SRC)/CreateColorbar.$(ARCH).o     \
    6666$(SRC)/MakeColormap.$(ARCH).o             $(SRC)/SetColormap.$(ARCH).o        \
    67 $(SRC)/PaintOverlay.$(ARCH).o             $(SRC)/SetGraphStyle.$(ARCH).o      \
     67$(SRC)/PaintOverlay.$(ARCH).o             $(SRC)/SetGraphData.$(ARCH).o       \
    6868$(SRC)/LoadOverlay.$(ARCH).o              $(SRC)/EraseOverlay.$(ARCH).o       \
    69 $(SRC)/SaveOverlay.$(ARCH).o        \
     69$(SRC)/SaveOverlay.$(ARCH).o              $(SRC)/SetImageData.$(ARCH).o       \
    7070$(SRC)/CSaveOverlay.$(ARCH).o             $(SRC)/EraseOverlay.$(ARCH).o       \
    7171$(SRC)/CheckVisual.$(ARCH).o              $(SRC)/CursorOps.$(ARCH).o          \
  • branches/kapa-mods-2007-05/Ohana/src/kapa2/include/prototypes.h

    r13432 r13434  
    6363int           EraseSections       PROTO((void));
    6464int           EraseImage          PROTO((void));
    65 int           SetGraphStyle       PROTO((int sock));
    66 int           GetGraphStyle       PROTO((int sock));
     65int           SetGraphData        PROTO((int sock));
     66int           GetGraphData        PROTO((int sock));
     67int           SetImageData        PROTO((int sock));
     68int           GetImageData        PROTO((int sock));
    6769
    6870int           LoadVectorData      PROTO((int sock, KapaGraphWidget *graph, int N, char *type));
  • branches/kapa-mods-2007-05/Ohana/src/kapa2/include/structures.h

    r13432 r13434  
    116116  Axis      axis[4];    /* coordinate axes */
    117117  Label     label[8];   /* fixed axis labels */
    118   Graphdata style;      /* current graph style */
     118  Graphdata data;       /* current graph data */
    119119
    120120  Gobjects *objects;    /* graphic objects */   
     
    161161  Coords   coords;
    162162  char     file[1024];     /* name of file */
    163   char     buffer_name[1024];  /* name of buffer */
     163  char     name[1024];  /* name of buffer */
    164164} KapaImageWidget;
    165165
  • branches/kapa-mods-2007-05/Ohana/src/kapa2/src/CheckPipe.c

    r13432 r13434  
    132132 
    133133  if (!strcmp (word, "GSTY")) {
    134     GetGraphStyle (sock);
     134    GetGraphData (sock);
    135135    KiiSendCommand (sock, 4, "DONE");
    136136    FINISHED (TRUE);
     
    138138 
    139139  if (!strcmp (word, "SSTY")) {
    140     status = SetGraphStyle (sock);
     140    status = SetGraphData (sock);
     141    KiiSendCommand (sock, 4, "DONE");
     142    FINISHED (TRUE);
     143  }
     144 
     145  if (!strcmp (word, "GIMD")) {
     146    GetImageData (sock);
     147    KiiSendCommand (sock, 4, "DONE");
     148    FINISHED (TRUE);
     149  }
     150 
     151  if (!strcmp (word, "SIMD")) {
     152    status = SetImageData (sock);
    141153    KiiSendCommand (sock, 4, "DONE");
    142154    FINISHED (TRUE);
  • branches/kapa-mods-2007-05/Ohana/src/kapa2/src/Graphs.c

    r13433 r13434  
    2121  }
    2222
    23   graph[0].style.xmin = 0.0;
    24   graph[0].style.xmax = 1.0;
    25   graph[0].style.ymin = 0.0;
    26   graph[0].style.ymax = 1.0;
     23  graph[0].data.xmin = 0.0;
     24  graph[0].data.xmax = 1.0;
     25  graph[0].data.ymin = 0.0;
     26  graph[0].data.ymax = 1.0;
    2727
    2828  graph[0].Nobjects = 0;
  • branches/kapa-mods-2007-05/Ohana/src/kapa2/src/LoadPicture.c

    r13409 r13434  
    2323  KiiScanMessage (sock, "%d %d %d %d %lf %lf", &header.Naxis[0], &header.Naxis[1]);
    2424  KiiScanMessage (sock, "%d %d %d %d %lf %lf", &header.bitpix, &header.unsign, &header.bzero, &header.bscale);
    25   KiiScanMessage (sock, "%lf %lf",  &image[0].zero, &image[0].range);
     25  KiiScanMessage (sock, "%lf %lf %s",  &image[0].zero, &image[0].range, image[0].name, image[0].file);
    2626  KiiScanMessage (sock, "%lf %lf %d", &image[0].min,  &image[0].max, &header.size);
    2727  KiiScanMessage (sock, "%lf %f %f %f %f", &image[0].coords.crval1, &image[0].coords.crpix1, &image[0].coords.cdelt1, &image[0].coords.pc1_1, &image[0].coords.pc1_2);
    2828  KiiScanMessage (sock, "%lf %f %f %f %f", &image[0].coords.crval2, &image[0].coords.crpix2, &image[0].coords.cdelt2, &image[0].coords.pc2_1, &image[0].coords.pc2_2);
    29          
    30   KiiScanMessage (sock, "%s %s %s", image[0].coords.ctype, image[0].file, image[0].buffer_name);
     29  KiiScanMessage (sock, "%s", image[0].coords.ctype);
    3130
    3231  gfits_free_matrix (&image[0].matrix);
  • branches/kapa-mods-2007-05/Ohana/src/kapa2/src/UpdateStatusBox.c

    r13401 r13434  
    3131   
    3232    bzero (line, 100);
    33     sprintf (line, "(%s)                                          ", image[0].buffer_name);
     33    sprintf (line, "(%s)                                          ", image[0].name);
    3434    XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc,
    3535                 image[0].text_x + PAD1, image[0].text_y + 6*textpad + 6*PAD1, line, 25);
  • branches/kapa-mods-2007-05/Ohana/src/kapa2/src/bDrawIt.c

    r13320 r13434  
    2222      section = GetSectionByNumber (i);
    2323      bDrawGraph (section->graph);
    24       // bDrawImage (section->graph);
     24      // bDrawImage (section->image);
    2525  }
    2626
  • branches/kapa-mods-2007-05/Ohana/src/libkapa/doc/api.txt

    r13404 r13434  
    3131SAVE | SaveOverlay      | KiiOverlay.c  | KiiSaveOverlay
    3232CSVE | CSaveOverlay     | KiiOverlay.c  | KiiSaveOverlay
    33 LIMS | GetLimits        | KapaWindow.c  | KapaGetLimits
    34 
    35 TICK | LoadTickmarks    | XXX not used
    36 NPIX | GetPixelCount    | XXX not used?
     33SLIM | GetLimits        | KapaWindow.c  | KapaGetLimits
     34SSTY | SetGraphData     | KapaWindow.c  | KapaSetGraphData
     35GSTY | GetGraphData     | KapaWindow.c  | KapaGetGraphData
     36SIMD | SetImageData     | KapaWindow.c  | KapaSetImageData
     37GIMD | GetImageData     | KapaWindow.c  | KapaGetImageData
  • branches/kapa-mods-2007-05/Ohana/src/libkapa/include/kapa.h

    r13432 r13434  
    2020  int Nx;
    2121  int Ny;
    22   char *file;
    23   char *name;
    2422} KiiImage;
    25 
    26 typedef struct {
    27   double zero;
    28   double range;
    29   int logflux;
    30 } KiiDisplayMode;
    3123
    3224typedef struct {
     
    9082
    9183typedef struct {
     84  int logflux;
     85  double zero, range;
     86  char name[1024];
     87  char file[1024];
     88} KapaImageData;
     89
     90typedef struct {
    9291  int dx, dy, ascent;
    9392  unsigned char *bits;
     
    123122
    124123/* KiiPicture.c */
    125 int KiiNewPicture1D (int fd, KiiImage *image, KiiDisplayMode *mode, Coords *coords);
    126 int KiiNewPicture2D (int fd, KiiImage *image, KiiDisplayMode *mode, Coords *coords);
     124int KiiNewPicture1D (int fd, KiiImage *image, KapaImageData *data, Coords *coords);
     125int KiiNewPicture2D (int fd, KiiImage *image, KapaImageData *data, Coords *coords);
    127126
    128127/* KiiOverlay.c */
     
    164163int KapaGetSection (int fd, char *name);
    165164int KapaMoveSection (int fd, char *name, char *direction);
    166 int KapaSetGraphStyle (int fd, Graphdata *graphmode);
    167 int KapaGetGraphStyle (int fd, Graphdata *graphmode);
     165int KapaSetGraphData (int fd, Graphdata *graphmode);
     166int KapaGetGraphData (int fd, Graphdata *graphmode);
     167int KapaSetImageData (int fd, KapaImageData *graphmode);
     168int KapaGetImageData (int fd, KapaImageData *graphmode);
    168169
    169170/* KapaColors */
  • branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KapaWindow.c

    r13432 r13434  
    9191}
    9292
    93 int KapaPrepPlot (int fd, int Npts, Graphdata *graphmode) {
     93int KapaPrepPlot (int fd, int Npts, Graphdata *data) {
    9494
    9595  /* tell kapa to look for the incoming image */
    9696  KiiSendCommand (fd, 4, "PLOT");
    9797 
    98   /* send Xgraph the plot details */
     98  /* send kapa the plot details */
    9999  KiiSendMessage (fd, "%8d %8d %d %d %d %d %d %f %f",
    100                   Npts, graphmode[0].style,
    101                   graphmode[0].ptype, graphmode[0].ltype,
    102                   graphmode[0].etype, graphmode[0].ebar, graphmode[0].color,
    103                   graphmode[0].lweight, graphmode[0].size);
     100                  Npts, data[0].style,
     101                  data[0].ptype, data[0].ltype,
     102                  data[0].etype, data[0].ebar, data[0].color,
     103                  data[0].lweight, data[0].size);
    104104  KiiSendMessage (fd, "%g %g %g %g",
    105                   graphmode[0].xmin, graphmode[0].xmax,
    106                   graphmode[0].ymin, graphmode[0].ymax);
    107   KiiWaitAnswer (fd, "DONE");
    108   return (TRUE);
    109 }
    110 
    111 int KapaSetGraphStyle (int fd, Graphdata *graphmode) {
     105                  data[0].xmin, data[0].xmax,
     106                  data[0].ymin, data[0].ymax);
     107  KiiWaitAnswer (fd, "DONE");
     108  return (TRUE);
     109}
     110
     111int KapaSetGraphData (int fd, Graphdata *data) {
    112112
    113113  /* tell kapa to look for the incoming image */
    114114  KiiSendCommand (fd, 4, "SSTY");
    115115 
    116   /* send Xgraph the plot details */
     116  /* send kapa the plot details */
    117117  KiiSendMessage (fd, "%8d %d %d %d %d %d %f %f",
    118                   graphmode[0].style,
    119                   graphmode[0].ptype, graphmode[0].ltype,
    120                   graphmode[0].etype, graphmode[0].ebar, graphmode[0].color,
    121                   graphmode[0].lweight, graphmode[0].size);
     118                  data[0].style,
     119                  data[0].ptype, data[0].ltype,
     120                  data[0].etype, data[0].ebar, data[0].color,
     121                  data[0].lweight, data[0].size);
    122122  KiiSendMessage (fd, "%g %g %g %g",
    123                   graphmode[0].xmin, graphmode[0].xmax,
    124                   graphmode[0].ymin, graphmode[0].ymax);
    125   KiiWaitAnswer (fd, "DONE");
    126   return (TRUE);
    127 }
    128 
    129 int KapaGetGraphStyle (int fd, Graphdata *graphmode) {
     123                  data[0].xmin, data[0].xmax,
     124                  data[0].ymin, data[0].ymax);
     125  KiiWaitAnswer (fd, "DONE");
     126  return (TRUE);
     127}
     128
     129int KapaGetGraphData (int fd, Graphdata *data) {
    130130
    131131  /* tell kapa to look for the incoming image */
    132132  KiiSendCommand (fd, 4, "GSTY");
    133133 
    134   /* send Xgraph the plot details */
     134  /* send kapa the plot details */
    135135  KiiScanMessage (fd, "%d %d %d %d %d %d %lf %lf",
    136                   &graphmode[0].style,
    137                   &graphmode[0].ptype, &graphmode[0].ltype,
    138                   &graphmode[0].etype, &graphmode[0].ebar, &graphmode[0].color,
    139                   &graphmode[0].lweight, &graphmode[0].size);
     136                  &data[0].style,
     137                  &data[0].ptype, &data[0].ltype,
     138                  &data[0].etype, &data[0].ebar, &data[0].color,
     139                  &data[0].lweight, &data[0].size);
    140140  KiiScanMessage (fd, "%lf %lf %lf %lf",
    141                   &graphmode[0].xmin, &graphmode[0].xmax,
    142                   &graphmode[0].ymin, &graphmode[0].ymax);
     141                  &data[0].xmin, &data[0].xmax,
     142                  &data[0].ymin, &data[0].ymax);
     143  KiiWaitAnswer (fd, "DONE");
     144  return (TRUE);
     145}
     146
     147int KapaSetImageData (int fd, KapaImageData *data) {
     148
     149  /* tell kapa to look for the incoming image */
     150  KiiSendCommand (fd, 4, "SIMD");
     151 
     152  /* send kapa the plot details */
     153  KiiSendMessage (fd, "%g %g %s %s",
     154                  data[0].zero, data[0].range, data[0].name, data[0].file);
     155
     156  KiiWaitAnswer (fd, "DONE");
     157  return (TRUE);
     158}
     159
     160int KapaGetImageData (int fd, KapaImageData *data) {
     161
     162  /* tell kapa to look for the incoming image */
     163  KiiSendCommand (fd, 4, "GIMD");
     164 
     165  KiiScanMessage (fd, "%lf %lf %s %s",
     166                  &data[0].zero, &data[0].range, data[0].name, data[0].file);
     167
    143168  KiiWaitAnswer (fd, "DONE");
    144169  return (TRUE);
     
    203228}
    204229
    205 int KapaSetLimits (int fd, Graphdata *graphmode) {
     230int KapaSetLimits (int fd, Graphdata *data) {
    206231
    207232  KiiSendCommand (fd, 4, "SLIM");
    208   KiiSendMessage (fd, "%g %g %g %g ", graphmode[0].xmin, graphmode[0].xmax, graphmode[0].ymin, graphmode[0].ymax);
     233  KiiSendMessage (fd, "%g %g %g %g ", data[0].xmin, data[0].xmax, data[0].ymin, data[0].ymax);
    209234  KiiWaitAnswer (fd, "DONE");
    210235  return (TRUE);
  • branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiPicture.c

    r13409 r13434  
    11# include <kapa_internal.h>
    22
    3 int KiiNewPicture1D (int fd, KiiImage *image, KiiDisplayMode *mode, Coords *coords) {
     3int KiiNewPicture1D (int fd, KiiImage *image, KapaImageData *data, Coords *coords) {
    44
    55  int i;
    66  int Npix, Ncolors, NNcolors, size;
    77  float *in, min, max;
    8   char *out, *outbuffer, *root, extra[1024];
     8  char *out, *outbuffer;
    99  double a1, a2;
    1010
    1111  Npix = image[0].Nx*image[0].Ny;
    1212
    13   KiiSendCommand (fd, 4, "READ"); /* tell Ximage to look for the incoming image */
     13  KiiSendCommand (fd, 4, "READ"); /* tell kapa to look for the incoming image */
    1414  KiiScanMessage (fd, "%d", &Ncolors);
    1515
     
    2222  /* define color table, */
    2323  NNcolors = Ncolors - 1;
    24   if (mode[0].logflux) {
    25     mode[0].range = MAX (2, mode[0].range);
    26     a1 = Ncolors / log10 (mode[0].range);
    27     a2 = mode[0].zero;
     24  if (data[0].logflux) {
     25    data[0].range = MAX (2, data[0].range);
     26    a1 = Ncolors / log10 (data[0].range);
     27    a2 = data[0].zero;
    2828    for (i = 0; i < Npix; i++, in++, out++) {
    2929      *out = (char) MIN (a1 * log10 (MAX (*in - a2, 1.0)), NNcolors);
    3030    }
    3131  } else {
    32     a1 = Ncolors / mode[0].range;
    33     a2 = Ncolors * mode[0].zero / mode[0].range;
     32    a1 = Ncolors / data[0].range;
     33    a2 = Ncolors * data[0].zero / data[0].range;
    3434    for (i = 0; i < Npix; i++, in++, out++) {
    3535      *out = (char) MIN (MAX (a1 * *in - a2, 0), NNcolors);
     
    4141  size = Npix*sizeof(char);
    4242
    43   /* done with the conversion, now send Ximage the converted picture */
     43  /* done with the conversion, now send kapa the converted picture */
    4444  KiiSendMessage (fd, "%8d %8d", image[0].Nx, image[0].Ny);
    4545  KiiSendMessage (fd, "8 1 0.0 1.0");
    46   KiiSendMessage (fd, "%f %f ", mode[0].zero, mode[0].range);
     46  KiiSendMessage (fd, "%f %f %s %s", data[0].zero, data[0].range, data[0].name, data[0].file);
    4747  KiiSendMessage (fd, "%f %f %d ", min, max, size);
    4848  KiiSendMessage (fd, "%f %f %g %g %g ", coords[0].crval1, coords[0].crpix1, coords[0].cdelt1, coords[0].pc1_1, coords[0].pc1_2);
    4949  KiiSendMessage (fd, "%f %f %g %g %g ", coords[0].crval2, coords[0].crpix2, coords[0].cdelt2, coords[0].pc2_1, coords[0].pc2_2);
    50 
    51   /* send the filename */
    52   root = filerootname (image[0].file);
    53   KiiSendMessage (fd, "%s %s %s ", coords[0].ctype, root, image[0].name);
    54   free (root);
     50  KiiSendMessage (fd, "%s", coords[0].ctype);
    5551
    5652  /* send the image data */
     
    6258}
    6359
    64 int KiiNewPicture2D (int fd, KiiImage *image, KiiDisplayMode *mode, Coords *coords) {
     60int KiiNewPicture2D (int fd, KiiImage *image, KapaImageData *data, Coords *coords) {
    6561
    6662  int i, j;
    6763  int Npix, Ncolors, NNcolors, size;
    6864  float *in, min, max;
    69   char *out, *outbuffer, *root;
    70   char buffer[1024];
     65  char *out, *outbuffer;
    7166  double a1, a2;
    7267
    7368  Npix = image[0].Nx*image[0].Ny;
    7469
    75   KiiSendCommand (fd, 4, "READ"); /* tell Ximage to look for the incoming image */
    76 
    77   /* convert from (float *) to 1 byte chars -- depends on how many colors Kii owns */
    78   /* use this response as a handshake test */
    79   read (fd, buffer, 16);
    80   sscanf (buffer, "%*s %d", &Ncolors);
     70  KiiSendCommand (fd, 4, "READ"); /* tell kapa to look for the incoming image */
     71  KiiScanMessage (fd, "%d", &Ncolors);
    8172
    8273  ALLOCATE (outbuffer, char, Npix);
     
    8778  /* define color table, */
    8879  NNcolors = Ncolors - 1;
    89   if (mode[0].logflux) {
    90     mode[0].range = MAX (2, mode[0].range);
    91     a1 = Ncolors / log10 (mode[0].range);
    92     a2 = mode[0].zero;
     80  if (data[0].logflux) {
     81    data[0].range = MAX (2, data[0].range);
     82    a1 = Ncolors / log10 (data[0].range);
     83    a2 = data[0].zero;
    9384    for (j = 0; j < image[0].Ny; j++) {
    9485      in = image[0].data2d[j];
     
    9889    }
    9990  } else {
    100     a1 = Ncolors / mode[0].range;
    101     a2 = Ncolors * mode[0].zero / mode[0].range;
     91    a1 = Ncolors / data[0].range;
     92    a2 = Ncolors * data[0].zero / data[0].range;
    10293    for (j = 0; j < image[0].Ny; j++) {
    10394      in = image[0].data2d[j];
     
    112103  size = Npix*sizeof(char);
    113104
    114   /* done with the conversion, now send Ximage the converted picture */
    115   KiiSendMessage (fd, "%8d %8d 8 1 %f %f", image[0].Nx, image[0].Ny, 0.0, 1.0);
    116   KiiSendMessage (fd, "%f %f %f %f %d ", mode[0].zero, mode[0].range, min, max, size);
     105  /* done with the conversion, now send kapa the converted picture */
     106  KiiSendMessage (fd, "%8d %8d", image[0].Nx, image[0].Ny);
     107  KiiSendMessage (fd, "8 1 0.0 1.0");
     108  KiiSendMessage (fd, "%f %f %s %s", data[0].zero, data[0].range, data[0].name, data[0].file);
     109  KiiSendMessage (fd, "%f %f %d ", min, max, size);
    117110  KiiSendMessage (fd, "%f %f %g %g %g ", coords[0].crval1, coords[0].crpix1, coords[0].cdelt1, coords[0].pc1_1, coords[0].pc1_2);
    118111  KiiSendMessage (fd, "%f %f %g %g %g ", coords[0].crval2, coords[0].crpix2, coords[0].cdelt2, coords[0].pc2_1, coords[0].pc2_2);
    119 
    120   /* send the filename */
    121   root = filerootname (image[0].file);
    122   KiiSendMessage (fd, "%s %s %s ", coords[0].ctype, root, image[0].name);
     112  KiiSendMessage (fd, "%s", coords[0].ctype);
    123113
    124114  /* send the image data */
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.astro/gauss.c

    r13391 r13434  
    99  char *name;
    1010  Buffer *buf;
     11  KapaImageData data;
    1112
    1213  name = NULL;
     
    1617    remove_argument (N, &argc, argv);
    1718  }
    18   if (!GetImage (&kapa, name)) return (FALSE);
     19  if (!GetImageData (&data, &kapa, name)) return (FALSE);
    1920  FREE (name);
    2021
     
    5051  }
    5152
    52   if ((buf = SelectBuffer (GetImageName(), OLDBUFFER, TRUE)) == NULL) return (FALSE);
     53  if ((buf = SelectBuffer (data.name, OLDBUFFER, TRUE)) == NULL) return (FALSE);
    5354
    5455  KiiCursorOn (kapa);
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.astro/objload.c

    r13391 r13434  
    1717    remove_argument (N, &argc, argv);
    1818  }
    19   if (!GetImage (&kapa, name)) return (FALSE);
     19  if (!GetImage (NULL, &kapa, name)) return (FALSE);
    2020  FREE (name);
    2121
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.astro/outline.c

    r13391 r13434  
    151151      KiiOverlay *overlay;
    152152     
    153       if (!GetImage (&kapa, NULL)) return (FALSE);
     153      if (!GetImage (NULL, &kapa, NULL)) return (FALSE);
    154154     
    155155      Noverlay = 0;
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.astro/outline2.c

    r13391 r13434  
    309309  KiiOverlay *overlay;
    310310 
    311   if (!GetImage (&kapa, NULL)) return (FALSE);
     311  if (!GetImage (NULL, &kapa, NULL)) return (FALSE);
    312312 
    313313  Noverlay = 0;
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/center.c

    r13391 r13434  
    1414    remove_argument (N, &argc, argv);
    1515  }
    16   if (!GetImage (&kapa, name)) return (FALSE);
     16  if (!GetImage (NULL, &kapa, name)) return (FALSE);
    1717  FREE (name);
    1818
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/cursor.c

    r13391 r13434  
    44
    55  char string[20], key[20], *name;
    6   int i, N, kapa, IsImage;
     6  int i, N, kapa;
    77  double X, Y, R, D, Z;
    88  void *oldsignal;
     
    1010  Buffer *buf;
    1111
    12   /* need to be able to specify graph vs image coords
    13   if ((N = get_argument (argc, argv, "-g"))) {
    14     remove_argument (N, &argc, argv);
    15     SetImageDevice (FALSE);
    16   } 
    17   if ((N = get_argument (argc, argv, "-i"))) {
    18     remove_argument (N, &argc, argv);
    19     SetImageDevice (TRUE);
    20   } 
    21   */
     12  // XXX need to be able to specify graph vs image coords
     13  // currently, if only one exists, that frame will be used
     14  // if both exist, defaults to ??
     15  // if ((N = get_argument (argc, argv, "-g"))) {
     16  // if ((N = get_argument (argc, argv, "-i"))) {
    2217
    2318  name = NULL;
     
    3934 
    4035  buf = NULL;
    41   if (IsImage) buf = SelectBuffer (GetImageName(), OLDBUFFER, FALSE);
     36  // if (IsImage) buf = SelectBuffer (GetImageName(), OLDBUFFER, FALSE);
     37  // XXX this stuff will go away with 32bit image data
    4238 
    4339  KiiCursorOn (kapa);
     
    4743  Z = -1.0;
    4844  for (i = 0; ((i < N) || (N == 0)) && !interrupt; i++) {
     45
     46    // XXX have kapa return x,y,z,ra,dec for all options
    4947    KiiCursorRead (kapa, &X, &Y, key);
    5048
     
    5553    set_str_variable ("KEY", key);
    5654   
    57     if (IsImage) {
    58       if (buf != NULL) {
    59         Z = gfits_get_matrix_value (&buf[0].matrix, (int) X, (int) Y);
    60       }
    61       gprint (GP_LOG, "%s %f %f  %f\n", key, X, Y, Z);
     55    if (buf != NULL) {
     56      Z = gfits_get_matrix_value (&buf[0].matrix, (int) X, (int) Y);
     57      // gprint (GP_LOG, "%s %f %f  %f\n", key, X, Y, Z);
    6258    } else {
    6359      XY_to_RD (&R, &D, X, Y, &graphmode.coords);
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/device.c

    r13391 r13434  
    1515
    1616  if (name == NULL) {
    17     name = GetGraphName ();
     17    name = GetKapaName ();
    1818    if (name == NULL) {
    1919      gprint (GP_ERR, "no device defined\n");
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/erase.c

    r13391 r13434  
    1313    remove_argument (N, &argc, argv);
    1414  }
    15   if (!GetImage (&kapa, name)) return (FALSE);
     15  if (!GetImage (NULL, &kapa, name)) return (FALSE);
    1616  FREE (name);
    1717
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/jpeg.c

    r13391 r13434  
    2222    IsPNG = TRUE;
    2323  }
     24  if (!strcmp (argv[0], "png")) IsPNG = TRUE;
     25  if (!strcmp (argv[0], "ppm")) IsPPM = TRUE;
    2426
    2527  /* file name */
     
    3840    remove_argument (N, &argc, argv);
    3941  }
    40   /* need to figure out what this implies
     42
     43  /* XXX output png / jpeg needs to include both graph and image
     44     if available.  this is a poor mix of data representations
     45     (png for image / jpeg for plots)
    4146  if ((N = get_argument (argc, argv, "-g"))) {
    42     remove_argument (N, &argc, argv);
    43     SetImageDevice (FALSE);
    44   } 
    4547  if ((N = get_argument (argc, argv, "-i"))) {
    46     remove_argument (N, &argc, argv);
    47     SetImageDevice (TRUE);
    48   } 
    4948  */
    5049
    5150  if (!GetGraph (NULL, &kapa, name)) return (FALSE);
    5251  if (!IsPNG && !IsPPM) {
    53     if (!filename[0]) strcpy (filename, "kapa.png");
     52    if (!filename[0]) strcpy (filename, "kapa.jpg");
    5453    KiiJPEG (kapa, filename);
    5554  }
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/load.c

    r13391 r13434  
    1313  Buffer *buf;
    1414  KiiOverlay *overlay;
     15  KapaImageData data;
    1516 
    1617  name = NULL;
     
    2021    remove_argument (N, &argc, argv);
    2122  }
    22   if (!GetImage (&kapa, name)) return (FALSE);
     23  if (!GetImageData (&data, &kapa, name)) return (FALSE);
    2324  FREE (name);
    2425
     
    4647
    4748  if (ISCEL) {
    48     if ((buf = SelectBuffer (GetImageName(), OLDBUFFER, TRUE)) == NULL) return (FALSE);
     49    if ((buf = SelectBuffer (data.name, OLDBUFFER, TRUE)) == NULL) return (FALSE);
    4950    GetCoords (&coords, &buf[0].header);
    5051  }
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/point.c

    r13391 r13434  
    1111  Buffer *buf;
    1212  KiiOverlay overlay;
     13  KapaImageData data;
    1314
    1415  name = NULL;
     
    1819    remove_argument (N, &argc, argv);
    1920  }
    20   if (!GetImage (&kapa, name)) return (FALSE);
     21  if (!GetImageData (&data, &kapa, name)) return (FALSE);
    2122  FREE (name);
    2223
     
    3940 
    4041  if (celestial) {
    41     if ((buf = SelectBuffer (GetImageName(), OLDBUFFER, TRUE)) == NULL) return (FALSE);
     42    if ((buf = SelectBuffer (data.name, OLDBUFFER, TRUE)) == NULL) return (FALSE);
    4243    GetCoords (&coords, &buf[0].header);
    4344  }
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/ps.c

    r13391 r13434  
    5555  if (argc > 1) strcpy (filename, argv[1]);
    5656
    57   if (!GetImage (&kapa, name)) return (FALSE);
     57  // get the connection to kapa, false if none available
     58  if (!GetGraphData (NULL, &kapa, name)) return (FALSE);
    5859  FREE (name);
    5960
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/resize.c

    r13391 r13434  
    1515    remove_argument (N, &argc, argv);
    1616  }
    17   if (!GetImage (&kapa, name)) return (FALSE);
     17  if (!GetImage (NULL, &kapa, name)) return (FALSE);
    1818  FREE (name);
    1919
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/save.c

    r13391 r13434  
    1313    remove_argument (N, &argc, argv);
    1414  }
    15   if (!GetImage (&kapa, name)) return (FALSE);
     15  if (!GetImage (NULL, &kapa, name)) return (FALSE);
    1616  FREE (name);
    1717
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/style.c

    r13432 r13434  
    44 
    55  int kapa;
    6   Graphdata graphmode;
     6  Graphdata data;
    77
    8   if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE;
     8  if (!style_args (&data, &argc, argv, &kapa)) return FALSE;
    99
    1010  if (argc > 1) {
     
    1212    return (FALSE);
    1313  }
    14   KapaSetGraphStyle (kapa, &graphmode);
     14  KapaSetGraphData (kapa, &data);
    1515
    1616  return (TRUE);
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/tv.c

    r13391 r13434  
    44 
    55  int N, kapa;
    6   char *name;
     6  char *name, *file;
    77  Coords coords;
    88  Buffer *buf;
    99  KiiImage image;
    10   KiiDisplayMode mode;
     10  KapaImageData data;
    1111
    1212  name = NULL;
     
    1616    remove_argument (N, &argc, argv);
    1717  }
    18   if (!GetImage (&kapa, name)) return (FALSE);
     18  if (!GetImage (&data, &kapa, name)) return (FALSE);
    1919  FREE (name);
    2020
     
    2525  }
    2626
    27   mode.logflux = FALSE;
     27  data.logflux = FALSE;
    2828  if ((N = get_argument (argc, argv, "-log"))) {
    2929    remove_argument (N, &argc, argv);
    30     mode.logflux = TRUE;
     30    data.logflux = TRUE;
    3131  }
    3232
     33  // use the currently-set zero,range values if not supplied
    3334  if ((argc != 2) && (argc != 4)) {
    3435    gprint (GP_ERR, "USAGE: tv <buffer> [zero range] [-n Nimage] [-log] [-kill]\n");
     
    3637  }
    3738
    38   GetImageScale (&mode.zero, &mode.range);
    3939  if (argc == 4) {
    40     mode.zero = atof (argv[2]);
    41     mode.range = atof (argv[3]);
    42     if (mode.range == 0.0) mode.range = 0.001;
    43     SetImageScale (mode.zero, mode.range);
     40    data.zero = atof (argv[2]);
     41    data.range = atof (argv[3]);
     42    if (data.range == 0.0) data.range = 0.001;
    4443  }
    4544
     
    5049  image.Nx = buf[0].matrix.Naxis[0];
    5150  image.Ny = buf[0].matrix.Naxis[1];
    52   image.file = buf[0].file;
    53   image.name = buf[0].name;
    5451
    55   KiiNewPicture1D (kapa, &image, &mode, &coords);
     52  // send only the root of the file, not the full path
     53  file = filerootname (buf[0].file);
     54  strcpy (data.file, file);
     55  free (file);
    5656
    57   SetImageName (argv[1]);
     57  strcpy (data.name, argv[1]);
     58 
     59  KiiNewPicture1D (kapa, &image, &data, &coords);
     60
    5861  set_str_variable ("TV", argv[1]);
    5962  return (TRUE);
    6063}
    61 
    62 
    63 /*
    64 projections and coordinates:
    65 
    66 IRAS:
    67 CTYPE1  = 'LL      '                    /TANGENT PLANE (L)                     
    68 CRVAL1  =         0.100000D+02          /R.A. OF MAP CENTER  *** SEE COMMENT   
    69 CDELT1  =        -0.133333D-01          /SEPARATION IN L (DEG)                 
    70 CRPIX1  =                  128          /MAPCENTER IN L                       
    71 CROTA1  =         0.000000E+00          /NO ROTATION           
    72                                                                                
    73 CTYPE2  = 'MM      '                    /TANGENT PLANE (M)                     
    74 CRVAL2  =         0.410000D+02          /DEC. OF MAP CENTER  *** SEE COMMENT   
    75 CDELT2  =         0.133333D-01          /SEPARATION IN M (DEG)                 
    76 CRPIX2  =                  128          /MAP CENTER IN M                       
    77 CROTA2  =         0.000000E+00          /NO ROTATION                           
    78 
    79 HIRAS:
    80 CTYPE1  = 'RA---TAN          ' / PRIMARY AXIS NAME                             
    81 CRVAL1  =   1.000000000000E+01 / PRIMARY REFERENCE VALUE                       
    82 CDELT1  =  -5.555555555556E-03 / PRIMARY PIXEL SEPARATION                     
    83 CRPIX1  =   2.560000000000E+02 / PRIMARY REFERENCE PIXEL                       
    84 CUNIT1  = 'DEGREE            ' / PRIMARY AXIS UNITS                           
    85 
    86 CDELT2  =   5.555555555556E-03 / PRIMARY PIXEL SEPARATION                     
    87 CRPIX2  =   2.560000000000E+02 / PRIMARY REFERENCE PIXEL                       
    88 CRVAL2  =   4.100000000000E+01 / PRIMARY REFERENCE VALUE                       
    89 CTYPE2  = 'DEC--TAN          ' / PRIMARY AXIS NAME                             
    90 CUNIT2  = 'DEGREE            ' / PRIMARY AXIS UNITS                           
    91 
    92 PROJTYPE= 'GNOMON    '                                                         
    93 COORDSYS= 'EQUATORIAL     '                                                   
    94 
    95 gene (small FOV linear):
    96 RA_O
    97 RA_X
    98 RA_Y
    99 DEC_O
    100 DEC_X
    101 DEC_Y
    102 
    103 
    104 */
    105 
    106 # ifdef NEWTVMODE 
    107   {
    108     double *pixvalues, slope;
    109 
    110     ALLOCATE (pixvalues, double, Ncolors + 1);
    111     range = fabs (range);
    112     for (i = 0; i < Ncolors + 1; i++) {
    113       if (ISLOG) {
    114         pixvalues[i] = i*range / NNcol + zero;
    115       }
    116       if (!ISLOG) {
    117         pixvalues[i] = pow (10.0, i*log10(range - 1.0) / NNcol) + zero - 1.0;
    118       }     
    119     }
    120     for (j = 0; j < Npix; j++, in++, out++) {
    121       if (*in < pixvalues[0]) {
    122         i = 0;
    123       } else {
    124         if (*in > pixvalues[NNcol]) {
    125           i = NNcol;
    126         } else {
    127           for (i = 0; (*in < pixvalues[i]) || (*in > pixvalues[i+1]); ) {
    128             slope = 1.0 / (pixvalues[i+1] - pixvalues[i]);
    129             i = MIN (MAX (0, i + (*in - pixvalues[i]) * slope), NNcol);
    130           }
    131         }       
    132       }
    133       /* for (i = 0; (i < Ncolors - 1) && (pixvalues[i] < *in); i++); */
    134       *out = i;
    135     }
    136     free (pixvalues);
    137   }
    138 # endif
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/tvcontour.c

    r13391 r13434  
    6969    remove_argument (N, &argc, argv);
    7070  }
    71   if (!GetImage (&kapa, name)) return (FALSE);
     71  if (!GetImage (NULL, &kapa, name)) return (FALSE);
    7272  FREE (name);
    7373
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/tvgrid.c

    r13391 r13434  
    2222    remove_argument (N, &argc, argv);
    2323  }
    24   if (!GetImage (&kapa, name)) return (FALSE);
     24  if (!GetImage (NULL, &kapa, name)) return (FALSE);
    2525  FREE (name);
    2626
     
    146146  }
    147147
    148   # if (0)
    149   /* write the labels on the axes */
    150   dDEC = fabs(dec1 - dec0) / 100;
    151   for (ra = dRA * ((int)(MIN(ra0, ra1)/dRA) + 1); ra < MAX(ra0, ra1); ra += dRA) {
    152     RD_to_XY (&x0, &y0, ra + 0.1*dRA, MIN(dec0, dec1), &coords);
    153     sprintf (label, format, ra);
    154     sprintf (buffer, "%15s %20.10f %20.10f %20.10f %20.10f ", "TEXT", x0, y0, (double)(strlen(label) + 1), 0.0);
    155     write (kapa, buffer, 128);
    156     write (kapa, label, strlen(label) + 1);
    157     RD_to_XY (&x0, &y0, ra, MIN(dec0, dec1), &coords);
    158     for (dec = MIN(dec0, dec1) + dDEC; dec < MAX(dec0,dec1); dec += dDEC) {
    159       RD_to_XY (&x1, &y1, ra, dec, &coords);
    160       sprintf (buffer, "%15s %20.10f %20.10f %20.10f %20.10f ", "LINE", x0, y0, (x1 - x0), (y1 - y0));
    161       write (kapa, buffer, 128);
    162       x0 = x1;
    163       y0 = y1;
    164     }
    165   }
    166   # endif
    167 
    168148  KiiLoadOverlay (kapa, overlay, Noverlay, argv[1]);
    169149  free (overlay);
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/vload.c

    r13391 r13434  
    1616    remove_argument (N, &argc, argv);
    1717  }
    18   if (!GetImage (&kapa, name)) return (FALSE);
     18  if (!GetImage (NULL, &kapa, name)) return (FALSE);
    1919  FREE (name);
    2020
  • branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/cmpload.c

    r13391 r13434  
    2222    remove_argument (N, &argc, argv);
    2323  }
    24   if (!GetImage (&kapa, name)) return (FALSE);
     24  if (!GetImage (NULL, &kapa, name)) return (FALSE);
    2525  FREE (name);
    2626
  • branches/kapa-mods-2007-05/Ohana/src/opihi/include/display.h

    r13432 r13434  
    55# define DISPLAY_H
    66
    7 /*** plotting functions ***/
    8 int           GetCurrentDevice      PROTO((void));
     7/*** kapa graph functions ***/
    98int           PlotVectorPair        PROTO((int kapa, int Npts, float *xValues, float *yValues, Graphdata *graphmode));
    109int           PlotVectorTriplet     PROTO((int kapa, int Npts, float *xValues, float *yValues, float *zValues, Graphdata *graphmode));
    1110int           GetGraphData          PROTO((Graphdata *data, int *kapa, char *name));
    1211int           GetGraph              PROTO((Graphdata *data, int *kapa, char *name));
    13 void          InitGraph             PROTO((void));
    14 int           open_graph            PROTO((int N));
    15 int           close_graph           PROTO((int N));
    16 void          QuitGraph             PROTO((void));
    17 void          SetGraph              PROTO((Graphdata *data));
    18 void          XGraphDead            PROTO((int input));
    19 int           GetColor              PROTO((char *name));
     12int           SetGraph              PROTO((Graphdata *data));
    2013
    21 /* image (tv) functions */
    22 int           GetImage              PROTO((int *kapa, char *name));
    23 char         *GetImageName          PROTO((void));
    24 void          GetImageScale         PROTO((double *zero, double *range));
    25 void          InitImage             PROTO((void));
    26 int           open_image            PROTO((int N));
    27 int           close_image           PROTO((int N));
    28 void          QuitImage             PROTO((void));
    29 void          SetImageDevice        PROTO((int state));
    30 void          SetImageName          PROTO((char *name));
    31 void          SetImageScale         PROTO((double zero, double range));
    32 void          XImageDead            PROTO((int input));
    33 int           SelectOverlay         PROTO((char *name, int *number));
     14/*** kapa image functions */
     15int           GetImageData          PROTO((KapaImageData *data, int *kapa, char *name));
     16int           GetImage              PROTO((KapaImageData *data, int *kapa, char *name));
     17int           SetImage              PROTO((KapaImageData *data));
    3418
    35 void QuitKapa ();
    36 void InitKapa ();
    37 int open_kapa (int entry);
    38 int close_kapa (char *name);
    39 int AddKapaDevice (char *name);
    40 int DelKapaDevice (char *name);
    41 int FindKapaDevice (char *name);
    42 char *GetGraphName ();
     19void          QuitKapa              PROTO(());
     20void          InitKapa              PROTO(());
     21int           open_kapa             PROTO((int entry));
     22int           close_kapa            PROTO((char *name));
     23int           AddKapaDevice         PROTO((char *name));
     24int           DelKapaDevice         PROTO((char *name));
     25int           FindKapaDevice        PROTO((char *name));
     26char         *GetKapaName           PROTO(());
    4327
    4428/* calling program need to define a function 'get_variable' which
  • branches/kapa-mods-2007-05/Ohana/src/opihi/lib.data/open_kapa.c

    r13433 r13434  
    2222  ALLOCATE (Device, char *, 1);                   // for future REALLOCATE calls
    2323  ALLOCATE (Socket, int, 1);                      // for future REALLOCATE calls
    24 
    25   InitGraph ();
    26   InitImage ();
    2724}
    2825
     
    117114}
    118115
    119 /**************** graph ops */
    120 
    121 # if (0)
    122 // XXX for now, use a local variable.  later: get from kapa
    123 static Graphdata graphdata;
    124 
    125 void InitGraph () {
    126   graphdata.xmin = graphdata.ymin = 0.0;
    127   graphdata.xmax = graphdata.ymax = 1.0;
    128   graphdata.style = graphdata.ptype = 0;
    129   graphdata.ltype = graphdata.color = 0;
    130   graphdata.etype = graphdata.ebar = 0;
    131   graphdata.lweight = graphdata.size = 1.0;
    132    
    133   graphdata.coords.pc1_1 = graphdata.coords.pc2_2 = 1.0;
    134   graphdata.coords.pc1_2 = graphdata.coords.pc2_1 = 0.0;
    135   strcpy (graphdata.coords.ctype, "RA---LIN");
    136   graphdata.coords.crval1 = 0.0;
    137   graphdata.coords.crval2 = 0.0;
    138   graphdata.coords.crpix1 = 0.0;
    139   graphdata.coords.crpix2 = 0.0;
    140   graphdata.coords.cdelt1 = graphdata.coords.cdelt2 = 1.0;
    141   graphdata.flipeast = TRUE;
    142   graphdata.flipnorth = FALSE;
    143   strcpy (graphdata.axis, "2222");
    144   strcpy (graphdata.ticks, "2222");
    145   strcpy (graphdata.labels, "2222");
    146 }
    147 
    148   /* test Xgraph[0], flush junk from pipe */
    149   signal (SIGPIPE, XGraphDead);
    150   fcntl (Socket[n], F_SETFL,  O_NONBLOCK);
    151   for (i = 0; (read (Socket[n], buffer, 64) > 0) && (i < 20); i++);
    152   fcntl (Socket[n], F_SETFL, !O_NONBLOCK);
    153 # endif
     116/**************** graph specific ops *******************/
    154117
    155118// return the current device name, if set
    156 char *GetGraphName () {
     119char *GetKapaName () {
    157120  if (Active < 0) return NULL;
    158121  return Device[Active];
     
    166129  int entry;
    167130
    168   SetImageDevice (FALSE);
    169131  if (name == NULL) {
    170132    if (Active < 0) {
     
    181143  }
    182144 
    183   if (data != NULL) KapaGetGraphStyle (Socket[Active], data);
     145  if (data != NULL) KapaGetGraphData (Socket[Active], data);
    184146  if (fd != NULL) *fd = Socket[Active];
    185147
     
    187149}
    188150
    189 /* return pointers for given Xgraph, don't set or open */
     151/* return pointers for given kapa, don't set or open */
    190152int GetGraphData (Graphdata *data, int *fd, char *name) {
    191153
     
    207169
    208170  if (fd != NULL) *fd = Socket[entry];
    209   if (data != NULL) KapaGetGraphStyle (Socket[entry], data);
    210   return (TRUE);
    211 }
    212 
    213 /* assign given values to current Xgraph */
    214 void SetGraph (Graphdata *data) {
     171  if (data != NULL) KapaGetGraphData (Socket[entry], data);
     172  return (TRUE);
     173}
     174
     175/* assign given values to current kapa */
     176int SetGraph (Graphdata *data) {
    215177  if (Active < 0) {
    216178    gprint (GP_ERR, "no active kapa window\n");
     
    221183    return (FALSE);
    222184  }
    223   KapaSetGraphStyle (Socket[Active], data);
    224 }
    225 
    226 /** internal tracking of current active device type **/
    227 /* drop this stuff */
    228 static int       IsImage = FALSE;
    229 
    230 int GetCurrentDevice () {
    231   return (IsImage);
    232 }
    233 
    234 void SetImageDevice (int state) {
    235   IsImage = state;
     185  KapaSetGraphData (Socket[Active], data);
    236186}
    237187
    238188/************* image ops ***********/
    239 // XXX for now, use local static:
    240 
    241 static char      Ximbuffer[512];
    242 static double    Xzero;
    243 static double    Xrange;
    244 
    245 void InitImage () {
    246   Xzero = 0;
    247   Xrange = 1024;
    248   strcpy (Ximbuffer, "none");
    249 }
    250189
    251190/* return pointers for current Ximage, set if desired, test, open if needed */
    252 int GetImage (int *fd, char *name) {
    253   int status;
    254   status = GetGraph (NULL, fd, name);
    255   return (status);
    256 }
    257 
    258 void SetImageName (char *name) {
    259   strcpy (Ximbuffer, name);
    260 }
    261 
    262 char *GetImageName () {
    263   return (Ximbuffer);
    264 }
    265  
    266 // leave this information on kapa, request when needed?
    267 void SetImageScale (double zero, double range) {
    268   Xzero = zero;
    269   Xrange = range;
    270 }
    271 void GetImageScale (double *zero, double *range) {
    272   *zero = Xzero;
    273   *range = Xrange;
     191int GetImage (KapaImageData *data, int *fd, char *name) {
     192
     193  int entry;
     194
     195  if (name == NULL) {
     196    if (Active < 0) {
     197      entry = AddKapaDevice ("0");
     198    } else {
     199      entry = Active;
     200    }
     201  } else {
     202    entry = AddKapaDevice (name);
     203  }
     204 
     205  if (!open_kapa (entry)) {
     206    return (FALSE);
     207  }
     208 
     209  if (data != NULL) KapaGetImageData (Socket[Active], data);
     210  if (fd != NULL) *fd = Socket[Active];
     211
     212  return (TRUE);
     213}
     214
     215/* return pointers for given kapa, don't set or open */
     216int GetImageData (KapaImageData *data, int *fd, char *name) {
     217
     218  int entry;
     219
     220  if (name == NULL) {
     221    if (Active < 0) {
     222      gprint (GP_ERR, "no active kapa window\n");
     223      return (FALSE);
     224    }
     225    entry = Active;
     226  } else {
     227    entry = FindKapaDevice (name);
     228    if (entry < 0) {
     229      gprint (GP_ERR, "invalid kapa window %s\n", name);
     230      return (FALSE);
     231    }
     232  }
     233
     234  if (fd != NULL) *fd = Socket[entry];
     235  if (data != NULL) KapaGetImageData (Socket[entry], data);
     236  return (TRUE);
     237}
     238
     239/* assign given values to current kapa */
     240int SetImage (KapaImageData *data) {
     241  if (Active < 0) {
     242    gprint (GP_ERR, "no active kapa window\n");
     243    return (FALSE);
     244  }
     245  if (Socket[Active] == -1) {
     246    gprint (GP_ERR, "no active kapa window\n");
     247    return (FALSE);
     248  }
     249  KapaSetImageData (Socket[Active], data);
    274250}
    275251
  • branches/kapa-mods-2007-05/Ohana/src/opihi/lib.shell/BufferOps.c

    r9275 r13434  
    195195}
    196196
    197 int SelectOverlay (char *name, int *number) {
    198 
    199   *number = -1;
    200   if (!strcmp (name, "red") || !strcmp (name, "0"))
    201     *number = 0;
    202   if (!strcmp (name, "green") || !strcmp (name, "1"))
    203     *number = 1;
    204   if (!strcmp (name, "blue") || !strcmp (name, "2"))
    205     *number = 2;
    206   if (!strcmp (name, "yellow") || !strcmp (name, "3"))
    207     *number = 3;
    208 
    209   if (*number < 0) {
    210     gprint (GP_ERR, "valid overlays may be: red (0), green (1), blue (2), yellow (3)\n");
    211     return (FALSE);
    212   }
    213   else {
    214     return (TRUE);
    215   }
    216 }
    217 
    218197void dump_buffers (int n) {
    219198
Note: See TracChangeset for help on using the changeset viewer.