IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5852


Ignore:
Timestamp:
Dec 27, 2005, 3:23:01 PM (21 years ago)
Author:
eugene
Message:

substantial work to move kii/kapa call into libkapa, unify RotFont, bDraw functions

Location:
trunk/Ohana/src
Files:
58 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/kapa/Makefile

    r5703 r5852  
    2323INCS    =       -I$(INC) -I$(LINC) -I$(XINC)
    2424#LIBS   =       -L$(LLIB) $(XLIB) -lFITS -lohana -lX11 -lm
    25 LIBS    =       -L$(LLIB) $(XLIB) -lFITS -lohana -lX11 -lsocket -lnsl -lpng -lz -lm
     25LIBS    =       -L$(LLIB) $(XLIB) -lFITS -lkapa -lohana -lX11 -lsocket -lnsl -lpng -lz -lm
    2626CFLAGS  =       -o $*.$(ARCH).o $(INCS)
    2727CCFLAGS =       $(INCS) $(LIBS)
     
    5252$(GDIR)/LoadPtext.$(ARCH).o               $(GDIR)/DrawPtext.$(ARCH).o           \
    5353$(GDIR)/PSLabels.$(ARCH).o                $(GDIR)/PSPtext.$(ARCH).o             \
    54 $(GDIR)/PNGit.$(ARCH).o                   $(GDIR)/PPMit2.$(ARCH).o              \
    55 $(GDIR)/DrawRotString.$(ARCH).o           $(GDIR)/RotFont.$(ARCH).o             \
    56 $(GDIR)/PSRotFont.$(ARCH).o
     54$(GDIR)/PPMit2.$(ARCH).o                  \
    5755
    5856BDRAW = \
    59 $(GDIR)/bDrawIt.$(ARCH).o                 $(GDIR)/bDrawFuncs.$(ARCH).o          \
     57$(GDIR)/bDrawIt.$(ARCH).o                 \
    6058$(GDIR)/bDrawFrame.$(ARCH).o              $(GDIR)/bDrawLabels.$(ARCH).o         \
    61 $(GDIR)/bDrawObjects.$(ARCH).o            $(GDIR)/bDrawRotFont.$(ARCH).o        \
     59$(GDIR)/bDrawObjects.$(ARCH).o            \
    6260$(GDIR)/PNGit2.$(ARCH).o \
    6361
     
    7573$(SDIR)/GetColor.$(ARCH).o                $(SDIR)/SetWMHints.$(ARCH).o         \
    7674$(SDIR)/LoadFont.$(ARCH).o                $(SDIR)/TopWindow.$(ARCH).o          \
    77 $(SDIR)/MakeColormap.$(ARCH).o            $(SDIR)/Ximage.$(ARCH).o             \
     75$(SDIR)/Ximage.$(ARCH).o             \
    7876$(SDIR)/MakeCursor.$(ARCH).o
    7977
  • trunk/Ohana/src/kapa/event/CheckPipe.c

    r3465 r5852  
    7373 
    7474  if (!strcmp (buffer, "LIMS")) {
    75     sprintf (buffer, "LIMS: %8.1f %8.1f ",
    76              section[TheSection].axis[0].dfx, section[TheSection].axis[1].dfy);
    77     write (sock, buffer, 30);
     75    KiiSendMessage (sock, "%8.1f %8.1f ",
     76                    section[TheSection].axis[0].dfx,
     77                    section[TheSection].axis[1].dfy);
    7878    return (TRUE);
    7979  }
  • trunk/Ohana/src/kapa/event/Resize.c

    r2473 r5852  
    11# include "Ximage.h"
    2 # define SCAN \
    3   status = read (sock, buffer, 16); \
    4   buffer[16] = 0; \
    5   sscanf (buffer, "%*s %d", &Nbytes); \
    6   status = read (sock, buffer, Nbytes); \
    7   buffer[status] = 0; /* make the string easy to parse */ \
    8   (DEBUG) && fprintf (stderr, "buffer: <%s>\n", buffer); \
    9 
    102
    113int Resize () {
    124 
    13   int i, status, Nbytes;
     5  int i;
    146  unsigned int NX, NY;
    15   char buffer[128];
    167
    17   SCAN;
    18   sscanf (buffer, "%d %d", &NX, &NY);
     8  KiiScanMessage (sock, "%d %d", &NX, &NY);
    199
    2010  if ((graphic.dx == NX) && (graphic.dy == NY))
  • trunk/Ohana/src/kapa/event/SetSection.c

    r4769 r5852  
    11# include "Ximage.h"
    2 # define SCAN \
    3 status = read (sock, buffer, 16); \
    4 buffer[16] = 0; \
    5 sscanf (buffer, "%*s %d", &Nbytes); \
    6 status = read (sock, buffer, Nbytes); \
    7 buffer[status] = 0;
    82
    93int SetSection (int SwitchSection) {
    104 
    11   int i, status, Nbytes, NewSection, ThisSection, MoveSection;
    12   char buffer[128], name[128];
     5  int i, NewSection, ThisSection, MoveSection;
     6  char name[128];
    137  double x, y, dx, dy;
    148
    15   SCAN;
    16 
    179  if (SwitchSection) {
    18     sscanf (buffer, "%s", name);
     10    KiiScanMessage (sock, "%s", name);
    1911  } else {
    20     sscanf (buffer, "%s %lf %lf %lf %lf",
    21             name, &x, &y, &dx, &dy);
     12    KiiScanMessage (sock, "%s %lf %lf %lf %lf", name, &x, &y, &dx, &dy);
    2213  }   
    2314
     
    9283int ListSection () {
    9384 
    94   int i, status, Nbytes, ThisSection;
    95   char buffer[128], name[128];
     85  int i, ThisSection;
     86  char name[128];
    9687
    97   SCAN;
    98 
    99   sscanf (buffer, "%s", name);
     88  KiiScanMessage (sock, "%s", name);
    10089
    10190  if (!strcmp (name, "*")) {
  • trunk/Ohana/src/kapa/graph/DrawFrame.c

    r5610 r5852  
    66  int i, fx, fy, dfx, dfy, P, IsLabel;
    77  double range, major, minor, first, next;
     8
     9  DrawRotTextInit (graphic.display, graphic.window, graphic.gc, graphic.fore, graphic.back);
    810
    911  /* each axis is drawn independently, but ticks and labels are placed according to
  • trunk/Ohana/src/kapa/graph/DrawLabels.c

    r5386 r5852  
    1010  fontname = GetRotFont (&size);
    1111  XSetForeground (graphic.display, graphic.gc, graphic.fore);
     12  DrawRotTextInit (graphic.display, graphic.window, graphic.gc, graphic.fore, graphic.back);
    1213
    1314  /* each label is drawn independently */
  • trunk/Ohana/src/kapa/graph/DrawPtext.c

    r4769 r5852  
    99  fontname = GetRotFont (&size);
    1010  XSetForeground (graphic.display, graphic.gc, graphic.fore);
     11  DrawRotTextInit (graphic.display, graphic.window, graphic.gc, graphic.fore, graphic.back);
    1112
    1213  for (i = 0; i < layout[0].Nptext; i++) {
  • trunk/Ohana/src/kapa/graph/LoadBox.c

    r5612 r5852  
    11# include "Ximage.h"
    2 # define SCAN \
    3 status = read (sock, buffer, 16); \
    4 buffer[16] = 0; \
    5 sscanf (buffer, "%*s %d", &Nbytes); \
    6 status = read (sock, buffer, Nbytes); \
    7 buffer[status] = 0;
    82
    93int LoadBox () {
    104 
    11   int i, status, Nbytes;
    12   char buffer[128], Axis[16], Labels[16], Ticks[16];
     5  int i, status;
     6  char Axis[16], Labels[16], Ticks[16];
    137  Layout *layout;
    148 
    159  layout = &section[TheSection];
    1610
    17   SCAN;
    18   sscanf (buffer, "%lf %lf %lf %lf",
    19           &layout[0].axis[0].min, &layout[0].axis[0].max,
    20           &layout[0].axis[1].min, &layout[0].axis[1].max);
     11  KiiScanMessage (sock, "%lf %lf %lf %lf",
     12                  &layout[0].axis[0].min, &layout[0].axis[0].max,
     13                  &layout[0].axis[1].min, &layout[0].axis[1].max);
    2114
    2215  layout[0].axis[3].min = layout[0].axis[1].min;
     
    2518  layout[0].axis[2].max = layout[0].axis[0].max;
    2619 
    27   SCAN;
    28   sscanf (buffer, "%s %s %s", Axis, Labels, Ticks);
     20  KiiScanMessage (sock, "%s %s %s", Axis, Labels, Ticks);
    2921
    3022  for (i = 0; i < 4; i++) {
     
    8375  layout[0].X = 0;
    8476  layout[0].Y = 0;
    85    layout[0].expand = 1;
     77  layout[0].expand = 1;
    8678*/
    8779 
  • trunk/Ohana/src/kapa/graph/LoadLabels.c

    r2473 r5852  
    33int LoadLabels () {
    44 
    5   char buffer[256], *c;
    6   int status, Nbytes, mode, size;
     5  char *c, *label;
     6  int mode, size, Nbytes;
    77  Layout *layout;
    88 
     
    1111  fcntl (sock, F_SETFL, !O_NONBLOCK); 
    1212 
    13   status = read (sock, buffer, 16);
    14   buffer[16] = 0;
    15   sscanf (buffer, "%d %d", &Nbytes, &mode);
     13  KiiScanMessage (sock, "%d", &mode);
     14  label = KiiRecvData (sock);
    1615
    17   status = read (sock, buffer, Nbytes);
    18   buffer[status] = 0;
    19 
    20   strncpy (layout[0].label[mode].text, buffer, Nbytes);
    21   layout[0].label[mode].text[Nbytes] = 0;
     16  Nbytes = MIN (strlen(label), 127);
     17  strncpy (layout[0].label[mode].text, label, Nbytes);
     18  label[Nbytes] = 0;
    2219
    2320  fcntl (sock, F_SETFL, O_NONBLOCK); 
  • trunk/Ohana/src/kapa/graph/LoadObject.c

    r5612 r5852  
    11# include "Ximage.h"
    2 # include <unistd.h>
    32# include <errno.h>
    4 
    5 # define SCAN \
    6 status = read (sock, buffer, 16); \
    7 buffer[16] = 0; \
    8 sscanf (buffer, "%*s %d", &Nbytes); \
    9 status = read (sock, buffer, Nbytes); \
    10 buffer[status] = 0;
    113
    124int LoadObject () {
    135 
    14   char buffer[1024];
    15   int status, N, Nbytes;
     6  int N;
    167  Layout *layout;
    178
     
    2718  layout[0].objects[N].dym = layout[0].objects[N].dyp = (float *) NULL;
    2819 
    29   SCAN;
    30   sscanf (buffer, "%d %d %d %d %d %d %d %lf %lf",
    31           &layout[0].objects[N].Npts, &layout[0].objects[N].style,
    32           &layout[0].objects[N].ptype, &layout[0].objects[N].ltype,
    33           &layout[0].objects[N].etype, &layout[0].objects[N].ebar,
    34           &layout[0].objects[N].color,
    35           &layout[0].objects[N].lweight, &layout[0].objects[N].size);
     20  KiiScanMessage (sock, "%d %d %d %d %d %d %d %lf %lf",
     21                  &layout[0].objects[N].Npts, &layout[0].objects[N].style,
     22                  &layout[0].objects[N].ptype, &layout[0].objects[N].ltype,
     23                  &layout[0].objects[N].etype, &layout[0].objects[N].ebar,
     24                  &layout[0].objects[N].color,
     25                  &layout[0].objects[N].lweight, &layout[0].objects[N].size);
    3626 
    3727  if (DEBUG) fprintf (stderr, "%d %d %d %d %d %d %d %lf %lf\n",
    38           layout[0].objects[N].Npts, layout[0].objects[N].style,
    39           layout[0].objects[N].ptype, layout[0].objects[N].ltype,
    40           layout[0].objects[N].etype, layout[0].objects[N].ebar,
    41           layout[0].objects[N].color,
    42           layout[0].objects[N].lweight, layout[0].objects[N].size);
     28                      layout[0].objects[N].Npts, layout[0].objects[N].style,
     29                      layout[0].objects[N].ptype, layout[0].objects[N].ltype,
     30                      layout[0].objects[N].etype, layout[0].objects[N].ebar,
     31                      layout[0].objects[N].color,
     32                      layout[0].objects[N].lweight, layout[0].objects[N].size);
    4333 
    4434  /* force valid ranges */
    45   if ((layout[0].objects[N].color > GetColormapSize()) || (layout[0].objects[N].color < 0))
     35  if ((layout[0].objects[N].color > KapaColormapSize()) || (layout[0].objects[N].color < 0))
    4636    layout[0].objects[N].color = 0;
    4737
    48   SCAN;
    49   sscanf (buffer, "%lf %lf %lf %lf",
    50           &layout[0].objects[N].x0, &layout[0].objects[N].x1,
    51           &layout[0].objects[N].y0, &layout[0].objects[N].y1);
     38  KiiScanMessage (sock, "%lf %lf %lf %lf",
     39                  &layout[0].objects[N].x0, &layout[0].objects[N].x1,
     40                  &layout[0].objects[N].y0, &layout[0].objects[N].y1);
    5241 
    5342  fcntl (sock, F_SETFL, O_NONBLOCK); 
  • trunk/Ohana/src/kapa/graph/PNGit2.c

    r5610 r5852  
    11# include "Ximage.h"
    2 # include <png.h>
    3 # include "bDraw.h"
    42
    53int PNGit () {
     
    5856  /* png_set_IHDR (png_ptr, info_ptr, graphic.dx, graphic.dy, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); */
    5957
    60   palette = MakePNGPalette (&Npalette);
     58  palette = KapaPNGPalette (&Npalette);
    6159  png_set_PLTE (png_ptr, info_ptr, palette, Npalette);
    6260 
  • trunk/Ohana/src/kapa/graph/PPMit2.c

    r5703 r5852  
    11# include "Ximage.h"
    2 # include <png.h>
    3 # include "bDraw.h"
    42
    53int PPMit () {
     
    2523  }
    2624 
    27   palette = MakePNGPalette (&Npalette);
     25  palette = KapaPNGPalette (&Npalette);
    2826
    2927  dx = graphic.dx;
  • trunk/Ohana/src/kapa/graph/PSObjects.c

    r4769 r5852  
    111111    lweight = MAX (0, MIN (10, layout[0].objects[i].lweight));
    112112    fprintf (f, "%.1f setlinewidth\n", lweight);
    113     fprintf (f, "%s setrgbcolor\n", GetRGBString(layout[0].objects[i].color));
     113    fprintf (f, "%s setrgbcolor\n", KapaColorRGBString(layout[0].objects[i].color));
    114114
    115115    switch (layout[0].objects[i].style) {
  • trunk/Ohana/src/kapa/graph/SetLimits.c

    r2473 r5852  
    11# include "Ximage.h"
    2 # define SCAN \
    3 status = read (sock, buffer, 16); \
    4 buffer[16] = 0; \
    5 sscanf (buffer, "%*s %d", &Nbytes); \
    6 status = read (sock, buffer, Nbytes); \
    7 buffer[status] = 0;
    82
    93int SetLimits () {
    104 
    11   int i, status, Nbytes;
    12   char buffer[128];
     5  int i;
    136  double xmin, xmax, ymin, ymax;
    147  Layout *layout;
     
    169  layout = &section[TheSection];
    1710
    18   SCAN;
    19   sscanf (buffer, "%lf %lf %lf %lf", &xmin, &xmax, &ymin, &ymax);
     11  KiiScanMessage (sock, "%lf %lf %lf %lf", &xmin, &xmax, &ymin, &ymax);
    2012
    2113  layout[0].axis[2].min = layout[0].axis[0].min = xmin;
  • trunk/Ohana/src/kapa/graph/bDrawFrame.c

    r5612 r5852  
    11# include "Ximage.h"
    2 # include "bDraw.h"
    32
    43int bDrawFrame (Layout *layout) {
  • trunk/Ohana/src/kapa/graph/bDrawFuncs.c

    r5612 r5852  
    1313  bDrawBuffer *buffer;
    1414
    15   white = GetColorByName ("white");
     15  white = KapaColorByName ("white");
    1616
    1717  ALLOCATE (buffer, bDrawBuffer, 1);
  • trunk/Ohana/src/kapa/graph/bDrawIt.c

    r5610 r5852  
    11# include "Ximage.h"
    2 # include "bDraw.h"
    32
    43bDrawBuffer *bDrawIt () {
     
    87  bDrawColor black;
    98
    10   black = GetColorByName ("black");
     9  black = KapaColorByName ("black");
    1110
    1211  buffer = bDrawBufferCreate (graphic.dx, graphic.dy);
  • trunk/Ohana/src/kapa/graph/bDrawLabels.c

    r5610 r5852  
    11# include "Ximage.h"
    2 # include "bDraw.h"
    32 
    43void bDrawLabels (Layout *layout) {
  • trunk/Ohana/src/kapa/graph/bDrawObjects.c

    r5612 r5852  
    11# include "Ximage.h"
    2 # include "bDraw.h"
    32
    43# define DrawLine(X1,Y1,X2,Y2) (bDrawLine ((X1), (Y1), (X2), (Y2)))
     
    2019  bDrawColor black;
    2120 
    22   black = GetColorByName ("black");
     21  black = KapaColorByName ("black");
    2322  for (i = 0; i < layout[0].Nobjects; i++) {
    2423
  • trunk/Ohana/src/kapa/graph/bDrawRotFont.c

    r5612 r5852  
    2020  RotFont *currentfont;
    2121
    22   white = GetColorByName ("white");
    23   black = GetColorByName ("black");
     22  white = KapaColorByName ("white");
     23  black = KapaColorByName ("black");
    2424
    2525  currentname = GetRotFont (&currentsize);
  • trunk/Ohana/src/kapa/include/Ximage.h

    r5242 r5852  
    11# include <Xohana.h>
    2 # include <fitsio.h>
     2# include <dvo.h>
     3# include <kapa.h>
    34# include "constants.h"
    45# include "structures.h"
  • trunk/Ohana/src/kapa/include/bDraw.h

    r5612 r5852  
     1# ifndef BDRAW_H
     2# define BDRAW_H
     3
    14# include <png.h>
    25
     
    4952int bDrawRotBitmap (int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale);
    5053
     54# endif
  • trunk/Ohana/src/kapa/include/globals.h

    r5612 r5852  
    55int MAP_WINDOW;
    66int FOREGROUND;
     7char *NAME_WINDOW;
    78
    89/* file descriptor for socket connection to mana */
  • trunk/Ohana/src/kapa/include/prototypes.h

    r5611 r5852  
    6464int           remove_argument     PROTO((int, int *, char **));
    6565
    66 RotFont *GetRotFontData (double *scale);
    67 int SetRotFont PROTO((char *name, int size));
    68 void InitRotFonts PROTO(());
    69 int DrawRotText PROTO((int x, int y, char *string, int pos, double angle));
    70 int DrawRotBitmap PROTO((int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale));
    71 char *GetRotFont PROTO((int *size));
    72 int RotStrlen PROTO((char *c));
    73 void PSRotText PROTO((FILE *f, int x, int y, char *string, int pos, double angle));
    74 void PSDumpRotSegment PROTO((FILE *f, char *segment, int *Nseg));
    75 void PSSetFont PROTO((FILE *f, char *name, int size));
    7666void MakeGC ();
    7767
    7868int EventLoop ();
    7969void CloseDisplay ();
     70int args (int *argc, char **argv);
    8071
    8172void DrawPtext (Layout *layout);
     
    8778void PSPtext (Layout *layout, FILE *f);
    8879void PSTick (FILE *f, double fx, double fy, double dfx, double dfy, int P, double min, double max, double value, int mode, int naxis);
     80
     81/* kapa bDraw Functions */
     82int bDrawObjects (Layout *layout);
     83void bDrawConnect (Layout *layout, Gobjects *object);
     84void bDrawClipLine (double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0);
     85void bDrawHistogram (Layout *layout, Gobjects *object);
     86void bDrawPoints (Layout *layout, Gobjects *object);
     87void bDrawXErrors (Layout *layout, Gobjects *object);
     88void bDrawYErrors (Layout *layout, Gobjects *object);
     89
     90int bDrawFrame (Layout *layout);
     91void bDrawTick (double fx, double fy, double dfx, double dfy, int P, double min, double max, double value, int mode, int naxis);
     92void bDrawLabels (Layout *layout);
     93void bDrawPtext (Layout *layout);
     94
     95bDrawBuffer *bDrawIt ();
    8996
    9097/******************* XGRAPH **
  • trunk/Ohana/src/kapa/include/structures.h

    r5611 r5852  
    8888} Overlay;
    8989 
     90# if (0)
    9091typedef struct {
    9192  char      ctype[16];
     
    9596  double    pc2_1, pc2_2;
    9697} Coords;
     98# endif
    9799
    98100typedef struct {
     
    110112  char label[64];
    111113} Axis;
    112 
    113 typedef struct {
    114   int dx, dy, ascent;
    115   unsigned char *bits;
    116 } RotFont;
    117 
    118 typedef struct {
    119   RotFont *font;
    120   char name[64];
    121   int size;
    122 } FontSet;
    123114
    124115/******** Here we define the Layout struct specific to this program  *******/
  • trunk/Ohana/src/kapa/setup/DefineLayout.c

    r5612 r5852  
    55void DefineLayout (int argc, char **argv) {
    66
    7   int i, status, N;
    8   struct sockaddr_un Address;
    9   char temp[100];
     7  int i;
    108 
    119  /** initiate connection with server **/
     
    1513      exit (0);
    1614    }
    17     strcpy (Address.sun_path, argv[1]);
    18     Address.sun_family = AF_UNIX;
    19     sock = socket (AF_UNIX, SOCK_STREAM, 0);
    20     status = connect (sock, (struct sockaddr *) &Address, sizeof (Address));
    21     if (status < 0) {
    22       fprintf (stderr, "kapa - unsuccessful connection: %d\n", status);
    23       exit (0);
    24     }
    25     fcntl (sock, F_SETFL, O_NONBLOCK); 
    26     sprintf (temp, "rm -f %s", argv[1]);
    27     system (temp);
     15    sock = KiiWait (argv[1]);
    2816  }
    2917
  • trunk/Ohana/src/kapa/setup/SetUpWindow.c

    r5612 r5852  
    55void SetUpWindow (int *argc, char **argv) {
    66
    7   int N;
    87  Icon icon;
     8  char *name;
     9  int Ncolors;
    910
    1011  icon.width = icon_width;
     
    2122  SetNormalHints ();
    2223  SetWMHints (&icon);
    23   NameWindow ("Kapa");
    2424
    25   MakeColormap (*argc, argv);  /* move to SetUpWindow? */
     25  if (NAME_WINDOW == NULL) {
     26    NameWindow ("Kapa");
     27  } else {
     28    ALLOCATE (name, char, strlen(NAME_WINDOW) + 10);
     29    sprintf (name, "Kapa %s", NAME_WINDOW);
     30    NameWindow (name);
     31    free (name);
     32  }
    2633
     34  graphic.color = KapaX11colors (graphic.display, graphic.colormap, graphic.fore, &Ncolors);
    2735  if (MAP_WINDOW) MapWindow (graphic);
    2836  return;
  • trunk/Ohana/src/kapa/setup/args.c

    r5612 r5852  
    99    remove_argument(N, argc, argv);
    1010    MAP_WINDOW = FALSE;
     11  }
     12
     13  NAME_WINDOW = NULL;
     14  if ((N = get_argument (*argc, argv, "-name"))) {
     15    remove_argument(N, argc, argv);
     16    NAME_WINDOW = strcreate (argv[N]);
     17    remove_argument(N, argc, argv);
    1118  }
    1219
  • trunk/Ohana/src/kii/Makefile

    r5700 r5852  
    2121#
    2222INCS    =       -I$(INC) -I$(LINC) -I$(XINC)
    23 LIBS    =       -L$(LLIB) $(XLIB) -ldvo -lFITS -lohana -ljpeg -lX11 -lsocket -lnsl -lm
     23LIBS    =       -L$(LLIB) $(XLIB) -ldvo -lFITS -lkapa -lohana -ljpeg -lX11 -lsocket -lnsl -lm
    2424# LIBS  =       -L$(LLIB) $(XLIB) -lohana -lFITS -ljpeg -lX11 -lsocket -lnsl -lm -static
    2525CFLAGS  =       -o $*.$(ARCH).o $(INCS)
     
    5252$(ODIR)/DrawOverlay.$(ARCH).o             $(ODIR)/CSaveOverlay.$(ARCH).o       \
    5353$(ODIR)/PaintTickmarks.$(ARCH).o          $(ODIR)/LoadTickmarks.$(ARCH).o      \
    54 $(ODIR)/bDrawColormap.$(ARCH).o           $(ODIR)/bDrawOverlay.$(ARCH).o       \
    55 $(ODIR)/bDrawFuncs.$(ARCH).o              $(ODIR)/bDrawRotFont.$(ARCH).o       \
    56 $(ODIR)/RotFont.$(ARCH).o
    57 
     54$(ODIR)/bDrawOverlay.$(ARCH).o
    5855
    5956POBJ = \
  • trunk/Ohana/src/kii/button/PSit.c

    r5701 r5852  
    246246  int i, k, m, val;
    247247  double Nchar, Npix, start, slope, frac;
    248   char *buff;
     248  unsigned char *buff;
    249249
    250250  Nchar = 255.0;
     
    318318  extra = 4 - (dx * 3) % 4;
    319319  /* start at the last line, print lines in decending order */
    320   buff = &layout[0].picture.data[(dy - 1)*(3*dx + extra)];
     320  buff = (unsigned char *)&layout[0].picture.data[(dy - 1)*(3*dx + extra)];
    321321  slope = layout[0].slope;
    322322  start = layout[0].start;
  • trunk/Ohana/src/kii/colorbar/CreateColorbar.c

    r2466 r5852  
    2828  case 16:
    2929    REALLOCATE (layout[0].cmapbar.data, char, 2*dy*dx);
    30     out8 = layout[0].cmapbar.data;
     30    out8 = (unsigned char *) layout[0].cmapbar.data;
    3131    for (i = 0; i < dx; i++) {
    3232      pixvalue = layout[0].cmap[(int)(i*layout[0].Npixels/dx)].pixel;
     
    4444    extra = 4 - (dx * 3) % 4;
    4545    REALLOCATE (layout[0].cmapbar.data, char, dy*(3*dx + extra));
    46     out8 = layout[0].cmapbar.data;
     46    out8 = (unsigned char *) layout[0].cmapbar.data;
    4747    for (i = 0; i < dx; i++) {
    4848      pixvalue = layout[0].cmap[(int)(i*layout[0].Npixels/dx)].pixel;
  • trunk/Ohana/src/kii/include/Ximage.h

    r3463 r5852  
    11# include <Xohana.h>
    22# include <dvo.h>
     3# include <kapa.h>
    34# include "constants.h"
    45# include "structures.h"
  • trunk/Ohana/src/kii/include/bDraw.h

    r5700 r5852  
    5050int bDrawRotBitmap (int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale);
    5151
     52void bDrawOverlay (Layout *layout, int N);
  • trunk/Ohana/src/kii/include/constants.h

    r5849 r5852  
    2525int DECIMAL_DEG;
    2626int DEBUG;
     27int FOREGROUND;
    2728int USE_XWINDOW;
    2829int MAP_WINDOW;
  • trunk/Ohana/src/kii/include/prototypes.h

    r5849 r5852  
    1 RotFont *GetRotFontData (double *scale);
    2 int SetRotFont PROTO((char *name, int size));
    3 void InitRotFonts PROTO(());
    4 int DrawRotText PROTO((int x, int y, char *string, int pos, double angle));
    5 int DrawRotBitmap PROTO((int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale));
    6 char *GetRotFont PROTO((int *size));
    7 int RotStrlen PROTO((char *c));
    8 void PSRotText PROTO((FILE *f, int x, int y, char *string, int pos, double angle));
    9 void PSDumpRotSegment PROTO((FILE *f, char *segment, int *Nseg));
    10 void PSSetFont PROTO((FILE *f, char *name, int size));
     1
     2int args (int *argc, char **argv);
     3
     4void bDrawOverlay (Layout *layout, int N);
    115
    126int SetColormap (Graphic *graphic, Layout *layout, char *name);
  • trunk/Ohana/src/kii/include/structures.h

    r5700 r5852  
    6767  int      dx, dy, x, y;
    6868  XImage  *pix;
    69   char    *data;
     69  char *data;
    7070} Picture;
    7171
     
    124124} Layout;
    125125
    126 typedef struct {
    127   int dx, dy, ascent;
    128   unsigned char *bits;
    129 } RotFont;
    130 
    131 typedef struct {
    132   RotFont *font;
    133   char name[64];
    134   int size;
    135 } FontSet;
    136 
    137126/* this routine is independent of the number of overlays */
    138127
  • trunk/Ohana/src/kii/overlay/bDrawColormap.c

    r5700 r5852  
    11# include "Ximage.h"
    2 # include "bDraw.h"
    32
    43/* this list must match the one in mana/include/package.h, and equiv
  • trunk/Ohana/src/kii/overlay/bDrawFrame.c

    r5700 r5852  
    11# include "Ximage.h"
    2 # include "bDraw.h"
    32
    43int bDrawFrame (Layout *layout) {
  • trunk/Ohana/src/kii/overlay/bDrawFuncs.c

    r5700 r5852  
    11# include "Ximage.h"
    2 # include "bDraw.h"
    32
    43static int bWeight;
  • trunk/Ohana/src/kii/overlay/bDrawOverlay.c

    r5700 r5852  
    11# include "Ximage.h"
    2 # include "bDraw.h"
    32# define INFRONT 4
    43
     
    1413 
    1514  /* translate color to bDrawColors : layout[0].overlay[N].color */
    16   color = GetColorByName (name[N]);
     15  color = KapaColorByName (name[N]);
    1716  bDrawSetStyle (color, 0, 0);
    1817 
  • trunk/Ohana/src/kii/overlay/bDrawRotFont.c

    r5700 r5852  
    11# include "Ximage.h"
    2 # include "bDraw.h"
    32
    43# define NROTCHARS 256
  • trunk/Ohana/src/kii/picture/CreatePicture.c

    r2466 r5852  
    44
    55  int i, j, extra;
    6   char *c;
     6  unsigned char *c;
    77  unsigned int *l;
    88  unsigned int start, start1, start2, start3;
     
    1313  case 8:
    1414    REALLOCATE (layout[0].picture.data, char, layout[0].picture.dx*layout[0].picture.dy);
    15     c = layout[0].picture.data;
     15    c = (unsigned char *) layout[0].picture.data;
    1616    for (i = 0; i < (layout[0].picture.dx*layout[0].picture.dy); i++, c++)
    1717      *c = start;
     
    2222  case 16:
    2323    REALLOCATE (layout[0].picture.data, char, 2*layout[0].picture.dy*layout[0].picture.dx);
    24     c = layout[0].picture.data;
     24    c = (unsigned char *) layout[0].picture.data;
    2525    start1 = 0x0000ff & (start);
    2626    start2 = 0x0000ff & (start >> 8);
  • trunk/Ohana/src/kii/picture/JPEGit24.c

    r5700 r5852  
    11# include "Ximage.h"
    22# include "jpeglib.h"
    3 # include <png.h>
    4 # include "bDraw.h"
    53
    64# define WHITE_R 255
     
    1816  int ii, i, j;
    1917  int i_start, i_end, j_start, j_end;
    20   int dropback, extra;  /* this is a bit of a kludge... */
     18  int dropback;  /* this is a bit of a kludge... */
    2119  int dx, dy, DX, DY;
    2220  int status, Nbytes, quality;
     
    194192    bDrawBuffer *buffer;
    195193
    196     palette = MakePNGPalette (&Npalette);
     194    palette = KapaPNGPalette (&Npalette);
    197195
    198196    buffer = bDrawBufferCreate (dx, dy);
     
    202200    }
    203201
    204     white = GetColorByName ("white");
     202    white = KapaColorByName ("white");
    205203    for (j = 0; j < dy; j++) {
    206204      for (i = 0; i < dx; i++) {
  • trunk/Ohana/src/kii/picture/NewPicture.c

    r5700 r5852  
    11# include "Ximage.h"
    2 # define SCAN \
    3   status = read (layout[0].Ximage, buffer, 16); \
    4   buffer[16] = 0; \
    5   sscanf (buffer, "%*s %d", &Nbytes); \
    6   status = read (layout[0].Ximage, buffer, Nbytes); \
    7   buffer[status] = 0; /* make the string easy to parse */ \
    8   (DEBUG) && fprintf (stderr, "buffer: <%s>\n", buffer); \
    92
    103int NewPicture (Graphic *graphic, Layout *layout) {
    114
    125  Header header;
    13   char buffer[1024], *buff;
    14   int status, bytes_left, Nbytes;
     6  char *buff;
     7  int status, bytes_left, socket;
    158 
    16   fits_free_matrix (&layout[0].matrix);
    17   sprintf (buffer, "NCOLOR: %6d ", layout[0].Npixels);
    18   write (layout[0].Ximage, buffer, 16);
     9  socket = layout[0].Ximage;
    1910
    20   fcntl (layout[0].Ximage, F_SETFL, !O_NONBLOCK); 
     11  KiiSendMessage (socket, "%d", layout[0].Npixels);
     12
     13  fcntl (socket, F_SETFL, !O_NONBLOCK); 
    2114
    2215  header.Naxes = 2;
    23   SCAN;
    24   sscanf (buffer, "%d %d %d %d %lf %lf",
    25           &header.Naxis[0], &header.Naxis[1], &header.bitpix,
    26           &header.unsign,   &header.bzero,    &header.bscale);
    2716
    28   SCAN;
    29   sscanf (buffer, "%lf %lf %lf %lf %d", &layout[0].zero, &layout[0].range, &layout[0].min,  &layout[0].max, &header.size);
     17  KiiScanMessage (socket, "%d %d %d %d %lf %lf", &header.Naxis[0], &header.Naxis[1]);
     18  KiiScanMessage (socket, "%d %d %d %d %lf %lf", &header.bitpix, &header.unsign, &header.bzero, &header.bscale);
     19  KiiScanMessage (socket, "%lf %lf",  &layout[0].zero, &layout[0].range);
     20  KiiScanMessage (socket, "%lf %lf %d", &layout[0].min,  &layout[0].max, &header.size);
     21  KiiScanMessage (socket, "%lf %f %f %f %f", &layout[0].coords.crval1, &layout[0].coords.crpix1, &layout[0].coords.cdelt1, &layout[0].coords.pc1_1, &layout[0].coords.pc1_2);
     22  KiiScanMessage (socket, "%lf %f %f %f %f", &layout[0].coords.crval2, &layout[0].coords.crpix2, &layout[0].coords.cdelt2, &layout[0].coords.pc2_1, &layout[0].coords.pc2_2);
     23         
     24  KiiScanMessage (socket, "%s %s %s", layout[0].coords.ctype, layout[0].file, layout[0].buffer_name);
    3025
    31   SCAN;
    32   sscanf (buffer, "%lf %f %f %f %f", &layout[0].coords.crval1, &layout[0].coords.crpix1, &layout[0].coords.cdelt1, &layout[0].coords.pc1_1, &layout[0].coords.pc1_2);
    33          
    34   SCAN;
    35   sscanf (buffer, "%lf %f %f %f %f", &layout[0].coords.crval2, &layout[0].coords.crpix2, &layout[0].coords.cdelt2, &layout[0].coords.pc2_1, &layout[0].coords.pc2_2);
    36          
    37   SCAN;
    38   sscanf (buffer, "%s %s %s", layout[0].coords.ctype, layout[0].file, layout[0].buffer_name);
    39 
     26  fits_free_matrix (&layout[0].matrix);
    4027  fits_create_matrix (&header, &layout[0].matrix);
    4128
    42   fcntl (layout[0].Ximage, F_SETFL, O_NONBLOCK); 
     29  fcntl (socket, F_SETFL, O_NONBLOCK); 
    4330
    4431  status = 1;
     
    4734  layout[0].matrix.size = 0;
    4835  while (bytes_left > 0) {
    49     status = read (layout[0].Ximage, buff, bytes_left);
     36    status = read (socket, buff, bytes_left);
    5037    if (status == 0) {  /* No more pipe */
    5138      fprintf (stderr, "error: pipe closed\n");
     
    5946  }
    6047
    61   (DEBUG) && fprintf (stderr, "read %d bytes\n", layout[0].matrix.size);
     48  if (DEBUG) fprintf (stderr, "read %d bytes\n", layout[0].matrix.size);
    6249  /* it it not obvious this condition should kill kii, but ... */
    6350  if (layout[0].matrix.size != header.size) { 
     
    6956
    7057  Remap (graphic, layout, &layout[0].matrix);
    71   (DEBUG) && fprintf (stderr, "remapped image\n");
     58  if (DEBUG) fprintf (stderr, "remapped image\n");
    7259  Refresh (graphic, layout, 0);
    73   (DEBUG) && fprintf (stderr, "refreshed\n");
     60  if (DEBUG) fprintf (stderr, "refreshed\n");
    7461  XFlush (graphic[0].display);
    7562
  • trunk/Ohana/src/kii/picture/Remap8.c

    r5386 r5852  
    6868  if ((i_end - i_start) % expand_out == 0) dropback = 0;
    6969
    70   out_pix = layout[0].picture.data;
    71   in_pix  = (unsigned char *) (matrix[0].buffer) + DX*(int)MAX(Y,0) + (int)MAX(X,0);
     70  out_pix = (unsigned char *) layout[0].picture.data;
     71  in_pix  = (unsigned char *) matrix[0].buffer + DX*(int)MAX(Y,0) + (int)MAX(X,0);
    7272
    7373  /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/
  • trunk/Ohana/src/kii/picture/Resize.c

    r5700 r5852  
    11# include "Ximage.h"
    2 # define SCAN \
    3   status = read (layout[0].Ximage, buffer, 16); \
    4   buffer[16] = 0; \
    5   sscanf (buffer, "%*s %d", &Nbytes); \
    6   status = read (layout[0].Ximage, buffer, Nbytes); \
    7   buffer[status] = 0; /* make the string easy to parse */ \
    8   (DEBUG) && fprintf (stderr, "buffer: <%s>\n", buffer); \
    9 
    102
    113int Resize (Graphic *graphic, Layout *layout) {
    124 
    13   int status, Nbytes;
    145  unsigned int NX, NY;
    15   char buffer[128];
    166
    17   SCAN;
    18   sscanf (buffer, "%d %d", &NX, &NY);
     7  KiiScanMessage (layout[0].Ximage, "%d %d", &NX, &NY);
    198
    209  NX += ZOOM_X + 3*PAD1 + 25;
  • trunk/Ohana/src/kii/setup/CheckVisual.c

    r5700 r5852  
    11# include "Ximage.h"
    22# define NPIXELS 64
    3 # define DEBUG 1
    43
    54/* DirectColor doesn't seem to work, even though it is available:
     
    195194    }
    196195  }
    197  
    198 
    199196}
    200 
  • trunk/Ohana/src/kii/setup/DefineLayout.c

    r5700 r5852  
    55void DefineLayout (Layout *layout, Graphic *graphic, int argc, char **argv) {
    66
    7   int i, status, N;
    8   struct sockaddr_un Address;
    9   char temp[100], *temp_name;
     7  int i, N;
     8  char *colormap;
    109
    1110  /** initiate connection with mana **/
    12   if (!DEBUG) {
     11  if (!FOREGROUND) {
    1312    if (argc < 2) {
    1413      fprintf (stderr, "socket path not specified\n");
    1514      exit (0);
    1615    }
    17     strcpy (Address.sun_path, argv[1]);
    18     Address.sun_family = AF_UNIX;
    19     layout[0].Ximage = socket (AF_UNIX, SOCK_STREAM, 0);
    20     status = connect (layout[0].Ximage, (struct sockaddr *) &Address, (socklen_t) sizeof (Address));
    21     if (status < 0) {
    22       fprintf (stderr, "kii - unsuccessful connection: %d\n", status);
    23       exit (0);
    24     }
    25     fcntl (layout[0].Ximage, F_SETFL, O_NONBLOCK); 
    26     sprintf (temp, "rm -f %s", argv[1]);
    27     system (temp);
     16    layout[0].Ximage = KiiWait (argv[1]);
    2817  }
    2918
     
    3423    MakeColormap (graphic, layout, argc, argv);
    3524  } else {
    36     temp_name = default_colormap;
     25    colormap = default_colormap;
    3726    if ((N = get_argument (argc, argv, "-cm"))) {
    3827      remove_argument (N, &argc, argv);
    39       temp_name = argv[N];
     28      colormap = argv[N];
    4029    }
    4130    layout[0].Npixels = 256;
    42     SetColormap (graphic, layout, temp_name);
     31    SetColormap (graphic, layout, colormap);
    4332  }
    4433
     
    7059}
    7160
    72 
    7361/* this routine is independent of the number of overlays */
    7462
    7563  /* cmap = the mapping of value to color in kii
    7664     colormap = the set of pixel -> color representation in X */
    77 
  • trunk/Ohana/src/kii/setup/SetUpWindow.c

    r5849 r5852  
    55void SetUpWindow (Graphic *graphic, int *argc, char **argv) {
    66
    7   int N;
    87  Icon icon;
    98  char *name;
  • trunk/Ohana/src/kii/setup/args.c

    r5849 r5852  
    2424  }
    2525
     26  DEBUG = FALSE;
    2627  if ((N = get_argument (*argc, argv, "-debug"))) {
    2728    remove_argument(N, argc, argv);
    2829    DEBUG = TRUE;
    29   } else {
    30     DEBUG = FALSE;
     30  }
     31
     32  FOREGROUND = FALSE;
     33  if ((N = get_argument (*argc, argv, "-fg"))) {
     34    remove_argument(N, argc, argv);
     35    FOREGROUND = TRUE;
    3136  }
    3237
  • trunk/Ohana/src/libkapa/Makefile

    r5848 r5852  
    2727$(SRC)/KiiOverlay.$(ARCH).o \
    2828$(SRC)/KiiCursor.$(ARCH).o \
    29 $(SRC)/KiiConvert.$(ARCH).o
     29$(SRC)/KiiConvert.$(ARCH).o \
     30$(SRC)/KapaWindow.$(ARCH).o \
     31$(SRC)/KapaColors.$(ARCH).o
    3032
    31 # $(SRC)/KiiTickmarks.$(ARCH).o
     33DRAW = \
     34$(SRC)/bDrawFuncs.$(ARCH).o     \
     35$(SRC)/bDrawRotFont.$(ARCH).o   \
     36$(SRC)/RotFont.$(ARCH).o        \
     37$(SRC)/DrawRotString.$(ARCH).o  \
     38$(SRC)/PSRotFont.$(ARCH).o
    3239
    3340$(OBJS): $(INCS)
     41$(DRAW): $(INCS)
    3442
    3543$(DESTLIB)/libkapa.a: $(LIB)/libkapa.$(ARCH).a
     
    3846        cp $(LIB)/libkapa.$(ARCH).a $(DESTLIB)/libkapa.a
    3947
    40 $(LIB)/libkapa.$(ARCH).a: $(OBJS)
     48$(LIB)/libkapa.$(ARCH).a: $(OBJS) $(DRAW)
    4149        @if [ ! -d $(LIB) ]; then mkdir -p $(LIB); fi
    4250        rm -f $(LIB)/libkapa.$(ARCH).a
    43         ar rcv $(LIB)/libkapa.$(ARCH).a $(OBJS)
     51        ar rcv $(LIB)/libkapa.$(ARCH).a $(OBJS) $(DRAW)
    4452        $(RANLIB) $(LIB)/libkapa.$(ARCH).a
    4553
  • trunk/Ohana/src/libkapa/include/kapa.h

    r5848 r5852  
    11# ifndef KAPA_H
    22# define KAPA_H
     3
     4# include <X11/Xlib.h>
     5# include <png.h>
    36
    47typedef struct {
     
    3437} KiiOverlayType;
    3538
     39typedef struct {
     40  char *name;
     41  float x;
     42  float y;
     43  float dx;
     44  float dy;
     45} KapaSection;
     46
     47typedef struct {
     48  double xmin, xmax, ymin, ymax;
     49  int style, ptype, ltype, etype, ebar, color;
     50  double lweight, size;
     51  Coords coords;
     52  int flipeast, flipnorth;
     53  char axis[8], labels[8], ticks[8];
     54} Graphdata;
     55
     56typedef struct {
     57  int dx, dy, ascent;
     58  unsigned char *bits;
     59} RotFont;
     60
     61typedef struct {
     62  RotFont *font;
     63  char name[64];
     64  int size;
     65} FontSet;
     66
     67typedef png_byte bDrawColor;
     68
     69typedef struct {
     70  int Nx, Ny;
     71  bDrawColor **pixels;
     72} bDrawBuffer;
     73
    3674/* IOfuncs.c */
    3775int KiiSendMessage (int device, char *format, ...);
    3876int KiiSendCommand (int device, int length, char *format, ...);
    3977int KiiSendCommandV (int device, int length, char *format, va_list argp);
     78int KiiScanMessage (int device, char *format, ...);
     79int KiiSendData (int device, char *data, int Nbytes);
     80char *KiiRecvData (int device);
    4081
    4182/* KiiOpen.c */
    4283int KiiOpen (char *kii_exec, char *name);
    4384int KiiClose (int socket);
     85int KiiWait (char *sockpath);
    4486
    4587/* KiiPicture.c */
    4688int KiiNewPicture1D (int fd, KiiImage *image, KiiDisplayMode *mode, Coords *coords);
    4789int KiiNewPicture2D (int fd, KiiImage *image, KiiDisplayMode *mode, Coords *coords);
    48 int KiiResize (int fd, int Nx, int Ny);
    49 int KiiCenter (int fd, double x, double y, int zoom);
    5090
    5191/* KiiOverlay.c */
     
    5898
    5999/* KiiConvert.c */
    60 int KiiJpeg (int fd, char *filename);
    61100int KiiPS (int fd, int scale, int raw, char *filename);
     101int KiiJPEG (int fd, char *filename);
     102int KapaPNG (int fd, char *filename);
     103int KapaPPM (int fd, char *filename);
    62104
    63105/* KiiCursor.c */
     
    66108int KiiCursorRead (int fd, double *x, double *y, char *key);
    67109
     110/* KapaWindow.c */
     111int KiiResize (int fd, int Nx, int Ny);
     112int KiiCenter (int fd, double x, double y, int zoom);
     113int KapaBox (int fd, Graphdata *graphdata);
     114int KapaClear (int fd, int ClearSection);
     115int KapaSetFont (int fd, char *name, int size);
     116int KapaSendLabel (int fd, char *string, int mode);
     117int KapaSendTextline (int fd, char *string, float x, float y, float angle);
     118int KapaSetLimits (int fd, Graphdata *graphmode);
     119int KapaSetSection (int fd, KapaSection *section);
     120int KapaSelectSection (int fd, char *name);
     121int KapaGetSection (int fd, char *name);
     122
     123/* KapaColors */
     124int KapaColorByName (char *name);
     125int KapaColormapSize ();
     126char *KapaColorRGBString (int N);
     127png_color *KapaPNGPalette (int *Npalette);
     128unsigned long *KapaX11colors (Display *display, Colormap colormap, unsigned long default_color, int *Ncolors);
     129
     130/* RotFont.c */
     131void InitRotFonts PROTO(());
     132int SetRotFont PROTO((char *name, int size));
     133char *GetRotFont PROTO((int *size));
     134RotFont *GetRotFontData (double *scale);
     135int RotStrlen PROTO((char *c));
     136
     137/* DrawRotString.c */
     138int DrawRotText PROTO((int x, int y, char *string, int pos, double angle));
     139int DrawRotBitmap PROTO((int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale));
     140int DrawRotTextInit (Display *display, Window window, GC gc, unsigned long fore, unsigned long back);
     141
     142
     143/* PSRotFont.c */
     144void PSRotText PROTO((FILE *f, int x, int y, char *string, int pos, double angle));
     145void PSDumpRotSegment PROTO((FILE *f, char *segment, int *Nseg));
     146void PSSetFont PROTO((FILE *f, char *name, int size));
     147
     148/* bDrawFuncs.c */
     149bDrawBuffer *bDrawBufferCreate (int Nx, int Ny);
     150void bDrawBufferFree (bDrawBuffer *buffer);
     151void bDrawSetBuffer (bDrawBuffer *buffer);
     152void bDrawSetStyle (bDrawColor color, int lw, int lt);
     153void bDrawPoint (int x, int y);
     154void bDrawPointf (float x, float y);
     155
     156void bDrawArc (double Xc, double Yc, double Xr, double Yr, double Ts, double Te);
     157void bDrawCircle (double Xc, double Yc, double radius);
     158void bDrawCircleFill (double xc, double yc, double radius);
     159
     160void bDrawLine (double x1, double y1, double x2, double y2);
     161void bDrawLineWeight (int X1, int Y1, int X2, int Y2, int swapcoords);
     162void bDrawLineBresen (int X1, int Y1, int X2, int Y2, int swapcoords);
     163void bDrawLineHorizontal (int X1, int X2, int Y);
     164void bDrawLineVertical (int X, int Y1, int Y2);
     165
     166void bDrawRectOpen (double x1, double y1, double x2, double y2);
     167void bDrawRectFill (double x1, double y1, double x2, double y2);
     168void bDrawTriOpen (double x1, double y1, double x2, double y2, double x3, double y3);
     169void bDrawTriFill (double x1, double y1, double x2, double y2, double x3, double y3);
     170
     171/* bDrawRotFont.c */
     172int bDrawRotText (int x, int y, char *string, int pos, double angle);
     173int bDrawRotBitmap (int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale);
     174
    68175# endif
  • trunk/Ohana/src/libkapa/include/kapa_internal.h

    r5848 r5852  
    1010# include <time.h>
    1111# include <errno.h>
     12
    1213# include <ohana.h>
    1314# include <dvo.h>
  • trunk/Ohana/src/libkapa/src/IOfuncs.c

    r5848 r5852  
    11# include <kapa_internal.h>
     2
     3/* why is this not defined in stdarg.h for linux/x64? */
     4int vsscanf(const char *str, const char *format, va_list ap);
     5
     6int KiiSendData (int device, char *data, int Nbytes) {
     7
     8  KiiSendCommand (device, 16, "LEN: %11d", Nbytes);
     9  write (device, data, Nbytes);
     10  return (TRUE);
     11}
     12
     13char *KiiRecvData (int device) {
     14
     15  int status, Nbytes;
     16  char *data, buffer[20];
     17
     18  /* read 16 bytes: LEN (length) */
     19  status = read (device, buffer, 16);
     20  buffer[16] = 0;
     21
     22  /* find the message length, allocate space */
     23  sscanf (buffer, "%*s %d", &Nbytes);
     24  ALLOCATE (data, char, Nbytes + 1);
     25  read (device, data, Nbytes);
     26  data[Nbytes] = 0;
     27
     28  return (data);
     29}
    230
    331/* send a message of arbitrary size, sending the size first */
     
    1442  if (!Nbyte) return (FALSE);
    1543
     44  /* the message may contain up to 99,999,999,999 bytes (100MB) */
    1645  va_start (argp, format);
    17   KiiSendCommand (device, 16, "NBYTES: %6d", Nbyte);
     46  KiiSendCommand (device, 16, "LEN: %11d", Nbyte);
    1847  status = KiiSendCommandV (device, Nbyte, format, argp);
    1948  va_end (argp);
     49
    2050  return (status);
    2151}
     
    2959  status = KiiSendCommandV (device, length, format, argp);
    3060  va_end (argp);
     61
    3162  return (status);
    3263}
     
    3667  char *string;
    3768
    38   /* I allocated and zero 1 extra byte */
     69  /* string is sent WITHOUT ending NULL char */
     70  /* allocate and zero length + 1 extra byte */
    3971  ALLOCATE (string, char, length + 1);
    4072  memset (string, 0, length + 1);
    4173  vsnprintf (string, length + 1, format, argp);
    4274
    43   /* fprintf (stderr, "msg: %s\n", string); */
    4475  write (device, string, length);
    4576  free (string);
    4677  return (TRUE);
    4778}
     79
     80/* scan a message of arbitrary size, accepting the size first */
     81int KiiScanMessage (int device, char *format, ...) {
     82
     83  int Nbytes, status;
     84  char buffer[20], *message;
     85  va_list argp; 
     86
     87  /* read 16 bytes: LEN (length) */
     88  status = read (device, buffer, 16);
     89  buffer[16] = 0;
     90
     91  /* find the message length, allocate space */
     92  sscanf (buffer, "%*s %d", &Nbytes);
     93  ALLOCATE (message, char, Nbytes + 1);
     94
     95  /* read Nbytes from the device */
     96  status = read (device, message, Nbytes);
     97  if (status != Nbytes) fprintf (stderr, "Kii/Kapa comm error\n");
     98  message[status] = 0;
     99  /* make the string easy to parse */
     100
     101  /* scan the incoming message */
     102  va_start (argp, format);
     103  Nbytes = vsscanf (message, format, argp);
     104  va_end (argp);
     105
     106  return (status);
     107}
  • trunk/Ohana/src/libkapa/src/KapaWindow.c

    r5849 r5852  
    1 # include <kapa_internals.h>
     1# include <kapa_internal.h>
    22
    3 typedef struct {
    4   double xmin, xmax, ymin, ymax;
    5   int style, ptype, ltype, etype, ebar, color;
    6   double lweight, size;
    7   Coords coords;
    8   int flipeast, flipnorth;
    9 } Graphdata;
     3int KiiResize (int fd, int Nx, int Ny) {
    104
    11 int KapaBox (int fd, Graphdata *graphdata, char *Axis, char *Labels, char *Ticks) {
    12 
    13  
    14 
    15   SendGraphCommand (fd, 4, "DBOX");
    16   SendGraphMessage (fd, "%12.6g %12.6g %12.6g %12.6g",
    17                     graphdata[0].xmin, graphdata[0].xmax, graphdata[0].ymin, graphdata[0].ymax);
    18   SendGraphMessage (fd, "%s %s %s", Axis, Labels, Ticks);
     5  KiiSendCommand (fd, 4, "RSIZ");
     6  KiiSendMessage (fd, "%d %d", Nx, Ny);
    197  return (TRUE);
    208}
     9
     10int 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);
     14  return (TRUE);
     15}
     16
     17int KapaBox (int fd, Graphdata *graphdata) {
     18
     19  KiiSendCommand (fd, 4, "DBOX");
     20
     21  KiiSendMessage (fd, "%12.6g %12.6g %12.6g %12.6g",
     22                    graphdata[0].xmin, graphdata[0].xmax, graphdata[0].ymin, graphdata[0].ymax);
     23
     24  KiiSendMessage (fd, "%s %s %s", graphdata[0].axis, graphdata[0].labels, graphdata[0].ticks);
     25  return (TRUE);
     26}
     27
     28int KapaClear (int fd, int ClearSection) {
     29
     30  if (ClearSection) {
     31    KiiSendCommand (fd, 4, "ERSS");
     32  } else {
     33    KiiSendCommand (fd, 4, "ERAS");
     34  }
     35  return (TRUE);
     36}
     37
     38int KapaSetFont (int fd, char *name, int size) {
     39
     40  KiiSendCommand (fd, 4, "FONT");
     41  KiiSendCommand (fd, 16, "%s", name);
     42  KiiSendCommand (fd, 16, "%d", size);
     43  return (TRUE);
     44}
     45
     46int KapaSendLabel (int fd, char *string, int mode) {
     47 
     48  KiiSendCommand (fd, 4, "LABL");
     49  KiiSendMessage (fd, "%6d", mode);
     50  KiiSendData (fd, string, strlen(string));
     51  return (TRUE);
     52}
     53
     54int KapaSendTextline (int fd, char *string, float x, float y, float angle) {
     55 
     56  KiiSendCommand (fd, 4, "PTXT");
     57  KiiSendMessage (fd, "%f", x);
     58  KiiSendMessage (fd, "%f", y);
     59  KiiSendMessage (fd, "%f", angle);
     60  KiiSendData (fd, string, strlen(string));
     61  return (TRUE);
     62}
     63
     64int KapaSetLimits (int fd, Graphdata *graphmode) {
     65
     66  KiiSendCommand (fd, 4, "SLIM");
     67  KiiSendMessage (fd, "%g %g %g %g ", graphmode[0].xmin, graphmode[0].xmax, graphmode[0].ymin, graphmode[0].ymax);
     68  return (TRUE);
     69}
     70
     71int KapaSetSection (int fd, KapaSection *section) {
     72
     73  KiiSendCommand (fd, 4, "DSEC");
     74  KiiSendMessage (fd, "%s %6.3f %6.3f %6.3f %6.3f",
     75                  section[0].name,
     76                  section[0].x,
     77                  section[0].y,
     78                  section[0].dx,
     79                  section[0].dy);
     80  return (TRUE);
     81}
     82
     83int KapaSelectSection (int fd, char *name) {
     84
     85  KiiSendCommand (fd, 4, "SSEC");
     86  KiiSendMessage (fd, "%s", name);
     87  return (TRUE);
     88}
     89
     90int KapaGetSection (int fd, char *name) {
     91
     92  KiiSendCommand (fd, 4, "LSEC");
     93  KiiSendMessage (fd, "%s", name);
     94  return (TRUE);
     95}
  • trunk/Ohana/src/libkapa/src/KiiConvert.c

    r5848 r5852  
    11# include <kapa_internal.h>
    22
    3 int KiiJpeg (int fd, char *filename) {
     3int KiiJPEG (int fd, char *filename) {
    44
    55  char buffer[20];
    66
    77  KiiSendCommand (fd, 4, "JPEG");
    8   KiiSendCommand (fd, 16, "LEN: %11d", strlen(filename));
    9   write (fd, filename, strlen(filename));
     8  KiiSendMessage (fd, "%s", filename);
     9
     10  /* block for the response, which says the operation completed */
     11  read (fd, buffer, 4);
     12  return (TRUE);
     13}
     14
     15int KapaPNG (int fd, char *filename) {
     16
     17  char buffer[20];
     18
     19  KiiSendCommand (fd, 4, "PNGF");
     20  KiiSendMessage (fd, "%s", filename);
     21
     22  /* block for the response, which says the operation completed */
     23  read (fd, buffer, 4);
     24  return (TRUE);
     25}
     26
     27int KapaPPM (int fd, char *filename) {
     28
     29  char buffer[20];
     30
     31  KiiSendCommand (fd, 4, "PPMF");
     32  KiiSendMessage (fd, "%s", filename);
    1033
    1134  /* block for the response, which says the operation completed */
     
    3255
    3356name:
    34   KiiSendCommand (fd, 16, "LEN: %11d", strlen(filename));
    35   write (fd, filename, strlen(filename));
     57  KiiSendMessage (fd, "%s", filename);
    3658
    3759  /* block for the response, which says the operation completed */
  • trunk/Ohana/src/libkapa/src/KiiOpen.c

    r5848 r5852  
    44int KiiOpen (char *kii_exec, char *name) {
    55
    6   int InitSocket, status, addreslen;
     6  int InitSocket, status;
    77  struct sockaddr_un Address;
     8  socklen_t AddressLength;
    89  char temp[128], socket_name[64];
    910  int Ntry, fd;
     
    3031  system (temp);
    3132
    32   addreslen =  sizeof (Address);
     33  AddressLength =  sizeof (Address);
    3334  fcntl (InitSocket, F_SETFL, O_NONBLOCK);
    3435
     
    3637  Ntry = 0;
    3738  while (Ntry < NTRY) {
    38     fd = accept (InitSocket, (struct sockaddr *)&Address, &addreslen);
     39    fd = accept (InitSocket, (struct sockaddr *)&Address, &AddressLength);
    3940    if (fd != -1) break;
    4041    if (errno != EAGAIN) break;
     
    4950}
    5051
     52int KiiWait (char *sockpath) {
     53
     54  int sock, status;
     55  struct sockaddr_un Address;
     56
     57  strcpy (Address.sun_path, sockpath);
     58  Address.sun_family = AF_UNIX;
     59  sock = socket (AF_UNIX, SOCK_STREAM, 0);
     60  status = connect (sock, (struct sockaddr *) &Address, sizeof (Address));
     61  if (status < 0) {
     62    fprintf (stderr, "unsuccessful connection: %d\n", status);
     63    exit (0);
     64  }
     65  fcntl (sock, F_SETFL, O_NONBLOCK); 
     66  unlink (sockpath);
     67  return (sock);
     68}
     69
    5170int KiiClose (int fd) {
    5271
  • trunk/Ohana/src/libkapa/src/KiiPicture.c

    r5848 r5852  
    77  float *in, min, max;
    88  char *out, *outbuffer, *root;
    9   char buffer[1024];
    109  double a1, a2;
    1110
     
    1312
    1413  KiiSendCommand (fd, 4, "READ"); /* tell Ximage to look for the incoming image */
    15 
    16   /* convert from (float *) to 1 byte chars -- depends on how many colors Kii owns */
    17   /* use this response as a handshake test */
    18   read (fd, buffer, 16);
    19   sscanf (buffer, "%*s %d", &Ncolors);
     14  KiiScanMessage (fd, "%d", &Ncolors);
    2015
    2116  ALLOCATE (outbuffer, char, Npix);
     
    4742
    4843  /* done with the conversion, now send Ximage the converted picture */
    49   KiiSendMessage (fd, "%8d %8d 8 1 %f %f", image[0].Nx, image[0].Ny, 0.0, 1.0);
    50   KiiSendMessage (fd, "%f %f %f %f %d ", mode[0].zero, mode[0].range, min, max, size);
     44  KiiSendMessage (fd, "%8d %8d", image[0].Nx, image[0].Ny);
     45  KiiSendMessage (fd, "8 1 0.0 1.0");
     46  KiiSendMessage (fd, "%f %f ", mode[0].zero, mode[0].range);
     47  KiiSendMessage (fd, "%f %f %d ", min, max, size);
    5148  KiiSendMessage (fd, "%f %f %g %g %g ", coords[0].crval1, coords[0].crpix1, coords[0].cdelt1, coords[0].pc1_1, coords[0].pc1_2);
    5249  KiiSendMessage (fd, "%f %f %g %g %g ", coords[0].crval2, coords[0].crpix2, coords[0].cdelt2, coords[0].pc2_1, coords[0].pc2_2);
     
    5552  root = filerootname (image[0].file);
    5653  KiiSendMessage (fd, "%s %s %s ", coords[0].ctype, root, image[0].name);
     54  free (root);
    5755
    5856  /* send the image data */
     
    135133   KiiSendFilename
    136134*/
    137 
    138 int KiiResize (int fd, int Nx, int Ny) {
    139 
    140   KiiSendCommand (fd, 4, "RSIZ");
    141   KiiSendMessage (fd, "%d %d", Nx, Ny);
    142   return (TRUE);
    143 }
    144 
    145 int KiiCenter (int fd, double x, double y, int zoom) {
    146 
    147   KiiSendCommand (fd, 4, "CENT");
    148   KiiSendMessage (fd, "%8.3f %8.3f %8d ", x, y, zoom);
    149   return (TRUE);
    150 }
Note: See TracChangeset for help on using the changeset viewer.