Changeset 5852
- Timestamp:
- Dec 27, 2005, 3:23:01 PM (21 years ago)
- Location:
- trunk/Ohana/src
- Files:
-
- 58 edited
-
kapa/Makefile (modified) (3 diffs)
-
kapa/event/CheckPipe.c (modified) (1 diff)
-
kapa/event/Resize.c (modified) (1 diff)
-
kapa/event/SetSection.c (modified) (2 diffs)
-
kapa/graph/DrawFrame.c (modified) (1 diff)
-
kapa/graph/DrawLabels.c (modified) (1 diff)
-
kapa/graph/DrawPtext.c (modified) (1 diff)
-
kapa/graph/LoadBox.c (modified) (3 diffs)
-
kapa/graph/LoadLabels.c (modified) (2 diffs)
-
kapa/graph/LoadObject.c (modified) (2 diffs)
-
kapa/graph/PNGit2.c (modified) (2 diffs)
-
kapa/graph/PPMit2.c (modified) (2 diffs)
-
kapa/graph/PSObjects.c (modified) (1 diff)
-
kapa/graph/SetLimits.c (modified) (2 diffs)
-
kapa/graph/bDrawFrame.c (modified) (1 diff)
-
kapa/graph/bDrawFuncs.c (modified) (1 diff)
-
kapa/graph/bDrawIt.c (modified) (2 diffs)
-
kapa/graph/bDrawLabels.c (modified) (1 diff)
-
kapa/graph/bDrawObjects.c (modified) (2 diffs)
-
kapa/graph/bDrawRotFont.c (modified) (1 diff)
-
kapa/include/Ximage.h (modified) (1 diff)
-
kapa/include/bDraw.h (modified) (2 diffs)
-
kapa/include/globals.h (modified) (1 diff)
-
kapa/include/prototypes.h (modified) (2 diffs)
-
kapa/include/structures.h (modified) (3 diffs)
-
kapa/setup/DefineLayout.c (modified) (2 diffs)
-
kapa/setup/SetUpWindow.c (modified) (2 diffs)
-
kapa/setup/args.c (modified) (1 diff)
-
kii/Makefile (modified) (2 diffs)
-
kii/button/PSit.c (modified) (2 diffs)
-
kii/colorbar/CreateColorbar.c (modified) (2 diffs)
-
kii/include/Ximage.h (modified) (1 diff)
-
kii/include/bDraw.h (modified) (1 diff)
-
kii/include/constants.h (modified) (1 diff)
-
kii/include/prototypes.h (modified) (1 diff)
-
kii/include/structures.h (modified) (2 diffs)
-
kii/overlay/bDrawColormap.c (modified) (1 diff)
-
kii/overlay/bDrawFrame.c (modified) (1 diff)
-
kii/overlay/bDrawFuncs.c (modified) (1 diff)
-
kii/overlay/bDrawOverlay.c (modified) (2 diffs)
-
kii/overlay/bDrawRotFont.c (modified) (1 diff)
-
kii/picture/CreatePicture.c (modified) (3 diffs)
-
kii/picture/JPEGit24.c (modified) (4 diffs)
-
kii/picture/NewPicture.c (modified) (4 diffs)
-
kii/picture/Remap8.c (modified) (1 diff)
-
kii/picture/Resize.c (modified) (1 diff)
-
kii/setup/CheckVisual.c (modified) (2 diffs)
-
kii/setup/DefineLayout.c (modified) (3 diffs)
-
kii/setup/SetUpWindow.c (modified) (1 diff)
-
kii/setup/args.c (modified) (1 diff)
-
libkapa/Makefile (modified) (2 diffs)
-
libkapa/include/kapa.h (modified) (4 diffs)
-
libkapa/include/kapa_internal.h (modified) (1 diff)
-
libkapa/src/IOfuncs.c (modified) (4 diffs)
-
libkapa/src/KapaWindow.c (modified) (1 diff)
-
libkapa/src/KiiConvert.c (modified) (2 diffs)
-
libkapa/src/KiiOpen.c (modified) (4 diffs)
-
libkapa/src/KiiPicture.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/kapa/Makefile
r5703 r5852 23 23 INCS = -I$(INC) -I$(LINC) -I$(XINC) 24 24 #LIBS = -L$(LLIB) $(XLIB) -lFITS -lohana -lX11 -lm 25 LIBS = -L$(LLIB) $(XLIB) -lFITS -l ohana -lX11 -lsocket -lnsl -lpng -lz -lm25 LIBS = -L$(LLIB) $(XLIB) -lFITS -lkapa -lohana -lX11 -lsocket -lnsl -lpng -lz -lm 26 26 CFLAGS = -o $*.$(ARCH).o $(INCS) 27 27 CCFLAGS = $(INCS) $(LIBS) … … 52 52 $(GDIR)/LoadPtext.$(ARCH).o $(GDIR)/DrawPtext.$(ARCH).o \ 53 53 $(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 \ 57 55 58 56 BDRAW = \ 59 $(GDIR)/bDrawIt.$(ARCH).o $(GDIR)/bDrawFuncs.$(ARCH).o\57 $(GDIR)/bDrawIt.$(ARCH).o \ 60 58 $(GDIR)/bDrawFrame.$(ARCH).o $(GDIR)/bDrawLabels.$(ARCH).o \ 61 $(GDIR)/bDrawObjects.$(ARCH).o $(GDIR)/bDrawRotFont.$(ARCH).o\59 $(GDIR)/bDrawObjects.$(ARCH).o \ 62 60 $(GDIR)/PNGit2.$(ARCH).o \ 63 61 … … 75 73 $(SDIR)/GetColor.$(ARCH).o $(SDIR)/SetWMHints.$(ARCH).o \ 76 74 $(SDIR)/LoadFont.$(ARCH).o $(SDIR)/TopWindow.$(ARCH).o \ 77 $(SDIR)/ MakeColormap.$(ARCH).o $(SDIR)/Ximage.$(ARCH).o \75 $(SDIR)/Ximage.$(ARCH).o \ 78 76 $(SDIR)/MakeCursor.$(ARCH).o 79 77 -
trunk/Ohana/src/kapa/event/CheckPipe.c
r3465 r5852 73 73 74 74 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); 78 78 return (TRUE); 79 79 } -
trunk/Ohana/src/kapa/event/Resize.c
r2473 r5852 1 1 # 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 10 2 11 3 int Resize () { 12 4 13 int i , status, Nbytes;5 int i; 14 6 unsigned int NX, NY; 15 char buffer[128];16 7 17 SCAN; 18 sscanf (buffer, "%d %d", &NX, &NY); 8 KiiScanMessage (sock, "%d %d", &NX, &NY); 19 9 20 10 if ((graphic.dx == NX) && (graphic.dy == NY)) -
trunk/Ohana/src/kapa/event/SetSection.c
r4769 r5852 1 1 # 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;8 2 9 3 int SetSection (int SwitchSection) { 10 4 11 int i, status, Nbytes,NewSection, ThisSection, MoveSection;12 char buffer[128],name[128];5 int i, NewSection, ThisSection, MoveSection; 6 char name[128]; 13 7 double x, y, dx, dy; 14 8 15 SCAN;16 17 9 if (SwitchSection) { 18 sscanf (buffer, "%s", name);10 KiiScanMessage (sock, "%s", name); 19 11 } 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); 22 13 } 23 14 … … 92 83 int ListSection () { 93 84 94 int i, status, Nbytes,ThisSection;95 char buffer[128],name[128];85 int i, ThisSection; 86 char name[128]; 96 87 97 SCAN; 98 99 sscanf (buffer, "%s", name); 88 KiiScanMessage (sock, "%s", name); 100 89 101 90 if (!strcmp (name, "*")) { -
trunk/Ohana/src/kapa/graph/DrawFrame.c
r5610 r5852 6 6 int i, fx, fy, dfx, dfy, P, IsLabel; 7 7 double range, major, minor, first, next; 8 9 DrawRotTextInit (graphic.display, graphic.window, graphic.gc, graphic.fore, graphic.back); 8 10 9 11 /* each axis is drawn independently, but ticks and labels are placed according to -
trunk/Ohana/src/kapa/graph/DrawLabels.c
r5386 r5852 10 10 fontname = GetRotFont (&size); 11 11 XSetForeground (graphic.display, graphic.gc, graphic.fore); 12 DrawRotTextInit (graphic.display, graphic.window, graphic.gc, graphic.fore, graphic.back); 12 13 13 14 /* each label is drawn independently */ -
trunk/Ohana/src/kapa/graph/DrawPtext.c
r4769 r5852 9 9 fontname = GetRotFont (&size); 10 10 XSetForeground (graphic.display, graphic.gc, graphic.fore); 11 DrawRotTextInit (graphic.display, graphic.window, graphic.gc, graphic.fore, graphic.back); 11 12 12 13 for (i = 0; i < layout[0].Nptext; i++) { -
trunk/Ohana/src/kapa/graph/LoadBox.c
r5612 r5852 1 1 # 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;8 2 9 3 int LoadBox () { 10 4 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]; 13 7 Layout *layout; 14 8 15 9 layout = §ion[TheSection]; 16 10 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); 21 14 22 15 layout[0].axis[3].min = layout[0].axis[1].min; … … 25 18 layout[0].axis[2].max = layout[0].axis[0].max; 26 19 27 SCAN; 28 sscanf (buffer, "%s %s %s", Axis, Labels, Ticks); 20 KiiScanMessage (sock, "%s %s %s", Axis, Labels, Ticks); 29 21 30 22 for (i = 0; i < 4; i++) { … … 83 75 layout[0].X = 0; 84 76 layout[0].Y = 0; 85 layout[0].expand = 1;77 layout[0].expand = 1; 86 78 */ 87 79 -
trunk/Ohana/src/kapa/graph/LoadLabels.c
r2473 r5852 3 3 int LoadLabels () { 4 4 5 char buffer[256], *c;6 int status, Nbytes, mode, size;5 char *c, *label; 6 int mode, size, Nbytes; 7 7 Layout *layout; 8 8 … … 11 11 fcntl (sock, F_SETFL, !O_NONBLOCK); 12 12 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); 16 15 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; 22 19 23 20 fcntl (sock, F_SETFL, O_NONBLOCK); -
trunk/Ohana/src/kapa/graph/LoadObject.c
r5612 r5852 1 1 # include "Ximage.h" 2 # include <unistd.h>3 2 # 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;11 3 12 4 int LoadObject () { 13 5 14 char buffer[1024]; 15 int status, N, Nbytes; 6 int N; 16 7 Layout *layout; 17 8 … … 27 18 layout[0].objects[N].dym = layout[0].objects[N].dyp = (float *) NULL; 28 19 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); 36 26 37 27 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); 43 33 44 34 /* 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)) 46 36 layout[0].objects[N].color = 0; 47 37 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); 52 41 53 42 fcntl (sock, F_SETFL, O_NONBLOCK); -
trunk/Ohana/src/kapa/graph/PNGit2.c
r5610 r5852 1 1 # include "Ximage.h" 2 # include <png.h>3 # include "bDraw.h"4 2 5 3 int PNGit () { … … 58 56 /* 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); */ 59 57 60 palette = MakePNGPalette (&Npalette);58 palette = KapaPNGPalette (&Npalette); 61 59 png_set_PLTE (png_ptr, info_ptr, palette, Npalette); 62 60 -
trunk/Ohana/src/kapa/graph/PPMit2.c
r5703 r5852 1 1 # include "Ximage.h" 2 # include <png.h>3 # include "bDraw.h"4 2 5 3 int PPMit () { … … 25 23 } 26 24 27 palette = MakePNGPalette (&Npalette);25 palette = KapaPNGPalette (&Npalette); 28 26 29 27 dx = graphic.dx; -
trunk/Ohana/src/kapa/graph/PSObjects.c
r4769 r5852 111 111 lweight = MAX (0, MIN (10, layout[0].objects[i].lweight)); 112 112 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)); 114 114 115 115 switch (layout[0].objects[i].style) { -
trunk/Ohana/src/kapa/graph/SetLimits.c
r2473 r5852 1 1 # 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;8 2 9 3 int SetLimits () { 10 4 11 int i, status, Nbytes; 12 char buffer[128]; 5 int i; 13 6 double xmin, xmax, ymin, ymax; 14 7 Layout *layout; … … 16 9 layout = §ion[TheSection]; 17 10 18 SCAN; 19 sscanf (buffer, "%lf %lf %lf %lf", &xmin, &xmax, &ymin, &ymax); 11 KiiScanMessage (sock, "%lf %lf %lf %lf", &xmin, &xmax, &ymin, &ymax); 20 12 21 13 layout[0].axis[2].min = layout[0].axis[0].min = xmin; -
trunk/Ohana/src/kapa/graph/bDrawFrame.c
r5612 r5852 1 1 # include "Ximage.h" 2 # include "bDraw.h"3 2 4 3 int bDrawFrame (Layout *layout) { -
trunk/Ohana/src/kapa/graph/bDrawFuncs.c
r5612 r5852 13 13 bDrawBuffer *buffer; 14 14 15 white = GetColorByName ("white");15 white = KapaColorByName ("white"); 16 16 17 17 ALLOCATE (buffer, bDrawBuffer, 1); -
trunk/Ohana/src/kapa/graph/bDrawIt.c
r5610 r5852 1 1 # include "Ximage.h" 2 # include "bDraw.h"3 2 4 3 bDrawBuffer *bDrawIt () { … … 8 7 bDrawColor black; 9 8 10 black = GetColorByName ("black");9 black = KapaColorByName ("black"); 11 10 12 11 buffer = bDrawBufferCreate (graphic.dx, graphic.dy); -
trunk/Ohana/src/kapa/graph/bDrawLabels.c
r5610 r5852 1 1 # include "Ximage.h" 2 # include "bDraw.h"3 2 4 3 void bDrawLabels (Layout *layout) { -
trunk/Ohana/src/kapa/graph/bDrawObjects.c
r5612 r5852 1 1 # include "Ximage.h" 2 # include "bDraw.h"3 2 4 3 # define DrawLine(X1,Y1,X2,Y2) (bDrawLine ((X1), (Y1), (X2), (Y2))) … … 20 19 bDrawColor black; 21 20 22 black = GetColorByName ("black");21 black = KapaColorByName ("black"); 23 22 for (i = 0; i < layout[0].Nobjects; i++) { 24 23 -
trunk/Ohana/src/kapa/graph/bDrawRotFont.c
r5612 r5852 20 20 RotFont *currentfont; 21 21 22 white = GetColorByName ("white");23 black = GetColorByName ("black");22 white = KapaColorByName ("white"); 23 black = KapaColorByName ("black"); 24 24 25 25 currentname = GetRotFont (¤tsize); -
trunk/Ohana/src/kapa/include/Ximage.h
r5242 r5852 1 1 # include <Xohana.h> 2 # include <fitsio.h> 2 # include <dvo.h> 3 # include <kapa.h> 3 4 # include "constants.h" 4 5 # include "structures.h" -
trunk/Ohana/src/kapa/include/bDraw.h
r5612 r5852 1 # ifndef BDRAW_H 2 # define BDRAW_H 3 1 4 # include <png.h> 2 5 … … 49 52 int bDrawRotBitmap (int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale); 50 53 54 # endif -
trunk/Ohana/src/kapa/include/globals.h
r5612 r5852 5 5 int MAP_WINDOW; 6 6 int FOREGROUND; 7 char *NAME_WINDOW; 7 8 8 9 /* file descriptor for socket connection to mana */ -
trunk/Ohana/src/kapa/include/prototypes.h
r5611 r5852 64 64 int remove_argument PROTO((int, int *, char **)); 65 65 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));76 66 void MakeGC (); 77 67 78 68 int EventLoop (); 79 69 void CloseDisplay (); 70 int args (int *argc, char **argv); 80 71 81 72 void DrawPtext (Layout *layout); … … 87 78 void PSPtext (Layout *layout, FILE *f); 88 79 void 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 */ 82 int bDrawObjects (Layout *layout); 83 void bDrawConnect (Layout *layout, Gobjects *object); 84 void bDrawClipLine (double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0); 85 void bDrawHistogram (Layout *layout, Gobjects *object); 86 void bDrawPoints (Layout *layout, Gobjects *object); 87 void bDrawXErrors (Layout *layout, Gobjects *object); 88 void bDrawYErrors (Layout *layout, Gobjects *object); 89 90 int bDrawFrame (Layout *layout); 91 void bDrawTick (double fx, double fy, double dfx, double dfy, int P, double min, double max, double value, int mode, int naxis); 92 void bDrawLabels (Layout *layout); 93 void bDrawPtext (Layout *layout); 94 95 bDrawBuffer *bDrawIt (); 89 96 90 97 /******************* XGRAPH ** -
trunk/Ohana/src/kapa/include/structures.h
r5611 r5852 88 88 } Overlay; 89 89 90 # if (0) 90 91 typedef struct { 91 92 char ctype[16]; … … 95 96 double pc2_1, pc2_2; 96 97 } Coords; 98 # endif 97 99 98 100 typedef struct { … … 110 112 char label[64]; 111 113 } 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;123 114 124 115 /******** Here we define the Layout struct specific to this program *******/ -
trunk/Ohana/src/kapa/setup/DefineLayout.c
r5612 r5852 5 5 void DefineLayout (int argc, char **argv) { 6 6 7 int i, status, N; 8 struct sockaddr_un Address; 9 char temp[100]; 7 int i; 10 8 11 9 /** initiate connection with server **/ … … 15 13 exit (0); 16 14 } 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]); 28 16 } 29 17 -
trunk/Ohana/src/kapa/setup/SetUpWindow.c
r5612 r5852 5 5 void SetUpWindow (int *argc, char **argv) { 6 6 7 int N;8 7 Icon icon; 8 char *name; 9 int Ncolors; 9 10 10 11 icon.width = icon_width; … … 21 22 SetNormalHints (); 22 23 SetWMHints (&icon); 23 NameWindow ("Kapa");24 24 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 } 26 33 34 graphic.color = KapaX11colors (graphic.display, graphic.colormap, graphic.fore, &Ncolors); 27 35 if (MAP_WINDOW) MapWindow (graphic); 28 36 return; -
trunk/Ohana/src/kapa/setup/args.c
r5612 r5852 9 9 remove_argument(N, argc, argv); 10 10 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); 11 18 } 12 19 -
trunk/Ohana/src/kii/Makefile
r5700 r5852 21 21 # 22 22 INCS = -I$(INC) -I$(LINC) -I$(XINC) 23 LIBS = -L$(LLIB) $(XLIB) -ldvo -lFITS -l ohana -ljpeg -lX11 -lsocket -lnsl -lm23 LIBS = -L$(LLIB) $(XLIB) -ldvo -lFITS -lkapa -lohana -ljpeg -lX11 -lsocket -lnsl -lm 24 24 # LIBS = -L$(LLIB) $(XLIB) -lohana -lFITS -ljpeg -lX11 -lsocket -lnsl -lm -static 25 25 CFLAGS = -o $*.$(ARCH).o $(INCS) … … 52 52 $(ODIR)/DrawOverlay.$(ARCH).o $(ODIR)/CSaveOverlay.$(ARCH).o \ 53 53 $(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 58 55 59 56 POBJ = \ -
trunk/Ohana/src/kii/button/PSit.c
r5701 r5852 246 246 int i, k, m, val; 247 247 double Nchar, Npix, start, slope, frac; 248 char *buff;248 unsigned char *buff; 249 249 250 250 Nchar = 255.0; … … 318 318 extra = 4 - (dx * 3) % 4; 319 319 /* 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)]; 321 321 slope = layout[0].slope; 322 322 start = layout[0].start; -
trunk/Ohana/src/kii/colorbar/CreateColorbar.c
r2466 r5852 28 28 case 16: 29 29 REALLOCATE (layout[0].cmapbar.data, char, 2*dy*dx); 30 out8 = layout[0].cmapbar.data;30 out8 = (unsigned char *) layout[0].cmapbar.data; 31 31 for (i = 0; i < dx; i++) { 32 32 pixvalue = layout[0].cmap[(int)(i*layout[0].Npixels/dx)].pixel; … … 44 44 extra = 4 - (dx * 3) % 4; 45 45 REALLOCATE (layout[0].cmapbar.data, char, dy*(3*dx + extra)); 46 out8 = layout[0].cmapbar.data;46 out8 = (unsigned char *) layout[0].cmapbar.data; 47 47 for (i = 0; i < dx; i++) { 48 48 pixvalue = layout[0].cmap[(int)(i*layout[0].Npixels/dx)].pixel; -
trunk/Ohana/src/kii/include/Ximage.h
r3463 r5852 1 1 # include <Xohana.h> 2 2 # include <dvo.h> 3 # include <kapa.h> 3 4 # include "constants.h" 4 5 # include "structures.h" -
trunk/Ohana/src/kii/include/bDraw.h
r5700 r5852 50 50 int bDrawRotBitmap (int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale); 51 51 52 void bDrawOverlay (Layout *layout, int N); -
trunk/Ohana/src/kii/include/constants.h
r5849 r5852 25 25 int DECIMAL_DEG; 26 26 int DEBUG; 27 int FOREGROUND; 27 28 int USE_XWINDOW; 28 29 int 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 2 int args (int *argc, char **argv); 3 4 void bDrawOverlay (Layout *layout, int N); 11 5 12 6 int SetColormap (Graphic *graphic, Layout *layout, char *name); -
trunk/Ohana/src/kii/include/structures.h
r5700 r5852 67 67 int dx, dy, x, y; 68 68 XImage *pix; 69 char *data;69 char *data; 70 70 } Picture; 71 71 … … 124 124 } Layout; 125 125 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 137 126 /* this routine is independent of the number of overlays */ 138 127 -
trunk/Ohana/src/kii/overlay/bDrawColormap.c
r5700 r5852 1 1 # include "Ximage.h" 2 # include "bDraw.h"3 2 4 3 /* this list must match the one in mana/include/package.h, and equiv -
trunk/Ohana/src/kii/overlay/bDrawFrame.c
r5700 r5852 1 1 # include "Ximage.h" 2 # include "bDraw.h"3 2 4 3 int bDrawFrame (Layout *layout) { -
trunk/Ohana/src/kii/overlay/bDrawFuncs.c
r5700 r5852 1 1 # include "Ximage.h" 2 # include "bDraw.h"3 2 4 3 static int bWeight; -
trunk/Ohana/src/kii/overlay/bDrawOverlay.c
r5700 r5852 1 1 # include "Ximage.h" 2 # include "bDraw.h"3 2 # define INFRONT 4 4 3 … … 14 13 15 14 /* translate color to bDrawColors : layout[0].overlay[N].color */ 16 color = GetColorByName (name[N]);15 color = KapaColorByName (name[N]); 17 16 bDrawSetStyle (color, 0, 0); 18 17 -
trunk/Ohana/src/kii/overlay/bDrawRotFont.c
r5700 r5852 1 1 # include "Ximage.h" 2 # include "bDraw.h"3 2 4 3 # define NROTCHARS 256 -
trunk/Ohana/src/kii/picture/CreatePicture.c
r2466 r5852 4 4 5 5 int i, j, extra; 6 char *c;6 unsigned char *c; 7 7 unsigned int *l; 8 8 unsigned int start, start1, start2, start3; … … 13 13 case 8: 14 14 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; 16 16 for (i = 0; i < (layout[0].picture.dx*layout[0].picture.dy); i++, c++) 17 17 *c = start; … … 22 22 case 16: 23 23 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; 25 25 start1 = 0x0000ff & (start); 26 26 start2 = 0x0000ff & (start >> 8); -
trunk/Ohana/src/kii/picture/JPEGit24.c
r5700 r5852 1 1 # include "Ximage.h" 2 2 # include "jpeglib.h" 3 # include <png.h>4 # include "bDraw.h"5 3 6 4 # define WHITE_R 255 … … 18 16 int ii, i, j; 19 17 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... */ 21 19 int dx, dy, DX, DY; 22 20 int status, Nbytes, quality; … … 194 192 bDrawBuffer *buffer; 195 193 196 palette = MakePNGPalette (&Npalette);194 palette = KapaPNGPalette (&Npalette); 197 195 198 196 buffer = bDrawBufferCreate (dx, dy); … … 202 200 } 203 201 204 white = GetColorByName ("white");202 white = KapaColorByName ("white"); 205 203 for (j = 0; j < dy; j++) { 206 204 for (i = 0; i < dx; i++) { -
trunk/Ohana/src/kii/picture/NewPicture.c
r5700 r5852 1 1 # 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 2 10 3 int NewPicture (Graphic *graphic, Layout *layout) { 11 4 12 5 Header header; 13 char buffer[1024],*buff;14 int status, bytes_left, Nbytes;6 char *buff; 7 int status, bytes_left, socket; 15 8 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; 19 10 20 fcntl (layout[0].Ximage, F_SETFL, !O_NONBLOCK); 11 KiiSendMessage (socket, "%d", layout[0].Npixels); 12 13 fcntl (socket, F_SETFL, !O_NONBLOCK); 21 14 22 15 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);27 16 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); 30 25 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); 40 27 fits_create_matrix (&header, &layout[0].matrix); 41 28 42 fcntl ( layout[0].Ximage, F_SETFL, O_NONBLOCK);29 fcntl (socket, F_SETFL, O_NONBLOCK); 43 30 44 31 status = 1; … … 47 34 layout[0].matrix.size = 0; 48 35 while (bytes_left > 0) { 49 status = read ( layout[0].Ximage, buff, bytes_left);36 status = read (socket, buff, bytes_left); 50 37 if (status == 0) { /* No more pipe */ 51 38 fprintf (stderr, "error: pipe closed\n"); … … 59 46 } 60 47 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); 62 49 /* it it not obvious this condition should kill kii, but ... */ 63 50 if (layout[0].matrix.size != header.size) { … … 69 56 70 57 Remap (graphic, layout, &layout[0].matrix); 71 (DEBUG) &&fprintf (stderr, "remapped image\n");58 if (DEBUG) fprintf (stderr, "remapped image\n"); 72 59 Refresh (graphic, layout, 0); 73 (DEBUG) &&fprintf (stderr, "refreshed\n");60 if (DEBUG) fprintf (stderr, "refreshed\n"); 74 61 XFlush (graphic[0].display); 75 62 -
trunk/Ohana/src/kii/picture/Remap8.c
r5386 r5852 68 68 if ((i_end - i_start) % expand_out == 0) dropback = 0; 69 69 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); 72 72 73 73 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ -
trunk/Ohana/src/kii/picture/Resize.c
r5700 r5852 1 1 # 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 10 2 11 3 int Resize (Graphic *graphic, Layout *layout) { 12 4 13 int status, Nbytes;14 5 unsigned int NX, NY; 15 char buffer[128];16 6 17 SCAN; 18 sscanf (buffer, "%d %d", &NX, &NY); 7 KiiScanMessage (layout[0].Ximage, "%d %d", &NX, &NY); 19 8 20 9 NX += ZOOM_X + 3*PAD1 + 25; -
trunk/Ohana/src/kii/setup/CheckVisual.c
r5700 r5852 1 1 # include "Ximage.h" 2 2 # define NPIXELS 64 3 # define DEBUG 14 3 5 4 /* DirectColor doesn't seem to work, even though it is available: … … 195 194 } 196 195 } 197 198 199 196 } 200 -
trunk/Ohana/src/kii/setup/DefineLayout.c
r5700 r5852 5 5 void DefineLayout (Layout *layout, Graphic *graphic, int argc, char **argv) { 6 6 7 int i, status, N; 8 struct sockaddr_un Address; 9 char temp[100], *temp_name; 7 int i, N; 8 char *colormap; 10 9 11 10 /** initiate connection with mana **/ 12 if (! DEBUG) {11 if (!FOREGROUND) { 13 12 if (argc < 2) { 14 13 fprintf (stderr, "socket path not specified\n"); 15 14 exit (0); 16 15 } 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]); 28 17 } 29 18 … … 34 23 MakeColormap (graphic, layout, argc, argv); 35 24 } else { 36 temp_name= default_colormap;25 colormap = default_colormap; 37 26 if ((N = get_argument (argc, argv, "-cm"))) { 38 27 remove_argument (N, &argc, argv); 39 temp_name= argv[N];28 colormap = argv[N]; 40 29 } 41 30 layout[0].Npixels = 256; 42 SetColormap (graphic, layout, temp_name);31 SetColormap (graphic, layout, colormap); 43 32 } 44 33 … … 70 59 } 71 60 72 73 61 /* this routine is independent of the number of overlays */ 74 62 75 63 /* cmap = the mapping of value to color in kii 76 64 colormap = the set of pixel -> color representation in X */ 77 -
trunk/Ohana/src/kii/setup/SetUpWindow.c
r5849 r5852 5 5 void SetUpWindow (Graphic *graphic, int *argc, char **argv) { 6 6 7 int N;8 7 Icon icon; 9 8 char *name; -
trunk/Ohana/src/kii/setup/args.c
r5849 r5852 24 24 } 25 25 26 DEBUG = FALSE; 26 27 if ((N = get_argument (*argc, argv, "-debug"))) { 27 28 remove_argument(N, argc, argv); 28 29 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; 31 36 } 32 37 -
trunk/Ohana/src/libkapa/Makefile
r5848 r5852 27 27 $(SRC)/KiiOverlay.$(ARCH).o \ 28 28 $(SRC)/KiiCursor.$(ARCH).o \ 29 $(SRC)/KiiConvert.$(ARCH).o 29 $(SRC)/KiiConvert.$(ARCH).o \ 30 $(SRC)/KapaWindow.$(ARCH).o \ 31 $(SRC)/KapaColors.$(ARCH).o 30 32 31 # $(SRC)/KiiTickmarks.$(ARCH).o 33 DRAW = \ 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 32 39 33 40 $(OBJS): $(INCS) 41 $(DRAW): $(INCS) 34 42 35 43 $(DESTLIB)/libkapa.a: $(LIB)/libkapa.$(ARCH).a … … 38 46 cp $(LIB)/libkapa.$(ARCH).a $(DESTLIB)/libkapa.a 39 47 40 $(LIB)/libkapa.$(ARCH).a: $(OBJS) 48 $(LIB)/libkapa.$(ARCH).a: $(OBJS) $(DRAW) 41 49 @if [ ! -d $(LIB) ]; then mkdir -p $(LIB); fi 42 50 rm -f $(LIB)/libkapa.$(ARCH).a 43 ar rcv $(LIB)/libkapa.$(ARCH).a $(OBJS) 51 ar rcv $(LIB)/libkapa.$(ARCH).a $(OBJS) $(DRAW) 44 52 $(RANLIB) $(LIB)/libkapa.$(ARCH).a 45 53 -
trunk/Ohana/src/libkapa/include/kapa.h
r5848 r5852 1 1 # ifndef KAPA_H 2 2 # define KAPA_H 3 4 # include <X11/Xlib.h> 5 # include <png.h> 3 6 4 7 typedef struct { … … 34 37 } KiiOverlayType; 35 38 39 typedef struct { 40 char *name; 41 float x; 42 float y; 43 float dx; 44 float dy; 45 } KapaSection; 46 47 typedef 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 56 typedef struct { 57 int dx, dy, ascent; 58 unsigned char *bits; 59 } RotFont; 60 61 typedef struct { 62 RotFont *font; 63 char name[64]; 64 int size; 65 } FontSet; 66 67 typedef png_byte bDrawColor; 68 69 typedef struct { 70 int Nx, Ny; 71 bDrawColor **pixels; 72 } bDrawBuffer; 73 36 74 /* IOfuncs.c */ 37 75 int KiiSendMessage (int device, char *format, ...); 38 76 int KiiSendCommand (int device, int length, char *format, ...); 39 77 int KiiSendCommandV (int device, int length, char *format, va_list argp); 78 int KiiScanMessage (int device, char *format, ...); 79 int KiiSendData (int device, char *data, int Nbytes); 80 char *KiiRecvData (int device); 40 81 41 82 /* KiiOpen.c */ 42 83 int KiiOpen (char *kii_exec, char *name); 43 84 int KiiClose (int socket); 85 int KiiWait (char *sockpath); 44 86 45 87 /* KiiPicture.c */ 46 88 int KiiNewPicture1D (int fd, KiiImage *image, KiiDisplayMode *mode, Coords *coords); 47 89 int 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);50 90 51 91 /* KiiOverlay.c */ … … 58 98 59 99 /* KiiConvert.c */ 60 int KiiJpeg (int fd, char *filename);61 100 int KiiPS (int fd, int scale, int raw, char *filename); 101 int KiiJPEG (int fd, char *filename); 102 int KapaPNG (int fd, char *filename); 103 int KapaPPM (int fd, char *filename); 62 104 63 105 /* KiiCursor.c */ … … 66 108 int KiiCursorRead (int fd, double *x, double *y, char *key); 67 109 110 /* KapaWindow.c */ 111 int KiiResize (int fd, int Nx, int Ny); 112 int KiiCenter (int fd, double x, double y, int zoom); 113 int KapaBox (int fd, Graphdata *graphdata); 114 int KapaClear (int fd, int ClearSection); 115 int KapaSetFont (int fd, char *name, int size); 116 int KapaSendLabel (int fd, char *string, int mode); 117 int KapaSendTextline (int fd, char *string, float x, float y, float angle); 118 int KapaSetLimits (int fd, Graphdata *graphmode); 119 int KapaSetSection (int fd, KapaSection *section); 120 int KapaSelectSection (int fd, char *name); 121 int KapaGetSection (int fd, char *name); 122 123 /* KapaColors */ 124 int KapaColorByName (char *name); 125 int KapaColormapSize (); 126 char *KapaColorRGBString (int N); 127 png_color *KapaPNGPalette (int *Npalette); 128 unsigned long *KapaX11colors (Display *display, Colormap colormap, unsigned long default_color, int *Ncolors); 129 130 /* RotFont.c */ 131 void InitRotFonts PROTO(()); 132 int SetRotFont PROTO((char *name, int size)); 133 char *GetRotFont PROTO((int *size)); 134 RotFont *GetRotFontData (double *scale); 135 int RotStrlen PROTO((char *c)); 136 137 /* DrawRotString.c */ 138 int DrawRotText PROTO((int x, int y, char *string, int pos, double angle)); 139 int DrawRotBitmap PROTO((int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale)); 140 int DrawRotTextInit (Display *display, Window window, GC gc, unsigned long fore, unsigned long back); 141 142 143 /* PSRotFont.c */ 144 void PSRotText PROTO((FILE *f, int x, int y, char *string, int pos, double angle)); 145 void PSDumpRotSegment PROTO((FILE *f, char *segment, int *Nseg)); 146 void PSSetFont PROTO((FILE *f, char *name, int size)); 147 148 /* bDrawFuncs.c */ 149 bDrawBuffer *bDrawBufferCreate (int Nx, int Ny); 150 void bDrawBufferFree (bDrawBuffer *buffer); 151 void bDrawSetBuffer (bDrawBuffer *buffer); 152 void bDrawSetStyle (bDrawColor color, int lw, int lt); 153 void bDrawPoint (int x, int y); 154 void bDrawPointf (float x, float y); 155 156 void bDrawArc (double Xc, double Yc, double Xr, double Yr, double Ts, double Te); 157 void bDrawCircle (double Xc, double Yc, double radius); 158 void bDrawCircleFill (double xc, double yc, double radius); 159 160 void bDrawLine (double x1, double y1, double x2, double y2); 161 void bDrawLineWeight (int X1, int Y1, int X2, int Y2, int swapcoords); 162 void bDrawLineBresen (int X1, int Y1, int X2, int Y2, int swapcoords); 163 void bDrawLineHorizontal (int X1, int X2, int Y); 164 void bDrawLineVertical (int X, int Y1, int Y2); 165 166 void bDrawRectOpen (double x1, double y1, double x2, double y2); 167 void bDrawRectFill (double x1, double y1, double x2, double y2); 168 void bDrawTriOpen (double x1, double y1, double x2, double y2, double x3, double y3); 169 void bDrawTriFill (double x1, double y1, double x2, double y2, double x3, double y3); 170 171 /* bDrawRotFont.c */ 172 int bDrawRotText (int x, int y, char *string, int pos, double angle); 173 int bDrawRotBitmap (int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale); 174 68 175 # endif -
trunk/Ohana/src/libkapa/include/kapa_internal.h
r5848 r5852 10 10 # include <time.h> 11 11 # include <errno.h> 12 12 13 # include <ohana.h> 13 14 # include <dvo.h> -
trunk/Ohana/src/libkapa/src/IOfuncs.c
r5848 r5852 1 1 # include <kapa_internal.h> 2 3 /* why is this not defined in stdarg.h for linux/x64? */ 4 int vsscanf(const char *str, const char *format, va_list ap); 5 6 int 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 13 char *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 } 2 30 3 31 /* send a message of arbitrary size, sending the size first */ … … 14 42 if (!Nbyte) return (FALSE); 15 43 44 /* the message may contain up to 99,999,999,999 bytes (100MB) */ 16 45 va_start (argp, format); 17 KiiSendCommand (device, 16, " NBYTES: %6d", Nbyte);46 KiiSendCommand (device, 16, "LEN: %11d", Nbyte); 18 47 status = KiiSendCommandV (device, Nbyte, format, argp); 19 48 va_end (argp); 49 20 50 return (status); 21 51 } … … 29 59 status = KiiSendCommandV (device, length, format, argp); 30 60 va_end (argp); 61 31 62 return (status); 32 63 } … … 36 67 char *string; 37 68 38 /* I allocated and zero 1 extra byte */ 69 /* string is sent WITHOUT ending NULL char */ 70 /* allocate and zero length + 1 extra byte */ 39 71 ALLOCATE (string, char, length + 1); 40 72 memset (string, 0, length + 1); 41 73 vsnprintf (string, length + 1, format, argp); 42 74 43 /* fprintf (stderr, "msg: %s\n", string); */44 75 write (device, string, length); 45 76 free (string); 46 77 return (TRUE); 47 78 } 79 80 /* scan a message of arbitrary size, accepting the size first */ 81 int 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_internal s.h>1 # include <kapa_internal.h> 2 2 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; 3 int KiiResize (int fd, int Nx, int Ny) { 10 4 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); 19 7 return (TRUE); 20 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); 14 return (TRUE); 15 } 16 17 int 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 28 int 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 38 int 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 46 int 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 54 int 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 64 int 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 71 int 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 83 int KapaSelectSection (int fd, char *name) { 84 85 KiiSendCommand (fd, 4, "SSEC"); 86 KiiSendMessage (fd, "%s", name); 87 return (TRUE); 88 } 89 90 int 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 1 1 # include <kapa_internal.h> 2 2 3 int KiiJ peg(int fd, char *filename) {3 int KiiJPEG (int fd, char *filename) { 4 4 5 5 char buffer[20]; 6 6 7 7 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 15 int 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 27 int KapaPPM (int fd, char *filename) { 28 29 char buffer[20]; 30 31 KiiSendCommand (fd, 4, "PPMF"); 32 KiiSendMessage (fd, "%s", filename); 10 33 11 34 /* block for the response, which says the operation completed */ … … 32 55 33 56 name: 34 KiiSendCommand (fd, 16, "LEN: %11d", strlen(filename)); 35 write (fd, filename, strlen(filename)); 57 KiiSendMessage (fd, "%s", filename); 36 58 37 59 /* block for the response, which says the operation completed */ -
trunk/Ohana/src/libkapa/src/KiiOpen.c
r5848 r5852 4 4 int KiiOpen (char *kii_exec, char *name) { 5 5 6 int InitSocket, status , addreslen;6 int InitSocket, status; 7 7 struct sockaddr_un Address; 8 socklen_t AddressLength; 8 9 char temp[128], socket_name[64]; 9 10 int Ntry, fd; … … 30 31 system (temp); 31 32 32 addreslen= sizeof (Address);33 AddressLength = sizeof (Address); 33 34 fcntl (InitSocket, F_SETFL, O_NONBLOCK); 34 35 … … 36 37 Ntry = 0; 37 38 while (Ntry < NTRY) { 38 fd = accept (InitSocket, (struct sockaddr *)&Address, & addreslen);39 fd = accept (InitSocket, (struct sockaddr *)&Address, &AddressLength); 39 40 if (fd != -1) break; 40 41 if (errno != EAGAIN) break; … … 49 50 } 50 51 52 int 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 51 70 int KiiClose (int fd) { 52 71 -
trunk/Ohana/src/libkapa/src/KiiPicture.c
r5848 r5852 7 7 float *in, min, max; 8 8 char *out, *outbuffer, *root; 9 char buffer[1024];10 9 double a1, a2; 11 10 … … 13 12 14 13 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); 20 15 21 16 ALLOCATE (outbuffer, char, Npix); … … 47 42 48 43 /* 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); 51 48 KiiSendMessage (fd, "%f %f %g %g %g ", coords[0].crval1, coords[0].crpix1, coords[0].cdelt1, coords[0].pc1_1, coords[0].pc1_2); 52 49 KiiSendMessage (fd, "%f %f %g %g %g ", coords[0].crval2, coords[0].crpix2, coords[0].cdelt2, coords[0].pc2_1, coords[0].pc2_2); … … 55 52 root = filerootname (image[0].file); 56 53 KiiSendMessage (fd, "%s %s %s ", coords[0].ctype, root, image[0].name); 54 free (root); 57 55 58 56 /* send the image data */ … … 135 133 KiiSendFilename 136 134 */ 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.
