IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5998


Ignore:
Timestamp:
Jan 15, 2006, 9:06:04 AM (21 years ago)
Author:
eugene
Message:

migrated to libkapa

Location:
trunk/Ohana/src/relphot
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/relphot/include/relphot.h

    r4865 r5998  
    11# include <ohana.h>
    22# include <dvo.h>
     3# include <kapa.h>
    34# include <signal.h>
    45
     
    67# define GRID_V2
    78
     9# if (0)
    810typedef struct {
    911  double xmin, xmax, ymin, ymax;
     
    1113  double lweight, size;
    1214} Graphdata;
     15# endif
    1316
    1417typedef struct {
  • trunk/Ohana/src/relphot/src/plotstuff.c

    r4796 r5998  
    2121int open_graph (int N) {
    2222
    23 # ifdef ANSI
    24 #   define F_SETFL      4   
    25 #   define O_NONBLOCK 0200000 
    26 #   define       AF_UNIX         1         
    27 #   define       SOCK_STREAM     1         
    28 #define ENOENT          2       /* No such file or directory    */
    29 # endif /* ANSI */
     23  int fd;
    3024
    31   int InitSocket, status, addreslen;
    32   struct sockaddr_un Address;
    33   char temp[100];
    34   char socket_name[100];
    35  
    36   active = N;
    37   sprintf (socket_name, "/tmp/kapa%d", N);
    38   sprintf (temp, "rm -f %s", socket_name);
    39   system (temp);
    40    
    41   strcpy (Address.sun_path, socket_name);
    42   Address.sun_family = AF_UNIX;
    43   InitSocket = socket (AF_UNIX, SOCK_STREAM, 0);
    44   status = bind (InitSocket, (struct sockaddr *) &Address, sizeof (Address));
    45   status = listen (InitSocket, 1);
    46  
    47   sprintf (temp, "kapa %s &", socket_name);
    48 # ifndef DEBUG
    49   system (temp);
    50 # else 
    51   fprintf (stderr, "start kapa, press return: %s\n", temp);
    52   fscanf (stdin, "%d", &i);
    53 # endif
    54  
    55   addreslen =  sizeof (Address);
    56   Xgraph[N] = accept (InitSocket, (struct sockaddr *) &Address, &addreslen);
     25  Xgraph[N] = KiiOpen ("kapa", NULL);
    5726  if (Xgraph[N] < 0) {
    5827    fprintf (stderr, "error starting kapa\n");
    5928    return (FALSE);
    6029  }
    61   else {
    62     return (TRUE);
    63   }
    64  
     30  return (TRUE);
    6531}
    6632
    6733void DonePlotting (Graphdata *graphmode, int N) {
    68   char buffer[65], buffer2[65];
    6934
    7035  if (Xgraph[N] == 0) return;
    7136
    72   write (Xgraph[N], "DBOX", 4);
    73   sprintf (buffer, "%f %f %f %f", graphmode[0].xmin, graphmode[0].xmax, graphmode[0].ymin, graphmode[0].ymax);
    74   sprintf (buffer2, "NBYTES: %6d", (int) strlen (buffer));
    75   write (Xgraph[N], buffer2, 16);
    76   write (Xgraph[N], buffer, strlen (buffer));
    77 
    78   sprintf (buffer, "%s %s %s", "2222", "2222", "2222");
    79   sprintf (buffer2, "NBYTES: %6d", (int) strlen (buffer));
    80   write (Xgraph[N], buffer2, 16);
    81   write (Xgraph[N], buffer, strlen (buffer));
     37  KapaBox (Xgraph[N], graphmode);
     38  return;
    8239}
    8340
    8441void JpegPlot (Graphdata *graphmode, int N, char *filename) {
    8542
    86   char buffer[65];
    87 
    8843  if (Xgraph[N] == 0) return;
    8944
    90   write (Xgraph[N], "PNGF", 4);
    91   sprintf (buffer, "LEN: %11d", (int) strlen (filename));
    92   write (Xgraph[N], buffer, 16);
    93   write (Xgraph[N], filename, strlen (filename));
    94   read (Xgraph[N], buffer, 4);
     45  KapaPNG (Xgraph[N], filename);
     46  return;
    9547}
    9648
    9749void PSPlot (Graphdata *graphmode, int N, char *filename) {
    9850
    99   char buffer[65];
    100 
    10151  if (Xgraph[N] == 0) return;
    10252
    103   write (Xgraph[N], "PSIT", 4);
    104   sprintf (buffer, "LEN: %11d", (int) strlen (filename));
    105   write (Xgraph[N], buffer, 16);
    106   write (Xgraph[N], filename, strlen (filename));
    107   read (Xgraph[N], buffer, 4);
     53  KiiPS (Xgraph[N], FALSE, FALSE, filename);
     54  return;
    10855}
    10956
     
    11360  char buffer[128], buffer2[128];
    11461
    115   active = N;
    11662  if (Npts < 1) return;
    11763
    11864  if (Xgraph[N] < 1) if (!open_graph(N)) return;
    11965
    120   /* test Xgraph[N], flush junk from pipe */
    121   signal (SIGPIPE, XDead);
    122   fcntl (Xgraph[N], F_SETFL,  O_NONBLOCK);
    123   for (i = 0; (read (Xgraph[N], buffer, 64) > 0) && (i < 20); i++);
    124   fcntl (Xgraph[N], F_SETFL, !O_NONBLOCK);
     66  KapaClear (Xgraph[N], TRUE);
     67
     68  KiiSendCommand (Xgraph[N], 4, "PLOT");
    12569 
    126   write (Xgraph[N], "ERAS", 4);
    127  
    128   /* tell kapa to look for the incoming image */
    129   status = write (Xgraph[N], "PLOT", 4);
     70  /* send Xgraph the plot details */
     71  KiiSendMessage (Xgraph[N], "%8d %8d %d %d %d %d %d %f %f",
     72                  Npts, graphmode[0].style,
     73                  graphmode[0].ptype, graphmode[0].ltype,
     74                  graphmode[0].etype, graphmode[0].ebar, graphmode[0].color,
     75                  graphmode[0].lweight, graphmode[0].size);
     76  KiiSendMessage (Xgraph[N], "%g %g %g %g",
     77                  graphmode[0].xmin, graphmode[0].xmax,
     78                  graphmode[0].ymin, graphmode[0].ymax);
    13079
    131   /* send Xgraph[N] the plot details */
    132   sprintf (buffer, "%8d %8d %d %d %d %d %f %f",
    133            Npts, graphmode[0].style,
    134            graphmode[0].ptype, graphmode[0].ltype,
    135            graphmode[0].etype, graphmode[0].color,
    136            graphmode[0].lweight, graphmode[0].size);
    137   sprintf (buffer2, "NBYTES: %6d", (int) strlen (buffer));
    138   write (Xgraph[N], buffer2, 16);
    139   write (Xgraph[N], buffer, strlen (buffer));
    140  
    141   sprintf (buffer, "%f %f %f %f",
    142            graphmode[0].xmin, graphmode[0].xmax,
    143            graphmode[0].ymin, graphmode[0].ymax);
    144   sprintf (buffer2, "NBYTES: %6d", (int) strlen (buffer));
    145   write (Xgraph[N], buffer2, 16);
    146   write (Xgraph[N], buffer, strlen (buffer));
    147 
     80  return;
    14881}
    14982
    15083void PlotLabel (char *string, int N) {
    15184
    152   char buffer[32];
    153 
    15485  if (Xgraph[N] == 0) return;
    15586
    156   write (Xgraph[N], "LABL", 4);
    157   sprintf (buffer, " %6d %6d", (int) strlen (string), 2);
    158   write (Xgraph[N], buffer, 16);
    159   write (Xgraph[N], string, strlen (string));
     87  KapaSendLabel (Xgraph[N], string, 2);
    16088}
    16189
     
    16593  int i, Nbytes;
    16694
    167   active = N;
    16895  if (Npts < 1) return;
    16996
     
    176103  write (Xgraph[N], values, Nbytes);
    177104  free (values);
    178 
     105  return;
    179106}
    180107
Note: See TracChangeset for help on using the changeset viewer.