IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13402


Ignore:
Timestamp:
May 16, 2007, 3:19:08 PM (19 years ago)
Author:
eugene
Message:

asserting the use of the libkapa APIs to interface with kapa2

Location:
branches/kapa-mods-2007-05/Ohana/src
Files:
1 added
18 edited

Legend:

Unmodified
Added
Removed
  • branches/kapa-mods-2007-05/Ohana/src/gastro/src/plotstuff.c

    r12332 r13402  
    1313int open_graph (int N) {
    1414
    15 # ifdef ANSI
    16 #   define F_SETFL      4   
    17 #   define O_NONBLOCK 0200000 
    18 #   define       AF_UNIX         1         
    19 #   define       SOCK_STREAM     1         
    20 #define ENOENT          2       /* No such file or directory    */
    21 # endif /* ANSI */
    22 
    23   int InitSocket, status;
    24   socklen_t addreslen;
    25   struct sockaddr_un Address;
    26   char temp[100];
    27   char socket_name[100];
     15  char name[100];
    2816 
    2917  active = N;
    30   sprintf (socket_name, "/tmp/kapa%d", N);
    31   sprintf (temp, "rm -f %s", socket_name);
    32   system (temp);
    33    
    34   strcpy (Address.sun_path, socket_name);
    35   Address.sun_family = AF_UNIX;
    36   InitSocket = socket (AF_UNIX, SOCK_STREAM, 0);
    37   status = bind (InitSocket, (struct sockaddr *) &Address, sizeof (Address));
    38   status = listen (InitSocket, 1);
    39  
    40   sprintf (temp, "kapa %s &", socket_name);
    41 # ifndef DEBUG
    42   system (temp);
    43 # else 
    44   fprintf (stderr, "start kapa, press return: %s\n", temp);
    45   fscanf (stdin, "%d", &i);
    46 # endif
    47  
    48   addreslen =  sizeof (Address);
    49   Xgraph[N] = accept (InitSocket, (struct sockaddr *) &Address, &addreslen);
     18
     19  sprintf (name, "gastro [%d]", N);
     20  Xgraph[N] = KapaOpen ("kapa2", name);
     21
    5022  if (Xgraph[N] < 0) {
    5123    fprintf (stderr, "error starting kapa\n");
    5224    return (FALSE);
    5325  }
    54   else {
    55     return (TRUE);
    56   }
    57  
     26  return (TRUE);
    5827}
    5928
    6029void DonePlotting (Graphdata *graphmode, int N) {
    61   char buffer[65], buffer2[65];
    6230
    63   write (Xgraph[N], "DBOX", 4);
    64   sprintf (buffer, "%f %f %f %f ", graphmode[0].xmin, graphmode[0].xmax, graphmode[0].ymin, graphmode[0].ymax);
    65   sprintf (buffer2, "NBYTES: %6d ", (unsigned int) strlen (buffer));
    66   write (Xgraph[N], buffer2, 16);
    67   write (Xgraph[N], buffer, strlen (buffer));
    68 
    69   sprintf (buffer, "%s %s %s", "2222", "2222", "2222");
    70   sprintf (buffer2, "NBYTES: %6d ", (unsigned int) strlen (buffer));
    71   write (Xgraph[N], buffer2, 16);
    72   write (Xgraph[N], buffer, strlen (buffer));
     31  if (Xgraph[N] == 0) return;
     32  KapaBox (Xgraph[N], graphmode);
     33  return;
    7334}
    7435
    7536void PrepPlotting (int Npts, Graphdata *graphmode, int N) {
    7637
    77   int i, status;
    78   char buffer[128], buffer2[128];
    79 
    8038  active = N;
    8139  if (Npts < 1) return;
    8240
    83   /* test Xgraph[N], flush junk from pipe */
    84   signal (SIGPIPE, XDead);
    85   fcntl (Xgraph[N], F_SETFL,  O_NONBLOCK);
    86   for (i = 0; (read (Xgraph[N], buffer, 64) > 0) && (i < 20); i++);
    87   fcntl (Xgraph[N], F_SETFL, !O_NONBLOCK);
    88  
    89   if (Xgraph[N] < 1) if (!open_graph(N)) return;
    90  
    91   /* tell kapa to look for the incoming image */
    92   status = write (Xgraph[N], "PLOT", 4);
    93 
    94   /* send Xgraph[N] the plot details */
    95   sprintf (buffer, "%8d %8d %d %d %d %d %f %f ",
    96            Npts, graphmode[0].style,
    97            graphmode[0].ptype, graphmode[0].ltype,
    98            graphmode[0].etype, graphmode[0].color,
    99            graphmode[0].lweight, graphmode[0].size);
    100   sprintf (buffer2, "NBYTES: %6d ", (unsigned int) strlen (buffer));
    101   write (Xgraph[N], buffer2, 16);
    102   write (Xgraph[N], buffer, strlen (buffer));
    103  
    104   sprintf (buffer, "%f %f %f %f ",
    105            graphmode[0].xmin, graphmode[0].xmax,
    106            graphmode[0].ymin, graphmode[0].ymax);
    107   sprintf (buffer2, "NBYTES: %6d ", (unsigned int) strlen (buffer));
    108   write (Xgraph[N], buffer2, 16);
    109   write (Xgraph[N], buffer, strlen (buffer));
    110 
     41  KapaPrepPlot (Xgraph[N], Npts, graphmode);
    11142}
    11243
     
    11647
    11748  if (Npts < 1) return;
    118 
    11949  active = N;
    120   Nbytes = Npts * sizeof (float);
    121   write (Xgraph[N], vect, Nbytes);
    122 
     50  KapaPlotVector (Xgraph[N], Npts, vect);
    12351}
    12452
     
    13563 
    13664  if (Xgraph[N] < 1) if (!open_graph(N)) return;
    137  
    138   write (Xgraph[N], "ERAS", 4);
     65  KapaClear (Xgraph[N], TRUE);
     66}
    13967
    140 }
    14168/* include these lines to plot a pair of vectors:
    14269
  • branches/kapa-mods-2007-05/Ohana/src/gastro2/src/plotstuff.c

    r12332 r13402  
    1313int open_graph (int N) {
    1414
    15 # ifdef ANSI
    16 #   define F_SETFL      4   
    17 #   define O_NONBLOCK 0200000 
    18 #   define       AF_UNIX         1         
    19 #   define       SOCK_STREAM     1         
    20 #define ENOENT          2       /* No such file or directory    */
    21 # endif /* ANSI */
    22 
    23   int InitSocket, status;
    24   socklen_t addreslen;
    25   struct sockaddr_un Address;
    26   char temp[100];
    27   char socket_name[100];
     15  char name[100];
    2816 
    2917  active = N;
    30   sprintf (socket_name, "/tmp/kapa%d", N);
    31   sprintf (temp, "rm -f %s", socket_name);
    32   system (temp);
    33    
    34   strcpy (Address.sun_path, socket_name);
    35   Address.sun_family = AF_UNIX;
    36   InitSocket = socket (AF_UNIX, SOCK_STREAM, 0);
    37   status = bind (InitSocket, (struct sockaddr *) &Address, sizeof (Address));
    38   status = listen (InitSocket, 1);
    39  
    40   sprintf (temp, "kapa %s -name %d &", socket_name, N);
    41 # ifndef DEBUG
    42   system (temp);
    43 # else 
    44   fprintf (stderr, "start kapa, press return: %s\n", temp);
    45   fscanf (stdin, "%d", &i);
    46 # endif
    47  
    48   addreslen =  sizeof (Address);
    49   Xgraph[N] = accept (InitSocket, (struct sockaddr *) &Address, &addreslen);
     18
     19  sprintf (name, "gastro [%d]", N);
     20  Xgraph[N] = KapaOpen ("kapa2", name);
     21
    5022  if (Xgraph[N] < 0) {
    5123    fprintf (stderr, "error starting kapa\n");
    5224    return (FALSE);
    5325  }
    54   else {
    55     return (TRUE);
    56   }
    57  
     26  return (TRUE);
    5827}
    5928
     
    6130  char buffer[65], buffer2[65];
    6231
    63   write (Xgraph[N], "DBOX", 4);
    64   sprintf (buffer, "%f %f %f %f", graphmode[0].xmin, graphmode[0].xmax, graphmode[0].ymin, graphmode[0].ymax);
    65   sprintf (buffer2, "NBYTES: %6d", (unsigned int) strlen (buffer));
    66   write (Xgraph[N], buffer2, 16);
    67   write (Xgraph[N], buffer, strlen (buffer));
    68 
    69   sprintf (buffer, "%s %s %s", "2222", "2222", "2222");
    70   sprintf (buffer2, "NBYTES: %6d", (unsigned int) strlen (buffer));
    71   write (Xgraph[N], buffer2, 16);
    72   write (Xgraph[N], buffer, strlen (buffer));
     32  KapaBox (Xgraph[N], graphmode);
    7333}
    7434
     
    8141  if (Npts < 1) return;
    8242
    83   /* test Xgraph[N], flush junk from pipe */
    84   signal (SIGPIPE, XDead);
    85   fcntl (Xgraph[N], F_SETFL,  O_NONBLOCK);
    86   for (i = 0; (read (Xgraph[N], buffer, 64) > 0) && (i < 20); i++);
    87   fcntl (Xgraph[N], F_SETFL, !O_NONBLOCK);
    88  
    89   if (Xgraph[N] < 1) if (!open_graph(N)) return;
    90  
    91   /* tell kapa to look for the incoming image */
    92   status = write (Xgraph[N], "PLOT", 4);
    93 
    94   /* send Xgraph[N] the plot details */
    95   sprintf (buffer, "%8d %8d %d %d %d %d %d %f %f",
    96            Npts, graphmode[0].style,
    97            graphmode[0].ptype, graphmode[0].ltype,
    98            graphmode[0].etype, graphmode[0].ebar, graphmode[0].color,
    99            graphmode[0].lweight, graphmode[0].size);
    100   sprintf (buffer2, "NBYTES: %6d", (unsigned int) strlen (buffer));
    101   write (Xgraph[N], buffer2, 16);
    102   write (Xgraph[N], buffer, strlen (buffer));
    103  
    104   sprintf (buffer, "%f %f %f %f",
    105            graphmode[0].xmin, graphmode[0].xmax,
    106            graphmode[0].ymin, graphmode[0].ymax);
    107   sprintf (buffer2, "NBYTES: %6d", (unsigned int) strlen (buffer));
    108   write (Xgraph[N], buffer2, 16);
    109   write (Xgraph[N], buffer, strlen (buffer));
    110 
     43  KapaPrepPlot (Xgraph[N], Npts, graphmode);
    11144}
    11245
     
    11649
    11750  if (Npts < 1) return;
    118 
    11951  active = N;
    120   Nbytes = Npts * sizeof (float);
    121   write (Xgraph[N], vect, Nbytes);
    122 
     52  KapaPlotVector (Xgraph[N], Npts, vect);
    12353}
    12454
     
    13565 
    13666  if (Xgraph[N] < 1) if (!open_graph(N)) return;
    137  
    138   write (Xgraph[N], "ERAS", 4);
     67  KapaClear (Xgraph[N], TRUE);
     68}
    13969
    140 }
    14170/* include these lines to plot a pair of vectors:
    14271
  • branches/kapa-mods-2007-05/Ohana/src/kapa2/include/prototypes.h

    r13344 r13402  
    6161int           ErasePlots          PROTO((void));
    6262int           EraseSections       PROTO((void));
     63int           EraseImage          PROTO((void));
    6364
    6465int           LoadVectorData      PROTO((int sock, KapaGraphWidget *graph, int N, char *type));
  • branches/kapa-mods-2007-05/Ohana/src/kapa2/src/CheckPipe.c

    r13394 r13402  
    1515
    1616  int status;
    17   char buffer[32];
     17  char word[5];
    1818
    1919  // check if we have a valid connection. if not, see if we can get one
     
    2626
    2727  /***** read (4 byte) message word from socket ****/
    28   status = read (sock, buffer, 4);
    29   buffer[4] = 0;
     28  status = read (sock, word, 4);
     29  word[4] = 0;
    3030  switch (status) {
    3131  case -1:                          /* no input from pipe: continue */
     
    4949  /***** handle different messages ****/
    5050  if (ACTIVE_CURSOR) {
    51     if (strcmp (buffer, "NCUR")) {
    52       fprintf (stderr, "wrong end message %s\n", buffer);
     51    if (strcmp (word, "NCUR")) {
     52      fprintf (stderr, "wrong end message %s\n", word);
    5353      return (TRUE);
    5454    }
     
    5757  }
    5858
    59   if (!strcmp (buffer, "QUIT")) return (FALSE);
    60  
    61   if (!strcmp (buffer, "CURS")) {
     59  if (!strcmp (word, "QUIT")) return (FALSE);
     60 
     61  if (!strcmp (word, "CURS")) {
    6262    ACTIVE_CURSOR = TRUE;
    6363    return (TRUE);
    6464  }
    6565 
    66   if (!strcmp (buffer, "PSIT")) {
     66  if (!strcmp (word, "PSIT")) {
    6767    status = PScommand (sock);
    68     write (sock, "DONE", 4);
    69     return (status);
    70   }
    71  
    72   if (!strcmp (buffer, "PNGF")) {
     68    KiiSendCommand (sock, 4, "DONE");
     69    return (status);
     70  }
     71 
     72  if (!strcmp (word, "PNGF")) {
    7373    status = PNGit (sock);
    74     write (sock, "DONE", 4);
    75     return (status);
    76   }
    77  
    78   if (!strcmp (buffer, "PPMF")) {
     74    KiiSendCommand (sock, 4, "DONE");
     75    return (status);
     76  }
     77 
     78  if (!strcmp (word, "PPMF")) {
    7979    status = PPMit (sock);
    80     write (sock, "DONE", 4);
    81     return (status);
    82   }
    83  
    84   if (!strcmp (buffer, "DBOX")) {
     80    KiiSendCommand (sock, 4, "DONE");
     81    return (status);
     82  }
     83 
     84  if (!strcmp (word, "DBOX")) {
    8585    status = LoadFrame (sock);
    86     return (status);
    87   }
    88  
    89   if (!strcmp (buffer, "PLOT")) {
     86    KiiSendCommand (sock, 4, "DONE");
     87    return (status);
     88  }
     89 
     90  if (!strcmp (word, "PLOT")) {
    9091    status = LoadObject (sock);
    91     return (status);
    92   }
    93  
    94   if (!strcmp (buffer, "LABL")) {
     92    KiiSendCommand (sock, 4, "DONE");
     93    return (status);
     94  }
     95 
     96  if (!strcmp (word, "LABL")) {
    9597    status = LoadLabels (sock);
    96     return (TRUE);
    97   }
    98  
    99   if (!strcmp (buffer, "PTXT")) {
     98    KiiSendCommand (sock, 4, "DONE");
     99    return (TRUE);
     100  }
     101 
     102  if (!strcmp (word, "PTXT")) {
    100103    status = LoadTextlines (sock);
    101     return (TRUE);
    102   }
    103  
    104   if (!strcmp (buffer, "RSIZ")) {
     104    KiiSendCommand (sock, 4, "DONE");
     105    return (TRUE);
     106  }
     107 
     108  if (!strcmp (word, "RSIZ")) {
    105109    status = Resize (sock);
    106     return (status);
    107   }
    108 
    109   if (!strcmp (buffer, "LIMS")) {
     110    KiiSendCommand (sock, 4, "DONE");
     111    return (status);
     112  }
     113
     114  if (!strcmp (word, "LIMS")) {
    110115    GetLimits (sock);
    111     return (TRUE);
    112   }
    113  
    114   if (!strcmp (buffer, "SLIM")) {
     116    KiiSendCommand (sock, 4, "DONE");
     117    return (TRUE);
     118  }
     119 
     120  if (!strcmp (word, "SLIM")) {
    115121    status = SetLimits (sock);
    116     return (TRUE);
    117   }
    118  
    119   if (!strcmp (buffer, "SSEC")) {
     122    KiiSendCommand (sock, 4, "DONE");
     123    return (TRUE);
     124  }
     125 
     126  if (!strcmp (word, "SSEC")) {
    120127    status = SetSection (sock);
    121     return (TRUE);
    122   }
    123  
    124   if (!strcmp (buffer, "LSEC")) {
     128    KiiSendCommand (sock, 4, "DONE");
     129    return (TRUE);
     130  }
     131 
     132  if (!strcmp (word, "LSEC")) {
    125133    status = ListSection (sock);
    126     return (TRUE);
    127   }
    128  
    129   if (!strcmp (buffer, "DSEC")) {
     134    KiiSendCommand (sock, 4, "DONE");
     135    return (TRUE);
     136  }
     137 
     138  if (!strcmp (word, "DSEC")) {
    130139    status = DefineSection (sock);
    131     return (TRUE);
    132   }
    133  
    134   if (!strcmp (buffer, "FONT")) {
     140    KiiSendCommand (sock, 4, "DONE");
     141    return (TRUE);
     142  }
     143 
     144  if (!strcmp (word, "FONT")) {
    135145    status = SetFont (sock);
     146    KiiSendCommand (sock, 4, "DONE");
    136147    return (TRUE);
    137148  }
    138149 
    139150  /* Erase Section */
    140   if (!strcmp (buffer, "ERSC")) {
     151  if (!strcmp (word, "ERSC")) {
    141152    status = EraseCurrentPlot ();
    142     return (status);
    143   }
    144  
    145   /* Erase Section */
    146   if (!strcmp (buffer, "ERAS")) {
     153    KiiSendCommand (sock, 4, "DONE");
     154    return (status);
     155  }
     156 
     157  /* Erase Plots */
     158  if (!strcmp (word, "ERSP")) {
    147159    status = ErasePlots ();
    148     return (status);
    149   }
    150  
    151   /* Don't Erase Section */
    152   if (!strcmp (buffer, "ERSS")) {
     160    KiiSendCommand (sock, 4, "DONE");
     161    return (status);
     162  }
     163 
     164  /* Erase Sections */
     165  if (!strcmp (word, "ERSS")) {
    153166    status = EraseSections ();
    154     return (status);
    155   }
    156  
    157 
    158   if (!strcmp (buffer, "READ")) {
     167    KiiSendCommand (sock, 4, "DONE");
     168    return (status);
     169  }
     170
     171  /* Erase Image */
     172  if (!strcmp (word, "ERSI")) {
     173    status = EraseImage ();
     174    KiiSendCommand (sock, 4, "DONE");
     175    return (status);
     176  }
     177
     178  /* Erase Overlay for this section */
     179  if (!strcmp (word, "ERSO")) {
     180    status = EraseOverlay (sock);
     181    KiiSendCommand (sock, 4, "DONE");
     182    return (status);
     183  }
     184
     185  if (!strcmp (word, "READ")) {
    159186    status = LoadPicture (sock);
    160     return (status);
    161   }
    162 
    163   // XXX duplicate Command word
    164   if (!strcmp (buffer, "ERAS")) {
    165     status = EraseOverlay (sock);
    166     return (status);
    167   }
    168 
    169   if (!strcmp (buffer, "LOAD")) {
     187    KiiSendCommand (sock, 4, "DONE");
     188    return (status);
     189  }
     190
     191  if (!strcmp (word, "LOAD")) {
    170192    status = LoadOverlay (sock);
    171     return (status);
    172   }
    173 
    174   if (!strcmp (buffer, "TICK")) {
     193    KiiSendCommand (sock, 4, "DONE");
     194    return (status);
     195  }
     196
     197  /* this is not currently used?
     198     tickmarks were equivalent to the overlays, but fixed wrt the window.
     199     this functionality is probably supplanted by the graph
     200  if (!strcmp (word, "TICK")) {
    175201    status = LoadTickmarks (sock);
    176     return (status);
    177   }
    178 
    179   if (!strcmp (buffer, "SAVE")) {
     202    KiiSendCommand (sock, 4, "DONE");
     203    return (status);
     204  }
     205  */
     206
     207  if (!strcmp (word, "SAVE")) {
    180208    status = SaveOverlay (sock);
    181     return (status);
    182   }
    183 
    184   if (!strcmp (buffer, "CSVE")) {
     209    KiiSendCommand (sock, 4, "DONE");
     210    return (status);
     211  }
     212
     213  if (!strcmp (word, "CSVE")) {
    185214    status = CSaveOverlay (sock);
    186     return (status);
    187   }
    188 
    189   if (!strcmp (buffer, "JPEG")) {
     215    KiiSendCommand (sock, 4, "DONE");
     216    return (status);
     217  }
     218
     219  if (!strcmp (word, "JPEG")) {
    190220    status = JPEGit24 (sock);
    191     write (sock, "DONE", 4);
    192     return (status);
    193   }
    194 
    195   if (!strcmp (buffer, "CENT")) {
     221    KiiSendCommand (sock, 4, "DONE");
     222    return (status);
     223  }
     224
     225  if (!strcmp (word, "CENT")) {
    196226    status = Center (sock);
    197     return (status);
    198   }
    199 
    200   if (!strcmp (buffer, "NPIX")) {
     227    KiiSendCommand (sock, 4, "DONE");
     228    return (status);
     229  }
     230
     231  if (!strcmp (word, "NPIX")) {
    201232    GetPixelCount (sock);
    202     return (TRUE);
    203   }
    204 
    205   fprintf (stderr, "unknown signal %s\n", buffer);
     233    KiiSendCommand (sock, 4, "DONE");
     234    return (TRUE);
     235  }
     236
     237  fprintf (stderr, "unknown signal %s\n", word);
    206238
    207239  return (TRUE);
  • branches/kapa-mods-2007-05/Ohana/src/kii/event/CheckPipe.c

    r13287 r13402  
    123123  }
    124124
     125  /* is this no longer used ?
    125126  if (!strcmp (buffer, "NPIX")) {
    126127    sprintf (buffer, "NPIX:   %8d", layout[0].Npixels);
     
    128129    return (TRUE);
    129130  }
     131  */
    130132
    131133  fprintf (stderr, "unknown signal %s\n", buffer);
  • branches/kapa-mods-2007-05/Ohana/src/libkapa/doc/api.txt

    r13401 r13402  
    11
    2 COMM | Kapa Function  | libkapa API
    3 -----------------------------------
    4 NCUR | !ACTIVE_CURSOR | KiiCursorOff
    5 QUIT | Quit           | 
    6 CURS
    7 PSIT
    8 PNGF
    9 PPMF
    10 DBOX
    11 PLOT
    12 LABL
    13 PTXT
    14 RSIZ
    15 LIMS
    16 SLIM
    17 SSEC
    18 LSEC
    19 DSEC
    20 FONT
    21 ERSC
    22 ERAS
    23 ERSS
    24 READ
    25 ERAS
    26 LOAD
    27 TICK
    28 SAVE
    29 CSVE
    30 JPEG
    31 CENT
    32 NPIX
     2COMM | Kapa Function    | libkapa file  | libkapa API
     3-----------------------------------------------------
     4DBOX | LoadFrame        | KapaWindow.c  | KapaBox
     5ERSP | ErasePlots       | KapaWindow.c  | KapaClearPlots
     6ERSS | EraseSections    | KapaWindow.c  | KapaClearSections
     7ERSI | EraseImage       | KapaWindow.c  | KapaClearImage
     8ERSC | EraseCurrentPlot | KapaWindow.c  | KapaClearCurrentPlot
     9LSEC | ListSection      | KapaWindow.c  | KapaGetSection
     10PNGF | PNGit            | KiiConvert.c  | KapaPNG
     11PPMF | PPMit            | KiiConvert.c  | KapaPPM
     12PLOT | LoadObject       | KapaWindow.c  | KapaPrepPlot
     13SSEC | SetSection       | KapaWindow.c  | KapaSelectSection
     14LABL | LoadLabels       | KapaWindow.c  | KapaSendLabel
     15PTXT | LoadTextlines    | KapaWindow.c  | KapaSendTextline
     16FONT | SetFont          | KapaWindow.c  | KapaSetFont
     17SLIM | SetLimits        | KapaWindow.c  | KapaSetLimits
     18DSEC | DefineSection    | KapaWindow.c  | KapaSetSection
     19CENT | Center           | KapaWindow.c  | KiiCenter
     20QUIT | Quit             | KiiOpen.c     | KiiClose
     21NCUR | !ACTIVE_CURSOR   | KiiCursor.c   | KiiCursorOff
     22CURS | +ACTIVE_CURSOR   | KiiCursor.c   | KiiCursorOn
     23ERSO | EraseOverlay     | KiiOverlay.c  | KiiEraseOverlay
     24JPEG | JPEGit24         | KiiConvert.c  | KiiJPEG
     25LOAD | LoadOverlay      | KiiOverlay.c  | KiiLoadOverlay
     26READ | LoadPicture      | KiiPicture.c  | KiiNewPicture1D
     27READ | LoadPicture      | KiiPicture.c  | KiiNewPicture2D
     28PSIT | PScommand        | KiiConvert.c  | KiiPS
     29RSIZ | Resize           | KapaWindow.c  | KiiResize
     30SAVE | SaveOverlay      | KiiOverlay.c  | KiiSaveOverlay
     31CSVE | CSaveOverlay     | KiiOverlay.c  | KiiSaveOverlay
     32LIMS | GetLimits        | KapaWindow.c  | KapaGetLimits
     33
     34TICK | LoadTickmarks    | XXX not used
     35NPIX | GetPixelCount    | XXX not used?
  • branches/kapa-mods-2007-05/Ohana/src/libkapa/include/kapa.h

    r13344 r13402  
    140140int KiiCenter (int fd, double x, double y, int zoom);
    141141int KapaBox (int fd, Graphdata *graphdata);
    142 int KapaClear (int fd, int ClearSection);
     142int KapaClearCurrentPlot (int fd);
     143int KapaClearPlots (int fd);
     144int KapaClearSections (int fd);
     145int KapaClearImage (int fd);
    143146int KapaInitGraph (Graphdata *graphdata);
    144147int KapaPrepPlot (int fd, int Npts, Graphdata *graphmode);
  • branches/kapa-mods-2007-05/Ohana/src/libkapa/src/IOfuncs.c

    r13344 r13402  
    116116
    117117  ALLOCATE (message, char, length + 1);
     118  fcntl (device, F_SETFL, !O_NONBLOCK);  // block until we get the response??
    118119
    119120  /* read Nbytes from the device */
    120121  status = read (device, message, length);
    121   if (status != length) fprintf (stderr, "Kii/Kapa comm error\n");
    122   message[status] = 0;
    123   /* make the string easy to parse */
     122  fcntl (device, F_SETFL, O_NONBLOCK);  // unblock
     123
     124  if (status != length) {
     125      fprintf (stderr, "Kii/Kapa comm error\n");
     126      return (0);
     127  }
     128  message[status] = 0; // make the string easy to parse
    124129
    125130  /* scan the incoming message */
    126131  va_start (argp, format);
    127   status = vsscanf (message, format, argp);
     132  vsscanf (message, format, argp);
    128133  va_end (argp);
    129134
    130   return (status);
     135  return (1);
    131136}
  • branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KapaWindow.c

    r10923 r13402  
    11# include <kapa_internal.h>
     2
     3int KiiCenter (int fd, double x, double y, int zoom) {
     4
     5  KiiSendCommand (fd, 4, "CENT");
     6  KiiSendMessage (fd, "%8.3f %8.3f %8d ", x, y, zoom);
     7  KiiScanCommand (fd, 4, "%s", word);
     8  if (strcmp (word, "DONE")) {
     9      fprintf (stderr, "unexpected response %s\n", word);
     10      return (FALSE);
     11  }
     12 
     13  return (TRUE);
     14}
    215
    316int KiiResize (int fd, int Nx, int Ny) {
     
    518  KiiSendCommand (fd, 4, "RSIZ");
    619  KiiSendMessage (fd, "%d %d", Nx, Ny);
    7   return (TRUE);
    8 }
    9 
    10 int KiiCenter (int fd, double x, double y, int zoom) {
    11 
    12   KiiSendCommand (fd, 4, "CENT");
    13   KiiSendMessage (fd, "%8.3f %8.3f %8d ", x, y, zoom);
     20  KiiScanCommand (fd, 4, "%s", word);
     21  if (strcmp (word, "DONE")) {
     22      fprintf (stderr, "unexpected response %s\n", word);
     23      return (FALSE);
     24  }
     25 
    1426  return (TRUE);
    1527}
     
    2335
    2436  KiiSendMessage (fd, "%s %s %s", graphdata[0].axis, graphdata[0].labels, graphdata[0].ticks);
    25   return (TRUE);
    26 }
    27 
    28 int KapaClear (int fd, int ClearSection) {
    29 
    30   if (ClearSection) {
    31     KiiSendCommand (fd, 4, "ERAS");
    32   } else {
    33     KiiSendCommand (fd, 4, "ERSS");
     37  KiiScanCommand (fd, 4, "%s", word);
     38  if (strcmp (word, "DONE")) {
     39      fprintf (stderr, "unexpected response %s\n", word);
     40      return (FALSE);
     41  }
     42 
     43  return (TRUE);
     44}
     45
     46int KapaClearCurrentPlot (int fd) {
     47 
     48  KiiSendCommand (fd, 4, "ERSC");
     49  KiiScanCommand (fd, 4, "%s", word);
     50  if (strcmp (word, "DONE")) {
     51      fprintf (stderr, "unexpected response %s\n", word);
     52      return (FALSE);
     53  }
     54  return (TRUE);
     55}
     56
     57int KapaClearPlots (int fd) {
     58 
     59  KiiSendCommand (fd, 4, "ERSP");
     60  KiiScanCommand (fd, 4, "%s", word);
     61  if (strcmp (word, "DONE")) {
     62      fprintf (stderr, "unexpected response %s\n", word);
     63      return (FALSE);
     64  }
     65  return (TRUE);
     66}
     67
     68int KapaClearSections (int fd) {
     69 
     70  KiiSendCommand (fd, 4, "ERSS");
     71  KiiScanCommand (fd, 4, "%s", word);
     72  if (strcmp (word, "DONE")) {
     73      fprintf (stderr, "unexpected response %s\n", word);
     74      return (FALSE);
     75  }
     76  return (TRUE);
     77}
     78
     79int KapaClearImage (int fd) {
     80 
     81  KiiSendCommand (fd, 4, "ERSI");
     82  KiiScanCommand (fd, 4, "%s", word);
     83  if (strcmp (word, "DONE")) {
     84      fprintf (stderr, "unexpected response %s\n", word);
     85      return (FALSE);
    3486  }
    3587  return (TRUE);
     
    76128                  graphmode[0].xmin, graphmode[0].xmax,
    77129                  graphmode[0].ymin, graphmode[0].ymax);
     130
     131  KiiScanCommand (fd, 4, "%s", word);
     132  if (strcmp (word, "DONE")) {
     133      fprintf (stderr, "unexpected response %s\n", word);
     134      return (FALSE);
     135  }
     136 
    78137  return (TRUE);
    79138}
     
    93152  KiiSendCommand (fd, 16, "%s", name);
    94153  KiiSendCommand (fd, 16, "%d", size);
     154
     155  KiiScanCommand (fd, 4, "%s", word);
     156  if (strcmp (word, "DONE")) {
     157      fprintf (stderr, "unexpected response %s\n", word);
     158      return (FALSE);
     159  }
     160 
    95161  return (TRUE);
    96162}
     
    101167  KiiSendMessage (fd, "%6d", mode);
    102168  KiiSendData (fd, string, strlen(string));
     169
     170  KiiScanCommand (fd, 4, "%s", word);
     171  if (strcmp (word, "DONE")) {
     172      fprintf (stderr, "unexpected response %s\n", word);
     173      return (FALSE);
     174  }
     175 
    103176  return (TRUE);
    104177}
     
    109182  KiiSendMessage (fd, "%f %f %f", x, y, angle);
    110183  KiiSendData (fd, string, strlen(string));
     184
     185  KiiScanCommand (fd, 4, "%s", word);
     186  if (strcmp (word, "DONE")) {
     187      fprintf (stderr, "unexpected response %s\n", word);
     188      return (FALSE);
     189  }
     190 
    111191  return (TRUE);
    112192}
     
    116196  KiiSendCommand (fd, 4, "SLIM");
    117197  KiiSendMessage (fd, "%g %g %g %g ", graphmode[0].xmin, graphmode[0].xmax, graphmode[0].ymin, graphmode[0].ymax);
     198
     199  KiiScanCommand (fd, 4, "%s", word);
     200  if (strcmp (word, "DONE")) {
     201      fprintf (stderr, "unexpected response %s\n", word);
     202      return (FALSE);
     203  }
     204 
     205  return (TRUE);
     206}
     207
     208// for now, this just gets the dimensions
     209int KapaGetLimits (int fd, float *dx, float *dy) {
     210
     211  KiiSendCommand (kapa, 4, "LIMS");
     212  KiiScanMessage (kapa, "%lf %lf", dx, dy);
     213
     214  KiiScanCommand (fd, 4, "%s", word);
     215  if (strcmp (word, "DONE")) {
     216      fprintf (stderr, "unexpected response %s\n", word);
     217      return (FALSE);
     218  }
     219 
    118220  return (TRUE);
    119221}
     
    128230                  section[0].dx,
    129231                  section[0].dy);
     232
     233  KiiScanCommand (fd, 4, "%s", word);
     234  if (strcmp (word, "DONE")) {
     235      fprintf (stderr, "unexpected response %s\n", word);
     236      return (FALSE);
     237  }
     238 
    130239  return (TRUE);
    131240}
     
    135244  KiiSendCommand (fd, 4, "SSEC");
    136245  KiiSendMessage (fd, "%s", name);
     246
     247  KiiScanCommand (fd, 4, "%s", word);
     248  if (strcmp (word, "DONE")) {
     249      fprintf (stderr, "unexpected response %s\n", word);
     250      return (FALSE);
     251  }
     252 
    137253  return (TRUE);
    138254}
     
    142258  KiiSendCommand (fd, 4, "LSEC");
    143259  KiiSendMessage (fd, "%s", name);
    144   return (TRUE);
    145 }
     260
     261  KiiScanCommand (fd, 4, "%s", word);
     262  if (strcmp (word, "DONE")) {
     263      fprintf (stderr, "unexpected response %s\n", word);
     264      return (FALSE);
     265  }
     266 
     267  return (TRUE);
     268}
  • branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiConvert.c

    r12892 r13402  
    99
    1010  /* block for the response, which says the operation completed */
    11   read (fd, buffer, 4);
     11  KiiScanCommand (fd, 4, "%s", word);
     12  if (strcmp (word, "DONE")) {
     13      fprintf (stderr, "unexpected response %s\n", word);
     14      return (FALSE);
     15  }
    1216  return (TRUE);
    1317}
     
    2125
    2226  /* block for the response, which says the operation completed */
    23   read (fd, buffer, 4);
     27  KiiScanCommand (fd, 4, "%s", word);
     28  if (strcmp (word, "DONE")) {
     29      fprintf (stderr, "unexpected response %s\n", word);
     30      return (FALSE);
     31  }
    2432  return (TRUE);
    2533}
     
    3341
    3442  /* block for the response, which says the operation completed */
    35   read (fd, buffer, 4);
     43  KiiScanCommand (fd, 4, "%s", word);
     44  if (strcmp (word, "DONE")) {
     45      fprintf (stderr, "unexpected response %s\n", word);
     46      return (FALSE);
     47  }
    3648  return (TRUE);
    3749}
     
    4759
    4860  /* block for the response, which says the operation completed */
    49   read (fd, buffer, 4);
     61  KiiScanCommand (fd, 4, "%s", word);
     62  if (strcmp (word, "DONE")) {
     63      fprintf (stderr, "unexpected response %s\n", word);
     64      return (FALSE);
     65  }
    5066  return (TRUE);
    5167}
  • branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiCursor.c

    r5848 r13402  
    22
    33int KiiCursorOn (int fd) {
    4   write (fd, "CURS", 4); /* ask Source to look for the keystrokes */
     4  KiiSendCommand (fd, 4, "CURS");
     5  KiiScanCommand (fd, 4, "%s", word);
     6  if (strcmp (word, "DONE")) {
     7      fprintf (stderr, "unexpected response %s\n", word);
     8      return (FALSE);
     9  }
    510  return (TRUE);
    611}
    712
    813int KiiCursorOff (int fd) {
    9   write (fd, "NCUR", 4); /* ask Source to look for the keystrokes */
     14  KiiSendCommand (fd, 4, "NCUR");
     15  KiiScanCommand (fd, 4, "%s", word);
     16  if (strcmp (word, "DONE")) {
     17      fprintf (stderr, "unexpected response %s\n", word);
     18      return (FALSE);
     19  }
    1020  return (TRUE);
    1121}
  • branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiOverlay.c

    r13334 r13402  
    8888     conversions back and forth
    8989  */
     90  KiiScanCommand (fd, 4, "%s", word);
     91  if (strcmp (word, "DONE")) {
     92      fprintf (stderr, "unexpected response %s\n", word);
     93      return (FALSE);
     94  }
    9095  return (TRUE);
    9196}
     
    97102  KiiSelectOverlay (overname, &n);
    98103   
    99   KiiSendCommand (fd, 4, "ERAS");
     104  KiiSendCommand (fd, 4, "ERSO");
    100105  KiiSendCommand (fd, 16, "OVERLAY %7d ", n);
    101106
     107  KiiScanCommand (fd, 4, "%s", word);
     108  if (strcmp (word, "DONE")) {
     109      fprintf (stderr, "unexpected response %s\n", word);
     110      return (FALSE);
     111  }
    102112  return (TRUE);
    103113}
     
    116126
    117127  KiiSendMessage (fd, "FILE: %d %s", n, file);
     128
     129  KiiScanCommand (fd, 4, "%s", word);
     130  if (strcmp (word, "DONE")) {
     131      fprintf (stderr, "unexpected response %s\n", word);
     132      return (FALSE);
     133  }
    118134  return (TRUE);
    119135}
  • branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiPicture.c

    r5852 r13402  
    5858  free (outbuffer);
    5959
     60  KiiScanCommand (fd, 4, "%s", word);
     61  if (strcmp (word, "DONE")) {
     62      fprintf (stderr, "unexpected response %s\n", word);
     63      return (FALSE);
     64  }
    6065  return (TRUE);
    6166}
     
    125130  free (outbuffer);
    126131
     132  KiiScanCommand (fd, 4, "%s", word);
     133  if (strcmp (word, "DONE")) {
     134      fprintf (stderr, "unexpected response %s\n", word);
     135      return (FALSE);
     136  }
    127137  return (TRUE);
    128138}
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.astro/region.c

    r13391 r13402  
    55  char string[256];
    66  double Ra, Dec, Radius;
    7   double dx, dy;
     7  float dx, dy;
    88  int N, kapa;
    99  char *name;
     
    6767 
    6868  /* ask kapa for coordinate limits, so get the right aspect ratio */
    69   KiiSendCommand (kapa, 4, "LIMS");
    70   KiiScanMessage (kapa, "%lf %lf", &dx, &dy);
     69  KapaGetLimits (kapa, &dx, &dy);
    7170  dx = fabs (dx);
    7271  dy = fabs (dy);
  • branches/kapa-mods-2007-05/Ohana/src/opihi/lib.data/PlotVectors.c

    r13391 r13402  
    66
    77  if (!GetGraph (NULL, &kapa, NULL)) return (FALSE);
    8  
    9   /* tell kapa to look for the incoming image */
    10   KiiSendCommand (kapa, 4, "PLOT");
    11  
    12   /* send kapa the plot details */
    13   KiiSendMessage (kapa, "%8d %8d %d %d %d %d %d %f %f",
    14                   Npts, graphmode[0].style,
    15                   graphmode[0].ptype, graphmode[0].ltype,
    16                   graphmode[0].etype, graphmode[0].ebar, graphmode[0].color,
    17                   graphmode[0].lweight, graphmode[0].size);
    18   KiiSendMessage (kapa, "%g %g %g %g",
    19                   graphmode[0].xmin, graphmode[0].xmax,
    20                   graphmode[0].ymin, graphmode[0].ymax);
     8  KapaPrepPlot (kapa, Npts, graphmode);
    219  return (TRUE);
    2210}
     
    2412int PlotVector (int Npts, float *values) {
    2513
    26   int Nbytes;
    27 
    28   Nbytes = Npts * sizeof (float);
    29   write (kapa, values, Nbytes);
     14  KapaPlotVector (kapa, Npts, values);
    3015  return (TRUE);
    3116}
     
    3318int PlotVectorPair (int N, float *xValues, float *yValues, Graphdata *graphmode) {
    3419
    35     PrepPlotting (N, graphmode);
    36     PlotVector (N, xValues);
    37     PlotVector (N, yValues);
     20  PrepPlotting (N, graphmode);
     21  PlotVector (N, xValues);
     22  PlotVector (N, yValues);
    3823
    39     return (TRUE);
     24  return (TRUE);
    4025}
    4126
    4227int PlotVectorTriplet (int N, float *xValues, float *yValues, float *zValues, Graphdata *graphmode) {
    4328
    44     PrepPlotting (N, graphmode);
    45     PlotVector (N, xValues);
    46     PlotVector (N, yValues);
    47     PlotVector (N, zValues);
     29  PrepPlotting (N, graphmode);
     30  PlotVector (N, xValues);
     31  PlotVector (N, yValues);
     32  PlotVector (N, zValues);
    4833
    49     return (TRUE);
     34  return (TRUE);
    5035}
    5136
    5237/* we don't use GetGraph in PlotVector because it flushes the connection */
     38/* PlotVector currently operates on the static identified socket
     39   rather than the currently active socket -- must be preceeded by PrepPlotting */
  • branches/kapa-mods-2007-05/Ohana/src/relastro/src/plotstuff.c

    r12892 r13402  
    2121int open_graph (int N) {
    2222
    23   Xgraph[N] = KiiOpen ("kapa", NULL);
     23  char name[100];
     24
     25  sprintf (name, "gastro [%d]", N);
     26  Xgraph[N] = KapaOpen ("kapa2", name);
     27
    2428  if (Xgraph[N] < 0) {
    2529    fprintf (stderr, "error starting kapa\n");
     
    6165  KapaClear (Xgraph[N], TRUE);
    6266
    63   KiiSendCommand (Xgraph[N], 4, "PLOT");
    64  
    65   /* send Xgraph the plot details */
    66   KiiSendMessage (Xgraph[N], "%8d %8d %d %d %d %d %d %f %f",
    67                   Npts, graphmode[0].style,
    68                   graphmode[0].ptype, graphmode[0].ltype,
    69                   graphmode[0].etype, graphmode[0].ebar, graphmode[0].color,
    70                   graphmode[0].lweight, graphmode[0].size);
    71   KiiSendMessage (Xgraph[N], "%g %g %g %g",
    72                   graphmode[0].xmin, graphmode[0].xmax,
    73                   graphmode[0].ymin, graphmode[0].ymax);
    74 
     67  KapaPrepPlot (Xgraph[N], Npts, graphmode);
    7568  return;
    7669}
     
    9588  }
    9689
    97   Nbytes = Npts * sizeof (float);
    98   write (Xgraph[N], values, Nbytes);
     90  KapaPlotVector (Xgraph[N], Npts, values);
    9991  free (values);
    10092  return;
  • branches/kapa-mods-2007-05/Ohana/src/relphot/src/plotstuff.c

    r12892 r13402  
    2121int open_graph (int N) {
    2222
    23   Xgraph[N] = KiiOpen ("kapa", NULL);
     23  char name[100];
     24
     25  sprintf (name, "gastro [%d]", N);
     26  Xgraph[N] = KapaOpen ("kapa2", name);
     27
    2428  if (Xgraph[N] < 0) {
    2529    fprintf (stderr, "error starting kapa\n");
     
    6165  KapaClear (Xgraph[N], TRUE);
    6266
    63   KiiSendCommand (Xgraph[N], 4, "PLOT");
    64  
    65   /* send Xgraph the plot details */
    66   KiiSendMessage (Xgraph[N], "%8d %8d %d %d %d %d %d %f %f",
    67                   Npts, graphmode[0].style,
    68                   graphmode[0].ptype, graphmode[0].ltype,
    69                   graphmode[0].etype, graphmode[0].ebar, graphmode[0].color,
    70                   graphmode[0].lweight, graphmode[0].size);
    71   KiiSendMessage (Xgraph[N], "%g %g %g %g",
    72                   graphmode[0].xmin, graphmode[0].xmax,
    73                   graphmode[0].ymin, graphmode[0].ymax);
    74 
     67  KapaPrepPlot (Xgraph[N], Npts, graphmode);
    7568  return;
    7669}
     
    9588  }
    9689
    97   Nbytes = Npts * sizeof (float);
    98   write (Xgraph[N], values, Nbytes);
     90  KapaPlotVector (Xgraph[N], Npts, values);
    9991  free (values);
    10092  return;
  • branches/kapa-mods-2007-05/Ohana/src/uniphot/src/plotstuff.c

    r4797 r13402  
    1313int open_graph (int N) {
    1414
    15   int i, InitSocket, status, addreslen;
    16   struct sockaddr_un Address;
    17   char temp[100], *display_name;
    18   char socket_name[100];
    19   FILE *f;
     15  char name[100];
    2016 
    2117  active = N;
    22   sprintf (socket_name, "/tmp/kapa%d", N);
    23   sprintf (temp, "rm -f %s", socket_name);
    24   system (temp);
    25    
    26   strcpy (Address.sun_path, socket_name);
    27   Address.sun_family = AF_UNIX;
    28   InitSocket = socket (AF_UNIX, SOCK_STREAM, 0);
    29   status = bind (InitSocket, &Address, sizeof (Address));
    30   status = listen (InitSocket, 1);
    31  
    32   sprintf (temp, "kapa %s &", socket_name);
    33 # ifndef DEBUG
    34   system (temp);
    35 # else 
    36   fprintf (stderr, "start kapa, press return: %s\n", temp);
    37   fscanf (stdin, "%d", &i);
    38 # endif
    39  
    40   addreslen =  sizeof (Address);
    41   Xgraph[N] = accept (InitSocket, &Address, &addreslen);
     18
     19  sprintf (name, "gastro [%d]", N);
     20  Xgraph[N] = KapaOpen ("kapa2", name);
     21
    4222  if (Xgraph[N] < 0) {
    4323    fprintf (stderr, "error starting kapa\n");
    4424    return (FALSE);
    4525  }
    46   else {
    47     return (TRUE);
    48   }
    49  
     26  return (TRUE);
    5027}
    5128
    5229void DonePlotting (Graphdata *graphmode, int N) {
    53   char buffer[65], buffer2[65];
    5430
    5531  if (Xgraph[N] == 0) return;
    56 
    57   write (Xgraph[N], "DBOX", 4);
    58   sprintf (buffer, "%f %f %f %f", graphmode[0].xmin, graphmode[0].xmax, graphmode[0].ymin, graphmode[0].ymax);
    59   sprintf (buffer2, "NBYTES: %6d", strlen (buffer));
    60   write (Xgraph[N], buffer2, 16);
    61   write (Xgraph[N], buffer, strlen (buffer));
    62 
    63   sprintf (buffer, "%s %s %s", "2222", "2222", "2222");
    64   sprintf (buffer2, "NBYTES: %6d", strlen (buffer));
    65   write (Xgraph[N], buffer2, 16);
    66   write (Xgraph[N], buffer, strlen (buffer));
    67 }
    68 
    69 void JpegPlot (Graphdata *graphmode, int N, char *filename) {
    70   char buffer[65], buffer2[65];
    71 
    72   if (Xgraph[N] == 0) return;
    73 
    74   write (Xgraph[N], "PNGF", 4);
    75   sprintf (buffer, "LEN: %11d", strlen (filename));
    76   write (Xgraph[N], buffer, 16);
    77   write (Xgraph[N], filename, strlen (filename));
    78   read (Xgraph[N], buffer, 4);
    79 }
    80 
    81 void PSPlot (Graphdata *graphmode, int N, char *filename) {
    82   char buffer[65], buffer2[65];
    83 
    84   if (Xgraph[N] == 0) return;
    85 
    86   write (Xgraph[N], "PSIT", 4);
    87   sprintf (buffer, "LEN: %11d", strlen (filename));
    88   write (Xgraph[N], buffer, 16);
    89   write (Xgraph[N], filename, strlen (filename));
    90   read (Xgraph[N], buffer, 4);
     32  KapaBox (Xgraph[N], graphmode);
     33  return;
    9134}
    9235
    9336void PrepPlotting (int Npts, Graphdata *graphmode, int N) {
    9437
    95   int i, status;
    96   char buffer[128], buffer2[128];
    97 
    9838  active = N;
    9939  if (Npts < 1) return;
    10040
    101   if (Xgraph[N] < 1) if (!open_graph(N)) return;
     41  KapaPrepPlot (Xgraph[N], Npts, graphmode);
     42}
    10243
    103   /* test Xgraph[N], flush junk from pipe */
    104   signal (SIGPIPE, XDead);
    105   fcntl (Xgraph[N], F_SETFL,  O_NONBLOCK);
    106   for (i = 0; (read (Xgraph[N], buffer, 64) > 0) && (i < 20); i++);
    107   fcntl (Xgraph[N], F_SETFL, !O_NONBLOCK);
    108  
    109   write (Xgraph[N], "ERAS", 4);
    110  
    111   /* tell kapa to look for the incoming image */
    112   status = write (Xgraph[N], "PLOT", 4);
     44void PlotVector (int Npts, float *vect, int mode, int N) {
    11345
    114   /* send Xgraph[N] the plot details */
    115   sprintf (buffer, "%8d %8d %d %d %d %d %f %f",
    116            Npts, graphmode[0].style,
    117            graphmode[0].ptype, graphmode[0].ltype,
    118            graphmode[0].etype, graphmode[0].color,
    119            graphmode[0].lweight, graphmode[0].size);
    120   sprintf (buffer2, "NBYTES: %6d", strlen (buffer));
    121   write (Xgraph[N], buffer2, 16);
    122   write (Xgraph[N], buffer, strlen (buffer));
    123  
    124   sprintf (buffer, "%f %f %f %f",
    125            graphmode[0].xmin, graphmode[0].xmax,
    126            graphmode[0].ymin, graphmode[0].ymax);
    127   sprintf (buffer2, "NBYTES: %6d", strlen (buffer));
    128   write (Xgraph[N], buffer2, 16);
    129   write (Xgraph[N], buffer, strlen (buffer));
     46  int Nbytes;
    13047
     48  if (Npts < 1) return;
     49  active = N;
     50  KapaPlotVector (Xgraph[N], Npts, vect);
    13151}
    13252
     
    13757  if (Xgraph[N] == 0) return;
    13858
    139   write (Xgraph[N], "LABL", 4);
    140   sprintf (buffer, " %6d %6d", strlen (string), 2);
    141   write (Xgraph[N], buffer, 16);
    142   write (Xgraph[N], string, strlen (string));
     59  KapaSendLabel (Xgraph[N[, string, 4);
    14360}
    14461
    145 void PlotVector (int Npts, double *vect, int mode, int N) {
     62void PlotReset (int N) {
    14663
    147   float *values;
    148   int i, Nbytes;
     64  char buffer[128];
     65  int i;
    14966
    150   active = N;
    151   if (Npts < 1) return;
     67  /* test Xgraph[N], flush junk from pipe */
     68  signal (SIGPIPE, XDead);
     69  fcntl (Xgraph[N], F_SETFL,  O_NONBLOCK);
     70  for (i = 0; (read (Xgraph[N], buffer, 64) > 0) && (i < 20); i++);
     71  fcntl (Xgraph[N], F_SETFL, !O_NONBLOCK);
     72 
     73  if (Xgraph[N] < 1) if (!open_graph(N)) return;
     74  KapaClear (Xgraph[N], TRUE);
     75}
    15276
    153   ALLOCATE (values, float, Npts);
    154   for (i = 0; i < Npts; i++) {
    155     values[i] = vect[i];
    156   }
     77void JpegPlot (Graphdata *graphmode, int N, char *filename) {
    15778
    158   Nbytes = Npts * sizeof (float);
    159   write (Xgraph[N], values, Nbytes);
    160   free (values);
     79  if (Xgraph[N] == 0) return;
    16180
     81  KapaPNG (Xgraph[N], filename);
     82  return;
     83}
     84
     85void PSPlot (Graphdata *graphmode, int N, char *filename) {
     86
     87  if (Xgraph[N] == 0) return;
     88
     89  KiiPS (Xgraph[N], filename, TRUE, KAPA_PS_NEWPLOT, "default");
     90  return;
    16291}
    16392
Note: See TracChangeset for help on using the changeset viewer.