Changeset 13479
- Timestamp:
- May 22, 2007, 12:23:09 PM (19 years ago)
- Location:
- trunk/Ohana
- Files:
-
- 21 added
- 159 edited
-
Makefile.in (modified) (2 diffs)
-
src/addstar/src/SEDops.c (modified) (6 diffs)
-
src/gastro/Makefile (modified) (1 diff)
-
src/gastro/src/plotstuff.c (modified) (3 diffs)
-
src/gastro2/Makefile (modified) (1 diff)
-
src/gastro2/src/plotstuff.c (modified) (3 diffs)
-
src/kapa2/Makefile (modified) (5 diffs)
-
src/kapa2/include/constants.h (modified) (1 diff)
-
src/kapa2/include/globals.h (modified) (1 diff)
-
src/kapa2/include/prototypes.h (modified) (5 diffs)
-
src/kapa2/include/structures.h (modified) (4 diffs)
-
src/kapa2/src/CSaveOverlay.c (modified) (4 diffs)
-
src/kapa2/src/Center.c (modified) (2 diffs)
-
src/kapa2/src/CheckPipe.c (modified) (2 diffs)
-
src/kapa2/src/CheckVisual.c (modified) (2 diffs)
-
src/kapa2/src/CreatePicture.c (modified) (1 diff)
-
src/kapa2/src/CreateZoom16.c (modified) (6 diffs)
-
src/kapa2/src/CreateZoom24.c (modified) (5 diffs)
-
src/kapa2/src/CreateZoom32.c (modified) (5 diffs)
-
src/kapa2/src/CreateZoom8.c (modified) (6 diffs)
-
src/kapa2/src/DefineSection.c (modified) (3 diffs)
-
src/kapa2/src/EraseCurrentPlot.c (modified) (1 diff)
-
src/kapa2/src/EraseImage.c (added)
-
src/kapa2/src/EraseOverlay.c (modified) (2 diffs)
-
src/kapa2/src/GetPixelCount.c (modified) (1 diff)
-
src/kapa2/src/Graphs.c (modified) (2 diffs)
-
src/kapa2/src/Image.c (modified) (5 diffs)
-
src/kapa2/src/InterpretKeys.c (modified) (4 diffs)
-
src/kapa2/src/InterpretPresses.c (modified) (4 diffs)
-
src/kapa2/src/JPEGit24.c (modified) (5 diffs)
-
src/kapa2/src/Layout.c (modified) (2 diffs)
-
src/kapa2/src/LoadFrame.c (modified) (3 diffs)
-
src/kapa2/src/LoadLabels.c (modified) (3 diffs)
-
src/kapa2/src/LoadObject.c (modified) (11 diffs)
-
src/kapa2/src/LoadOverlay.c (modified) (2 diffs)
-
src/kapa2/src/LoadPicture.c (modified) (3 diffs)
-
src/kapa2/src/LoadTextlines.c (modified) (3 diffs)
-
src/kapa2/src/LoadTickmarks.c (modified) (3 diffs)
-
src/kapa2/src/PNGit.c (modified) (1 diff)
-
src/kapa2/src/PPMit.c (modified) (1 diff)
-
src/kapa2/src/PSOverlay.c (modified) (1 diff)
-
src/kapa2/src/PSit.c (modified) (1 diff)
-
src/kapa2/src/PaintOverlay.c (modified) (1 diff)
-
src/kapa2/src/PaintTickmarks.c (modified) (1 diff)
-
src/kapa2/src/Reconfig.c (modified) (1 diff)
-
src/kapa2/src/Refresh.c (modified) (1 diff)
-
src/kapa2/src/Remap16.c (modified) (6 diffs)
-
src/kapa2/src/Remap24.c (modified) (6 diffs)
-
src/kapa2/src/Remap32.c (modified) (5 diffs)
-
src/kapa2/src/Remap8.c (modified) (5 diffs)
-
src/kapa2/src/Resize.c (modified) (2 diffs)
-
src/kapa2/src/SaveOverlay.c (modified) (4 diffs)
-
src/kapa2/src/Sections.c (modified) (4 diffs)
-
src/kapa2/src/SetFont.c (modified) (1 diff)
-
src/kapa2/src/SetGraphData.c (added)
-
src/kapa2/src/SetGraphSize.c (modified) (2 diffs)
-
src/kapa2/src/SetGraphStyle.c (added)
-
src/kapa2/src/SetImageData.c (added)
-
src/kapa2/src/SetImageSize.c (modified) (2 diffs)
-
src/kapa2/src/SetLimits.c (modified) (3 diffs)
-
src/kapa2/src/SetNormalHints.c (modified) (1 diff)
-
src/kapa2/src/SetSection.c (modified) (1 diff)
-
src/kapa2/src/SetToolbox.c (added)
-
src/kapa2/src/UpdatePointer.c (modified) (4 diffs)
-
src/kapa2/src/UpdateStatusBox.c (modified) (4 diffs)
-
src/kapa2/src/bDrawIt.c (modified) (1 diff)
-
src/kapa2/src/bDrawOverlay.c (modified) (2 diffs)
-
src/kapa2/src/kapa.c (modified) (1 diff)
-
src/kii/event/CheckPipe.c (modified) (2 diffs)
-
src/libkapa/Makefile (modified) (1 diff)
-
src/libkapa/doc/api.txt (added)
-
src/libkapa/include/kapa.h (modified) (9 diffs)
-
src/libkapa/src/IOfuncs.c (modified) (6 diffs)
-
src/libkapa/src/KapaOpen.c (modified) (6 diffs)
-
src/libkapa/src/KapaWindow.c (modified) (9 diffs)
-
src/libkapa/src/KiiConvert.c (modified) (4 diffs)
-
src/libkapa/src/KiiCursor.c (modified) (1 diff)
-
src/libkapa/src/KiiOverlay.c (modified) (4 diffs)
-
src/libkapa/src/KiiPicture.c (modified) (8 diffs)
-
src/opihi/cmd.astro/cgrid.c (modified) (3 diffs)
-
src/opihi/cmd.astro/cplot.c (modified) (3 diffs)
-
src/opihi/cmd.astro/czplot.c (modified) (4 diffs)
-
src/opihi/cmd.astro/gauss.c (modified) (3 diffs)
-
src/opihi/cmd.astro/objload.c (modified) (2 diffs)
-
src/opihi/cmd.astro/outline.c (modified) (3 diffs)
-
src/opihi/cmd.astro/outline2.c (modified) (3 diffs)
-
src/opihi/cmd.astro/region.c (modified) (3 diffs)
-
src/opihi/cmd.data/box.c (modified) (2 diffs)
-
src/opihi/cmd.data/center.c (modified) (2 diffs)
-
src/opihi/cmd.data/clear.c (modified) (1 diff)
-
src/opihi/cmd.data/close.c (modified) (1 diff)
-
src/opihi/cmd.data/cursor.c (modified) (3 diffs)
-
src/opihi/cmd.data/device.c (modified) (1 diff)
-
src/opihi/cmd.data/dot.c (modified) (2 diffs)
-
src/opihi/cmd.data/erase.c (modified) (3 diffs)
-
src/opihi/cmd.data/grid.c (modified) (2 diffs)
-
src/opihi/cmd.data/init.c (modified) (1 diff)
-
src/opihi/cmd.data/jpeg.c (modified) (3 diffs)
-
src/opihi/cmd.data/labels.c (modified) (9 diffs)
-
src/opihi/cmd.data/limits.c (modified) (3 diffs)
-
src/opihi/cmd.data/line.c (modified) (2 diffs)
-
src/opihi/cmd.data/load.c (modified) (3 diffs)
-
src/opihi/cmd.data/plot.c (modified) (3 diffs)
-
src/opihi/cmd.data/point.c (modified) (3 diffs)
-
src/opihi/cmd.data/ps.c (modified) (2 diffs)
-
src/opihi/cmd.data/rd.c (modified) (6 diffs)
-
src/opihi/cmd.data/resize.c (modified) (2 diffs)
-
src/opihi/cmd.data/save.c (modified) (2 diffs)
-
src/opihi/cmd.data/section.c (modified) (3 diffs)
-
src/opihi/cmd.data/style.c (modified) (2 diffs)
-
src/opihi/cmd.data/textline.c (modified) (3 diffs)
-
src/opihi/cmd.data/tv.c (modified) (3 diffs)
-
src/opihi/cmd.data/tvcontour.c (modified) (2 diffs)
-
src/opihi/cmd.data/tvgrid.c (modified) (2 diffs)
-
src/opihi/cmd.data/vload.c (modified) (2 diffs)
-
src/opihi/cmd.data/zplot.c (modified) (3 diffs)
-
src/opihi/dimm/dimm.c.in (modified) (1 diff)
-
src/opihi/dvo/ImageSelection.c (modified) (1 diff)
-
src/opihi/dvo/Makefile (modified) (1 diff)
-
src/opihi/dvo/avextract.c (modified) (3 diffs)
-
src/opihi/dvo/catalog.c (modified) (2 diffs)
-
src/opihi/dvo/cmpload.c (modified) (2 diffs)
-
src/opihi/dvo/dbBooleanCond.c (added)
-
src/opihi/dvo/dbCheckStack.c (added)
-
src/opihi/dvo/dbCmdlineFields.c (added)
-
src/opihi/dvo/dbExtractAverages.c (added)
-
src/opihi/dvo/dbExtractMeasures.c (added)
-
src/opihi/dvo/dbFields.c (added)
-
src/opihi/dvo/dbRPN.c (added)
-
src/opihi/dvo/dbStackMath.c (added)
-
src/opihi/dvo/dbStackOps.c (added)
-
src/opihi/dvo/db_check_stack.c (added)
-
src/opihi/dvo/db_convert_to_RPN.c (added)
-
src/opihi/dvo/dmt.c (modified) (3 diffs)
-
src/opihi/dvo/dvo.c.in (modified) (1 diff)
-
src/opihi/dvo/dvoBooleanElements.c (added)
-
src/opihi/dvo/dvoEvaluateStack.c (added)
-
src/opihi/dvo/dvodb.c (added)
-
src/opihi/dvo/dvofields.c (added)
-
src/opihi/dvo/extract.c (modified) (1 diff)
-
src/opihi/dvo/fitcolors.c (modified) (6 diffs)
-
src/opihi/dvo/fitsed.c (modified) (6 diffs)
-
src/opihi/dvo/images.c (modified) (4 diffs)
-
src/opihi/dvo/imbox.c (modified) (4 diffs)
-
src/opihi/dvo/imdense.c (modified) (3 diffs)
-
src/opihi/dvo/imextract.c (modified) (2 diffs)
-
src/opihi/dvo/imlist.c (modified) (1 diff)
-
src/opihi/dvo/imstats.c (modified) (3 diffs)
-
src/opihi/dvo/lcat.c (modified) (1 diff)
-
src/opihi/dvo/lcurve.c (modified) (4 diffs)
-
src/opihi/dvo/mextract.c (modified) (3 diffs)
-
src/opihi/dvo/paverage.c (modified) (5 diffs)
-
src/opihi/dvo/pcat.c (modified) (4 diffs)
-
src/opihi/dvo/photometry.c (modified) (2 diffs)
-
src/opihi/dvo/pmeasure.c (modified) (5 diffs)
-
src/opihi/dvo/procks.c (modified) (4 diffs)
-
src/opihi/dvo/region_list.c (modified) (2 diffs)
-
src/opihi/dvo/scripts/navigate (modified) (4 diffs)
-
src/opihi/dvo/showtile.c (modified) (3 diffs)
-
src/opihi/dvo/simage.c (modified) (2 diffs)
-
src/opihi/dvo/skycat.c (modified) (4 diffs)
-
src/opihi/include/data.h (modified) (1 diff)
-
src/opihi/include/display.h (modified) (1 diff)
-
src/opihi/include/dvoshell.h (modified) (2 diffs)
-
src/opihi/lib.data/Makefile (modified) (1 diff)
-
src/opihi/lib.data/PlotVectors.c (modified) (1 diff)
-
src/opihi/lib.data/graphtools.c (modified) (2 diffs)
-
src/opihi/lib.data/open_image.c (modified) (1 diff)
-
src/opihi/lib.data/open_kapa.c (modified) (4 diffs)
-
src/opihi/lib.data/style_args.c (modified) (1 diff)
-
src/opihi/lib.shell/BufferOps.c (modified) (1 diff)
-
src/opihi/lib.shell/startup.c (modified) (1 diff)
-
src/opihi/mana/mana.c.in (modified) (1 diff)
-
src/opihi/mana/opihi.c (modified) (1 diff)
-
src/opihi/pantasks/pantasks.c.in (modified) (1 diff)
-
src/opihi/pantasks/pantasks_client.c.in (modified) (1 diff)
-
src/opihi/pantasks/pantasks_server.c (modified) (1 diff)
-
src/relastro/src/plotstuff.c (modified) (5 diffs)
-
src/relphot/src/plotstuff.c (modified) (5 diffs)
-
src/uniphot/src/plotstuff.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/Makefile.in
r12859 r13479 37 37 imclean \ 38 38 imregister \ 39 kapa \ 40 kii \ 39 kapa2 \ 41 40 misc \ 42 41 mosastro \ … … 96 95 mana: 97 96 make libs 98 make kii.install 99 make kapa.install 97 make kapa2.install 100 98 cd src/opihi; make mana.install && exit 101 99 102 100 dvoshell: 103 101 make libs 104 make kii.install 105 make kapa.install 102 make kapa2.install 106 103 cd src/opihi; make dvo.install && exit 107 104 -
trunk/Ohana/src/addstar/src/SEDops.c
r8361 r13479 111 111 graphdata.style = 2; 112 112 graphdata.ptype = 2; 113 KapaClear (Xgraph, TRUE);113 KapaClearSections (Xgraph); 114 114 magSection.name = strcreate ("mag"); 115 115 magSection.x = 0; … … 141 141 142 142 int j, minRow, Nfilter; 143 double X, Y ;143 double X, Y, Z, RA, DEC; 144 144 char line[1024], key[20]; 145 145 … … 156 156 SWAP (graphdata.ymin, graphdata.ymax); 157 157 158 KapaClear (Xgraph, TRUE);158 KapaClearSections (Xgraph); 159 159 KapaSetSection (Xgraph, &magSection); 160 160 KapaSetLimits (Xgraph, &graphdata); … … 164 164 graphdata.ptype = 7; 165 165 KapaPrepPlot (Xgraph, Nfilter, &graphdata); 166 KapaPlotVector (Xgraph, Nfilter, table[0].wavecode );167 KapaPlotVector (Xgraph, Nfilter, fitmags );166 KapaPlotVector (Xgraph, Nfilter, table[0].wavecode, "x"); 167 KapaPlotVector (Xgraph, Nfilter, fitmags, "y"); 168 168 169 169 graphdata.color = KapaColorByName ("red"); … … 178 178 } 179 179 KapaPrepPlot (Xgraph, Nfilter, &graphdata); 180 KapaPlotVector (Xgraph, Nfilter, table[0].wavecode );181 KapaPlotVector (Xgraph, Nfilter, fitmags );182 KapaPlotVector (Xgraph, Nfilter, fiterrs );183 KapaPlotVector (Xgraph, Nfilter, fiterrs );180 KapaPlotVector (Xgraph, Nfilter, table[0].wavecode, "x"); 181 KapaPlotVector (Xgraph, Nfilter, fitmags, "x"); 182 KapaPlotVector (Xgraph, Nfilter, fiterrs, "dym"); 183 KapaPlotVector (Xgraph, Nfilter, fiterrs, "dyp"); 184 184 KapaSendLabel (Xgraph, "model,fit (mags)", 1); 185 185 … … 208 208 } 209 209 KapaPrepPlot (Xgraph, Nfilter, &graphdata); 210 KapaPlotVector (Xgraph, Nfilter, table[0].wavecode );211 KapaPlotVector (Xgraph, Nfilter, fitmags );212 KapaPlotVector (Xgraph, Nfilter, fiterrs );213 KapaPlotVector (Xgraph, Nfilter, fiterrs );210 KapaPlotVector (Xgraph, Nfilter, table[0].wavecode, "x"); 211 KapaPlotVector (Xgraph, Nfilter, fitmags, "y"); 212 KapaPlotVector (Xgraph, Nfilter, fiterrs, "dym"); 213 KapaPlotVector (Xgraph, Nfilter, fiterrs, "dyp"); 214 214 KapaSendLabel (Xgraph, "wavelength (nm)", 0); 215 215 KapaSendLabel (Xgraph, "resid (mags)", 1); 216 216 217 217 KiiCursorOn (Xgraph); 218 while (KiiCursorRead (Xgraph, &X, &Y, key)) {218 while (KiiCursorRead (Xgraph, &X, &Y, &Z, &RA, &DEC, key)) { 219 219 // fprintf (stderr, "window: %f %f (%s)\n", X, Y, key); 220 220 if (!strcasecmp (key, "Q")) { -
trunk/Ohana/src/gastro/Makefile
r12842 r13479 15 15 FULL_CFLAGS = $(BASE_CFLAGS) 16 16 FULL_CPPFLAGS = $(BASE_CPPFLAGS) 17 FULL_LDFLAGS = -l dvo -lFITS -lohana $(BASE_LDFLAGS)17 FULL_LDFLAGS = -lkapa -ldvo -lFITS -lohana $(BASE_LDFLAGS) 18 18 19 19 gastro: $(BIN)/gastro.$(ARCH) -
trunk/Ohana/src/gastro/src/plotstuff.c
r12332 r13479 13 13 int open_graph (int N) { 14 14 15 # ifdef ANSI 16 # define F_SETFL 4 17 # define O_NONBLOCK 0200000 18 # define AF_UNIX 1 19 # define SOCK_STREAM 1 20 #define ENOENT 2 /* No such file or directory */ 21 # endif /* ANSI */ 22 23 int InitSocket, status; 24 socklen_t addreslen; 25 struct sockaddr_un Address; 26 char temp[100]; 27 char socket_name[100]; 15 char name[100]; 28 16 29 17 active = N; 30 sprintf (socket_name, "/tmp/kapa%d", N); 31 sprintf (temp, "rm -f %s", socket_name); 32 system (temp); 33 34 strcpy (Address.sun_path, socket_name); 35 Address.sun_family = AF_UNIX; 36 InitSocket = socket (AF_UNIX, SOCK_STREAM, 0); 37 status = bind (InitSocket, (struct sockaddr *) &Address, sizeof (Address)); 38 status = listen (InitSocket, 1); 39 40 sprintf (temp, "kapa %s &", socket_name); 41 # ifndef DEBUG 42 system (temp); 43 # else 44 fprintf (stderr, "start kapa, press return: %s\n", temp); 45 fscanf (stdin, "%d", &i); 46 # endif 47 48 addreslen = sizeof (Address); 49 Xgraph[N] = accept (InitSocket, (struct sockaddr *) &Address, &addreslen); 18 19 sprintf (name, "gastro [%d]", N); 20 Xgraph[N] = KapaOpen ("kapa", name); 21 50 22 if (Xgraph[N] < 0) { 51 23 fprintf (stderr, "error starting kapa\n"); 52 24 return (FALSE); 53 25 } 54 else { 55 return (TRUE); 56 } 57 26 return (TRUE); 58 27 } 59 28 60 29 void DonePlotting (Graphdata *graphmode, int N) { 61 char buffer[65], buffer2[65];62 30 63 write (Xgraph[N], "DBOX", 4); 64 sprintf (buffer, "%f %f %f %f ", graphmode[0].xmin, graphmode[0].xmax, graphmode[0].ymin, graphmode[0].ymax); 65 sprintf (buffer2, "NBYTES: %6d ", (unsigned int) strlen (buffer)); 66 write (Xgraph[N], buffer2, 16); 67 write (Xgraph[N], buffer, strlen (buffer)); 68 69 sprintf (buffer, "%s %s %s", "2222", "2222", "2222"); 70 sprintf (buffer2, "NBYTES: %6d ", (unsigned int) strlen (buffer)); 71 write (Xgraph[N], buffer2, 16); 72 write (Xgraph[N], buffer, strlen (buffer)); 31 if (Xgraph[N] == 0) return; 32 KapaBox (Xgraph[N], graphmode); 33 return; 73 34 } 74 35 75 36 void PrepPlotting (int Npts, Graphdata *graphmode, int N) { 76 37 77 int i, status; 78 char buffer[128], buffer2[128]; 38 if (Xgraph[N] == 0) return; 79 39 80 40 active = N; 81 41 if (Npts < 1) return; 82 42 83 /* test Xgraph[N], flush junk from pipe */ 84 signal (SIGPIPE, XDead); 85 fcntl (Xgraph[N], F_SETFL, O_NONBLOCK); 86 for (i = 0; (read (Xgraph[N], buffer, 64) > 0) && (i < 20); i++); 87 fcntl (Xgraph[N], F_SETFL, !O_NONBLOCK); 88 89 if (Xgraph[N] < 1) if (!open_graph(N)) return; 90 91 /* tell kapa to look for the incoming image */ 92 status = write (Xgraph[N], "PLOT", 4); 93 94 /* send Xgraph[N] the plot details */ 95 sprintf (buffer, "%8d %8d %d %d %d %d %f %f ", 96 Npts, graphmode[0].style, 97 graphmode[0].ptype, graphmode[0].ltype, 98 graphmode[0].etype, graphmode[0].color, 99 graphmode[0].lweight, graphmode[0].size); 100 sprintf (buffer2, "NBYTES: %6d ", (unsigned int) strlen (buffer)); 101 write (Xgraph[N], buffer2, 16); 102 write (Xgraph[N], buffer, strlen (buffer)); 103 104 sprintf (buffer, "%f %f %f %f ", 105 graphmode[0].xmin, graphmode[0].xmax, 106 graphmode[0].ymin, graphmode[0].ymax); 107 sprintf (buffer2, "NBYTES: %6d ", (unsigned int) strlen (buffer)); 108 write (Xgraph[N], buffer2, 16); 109 write (Xgraph[N], buffer, strlen (buffer)); 110 43 KapaPrepPlot (Xgraph[N], Npts, graphmode); 111 44 } 112 45 … … 116 49 117 50 if (Npts < 1) return; 118 119 51 active = N; 120 Nbytes = Npts * sizeof (float); 121 write (Xgraph[N], vect, Nbytes); 122 52 KapaPlotVector (Xgraph[N], Npts, vect); 123 53 } 124 54 … … 135 65 136 66 if (Xgraph[N] < 1) if (!open_graph(N)) return; 137 138 write (Xgraph[N], "ERAS", 4); 67 KapaClearSections (Xgraph[N]); 68 } 139 69 140 }141 70 /* include these lines to plot a pair of vectors: 142 71 -
trunk/Ohana/src/gastro2/Makefile
r12842 r13479 15 15 FULL_CFLAGS = $(BASE_CFLAGS) 16 16 FULL_CPPFLAGS = $(BASE_CPPFLAGS) 17 FULL_LDFLAGS = -l dvo -lFITS -lohana $(BASE_LDFLAGS)17 FULL_LDFLAGS = -lkapa -ldvo -lFITS -lohana $(BASE_LDFLAGS) 18 18 19 19 gastro2: $(BIN)/gastro2.$(ARCH) -
trunk/Ohana/src/gastro2/src/plotstuff.c
r12332 r13479 13 13 int open_graph (int N) { 14 14 15 # ifdef ANSI 16 # define F_SETFL 4 17 # define O_NONBLOCK 0200000 18 # define AF_UNIX 1 19 # define SOCK_STREAM 1 20 #define ENOENT 2 /* No such file or directory */ 21 # endif /* ANSI */ 22 23 int InitSocket, status; 24 socklen_t addreslen; 25 struct sockaddr_un Address; 26 char temp[100]; 27 char socket_name[100]; 15 char name[100]; 28 16 29 17 active = N; 30 sprintf (socket_name, "/tmp/kapa%d", N); 31 sprintf (temp, "rm -f %s", socket_name); 32 system (temp); 33 34 strcpy (Address.sun_path, socket_name); 35 Address.sun_family = AF_UNIX; 36 InitSocket = socket (AF_UNIX, SOCK_STREAM, 0); 37 status = bind (InitSocket, (struct sockaddr *) &Address, sizeof (Address)); 38 status = listen (InitSocket, 1); 39 40 sprintf (temp, "kapa %s -name %d &", socket_name, N); 41 # ifndef DEBUG 42 system (temp); 43 # else 44 fprintf (stderr, "start kapa, press return: %s\n", temp); 45 fscanf (stdin, "%d", &i); 46 # endif 47 48 addreslen = sizeof (Address); 49 Xgraph[N] = accept (InitSocket, (struct sockaddr *) &Address, &addreslen); 18 19 sprintf (name, "gastro [%d]", N); 20 Xgraph[N] = KapaOpen ("kapa", name); 21 50 22 if (Xgraph[N] < 0) { 51 23 fprintf (stderr, "error starting kapa\n"); 52 24 return (FALSE); 53 25 } 54 else { 55 return (TRUE); 56 } 57 26 return (TRUE); 58 27 } 59 28 60 29 void DonePlotting (Graphdata *graphmode, int N) { 61 char buffer[65], buffer2[65];62 30 63 write (Xgraph[N], "DBOX", 4); 64 sprintf (buffer, "%f %f %f %f", graphmode[0].xmin, graphmode[0].xmax, graphmode[0].ymin, graphmode[0].ymax); 65 sprintf (buffer2, "NBYTES: %6d", (unsigned int) strlen (buffer)); 66 write (Xgraph[N], buffer2, 16); 67 write (Xgraph[N], buffer, strlen (buffer)); 68 69 sprintf (buffer, "%s %s %s", "2222", "2222", "2222"); 70 sprintf (buffer2, "NBYTES: %6d", (unsigned int) strlen (buffer)); 71 write (Xgraph[N], buffer2, 16); 72 write (Xgraph[N], buffer, strlen (buffer)); 31 if (Xgraph[N] == 0) return; 32 KapaBox (Xgraph[N], graphmode); 33 return; 73 34 } 74 35 75 36 void PrepPlotting (int Npts, Graphdata *graphmode, int N) { 76 37 77 int i, status; 78 char buffer[128], buffer2[128]; 38 if (Xgraph[N] == 0) return; 79 39 80 40 active = N; 81 41 if (Npts < 1) return; 82 42 83 /* test Xgraph[N], flush junk from pipe */ 84 signal (SIGPIPE, XDead); 85 fcntl (Xgraph[N], F_SETFL, O_NONBLOCK); 86 for (i = 0; (read (Xgraph[N], buffer, 64) > 0) && (i < 20); i++); 87 fcntl (Xgraph[N], F_SETFL, !O_NONBLOCK); 88 89 if (Xgraph[N] < 1) if (!open_graph(N)) return; 90 91 /* tell kapa to look for the incoming image */ 92 status = write (Xgraph[N], "PLOT", 4); 93 94 /* send Xgraph[N] the plot details */ 95 sprintf (buffer, "%8d %8d %d %d %d %d %d %f %f", 96 Npts, graphmode[0].style, 97 graphmode[0].ptype, graphmode[0].ltype, 98 graphmode[0].etype, graphmode[0].ebar, graphmode[0].color, 99 graphmode[0].lweight, graphmode[0].size); 100 sprintf (buffer2, "NBYTES: %6d", (unsigned int) strlen (buffer)); 101 write (Xgraph[N], buffer2, 16); 102 write (Xgraph[N], buffer, strlen (buffer)); 103 104 sprintf (buffer, "%f %f %f %f", 105 graphmode[0].xmin, graphmode[0].xmax, 106 graphmode[0].ymin, graphmode[0].ymax); 107 sprintf (buffer2, "NBYTES: %6d", (unsigned int) strlen (buffer)); 108 write (Xgraph[N], buffer2, 16); 109 write (Xgraph[N], buffer, strlen (buffer)); 110 43 KapaPrepPlot (Xgraph[N], Npts, graphmode); 111 44 } 112 45 … … 116 49 117 50 if (Npts < 1) return; 118 119 51 active = N; 120 Nbytes = Npts * sizeof (float); 121 write (Xgraph[N], vect, Nbytes); 122 52 KapaPlotVector (Xgraph[N], Npts, vect); 123 53 } 124 54 … … 135 65 136 66 if (Xgraph[N] < 1) if (!open_graph(N)) return; 137 138 write (Xgraph[N], "ERAS", 4); 67 KapaClearSections (Xgraph[N]); 68 } 139 69 140 }141 70 /* include these lines to plot a pair of vectors: 142 71 -
trunk/Ohana/src/kapa2/Makefile
r13333 r13479 1 default: kapa 21 default: kapa 2 2 help: 3 3 @echo "make options: kapa (default)" … … 20 20 INDEPS = $(DESTINC)/kapa.h $(DESTINC)/dvo.h $(DESTINC)/gfitsio.h $(DESTINC)/ohana.h 21 21 22 kapa2: $(BIN)/kapa 2.$(ARCH)23 install: $(DESTBIN)/kapa 222 kapa2: $(BIN)/kapa.$(ARCH) 23 install: $(DESTBIN)/kapa 24 24 25 25 KAPA = \ … … 49 49 $(SRC)/Graphs.$(ARCH).o $(SRC)/SetGraphSize.$(ARCH).o \ 50 50 $(SRC)/Resize.$(ARCH).o $(SRC)/ErasePlots.$(ARCH).o \ 51 $(SRC)/EraseImage.$(ARCH).o $(SRC)/SetToolbox.$(ARCH).o \ 51 52 $(SRC)/EraseCurrentPlot.$(ARCH).o $(SRC)/EraseSections.$(ARCH).o \ 52 53 $(SRC)/SetSection.$(ARCH).o $(SRC)/DefineSection.$(ARCH).o \ … … 64 65 $(SRC)/CreatePicture.$(ARCH).o $(SRC)/CreateColorbar.$(ARCH).o \ 65 66 $(SRC)/MakeColormap.$(ARCH).o $(SRC)/SetColormap.$(ARCH).o \ 66 $(SRC)/PaintOverlay.$(ARCH).o $(SRC)/ PaintTickmarks.$(ARCH).o\67 $(SRC)/PaintOverlay.$(ARCH).o $(SRC)/SetGraphData.$(ARCH).o \ 67 68 $(SRC)/LoadOverlay.$(ARCH).o $(SRC)/EraseOverlay.$(ARCH).o \ 68 $(SRC)/ LoadTickmarks.$(ARCH).o $(SRC)/SaveOverlay.$(ARCH).o\69 $(SRC)/SaveOverlay.$(ARCH).o $(SRC)/SetImageData.$(ARCH).o \ 69 70 $(SRC)/CSaveOverlay.$(ARCH).o $(SRC)/EraseOverlay.$(ARCH).o \ 70 71 $(SRC)/CheckVisual.$(ARCH).o $(SRC)/CursorOps.$(ARCH).o \ … … 88 89 $(OBJ): $(INDEPS) $(LDDEPS) 89 90 90 $(BIN)/kapa 2.$(ARCH): $(OBJ)91 $(BIN)/kapa.$(ARCH): $(OBJ) -
trunk/Ohana/src/kapa2/include/constants.h
r13320 r13479 10 10 | PointerMotionMask) 11 11 12 # define PAD1 513 # define PAD2 312 # define PAD1 3 13 # define PAD2 5 14 14 # define TEXTPAD 25 15 15 # define COLORPAD 10 16 16 # define TEXT_Y 15 17 # define ZOOM_X 1 7018 # define ZOOM_Y 1 7017 # define ZOOM_X 152 18 # define ZOOM_Y 152 19 19 # define NOVERLAYS 4 20 20 # define BUTTON_WIDTH 28 -
trunk/Ohana/src/kapa2/include/globals.h
r13333 r13479 15 15 16 16 /* file descriptor for socket connection to mana */ 17 int sock;17 // int sock; 18 18 19 19 /* each layout / section defines one of the active portions of the graphics window -
trunk/Ohana/src/kapa2/include/prototypes.h
r13333 r13479 39 39 40 40 /* EventLoop */ 41 int PScommand PROTO(( ));41 int PScommand PROTO((int sock)); 42 42 int CheckPipe PROTO(()); 43 43 int Reconfig PROTO((XEvent *event)); … … 45 45 46 46 /* CheckPipe */ 47 int PNGit PROTO(()); 48 int PPMit PROTO(()); 49 int LoadFrame PROTO(()); 50 int LoadObject PROTO(()); 51 int LoadLabels PROTO(()); 52 int LoadTextlines PROTO(()); 53 int LoadVectorData PROTO(()); 54 int Resize PROTO(()); 55 int GetLimits PROTO(()); 56 int SetLimits PROTO(()); 57 int SetSection PROTO(()); 58 int ListSection PROTO(()); 59 int DefineSection PROTO(()); 60 int SetFont PROTO(()); 61 int EraseCurrentPlot PROTO(()); 62 int ErasePlots PROTO(()); 63 int EraseSections PROTO(()); 47 int PNGit PROTO((int sock)); 48 int PPMit PROTO((int sock)); 49 int LoadFrame PROTO((int sock)); 50 int LoadObject PROTO((int sock)); 51 int LoadLabels PROTO((int sock)); 52 int LoadTextlines PROTO((int sock)); 53 int Resize PROTO((int sock)); 54 int GetLimits PROTO((int sock)); 55 int SetLimits PROTO((int sock)); 56 int SetSection PROTO((int sock)); 57 int ListSection PROTO((int sock)); 58 int MoveSection PROTO((int sock)); 59 int DefineSection PROTO((int sock)); 60 int SetFont PROTO((int sock)); 61 int EraseCurrentPlot PROTO((void)); 62 int ErasePlots PROTO((void)); 63 int EraseSections PROTO((void)); 64 int EraseImage PROTO((void)); 65 int SetGraphData PROTO((int sock)); 66 int GetGraphData PROTO((int sock)); 67 int SetImageData PROTO((int sock)); 68 int GetImageData PROTO((int sock)); 69 70 int LoadVectorData PROTO((int sock, KapaGraphWidget *graph, int N, char *type)); 64 71 65 72 /* Section Utilities */ … … 74 81 Section *GetActiveSection PROTO(()); 75 82 int SetActiveSectionByNumber PROTO((int N)); 76 int ListSection PROTO(( ));83 int ListSection PROTO((int sock)); 77 84 78 85 KapaGraphWidget *InitGraph PROTO(()); 79 86 void DrawGraph PROTO((KapaGraphWidget *graph)); 80 87 void SetGraphSize PROTO((Section *section)); 88 void FreeGraph PROTO((KapaGraphWidget *graph)); 81 89 82 90 void InitLayout PROTO((int argc, char **argv)); … … 124 132 void QuitX PROTO((Display *display, char *message)); 125 133 Graphic *GetGraphic PROTO(()); 134 int GetPixelCount PROTO((int sock)); 126 135 127 136 int Center PROTO(()); … … 131 140 void Remap24 PROTO((Graphic *graphic, KapaImageWidget *image, Matrix *matrix)); 132 141 void Remap32 PROTO((Graphic *graphic, KapaImageWidget *image, Matrix *matrix)); 133 int LoadPicture PROTO(()); 142 int LoadPicture PROTO((int sock)); 143 134 144 KapaImageWidget *InitImage PROTO(()); 145 void FreeImage PROTO((KapaImageWidget *image)); 135 146 void SetImageSize PROTO((Section *section)); 136 int GetPixelCount PROTO(()); 147 137 148 void InitButtonSize PROTO((Button *button, int width, int height, char *bitmap)); 138 149 void InitButtonFunc PROTO((Button *button, int (*function)())); -
trunk/Ohana/src/kapa2/include/structures.h
r13320 r13479 95 95 int Nobjects; 96 96 unsigned long color; 97 Object*objects;97 KiiOverlay *objects; 98 98 } Overlay; 99 99 … … 116 116 Axis axis[4]; /* coordinate axes */ 117 117 Label label[8]; /* fixed axis labels */ 118 Graphdata data; /* current graph data */ 118 119 119 120 Gobjects *objects; /* graphic objects */ … … 138 139 Button grey_button; 139 140 Button rainbow_button; 140 Button puns_button;141 Button puns_button; 141 142 Button overlay_button[NOVERLAYS]; 142 143 143 144 // location of the status box 144 145 int text_x, text_y; 146 int text_dx, text_dy; 145 147 int location; // position of the zoom/status widgets (0 = none, 1-4 = bottom,left,top,right) 146 148 int MovePointer; … … 159 161 Coords coords; 160 162 char file[1024]; /* name of file */ 161 char buffer_name[1024]; /* name of buffer */163 char name[1024]; /* name of buffer */ 162 164 } KapaImageWidget; 163 165 -
trunk/Ohana/src/kapa2/src/CSaveOverlay.c
r13320 r13479 1 1 # include "Ximage.h" 2 2 3 int CSaveOverlay ( ) {3 int CSaveOverlay (int sock) { 4 4 5 char filename[256] ;5 char filename[256], *type; 6 6 int i, N; 7 7 double ra, dec, ra1, dec1, x1, y1, dra, ddec; … … 10 10 KapaImageWidget *image; 11 11 12 KiiScanMessage (sock, "%*s %d %s", &N, filename); 13 12 14 section = GetActiveSection(); 13 15 image = section->image; 16 if (image == NULL) return (TRUE); 14 17 15 KiiScanMessage (sock, "%*s %d %s", &N, filename);16 17 18 f = fopen (filename, "w"); 18 19 if (f == NULL) { … … 22 23 23 24 for (i = 0; i < image[0].overlay[N].Nobjects; i++) { 24 if ( !strcmp (image[0].overlay[N].objects[i].type, "LINE")) {25 if (image[0].overlay[N].objects[i].type == KII_OVERLAY_LINE) { 25 26 XY_to_RD (&ra, &dec, image[0].overlay[N].objects[i].x, image[0].overlay[N].objects[i].y, &image[0].coords); 26 27 x1 = image[0].overlay[N].objects[i].x + image[0].overlay[N].objects[i].dx; … … 40 41 dra = cos (dec*RAD_DEG) * fabs (ra1 - ra); 41 42 } 42 fprintf (f, "%s %lf %lf %lf %lf\n", image[0].overlay[N].objects[i].type, ra, dec, dra, ddec); 43 type = KiiOverlayTypeByNumber (image[0].overlay[N].objects[i].type); 44 if (type == NULL) continue; 45 fprintf (f, "%s %lf %lf %lf %lf\n", type, ra, dec, dra, ddec); 43 46 } 44 47 fclose (f); -
trunk/Ohana/src/kapa2/src/Center.c
r13320 r13479 1 1 # include "Ximage.h" 2 2 3 int Center ( ) {3 int Center (int sock) { 4 4 5 5 int zoom; … … 9 9 KapaImageWidget *image; 10 10 11 KiiScanMessage (sock, "%lf %lf %d", &X, &Y, &zoom); 12 11 13 graphic = GetGraphic(); 12 14 section = GetActiveSection(); 13 15 image = section->image; 14 15 KiiScanMessage (sock, "%lf %lf %d", &X, &Y, &zoom); 16 if (image == NULL) return (TRUE); 16 17 17 18 image[0].X = 0.5*image[0].matrix.Naxis[0] - X; -
trunk/Ohana/src/kapa2/src/CheckPipe.c
r13333 r13479 2 2 # define STRCONST(A) ((int)(0x1000000*A[0] + 0x10000*A[1] + 0x100*A[2] + 0x1*A[3])) 3 3 4 static KapaSockAddress Address; 5 static int InitSocket = -1; 6 static int sock = -1; 7 8 // we can supply a port here, with only small changes 9 void InitPipe () { 10 InitSocket = KapaServerInit (&Address); 11 return; 12 } 13 14 int GetActiveSocket () { 15 return (sock); 16 } 17 18 // after we have processed the command, we unblock the socket 19 # define FINISHED(A) { fcntl (sock, F_SETFL, O_NONBLOCK); return (A); } 20 4 21 int CheckPipe () { 5 22 6 23 int status; 7 char buffer[32]; 24 char word[5]; 25 26 // check if we have a valid connection. if not, see if we can get one 27 if (sock == -1) { 28 sock = KapaServerWait (InitSocket, &Address); 29 if (sock == -1) return (TRUE); 30 close (InitSocket); /* stop listening for new connections */ 31 fcntl (sock, F_SETFL, O_NONBLOCK); 32 } 8 33 9 34 /***** read (4 byte) message word from socket ****/ 10 status = read (sock, buffer, 4);11 buffer[4] = 0;35 status = read (sock, word, 4); 36 word[4] = 0; 12 37 switch (status) { 13 38 case -1: /* no input from pipe: continue */ … … 29 54 } 30 55 56 /* once we get a command, we block to ensure we get complete messages */ 57 fcntl (sock, F_SETFL, !O_NONBLOCK); 58 31 59 /***** handle different messages ****/ 32 60 if (ACTIVE_CURSOR) { 33 if (strcmp (buffer, "NCUR")) { 34 fprintf (stderr, "wrong end message %s\n", buffer); 35 return (TRUE); 61 if (strcmp (word, "NCUR")) { 62 fprintf (stderr, "wrong end message %s\n", word); 63 KiiSendCommand (sock, 4, "DONE"); 64 FINISHED (TRUE); 36 65 } 37 66 ACTIVE_CURSOR = FALSE; 38 return (TRUE); 67 KiiSendCommand (sock, 4, "DONE"); 68 FINISHED (TRUE); 39 69 } 40 70 41 if (!strcmp ( buffer, "QUIT")) return(FALSE);42 43 if (!strcmp ( buffer, "CURS")) {71 if (!strcmp (word, "QUIT")) FINISHED (FALSE); 72 73 if (!strcmp (word, "CURS")) { 44 74 ACTIVE_CURSOR = TRUE; 45 return (TRUE); 46 } 47 48 if (!strcmp (buffer, "PSIT")) { 49 status = PScommand (); 50 write (sock, "DONE", 4); 51 return (status); 52 } 53 54 if (!strcmp (buffer, "PNGF")) { 55 status = PNGit (); 56 write (sock, "DONE", 4); 57 return (status); 58 } 59 60 if (!strcmp (buffer, "PPMF")) { 61 status = PPMit (); 62 write (sock, "DONE", 4); 63 return (status); 64 } 65 66 if (!strcmp (buffer, "DBOX")) { 67 status = LoadFrame (); 68 return (status); 69 } 70 71 if (!strcmp (buffer, "PLOT")) { 72 status = LoadObject (); 73 return (status); 74 } 75 76 if (!strcmp (buffer, "LABL")) { 77 status = LoadLabels (); 78 return (TRUE); 79 } 80 81 if (!strcmp (buffer, "PTXT")) { 82 status = LoadTextlines (); 83 return (TRUE); 84 } 85 86 if (!strcmp (buffer, "RSIZ")) { 87 status = Resize (); 88 return (status); 89 } 90 91 if (!strcmp (buffer, "LIMS")) { 92 GetLimits (); 93 return (TRUE); 94 } 95 96 if (!strcmp (buffer, "SLIM")) { 97 status = SetLimits (); 98 return (TRUE); 99 } 100 101 if (!strcmp (buffer, "SSEC")) { 102 status = SetSection (); 103 return (TRUE); 104 } 105 106 if (!strcmp (buffer, "LSEC")) { 107 status = ListSection (); 108 return (TRUE); 109 } 110 111 if (!strcmp (buffer, "DSEC")) { 112 status = DefineSection (); 113 return (TRUE); 114 } 115 116 if (!strcmp (buffer, "FONT")) { 117 status = SetFont (); 118 return (TRUE); 75 KiiSendCommand (sock, 4, "DONE"); 76 FINISHED (TRUE); 77 } 78 79 if (!strcmp (word, "PSIT")) { 80 status = PScommand (sock); 81 KiiSendCommand (sock, 4, "DONE"); 82 FINISHED (status); 83 } 84 85 if (!strcmp (word, "PNGF")) { 86 status = PNGit (sock); 87 KiiSendCommand (sock, 4, "DONE"); 88 FINISHED (status); 89 } 90 91 if (!strcmp (word, "PPMF")) { 92 status = PPMit (sock); 93 KiiSendCommand (sock, 4, "DONE"); 94 FINISHED (status); 95 } 96 97 if (!strcmp (word, "DBOX")) { 98 status = LoadFrame (sock); 99 KiiSendCommand (sock, 4, "DONE"); 100 FINISHED (status); 101 } 102 103 if (!strcmp (word, "PLOT")) { 104 status = LoadObject (sock); 105 // LoadObject sends its own handshake 106 // KiiSendCommand (sock, 4, "DONE"); 107 FINISHED (status); 108 } 109 110 if (!strcmp (word, "LABL")) { 111 status = LoadLabels (sock); 112 KiiSendCommand (sock, 4, "DONE"); 113 FINISHED (TRUE); 114 } 115 116 if (!strcmp (word, "PTXT")) { 117 status = LoadTextlines (sock); 118 KiiSendCommand (sock, 4, "DONE"); 119 FINISHED (TRUE); 120 } 121 122 if (!strcmp (word, "RSIZ")) { 123 status = Resize (sock); 124 KiiSendCommand (sock, 4, "DONE"); 125 FINISHED (status); 126 } 127 128 if (!strcmp (word, "GLIM")) { 129 GetLimits (sock); 130 KiiSendCommand (sock, 4, "DONE"); 131 FINISHED (TRUE); 132 } 133 134 if (!strcmp (word, "SLIM")) { 135 status = SetLimits (sock); 136 KiiSendCommand (sock, 4, "DONE"); 137 FINISHED (TRUE); 138 } 139 140 if (!strcmp (word, "GSTY")) { 141 GetGraphData (sock); 142 KiiSendCommand (sock, 4, "DONE"); 143 FINISHED (TRUE); 144 } 145 146 if (!strcmp (word, "SSTY")) { 147 status = SetGraphData (sock); 148 KiiSendCommand (sock, 4, "DONE"); 149 FINISHED (TRUE); 150 } 151 152 if (!strcmp (word, "GIMD")) { 153 GetImageData (sock); 154 KiiSendCommand (sock, 4, "DONE"); 155 FINISHED (TRUE); 156 } 157 158 if (!strcmp (word, "SIMD")) { 159 status = SetImageData (sock); 160 KiiSendCommand (sock, 4, "DONE"); 161 FINISHED (TRUE); 162 } 163 164 if (!strcmp (word, "TOOL")) { 165 status = SetToolbox (sock); 166 KiiSendCommand (sock, 4, "DONE"); 167 FINISHED (TRUE); 168 } 169 170 if (!strcmp (word, "SSEC")) { 171 status = SetSection (sock); 172 KiiSendCommand (sock, 4, "DONE"); 173 FINISHED (TRUE); 174 } 175 176 if (!strcmp (word, "LSEC")) { 177 status = ListSection (sock); 178 KiiSendCommand (sock, 4, "DONE"); 179 FINISHED (TRUE); 180 } 181 182 if (!strcmp (word, "DSEC")) { 183 status = DefineSection (sock); 184 KiiSendCommand (sock, 4, "DONE"); 185 FINISHED (TRUE); 186 } 187 188 if (!strcmp (word, "MSEC")) { 189 status = MoveSection (sock); 190 KiiSendCommand (sock, 4, "DONE"); 191 FINISHED (TRUE); 192 } 193 194 if (!strcmp (word, "FONT")) { 195 status = SetFont (sock); 196 KiiSendCommand (sock, 4, "DONE"); 197 FINISHED (TRUE); 119 198 } 120 199 121 200 /* Erase Section */ 122 if (!strcmp (buffer, "ERSC")) { 123 status = EraseCurrentPlot (TRUE); 124 return (status); 125 } 126 127 /* Erase Section */ 128 if (!strcmp (buffer, "ERAS")) { 129 status = ErasePlots (TRUE); 130 return (status); 131 } 132 133 /* Don't Erase Section */ 134 if (!strcmp (buffer, "ERSS")) { 135 status = EraseSections (FALSE); 136 return (status); 137 } 138 139 140 if (!strcmp (buffer, "READ")) { 141 status = LoadPicture (); 142 return (status); 143 } 144 145 // XXX duplicate Command word 146 if (!strcmp (buffer, "ERAS")) { 147 status = EraseOverlay (); 148 return (status); 149 } 150 151 if (!strcmp (buffer, "LOAD")) { 152 status = LoadOverlay (); 153 return (status); 154 } 155 156 if (!strcmp (buffer, "TICK")) { 157 status = LoadTickmarks (); 158 return (status); 159 } 160 161 if (!strcmp (buffer, "SAVE")) { 162 status = SaveOverlay (); 163 return (status); 164 } 165 166 if (!strcmp (buffer, "CSVE")) { 167 status = CSaveOverlay (); 168 return (status); 169 } 170 171 if (!strcmp (buffer, "JPEG")) { 172 status = JPEGit24 (); 173 write (sock, "DONE", 4); 174 return (status); 175 } 176 177 if (!strcmp (buffer, "CENT")) { 178 status = Center (); 179 return (status); 180 } 181 182 if (!strcmp (buffer, "NPIX")) { 183 GetPixelCount (); 184 return (TRUE); 185 } 186 187 fprintf (stderr, "unknown signal %s\n", buffer); 188 189 return (TRUE); 190 201 if (!strcmp (word, "ERSC")) { 202 status = EraseCurrentPlot (); 203 KiiSendCommand (sock, 4, "DONE"); 204 FINISHED (status); 205 } 206 207 /* Erase Plots */ 208 if (!strcmp (word, "ERSP")) { 209 status = ErasePlots (); 210 KiiSendCommand (sock, 4, "DONE"); 211 FINISHED (status); 212 } 213 214 /* Erase Sections */ 215 if (!strcmp (word, "ERSS")) { 216 status = EraseSections (); 217 KiiSendCommand (sock, 4, "DONE"); 218 FINISHED (status); 219 } 220 221 /* Erase Image */ 222 if (!strcmp (word, "ERSI")) { 223 status = EraseImage (); 224 KiiSendCommand (sock, 4, "DONE"); 225 FINISHED (status); 226 } 227 228 /* Erase Overlay for this section */ 229 if (!strcmp (word, "ERSO")) { 230 status = EraseOverlay (sock); 231 KiiSendCommand (sock, 4, "DONE"); 232 FINISHED (status); 233 } 234 235 if (!strcmp (word, "READ")) { 236 status = LoadPicture (sock); 237 KiiSendCommand (sock, 4, "DONE"); 238 FINISHED (status); 239 } 240 241 if (!strcmp (word, "LOAD")) { 242 status = LoadOverlay (sock); 243 KiiSendCommand (sock, 4, "DONE"); 244 FINISHED (status); 245 } 246 247 if (!strcmp (word, "SAVE")) { 248 status = SaveOverlay (sock); 249 KiiSendCommand (sock, 4, "DONE"); 250 FINISHED (status); 251 } 252 253 if (!strcmp (word, "CSVE")) { 254 status = CSaveOverlay (sock); 255 KiiSendCommand (sock, 4, "DONE"); 256 FINISHED (status); 257 } 258 259 if (!strcmp (word, "JPEG")) { 260 status = JPEGit24 (sock); 261 KiiSendCommand (sock, 4, "DONE"); 262 FINISHED (status); 263 } 264 265 if (!strcmp (word, "CENT")) { 266 status = Center (sock); 267 KiiSendCommand (sock, 4, "DONE"); 268 FINISHED (status); 269 } 270 271 if (!strcmp (word, "NPIX")) { 272 GetPixelCount (sock); 273 KiiSendCommand (sock, 4, "DONE"); 274 FINISHED (TRUE); 275 } 276 277 fprintf (stderr, "unknown signal %s\n", word); 278 KiiSendCommand (sock, 4, "DONE"); 279 FINISHED (TRUE); 191 280 } -
trunk/Ohana/src/kapa2/src/CheckVisual.c
r13320 r13479 158 158 /* make private colormap */ 159 159 if (graphic[0].Npixels < 16) { 160 fprintf (stderr, "can't allocate enough cells, using private colormap\n");160 // fprintf (stderr, "can't allocate enough cells, using private colormap\n"); 161 161 graphic[0].colormap = XCreateColormap (graphic[0].display, RootWindow (graphic[0].display, graphic[0].screen), graphic[0].visual, AllocNone); 162 162 for (graphic[0].Npixels = NPIXELS; … … 178 178 if (!dyn) { 179 179 graphic[0].Npixels = 256; 180 fprintf (stderr, "can't use dynamic colors, color scrollbar inactive\n");181 fprintf (stderr, " this can be avoided by using a dynamic visual class\n");182 fprintf (stderr, " (see Kii help page for details)\n");180 // fprintf (stderr, "can't use dynamic colors, color scrollbar inactive\n"); 181 // fprintf (stderr, " this can be avoided by using a dynamic visual class\n"); 182 // fprintf (stderr, " (see Kii help page for details)\n"); 183 183 } 184 184 -
trunk/Ohana/src/kapa2/src/CreatePicture.c
r13320 r13479 56 56 case 32: 57 57 REALLOCATE (image[0].picture.data, char, (4*image[0].picture.dx*image[0].picture.dy + 32)); 58 fprintf (stderr, "allocating %d for picture data\n", (4*image[0].picture.dx*image[0].picture.dy + 32));59 58 memset (image[0].picture.data, 0xbd, 4*image[0].picture.dx*image[0].picture.dy + 30); 60 59 l = (unsigned int *) image[0].picture.data; -
trunk/Ohana/src/kapa2/src/CreateZoom16.c
r13320 r13479 1 1 # include "Ximage.h" 2 # define XPIX(x,Rx,S) (x*S + Rx)3 # define ZPIX(value,Rz1,Rz2) (value*Rz1 - Rz2)4 2 # define FRAC(a) ((a) - (int)(a)) 3 4 static float slope = 1.0; 5 static float start = 0.0; 6 static int MaxValue = 255; 7 8 // XXX inline this if needed 9 static int PixelLookup(float value) { 10 int out; 11 out = MIN (MAX (slope * value - start, 0), MaxValue); 12 return (out); 13 } 5 14 6 15 void CreateZoom16 (KapaImageWidget *image, Graphic *graphic, double x, double y) { … … 9 18 int i_start, i_end, j_start, j_end; 10 19 int dropback; /* this is a bit of a kludge... */ 11 int dx, dy, DX, DY ;20 int dx, dy, DX, DY, pixelN; 12 21 double expand, zoomscale, Rx, Ry; 13 22 int expand_in, expand_out; 14 23 unsigned char *out_pix, *out_pix2, *data; 15 unsigned char*in_pix, *in_pix2;24 float *imdata, *in_pix, *in_pix2; 16 25 unsigned char pixel1[256], pixel2[256]; 17 26 unsigned char pixvalue1, pixvalue2; … … 37 46 back1 = 0x0000ff & back; 38 47 back2 = 0x0000ff & (back >> 8); 48 // define the color transform parameters 49 MaxValue = graphic[0].Npixels - 1; 50 if (image[0].range != 0.0) { 51 slope = graphic[0].Npixels / image[0].range; 52 start = graphic[0].Npixels * image[0].zero / image[0].range; 53 } else { 54 slope = 1.0; 55 start = image[0].zero; 56 } 39 57 40 58 zoomscale = MAX (5, image[0].expand + 5); … … 56 74 57 75 data = out_pix = (unsigned char *) image[0].zoom.data; 58 in_pix = (unsigned char *) (image[0].matrix.buffer) + DX*(int)MAX(Ry,0) + (int)MAX(Rx,0); 76 imdata = (float *) image[0].matrix.buffer; 77 in_pix = &imdata[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)]; 59 78 60 79 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ … … 91 110 if (expand_out == 1) { 92 111 for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix+=2) { 93 out_pix[0] = pixel1[*in_pix2]; 94 out_pix[1] = pixel2[*in_pix2]; 112 pixelN = PixelLookup(*in_pix2); 113 out_pix[0] = pixel1[pixelN]; 114 out_pix[1] = pixel2[pixelN]; 95 115 } 96 } 97 else { 116 } else { 98 117 for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= 2*expand_out) { 99 pixvalue1 = pixel1[*in_pix2]; 100 pixvalue2 = pixel2[*in_pix2]; 118 pixelN = PixelLookup(*in_pix2); 119 pixvalue1 = pixel1[pixelN]; 120 pixvalue2 = pixel2[pixelN]; 101 121 out_pix2 = out_pix; 102 122 for (jj = 0; jj < expand_out; jj++, out_pix2+=2*(dx-expand_out)) { … … 129 149 } 130 150 131 image[0].zoom.pix = XCreateImage (graphic[0].display, graphic[0].visual, 16, ZPixmap, 0,132 image[0].zoom.data, image[0].zoom.dx, image[0].zoom.dy, 32, 0);151 image[0].zoom.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0, 152 image[0].zoom.data, image[0].zoom.dx, image[0].zoom.dy, 16, 0); 133 153 134 154 } -
trunk/Ohana/src/kapa2/src/CreateZoom24.c
r13320 r13479 1 1 # include "Ximage.h" 2 # define XPIX(x,Rx,S) (x*S + Rx)3 # define ZPIX(value,Rz1,Rz2) (value*Rz1 - Rz2)4 2 # define FRAC(a) ((a) - (int)(a)) 3 4 static float slope = 1.0; 5 static float start = 0.0; 6 static int MaxValue = 255; 7 8 // XXX inline this if needed 9 static int PixelLookup(float value) { 10 int out; 11 out = MIN (MAX (slope * value - start, 0), MaxValue); 12 return (out); 13 } 5 14 6 15 void CreateZoom24 (KapaImageWidget *image, Graphic *graphic, double x, double y) { … … 9 18 int i_start, i_end, j_start, j_end; 10 19 int dropback; /* this is a bit of a kludge... */ 11 int dx, dy, DX, DY ;20 int dx, dy, DX, DY, pixelN; 12 21 double expand, zoomscale, Rx, Ry; 13 22 int expand_in, expand_out; 14 23 unsigned char *out_pix, *out_pix2, *data; 15 unsigned char *in_pix,*in_pix2;24 float *imdata, *in_pix, *in_pix2; 16 25 unsigned char pixel1[256], pixel2[256], pixel3[256]; 17 26 unsigned char pixvalue1, pixvalue2, pixvalue3; … … 41 50 back3 = 0x0000ff & (back >> 16); 42 51 52 // define the color transform parameters 53 MaxValue = graphic[0].Npixels - 1; 54 if (image[0].range != 0.0) { 55 slope = graphic[0].Npixels / image[0].range; 56 start = graphic[0].Npixels * image[0].zero / image[0].range; 57 } else { 58 slope = 1.0; 59 start = image[0].zero; 60 } 61 43 62 zoomscale = MAX (5, image[0].expand + 5); 44 63 expand = 1 / zoomscale; … … 59 78 60 79 data = out_pix = (unsigned char *) image[0].zoom.data; 61 in_pix = (unsigned char *) (image[0].matrix.buffer) + DX*(int)MAX(Ry,0) + (int)MAX(Rx,0); 80 imdata = (float *) image[0].matrix.buffer; 81 in_pix = &imdata[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)]; 62 82 63 83 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ … … 97 117 if (expand_out == 1) { 98 118 for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix+=3) { 99 out_pix[0] = pixel1[*in_pix2]; 100 out_pix[1] = pixel2[*in_pix2]; 101 out_pix[2] = pixel3[*in_pix2]; 119 pixelN = PixelLookup(*in_pix2); 120 out_pix[0] = pixel1[pixelN]; 121 out_pix[1] = pixel2[pixelN]; 122 out_pix[2] = pixel3[pixelN]; 102 123 } 103 } 104 else { 124 } else { 105 125 for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= 3*expand_out) { 106 pixvalue1 = pixel1[*in_pix2]; 107 pixvalue2 = pixel2[*in_pix2]; 108 pixvalue3 = pixel3[*in_pix2]; 126 pixelN = PixelLookup(*in_pix2); 127 pixvalue1 = pixel1[pixelN]; 128 pixvalue2 = pixel2[pixelN]; 129 pixvalue3 = pixel3[pixelN]; 109 130 out_pix2 = out_pix; 110 131 for (jj = 0; jj < expand_out; jj++, out_pix2+=3*(dx-expand_out)+extra) { -
trunk/Ohana/src/kapa2/src/CreateZoom32.c
r13320 r13479 1 1 # include "Ximage.h" 2 # define XPIX(x,Rx,S) (x*S + Rx)3 # define ZPIX(value,Rz1,Rz2) (value*Rz1 - Rz2)4 2 # define FRAC(a) ((a) - (int)(a)) 3 4 static float slope = 1.0; 5 static float start = 0.0; 6 static int MaxValue = 255; 7 8 // XXX inline this if needed 9 static int PixelLookup(float value) { 10 int out; 11 out = MIN (MAX (slope * value - start, 0), MaxValue); 12 return (out); 13 } 5 14 6 15 void CreateZoom32 (KapaImageWidget *image, Graphic *graphic, double x, double y) { … … 9 18 int i_start, i_end, j_start, j_end; 10 19 int dropback; /* this is a bit of a kludge... */ 11 int dx, dy, DX, DY ;20 int dx, dy, DX, DY, pixelN; 12 21 double expand, zoomscale, Rx, Ry; 13 22 int expand_in, expand_out; 14 unsigned int *out_pix, *out_pix2 , *data;15 unsigned char *in_pix,*in_pix2;23 unsigned int *out_pix, *out_pix2; 24 float *imdata, *in_pix, *in_pix2; 16 25 unsigned long pixel[256], pixvalue; 17 26 unsigned long back; … … 28 37 } 29 38 back = graphic[0].back; 39 40 // define the color transform parameters 41 MaxValue = graphic[0].Npixels - 1; 42 if (image[0].range != 0.0) { 43 slope = graphic[0].Npixels / image[0].range; 44 start = graphic[0].Npixels * image[0].zero / image[0].range; 45 } else { 46 slope = 1.0; 47 start = image[0].zero; 48 } 30 49 31 50 zoomscale = MAX (5, image[0].expand + 5); … … 49 68 50 69 out_pix = (unsigned int *) image[0].zoom.data; 51 data = (unsigned int *) image[0].zoom.data;52 in_pix = (unsigned char *) (image[0].matrix.buffer) + DX*(int)MAX(Ry,0) + (int)MAX(Rx,0);70 imdata = (float *) image[0].matrix.buffer; 71 in_pix = &imdata[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)]; 53 72 54 73 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ … … 81 100 if (expand_out == 1) { 82 101 for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) { 83 out_pix[0] = pixel[*in_pix2]; 102 pixelN = PixelLookup(*in_pix2); 103 out_pix[0] = pixel[pixelN]; 84 104 } 85 105 } 86 106 else { 87 107 for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) { 88 pixvalue = *(pixel + *in_pix2); 108 pixelN = PixelLookup(*in_pix2); 109 pixvalue = pixel[pixelN]; 89 110 out_pix2 = out_pix; 90 111 for (jj = 0; jj < expand_out; jj++, out_pix2+=(dx-expand_out)) { -
trunk/Ohana/src/kapa2/src/CreateZoom8.c
r13320 r13479 1 1 # include "Ximage.h" 2 # define XPIX(x,Rx,S) (x*S + Rx)3 # define ZPIX(value,Rz1,Rz2) (value*Rz1 - Rz2)4 2 # define FRAC(a) ((a) - (int)(a)) 3 4 static float slope = 1.0; 5 static float start = 0.0; 6 static int MaxValue = 255; 7 8 // XXX inline this if needed 9 static int PixelLookup(float value) { 10 int out; 11 out = MIN (MAX (slope * value - start, 0), MaxValue); 12 return (out); 13 } 5 14 6 15 void CreateZoom8 (KapaImageWidget *image, Graphic *graphic, double x, double y) { … … 9 18 int i_start, i_end, j_start, j_end; 10 19 int dropback; /* this is a bit of a kludge... */ 11 int dx, dy, DX, DY ;20 int dx, dy, DX, DY, pixelN; 12 21 double expand, zoomscale, Rx, Ry; 13 22 int expand_in, expand_out; 14 char*out_pix, *out_pix2;15 char *in_pix,*in_pix2;23 unsigned char *out_pix, *out_pix2; 24 float *imdata, *in_pix, *in_pix2; 16 25 unsigned long pixel[256], pixvalue; 17 26 unsigned long back; … … 30 39 back = graphic[0].back; 31 40 41 // define the color transform parameters 42 MaxValue = graphic[0].Npixels - 1; 43 if (image[0].range != 0.0) { 44 slope = graphic[0].Npixels / image[0].range; 45 start = graphic[0].Npixels * image[0].zero / image[0].range; 46 } else { 47 slope = 1.0; 48 start = image[0].zero; 49 } 50 32 51 zoomscale = MAX (5, image[0].expand + 5); 33 52 expand = 1 / zoomscale; 34 53 expand_out = (int) zoomscale; 35 54 expand_in = 1; 36 37 /*38 dx = image[0].zoom.dx;39 dy = image[0].zoom.dy;40 DX = image[0].matrix.Naxis[0];41 DY = image[0].matrix.Naxis[1];42 Rx = 0.5*(DX - (dx - 1)*expand) - x;43 Ry = 0.5*(DY - (dy - 1)*expand) - y;44 data coords of 0,0 point in pic array45 X = 0.5*image[0].matrix.Naxis[0] - expand*((int)(0.5*image[0].zoom.dx + 0.5) - 0.0) - image[0].X;46 Y = 0.5*image[0].matrix.Naxis[1] - expand*((int)(0.5*image[0].zoom.dy + 0.5) - 0.0) - image[0].Y;47 i_start = MIN (MAX (-Rx / expand, 0), dx - expand_out + 1);48 j_start = MIN (MAX (-Ry / expand, 0), dy - expand_out + 1);49 i_end = MAX (MIN ((DX-Rx) / expand, dx - expand_out + 1), 0);50 j_end = MAX (MIN ((DY-Ry) / expand, dy - expand_out + 1), 0);51 dropback = expand_out - (i_end - i_start) % expand_out;52 if ((i_end - i_start) % expand_out == 0) dropback = 0;53 54 out_pix = image[0].zoom.data;55 in_pix = (char *) (image[0].matrix.buffer) + DX*(int)MAX(Y,0) + (int)MAX(X,0);56 57 */58 55 59 56 dx = image[0].zoom.dx; … … 72 69 73 70 out_pix = (char *) image[0].zoom.data; 74 in_pix = (char *) (image[0].matrix.buffer) + DX*(int)MAX(Ry,0) + (int)MAX(Rx,0); 71 imdata = (float *) image[0].matrix.buffer; 72 in_pix = &imdata[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)]; 75 73 76 74 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ … … 100 98 in_pix2 = in_pix; 101 99 if (expand_out == 1) { 102 for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) 103 *out_pix = *(pixel + *in_pix2); 104 } 105 else { 100 for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) { 101 pixelN = PixelLookup(*in_pix2); 102 *out_pix = pixel[pixelN]; 103 } 104 } else { 106 105 for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) { 107 pixvalue = *(pixel + *in_pix2); 106 pixelN = PixelLookup(*in_pix2); 107 pixvalue = pixel[pixelN]; 108 108 out_pix2 = out_pix; 109 109 for (jj = 0; jj < expand_out; jj++, out_pix2+=(dx-expand_out)) { … … 131 131 132 132 /**** fill in top area ****/ 133 for (j = 0; (j < dx*(dy - j_end)) && (out_pix - image[0].zoom.data < dx*dy); j++, out_pix++) {133 for (j = 0; (j < dx*(dy - j_end)) && (out_pix - (unsigned char *) image[0].zoom.data < dx*dy); j++, out_pix++) { 134 134 *out_pix = back; 135 135 } -
trunk/Ohana/src/kapa2/src/DefineSection.c
r13320 r13479 1 1 # include "Ximage.h" 2 2 3 int DefineSection () { 3 // define the section, but do not create a graph or image 4 int DefineSection (int sock) { 4 5 5 6 int i, N, MoveSection; … … 15 16 if (N < 0) { 16 17 section = AddSection (name, x, y, dx, dy); 17 section->graph = InitGraph ();18 18 MoveSection = TRUE; 19 19 } else { … … 33 33 34 34 if (MoveSection) { 35 Set GraphSize(section);35 SetSectionSizes (section); 36 36 Refresh (1); 37 37 } -
trunk/Ohana/src/kapa2/src/EraseCurrentPlot.c
r13320 r13479 11 11 section = GetActiveSection(); 12 12 if (section->graph == NULL) return (TRUE); 13 13 14 EraseGraph (section->graph); 14 15 -
trunk/Ohana/src/kapa2/src/EraseOverlay.c
r13331 r13479 1 1 # include "Ximage.h" 2 2 3 int EraseOverlay ( ) {3 int EraseOverlay (int sock) { 4 4 5 5 char buffer[256]; … … 12 12 section = GetActiveSection(); 13 13 image = section->image; 14 if (image == NULL) return (TRUE); 14 15 15 16 KiiScanCommand (sock, 16, "%*s %d", &N); 16 17 17 18 if (N > NOVERLAYS) { 18 REALLOCATE (image[0].tickmarks.objects, Object, 1);19 REALLOCATE (image[0].tickmarks.objects, KiiOverlay, 1); 19 20 image[0].tickmarks.Nobjects = 0; 20 21 } else { 21 22 for (i = 0; i < image[0].overlay[N].Nobjects; i++) { 22 if ( !strcmp (image[0].overlay[N].objects[i].type, "TEXT")) {23 if (image[0].overlay[N].objects[i].type == KII_OVERLAY_TEXT) { 23 24 free (image[0].overlay[N].objects[i].text); 24 25 } 25 26 } 26 REALLOCATE (image[0].overlay[N].objects, Object, 1);27 REALLOCATE (image[0].overlay[N].objects, KiiOverlay, 1); 27 28 image[0].overlay[N].Nobjects = 0; 28 29 image[0].overlay[N].active = FALSE; -
trunk/Ohana/src/kapa2/src/GetPixelCount.c
r13320 r13479 1 1 # include "Ximage.h" 2 2 3 int GetPixelCount ( ) {3 int GetPixelCount (int sock) { 4 4 5 5 int i; -
trunk/Ohana/src/kapa2/src/Graphs.c
r13320 r13479 20 20 strcpy (graph[0].label[i].text, ""); 21 21 } 22 23 graph[0].data.xmin = 0.0; 24 graph[0].data.xmax = 1.0; 25 graph[0].data.ymin = 0.0; 26 graph[0].data.ymax = 1.0; 22 27 23 28 graph[0].Nobjects = 0; … … 100 105 FREE (graph[0].objects); 101 106 FREE (graph[0].textline); 107 free (graph); 102 108 return; 103 109 } -
trunk/Ohana/src/kapa2/src/Image.c
r13331 r13479 21 21 image[0].start = 0; 22 22 image[0].slope = 1; 23 image[0].location = 4; 23 24 24 25 image[0].coords.Npolyterms = 0; 25 26 for (i = 0; i < NOVERLAYS; i++) { 26 27 image[0].overlay[i].Nobjects = 0; 27 ALLOCATE (image[0].overlay[i].objects, Object, 1); /* allocate so later free will not crash! */28 ALLOCATE (image[0].overlay[i].objects, KiiOverlay, 1); /* allocate so later free will not crash! */ 28 29 image[0].overlay[i].active = FALSE; 29 30 image[0].overlay[i].color = graphic[0].overlay_color[i]; … … 96 97 graphic = GetGraphic (); 97 98 98 XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore);99 XDrawRectangle (graphic[0].display, graphic[0].window, graphic[0].gc,100 image[0].picture.x, image[0].picture.y,101 image[0].picture.dx + 1, image[0].picture.dy +1);99 XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore); 100 XDrawRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, 101 image[0].picture.x, image[0].picture.y, 102 image[0].picture.dx+1, image[0].picture.dy+1); 102 103 103 104 XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc, … … 106 107 image[0].picture.dx, image[0].picture.dy); 107 108 108 XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc,109 image[0].cmapbar.pix, 0, 0,110 image[0].cmapbar.x, image[0].cmapbar.y,111 image[0].cmapbar.dx, image[0].cmapbar.dy);112 113 CrossHairs (graphic, image);114 115 109 for (i = 0; i < NOVERLAYS; i++) { 116 110 if (image[0].overlay[i].active) { … … 118 112 } 119 113 } 120 # if (0)121 PaintTickmarks (graphic, image);122 # endif123 114 124 // XXX make this optional?a 125 if (1) { 115 if (image[0].location) { 116 XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc, 117 image[0].cmapbar.pix, 0, 0, 118 image[0].cmapbar.x, image[0].cmapbar.y, 119 image[0].cmapbar.dx, image[0].cmapbar.dy); 120 121 CrossHairs (graphic, image); 122 126 123 /* erase everything below zoom box, then draw */ 124 /* 127 125 XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].back); 128 126 XFillRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, 129 image[0].text_x, image[0].text_x, image[0]. zoom.dx, graphic[0].dy);130 127 image[0].text_x, image[0].text_x, image[0].text_dx, image[0].text_dy); 128 */ 131 129 DrawButton (graphic, &image[0].PS_button); 132 130 DrawButton (graphic, &image[0].recenter_button); … … 139 137 DrawButton (graphic, &image[0].overlay_button[i]); 140 138 } 139 StatusBox (graphic, image); 141 140 } 142 143 StatusBox (graphic, image);144 141 145 142 FlushDisplay (graphic[0].display); 146 143 } 144 145 void FreeImage (KapaImageWidget *image) { 146 147 int i; 148 149 if (image == NULL) return; 150 151 for (i = 0; i < NOVERLAYS; i++) { 152 free (image[0].overlay[i].objects); 153 } 154 free (image[0].matrix.buffer); 155 free (image[0].picture.data); 156 free (image[0].cmapbar.data); 157 free (image[0].zoom.data); 158 159 free (image); 160 } -
trunk/Ohana/src/kapa2/src/InterpretKeys.c
r13333 r13479 3 3 int InterpretKeys (Graphic *graphic, XKeyEvent *event) { 4 4 5 double X, Y, offset; 6 int modstate; 5 float *imdata; 6 double X, Y, Z, R, D, offset; 7 int sock, DX, DY, modstate; 7 8 char *name, string[16], line[40]; 8 9 KeySym keysym; … … 23 24 // XXX allow user to choose graph or image coords 24 25 if (ACTIVE_CURSOR) { 26 27 sock = GetActiveSocket (); 28 if (sock == -1) goto skip_cursor; 29 25 30 name = XKeysymToString (keysym); 26 31 … … 43 48 if (!strcmp (name, "(null)")) goto skip_cursor; 44 49 50 Z = -1; 51 45 52 if (graph) { 46 53 X = (event[0].x - graph[0].axis[0].fx)*(graph[0].axis[0].max - graph[0].axis[0].min)/graph[0].axis[0].dfx + graph[0].axis[0].min; 47 54 Y = (event[0].y - graph[0].axis[1].fy)*(graph[0].axis[1].max - graph[0].axis[1].min)/graph[0].axis[1].dfy + graph[0].axis[1].min; 55 XY_to_RD (&R, &D, X, Y, &graph[0].data.coords); 48 56 } 49 57 if (image && !graph) { … … 53 61 if (event[0].y > image[0].picture.y + image[0].picture.dy) goto skip_cursor; 54 62 Screen_to_Image (&X, &Y, (double)event[0].x, (double)event[0].y, image); 63 XY_to_RD (&R, &D, X, Y, &image[0].coords); 64 65 DX = image[0].matrix.Naxis[0]; 66 DY = image[0].matrix.Naxis[1]; 67 68 if (X < 0) goto off_image; 69 if (Y < 0) goto off_image; 70 if (X >= DX) goto off_image; 71 if (Y >= DY) goto off_image; 72 imdata = (float *) image[0].matrix.buffer; 73 Z = imdata[DX*(int)(Y) + (int)(X)]; 55 74 } 56 snprintf (line, 40, "%12s %12.6f %12.6f ", name, X, Y);57 write (sock, line, 40);75 off_image: 76 KiiSendMessage (sock, "%12s %12.6f %12.6f %12.6f %12.6f %12.6f", name, X, Y, Z, R, D); 58 77 } 59 78 60 79 skip_cursor: 80 if (image == NULL) return (TRUE); 81 61 82 // offset is in image pixels: 62 83 // 0.5 image pixels is 1 screen pixel for expand == +2 -
trunk/Ohana/src/kapa2/src/InterpretPresses.c
r13333 r13479 3 3 int InterpretPresses (Graphic *graphic, XButtonEvent *event) { 4 4 5 int s tatus, done, this_button, old_cursor;5 int sock, DX, DY, status, done, this_button, old_cursor; 6 6 char name[16], line[40]; 7 double X, Y; 7 double X, Y, Z, R, D; 8 float *imdata; 8 9 KeySym keysym; 9 10 Button *button; … … 20 21 // XXX allow user to choose graph or image coords 21 22 if (ACTIVE_CURSOR) { 23 sock = GetActiveSocket (); 24 if (sock == -1) goto skip_cursor; 25 22 26 sprintf (name, "Button%d", event[0].button); 23 27 if (graph) { 24 28 X = (event[0].x - graph[0].axis[0].fx)*(graph[0].axis[0].max - graph[0].axis[0].min)/graph[0].axis[0].dfx + graph[0].axis[0].min; 25 29 Y = (event[0].y - graph[0].axis[1].fy)*(graph[0].axis[1].max - graph[0].axis[1].min)/graph[0].axis[1].dfy + graph[0].axis[1].min; 30 XY_to_RD (&R, &D, X, Y, &graph[0].data.coords); 26 31 } 27 32 if (image && !graph) { … … 30 35 if (event[0].x > image[0].picture.x + image[0].picture.dx) goto skip_cursor; 31 36 if (event[0].y > image[0].picture.y + image[0].picture.dy) goto skip_cursor; 32 33 37 Screen_to_Image (&X, &Y, (double)event[0].x, (double)event[0].y, image); 38 39 XY_to_RD (&R, &D, X, Y, &image[0].coords); 40 41 DX = image[0].matrix.Naxis[0]; 42 DY = image[0].matrix.Naxis[1]; 43 44 if (X < 0) goto off_image; 45 if (Y < 0) goto off_image; 46 if (X >= DX) goto off_image; 47 if (Y >= DY) goto off_image; 48 imdata = (float *) image[0].matrix.buffer; 49 Z = imdata[DX*(int)(Y) + (int)(X)]; 34 50 } 35 snprintf (line, 40, "%12s %12.6f %12.6f ", name, X, Y);36 write (sock, line, 40);51 off_image: 52 KiiSendMessage (sock, "%12s %12.6f %12.6f %12.6f %12.6f %12.6f", name, X, Y, Z, R, D); 37 53 } 38 54 … … 40 56 status = TRUE; 41 57 this_button = event[0].button; 58 59 // XXX add graph buttons here 60 if (image == NULL) return (TRUE); 42 61 43 62 if ((event[0].type == ButtonPress) && InPicture (event, &image[0].picture)) { -
trunk/Ohana/src/kapa2/src/JPEGit24.c
r13320 r13479 6 6 # define WHITE_B 255 7 7 8 // XXX this currently writes out the jpeg for the active image 9 int JPEGit24 () { 8 static float slope = 1.0; 9 static float start = 0.0; 10 static int MaxValue = 255; 11 12 // XXX inline this if needed 13 static int PixelLookup(float value) { 14 int out; 15 out = MIN (MAX (slope * value - start, 0), MaxValue); 16 return (out); 17 } 18 19 // XXX this currently writes out the jpeg for just the active image 20 int JPEGit24 (int sock) { 10 21 11 22 struct jpeg_compress_struct cinfo; … … 21 32 int i_start, i_end, j_start, j_end; 22 33 int dropback; /* this is a bit of a kludge... */ 23 int dx, dy, DX, DY ;34 int dx, dy, DX, DY, pixelN; 24 35 int status, Nbytes, quality; 25 36 int expand_in, expand_out; 26 37 double expand, Rx, Ry, X, Y; 27 unsigned char *out_pix, *in_pix, *in_pix_ref; 38 unsigned char *out_pix; 39 float *imdata, *in_pix, *in_pix_ref; 28 40 unsigned char pixel1[256], pixel2[256], pixel3[256]; 29 41 char filename[1024]; 30 42 FILE *f; 31 43 44 /* expect a line telling the number of bytes and a filename */ 45 KiiScanMessage (sock, "%s", filename); 46 32 47 graphic = GetGraphic(); 33 48 section = GetActiveSection(); 34 49 image = section->image; 35 36 /* expect a line telling the number of bytes and a filename */ 37 KiiScanMessage (sock, "%s", filename); 50 if (image == NULL) return (TRUE); 38 51 39 52 /***** JPEG init calls */ … … 69 82 } 70 83 84 // define the color transform parameters 85 MaxValue = graphic[0].Npixels - 1; 86 if (image[0].range != 0.0) { 87 slope = graphic[0].Npixels / image[0].range; 88 start = graphic[0].Npixels * image[0].zero / image[0].range; 89 } else { 90 slope = 1.0; 91 start = image[0].zero; 92 } 93 71 94 expand = expand_in = expand_out = 1.0; 72 95 if (image[0].expand == 0) /* set up expansions */ … … 122 145 ALLOCATE (line_buffer, JSAMPLE, 3*dx); 123 146 124 in_pix_ref = (unsigned char *) (image[0].matrix.buffer) + DX*(int)MAX(Y,0) + (int)MAX(X,0); 147 imdata = (float *) image[0].matrix.buffer; 148 in_pix_ref = &imdata[DX*(int)MAX(Y,0) + (int)MAX(X,0)]; 125 149 126 150 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ … … 153 177 /*** fill in the picture region ***/ 154 178 for (i = i_start; i < i_end; i+=expand_out, in_pix+=expand_in) { 179 pixelN = PixelLookup(*in_pix); 155 180 for (ii = 0; ii < expand_out; ii++, out_pix+=3) { 156 out_pix[0] = pixel1[ *in_pix];157 out_pix[1] = pixel2[ *in_pix];158 out_pix[2] = pixel3[ *in_pix];181 out_pix[0] = pixel1[pixelN]; 182 out_pix[1] = pixel2[pixelN]; 183 out_pix[2] = pixel3[pixelN]; 159 184 } 160 185 } -
trunk/Ohana/src/kapa2/src/Layout.c
r13333 r13479 4 4 void InitLayout (int argc, char **argv) { 5 5 6 int N , UseGraph;6 int N; 7 7 Section *section; 8 8 9 UseGraph = FALSE; 10 if ((N = get_argument (argc, argv, "-image"))) { 11 remove_argument(N, &argc, argv); 12 UseGraph = FALSE; 13 } 14 15 /** initiate connection with server **/ 16 if (!FOREGROUND) { 17 if (argc < 2) { 18 fprintf (stderr, "socket path not specified\n"); 19 exit (0); 20 } 21 sock = KiiWait (argv[1]); 22 } 9 InitPipe(); 23 10 24 11 ACTIVE_CURSOR = FALSE; … … 37 24 } 38 25 26 /* move this out of here... */ 27 if (argc != 1) { 28 fprintf (stderr, "USAGE: kapa\n"); 29 exit (0); 30 } 31 39 32 InitRotFonts (); 40 33 41 /* create basic section */34 /* create basic section, empty of image or graph */ 42 35 section = AddSection ("default", 0.0, 0.0, 1.0, 1.0); 43 if (UseGraph) {44 section->graph = InitGraph ();45 SetGraphSize (section);46 } else {47 section->image = InitImage ();48 SetImageSize (section);49 }50 36 } -
trunk/Ohana/src/kapa2/src/LoadFrame.c
r13320 r13479 1 1 # include "Ximage.h" 2 2 3 int LoadFrame ( ) {3 int LoadFrame (int sock) { 4 4 5 5 int i, status; … … 9 9 10 10 section = GetActiveSection(); 11 if (section->graph == NULL) { 12 section->graph = InitGraph (); 13 SetSectionSizes (section); 14 } 11 15 graph = section->graph; 12 16 13 // XXX what to do if graph is NULL?14 15 17 KiiScanMessage (sock, "%lf %lf %lf %lf", 16 18 &graph[0].axis[0].min, &graph[0].axis[0].max, … … 60 62 } 61 63 64 SetSectionSizes (section); 62 65 if (USE_XWINDOW) DrawFrame (graph); 63 66 FlushDisplay (); -
trunk/Ohana/src/kapa2/src/LoadLabels.c
r13320 r13479 1 1 # include "Ximage.h" 2 2 3 int LoadLabels ( ) {3 int LoadLabels (int sock) { 4 4 5 5 char *c, *label; … … 9 9 10 10 section = GetActiveSection(); 11 if (section->graph == NULL) { 12 section->graph = InitGraph (); 13 SetSectionSizes (section); 14 } 11 15 graph = section->graph; 12 13 fcntl (sock, F_SETFL, !O_NONBLOCK);14 16 15 17 KiiScanMessage (sock, "%d", &mode); … … 21 23 strncpy (graph[0].label[mode].text, label, Nbytes); 22 24 label[Nbytes] = 0; 23 24 fcntl (sock, F_SETFL, O_NONBLOCK);25 25 26 26 c = GetRotFont (&size); -
trunk/Ohana/src/kapa2/src/LoadObject.c
r13320 r13479 1 1 # include "Ximage.h" 2 2 # include <errno.h> 3 4 int LoadObject () { 3 # define DEBUG 0 4 5 int LoadObject (int sock) { 5 6 6 7 int N; … … 9 10 10 11 section = GetActiveSection(); 12 if (section->graph == NULL) { 13 section->graph = InitGraph (); 14 SetSectionSizes (section); 15 } 11 16 graph = section->graph; 12 13 fcntl (sock, F_SETFL, !O_NONBLOCK);14 17 15 18 N = graph[0].Nobjects; … … 41 44 &graph[0].objects[N].x0, &graph[0].objects[N].x1, 42 45 &graph[0].objects[N].y0, &graph[0].objects[N].y1); 43 44 fcntl (sock, F_SETFL, O_NONBLOCK); 45 46 if (!LoadVectorData (graph, N, "x")) { 46 47 // acknowledge receipt of the metadata 48 KiiSendCommand (sock, 4, "DONE"); 49 50 // XXX Currently, I require these in a special order. The data includes a message defining the 51 // object type. This could be made more flexible by using the information (though we still need 52 // to know how many items will be sent) 53 54 if (!LoadVectorData (sock, graph, N, "x")) { 47 55 FreeObjectData (&graph[0].objects[N]); 48 56 graph[0].Nobjects --; … … 50 58 } 51 59 52 if (!LoadVectorData ( graph, N, "y")) {60 if (!LoadVectorData (sock, graph, N, "y")) { 53 61 FreeObjectData (&graph[0].objects[N]); 54 62 graph[0].Nobjects --; … … 56 64 } 57 65 if (graph[0].objects[N].size < 0.0) { 58 if (!LoadVectorData ( graph, N, "z")) {66 if (!LoadVectorData (sock, graph, N, "z")) { 59 67 FreeObjectData (&graph[0].objects[N]); 60 68 graph[0].Nobjects --; … … 63 71 } 64 72 if (graph[0].objects[N].etype & 0x01) { 65 if (!LoadVectorData ( graph, N, "dym")) {66 FreeObjectData (&graph[0].objects[N]); 67 graph[0].Nobjects --; 68 REALLOCATE (graph[0].objects, Gobjects, MAX (1, graph[0].Nobjects)); 69 } 70 if (!LoadVectorData ( graph, N, "dyp")) {73 if (!LoadVectorData (sock, graph, N, "dym")) { 74 FreeObjectData (&graph[0].objects[N]); 75 graph[0].Nobjects --; 76 REALLOCATE (graph[0].objects, Gobjects, MAX (1, graph[0].Nobjects)); 77 } 78 if (!LoadVectorData (sock, graph, N, "dyp")) { 71 79 FreeObjectData (&graph[0].objects[N]); 72 80 graph[0].Nobjects --; … … 75 83 } 76 84 if (graph[0].objects[N].etype & 0x02) { 77 if (!LoadVectorData ( graph, N, "dxm")) {78 FreeObjectData (&graph[0].objects[N]); 79 graph[0].Nobjects --; 80 REALLOCATE (graph[0].objects, Gobjects, MAX (1, graph[0].Nobjects)); 81 } 82 if (!LoadVectorData ( graph, N, "dxp")) {85 if (!LoadVectorData (sock, graph, N, "dxm")) { 86 FreeObjectData (&graph[0].objects[N]); 87 graph[0].Nobjects --; 88 REALLOCATE (graph[0].objects, Gobjects, MAX (1, graph[0].Nobjects)); 89 } 90 if (!LoadVectorData (sock, graph, N, "dxp")) { 83 91 FreeObjectData (&graph[0].objects[N]); 84 92 graph[0].Nobjects --; … … 96 104 } 97 105 98 /* load data for the named component */ 99 int LoadVectorData (KapaGraphWidget *graph, int N, char *type) { 100 101 int Npts, Ninpts, status, Ntry; 106 int LoadVectorData (int sock, KapaGraphWidget *graph, int N, char *type) { 107 108 int i, Npts, Ninpts, status, Ntry; 102 109 int bytes_left; 103 char *buff; 104 105 buff = NULL; 110 char *byte, *buffer, type_send[16], tmp; 111 int Npts_send, Nbytes_send, swap_client, swap_host; 112 113 buffer = NULL; 106 114 Npts = graph[0].objects[N].Npts; 115 116 KiiWaitAnswer (sock, "PLOB"); 117 KiiScanMessage (sock, "%s %d %d %d", type_send, &Npts_send, &Nbytes_send, &swap_client); 118 if (strcmp (type, type_send)) { 119 fprintf (stderr, "Kapa Communication error: unexpected data type %s vs %s\n", type_send, type); 120 } 121 if (Npts_send != Npts) { 122 fprintf (stderr, "Kapa Communication error: unexpected number of points %d vs %d\n", Npts_send, Npts); 123 } 124 if (Nbytes_send != Npts_send*sizeof(float)) { 125 fprintf (stderr, "Kapa Communication error: unexpected data size %d vs %d\n", Nbytes_send, Npts_send*sizeof(float)); 126 } 127 107 128 status = 1; 108 129 if (!strcmp (type, "x")) { 109 130 ALLOCATE (graph[0].objects[N].x, float, MAX (1, Npts)); 110 buff = (char *) graph[0].objects[N].x;131 buffer = (char *) graph[0].objects[N].x; 111 132 } 112 133 if (!strcmp (type, "y")) { 113 134 ALLOCATE (graph[0].objects[N].y, float, MAX (1, Npts)); 114 buff = (char *) graph[0].objects[N].y;135 buffer = (char *) graph[0].objects[N].y; 115 136 } 116 137 if (!strcmp (type, "z")) { 117 138 ALLOCATE (graph[0].objects[N].z, float, MAX (1, Npts)); 118 buff = (char *) graph[0].objects[N].z;139 buffer = (char *) graph[0].objects[N].z; 119 140 } 120 141 if (!strcmp (type, "dxm")) { 121 142 ALLOCATE (graph[0].objects[N].dxm, float, MAX (1, Npts)); 122 buff = (char *) graph[0].objects[N].dxm;143 buffer = (char *) graph[0].objects[N].dxm; 123 144 } 124 145 if (!strcmp (type, "dxp")) { 125 146 ALLOCATE (graph[0].objects[N].dxp, float, MAX (1, Npts)); 126 buff = (char *) graph[0].objects[N].dxp;147 buffer = (char *) graph[0].objects[N].dxp; 127 148 } 128 149 if (!strcmp (type, "dym")) { 129 150 ALLOCATE (graph[0].objects[N].dym, float, MAX (1, Npts)); 130 buff = (char *) graph[0].objects[N].dym;151 buffer = (char *) graph[0].objects[N].dym; 131 152 } 132 153 if (!strcmp (type, "dyp")) { 133 154 ALLOCATE (graph[0].objects[N].dyp, float, MAX (1, Npts)); 134 buff = (char *) graph[0].objects[N].dyp;155 buffer = (char *) graph[0].objects[N].dyp; 135 156 } 136 157 137 158 bytes_left = Npts*sizeof (float); 138 159 160 fcntl (sock, F_SETFL, O_NONBLOCK); 161 162 // read the vector data as raw binary in client machine byte order (floats) 139 163 Ntry = 0; 140 164 if (DEBUG) fprintf (stderr, "starting vector load\n"); 141 165 Ninpts = 0; 166 byte = buffer; 142 167 while (bytes_left > 0) { 143 status = read (sock, b uff, bytes_left);168 status = read (sock, byte, bytes_left); 144 169 if (DEBUG) fprintf (stderr, "status: %d, %d\n", status, bytes_left); 145 170 if (status == 0) { /* No more pipe */ … … 150 175 Ninpts += status; 151 176 bytes_left -= status; 152 b uff = (char *)(buff+ status);177 byte = (char *)(byte + status); 153 178 Ntry = 0; 154 179 continue; … … 165 190 perror ("kapa load"); 166 191 } 192 193 fcntl (sock, F_SETFL, !O_NONBLOCK); 194 KiiSendCommand (sock, 4, "DONE"); 195 196 # ifdef BYTE_SWAP 197 swap_host = 1; 198 # else 199 swap_host = 0; 200 # endif 201 202 // if host and client have opposite swap parities, word swap the incoming data 203 // SWAP_WORD is strangely defined... it takes the number of the start byte in a 204 // buffer called 'byte' 205 if ((swap_host && !swap_client) || (!swap_host && swap_client)) { 206 byte = buffer; 207 for (i = 0; i < Nbytes_send; i+=4) { 208 SWAP_WORD (i); 209 } 210 } 211 167 212 if (Ninpts != Npts*sizeof(float)) { 168 213 fprintf (stderr, "error: expected %d bytes, but got only %d\n", Ninpts, (unsigned int)(Npts*sizeof(float))); … … 185 230 if (object[0].dyp != (float *) NULL) free (object[0].dyp); 186 231 } 187 -
trunk/Ohana/src/kapa2/src/LoadOverlay.c
r13331 r13479 1 1 # include "Ximage.h" 2 2 3 // XXX this is a very inefficient method to send the data: binary would be better 4 int LoadOverlay () { 3 int LoadOverlay (int sock) { 5 4 6 char word[17], type[16], string[128]; 7 char *buffer, *buff; 8 double x, y, dx, dy; 9 int Nin, bytes, status; 10 int i, N, NOBJECTS, Nobjects, Nstart; 5 int i, j, Ntotal, Nbytes, Nread, Nfound, Ntext, Nobjects, overnum; 6 int Noverlay, NOVERLAY, Ntextdata; 7 char *textdata, *buffer, *p, *q; 11 8 Section *section; 12 9 KapaImageWidget *image; 13 10 Graphic *graphic; 11 KiiOverlayBase *overlay; 14 12 15 13 graphic = GetGraphic (); 16 14 section = GetActiveSection(); 17 image = section->image; 15 if (section->image == NULL) { 16 section->image = InitImage (); 17 SetSectionSizes (section); 18 } 19 image = section->image; 18 20 19 ALLOCATE (buffer, char, 65536); /* space for 512 lines of 128 bytes */ 20 bzero (buffer, 65536); 21 KiiScanMessage (sock, "%d %d %d %d", &overnum, &Noverlay, &Ntext, &Ntextdata); 21 22 22 KiiScanCommand (sock, 16, "%*s %d", &N);23 Nstart = image[0].overlay[N].Nobjects;23 // XXX need to validate overnum 24 if ((overnum < 0) || (overnum >= NOVERLAYS)) overnum = 0; 24 25 25 while (1) { 26 KiiScanCommand (sock, 16, "%s %d", word, &Nin); 27 if (!strcmp (word, "DONE")) break; 28 if (strcmp (word, "NLINES")) abort(); 26 // read the overlay data as binary 27 Ntotal = 0; 28 Nbytes = Noverlay*sizeof(KiiOverlayBase); 29 fcntl (sock, F_SETFL, O_NONBLOCK); 30 ALLOCATE (overlay, KiiOverlayBase, Noverlay); 31 buffer = (char *) overlay; 32 while (Nbytes > 0) { 33 Nread = read (sock, &buffer[Ntotal], Nbytes); 34 // fprintf (stderr, "read: %d of %d remaining, %d so far, %d expected\n", Nread, Nbytes, Ntotal, Noverlay*sizeof(KiiOverlayBase)); 35 if (Nread == 0) { /* No more pipe */ 36 fprintf (stderr, "error: pipe closed\n"); 37 free (overlay); 38 fcntl (sock, F_SETFL, !O_NONBLOCK); 39 return (FALSE); 40 } 41 if (Nread != -1) { /* pipe has data */ 42 Nbytes -= Nread; 43 Ntotal += Nread; 44 } 45 } 46 fcntl (sock, F_SETFL, !O_NONBLOCK); 47 KiiSendCommand (sock, 4, "DONE"); 29 48 30 buff = buffer; 31 bytes = 128*Nin; 49 // read the textdata as binary 50 Ntotal = 0; 51 Nbytes = Ntextdata; 52 fcntl (sock, F_SETFL, O_NONBLOCK); 53 ALLOCATE (textdata, char, Ntextdata); 54 while (Nbytes > 0) { 55 Nread = read (sock, &textdata[Ntotal], Nbytes); 56 if (Nread == 0) { /* No more pipe */ 57 fprintf (stderr, "error: pipe closed\n"); 58 free (textdata); 59 free (overlay); 60 fcntl (sock, F_SETFL, !O_NONBLOCK); 61 return (FALSE); 62 } 63 if (Nread != -1) { /* pipe has data */ 64 Nbytes -= Nread; 65 Ntotal += Nread; 66 } 67 } 68 fcntl (sock, F_SETFL, !O_NONBLOCK); 69 KiiSendCommand (sock, 4, "DONE"); 32 70 33 /* accept data from the socket until we have all of the bytes */ 34 fcntl (sock, F_SETFL, O_NONBLOCK); 35 while (bytes > 0) { 36 status = read (sock, buff, bytes); 37 if (status == 0) { /* No more pipe */ 38 fprintf (stderr, "error: pipe closed\n"); 39 free (buffer); 40 fcntl (sock, F_SETFL, O_NONBLOCK); 41 return (FALSE); 42 } 43 if (status != -1) { /* pipe has data */ 44 bytes -= status; 45 buff = (char *)(buff + status); 46 } 47 } 48 fcntl (sock, F_SETFL, !O_NONBLOCK); 71 // add new overlay objects to existing data 72 Nobjects = image[0].overlay[overnum].Nobjects + Noverlay; 73 REALLOCATE (image[0].overlay[overnum].objects, KiiOverlay, Nobjects); 49 74 50 /* parse buffer data */ 51 NOBJECTS = image[0].overlay[N].Nobjects + Nin; 52 Nobjects = image[0].overlay[N].Nobjects; 53 REALLOCATE (image[0].overlay[N].objects, Object, NOBJECTS); 54 for (i = 0; i < Nin; i++) { 55 sscanf (&buffer[i*128], "%s %lf %lf %lf %lf\n", type, &x, &y, &dx, &dy); 56 57 if (strcasecmp (type, "TEXT") && strcasecmp (type, "LINE") && strcasecmp (type, "BOX") && strcasecmp (type, "CIRCLE")) { /* skip */ 58 fprintf (stderr, "don't know %s, skipping\n", type); 59 continue; 60 } 61 62 if (!strcasecmp (type, "TEXT")) { /* end of objects */ 63 sscanf (&buffer[i*128], "%s %lf %lf %s\n", type, &x, &y, string); 64 } 65 66 strcpy (image[0].overlay[N].objects[Nobjects].type, type); 67 image[0].overlay[N].objects[Nobjects].x = x; 68 image[0].overlay[N].objects[Nobjects].y = y; 69 if (!strcmp (type, "TEXT")) { 70 image[0].overlay[N].objects[Nobjects].dx = 0; 71 image[0].overlay[N].objects[Nobjects].dy = 0; 72 image[0].overlay[N].objects[Nobjects].text = strcreate (string); 73 } else { 74 image[0].overlay[N].objects[Nobjects].dx = dx; 75 image[0].overlay[N].objects[Nobjects].dy = dy; 76 } 77 Nobjects++; 78 } 79 REALLOCATE (image[0].overlay[N].objects, Object, MAX(Nobjects, 1)); 80 image[0].overlay[N].Nobjects = Nobjects; 75 j = image[0].overlay[overnum].Nobjects; 76 for (i = 0; i < Noverlay; i++, j++) { 77 image[0].overlay[overnum].objects[j].x = overlay[i].x; 78 image[0].overlay[overnum].objects[j].y = overlay[i].y; 79 image[0].overlay[overnum].objects[j].dx = overlay[i].dx; 80 image[0].overlay[overnum].objects[j].dy = overlay[i].dy; 81 image[0].overlay[overnum].objects[j].type = overlay[i].type; 82 image[0].overlay[overnum].objects[j].text = NULL; 81 83 } 82 84 83 /* cleanup */ 84 free (buffer); 85 REALLOCATE (image[0].overlay[N].objects, Object, MAX (1, image[0].overlay[N].Nobjects)); 86 image[0].overlay[N].active = TRUE; 87 fcntl (sock, F_SETFL, O_NONBLOCK); 85 // parse the text data : text lines are separated by '\n', one per text entry 86 p = textdata; 87 Nfound = 0; 88 for (i = 0; i < Noverlay; i++) { 89 if (overlay[i].type != KII_OVERLAY_TEXT) continue; 90 if (Nfound >= Ntext) { 91 fprintf (stderr, "inconsistent number of text lines\n"); 92 break; 93 } 94 if (! *p) { 95 fprintf (stderr, "inconsistent number of text lines\n"); 96 break; 97 } 98 q = strchr (p, '\n'); 99 if (q == NULL) { 100 fprintf (stderr, "inconsistent text line\n"); 101 break; 102 } 103 j = image[0].overlay[overnum].Nobjects + i; 104 image[0].overlay[overnum].objects[j].text = strncreate (p, q-p); 105 p = q + 1; 106 Nfound ++; 107 } 108 if (Nfound != Ntext) { 109 fprintf (stderr, "read %d text lines, expected %d\n", Nfound, Ntext); 110 } 111 112 free (textdata); 113 free (overlay); 114 115 image[0].overlay[overnum].Nobjects = Nobjects; 116 image[0].overlay[overnum].active = TRUE; 88 117 89 118 if (USE_XWINDOW) { … … 93 122 } 94 123 } 95 PaintTickmarks (graphic, image);96 124 XFlush (graphic[0].display); 97 125 } -
trunk/Ohana/src/kapa2/src/LoadPicture.c
r13320 r13479 1 1 # include "Ximage.h" 2 2 3 int LoadPicture ( ) {3 int LoadPicture (int sock) { 4 4 5 5 Header header; … … 12 12 graphic = GetGraphic (); 13 13 section = GetActiveSection(); 14 image = section->image; 14 if (section->image == NULL) { 15 section->image = InitImage (); 16 SetSectionSizes (section); 17 } 18 image = section->image; 15 19 16 20 KiiSendMessage (sock, "%d", graphic->Npixels); 17 21 18 fcntl (sock, F_SETFL, !O_NONBLOCK);19 20 22 header.Naxes = 2; 21 22 23 KiiScanMessage (sock, "%d %d %d %d %lf %lf", &header.Naxis[0], &header.Naxis[1]); 23 24 KiiScanMessage (sock, "%d %d %d %d %lf %lf", &header.bitpix, &header.unsign, &header.bzero, &header.bscale); 24 KiiScanMessage (sock, "%lf %lf ", &image[0].zero, &image[0].range);25 KiiScanMessage (sock, "%lf %lf %s", &image[0].zero, &image[0].range, image[0].name, image[0].file); 25 26 KiiScanMessage (sock, "%lf %lf %d", &image[0].min, &image[0].max, &header.size); 26 27 KiiScanMessage (sock, "%lf %f %f %f %f", &image[0].coords.crval1, &image[0].coords.crpix1, &image[0].coords.cdelt1, &image[0].coords.pc1_1, &image[0].coords.pc1_2); 27 28 KiiScanMessage (sock, "%lf %f %f %f %f", &image[0].coords.crval2, &image[0].coords.crpix2, &image[0].coords.cdelt2, &image[0].coords.pc2_1, &image[0].coords.pc2_2); 28 29 KiiScanMessage (sock, "%s %s %s", image[0].coords.ctype, image[0].file, image[0].buffer_name); 29 KiiScanMessage (sock, "%s", image[0].coords.ctype); 30 30 31 31 gfits_free_matrix (&image[0].matrix); … … 51 51 } 52 52 53 fcntl (sock, F_SETFL, !O_NONBLOCK); 54 53 55 if (DEBUG) fprintf (stderr, "read %d bytes\n", image[0].matrix.size); 54 56 /* it it not obvious this condition should kill kii, but ... */ -
trunk/Ohana/src/kapa2/src/LoadTextlines.c
r13320 r13479 1 1 # include "Ximage.h" 2 2 3 int LoadTextlines ( ) {3 int LoadTextlines (int sock) { 4 4 5 5 char *string; … … 11 11 section = GetActiveSection(); 12 12 graph = section->graph; 13 14 fcntl (sock, F_SETFL, !O_NONBLOCK); 15 13 if (section->graph == NULL) { 14 section->graph = InitGraph (); 15 SetSectionSizes (section); 16 } 17 16 18 graph[0].Ntextline = MAX (graph[0].Ntextline, 0); 17 19 N = graph[0].Ntextline; … … 34 36 strcpy (graph[0].textline[N].text, string); 35 37 free (string); 36 37 fcntl (sock, F_SETFL, O_NONBLOCK);38 38 39 39 string = GetRotFont (&size); -
trunk/Ohana/src/kapa2/src/LoadTickmarks.c
r13320 r13479 1 1 # include "Ximage.h" 2 2 3 int LoadTickmarks ( ) {3 int LoadTickmarks (int sock) { 4 4 5 5 char line[129], type[16]; … … 10 10 11 11 section = GetActiveSection(); 12 if (section->image == NULL) { 13 section->image = InitImage (); 14 SetSectionSizes (section); 15 } 12 16 image = section->image; 13 fcntl (sock, F_SETFL, !O_NONBLOCK);14 17 15 18 Nobjects = image[0].tickmarks.Nobjects; 16 19 NOBJECTS = Nobjects + 100; 17 REALLOCATE (image[0].tickmarks.objects, Object, NOBJECTS);20 REALLOCATE (image[0].tickmarks.objects, KiiOverlay, NOBJECTS); 18 21 19 22 done = FALSE; … … 51 54 if (Nobjects >= NOBJECTS) { 52 55 NOBJECTS = Nobjects + 100; 53 REALLOCATE (image[0].tickmarks.objects, Object, NOBJECTS);56 REALLOCATE (image[0].tickmarks.objects, KiiOverlay, NOBJECTS); 54 57 } 55 58 56 59 } 57 60 58 REALLOCATE (image[0].tickmarks.objects, Object, MAX(Nobjects, 1));61 REALLOCATE (image[0].tickmarks.objects, KiiOverlay, MAX(Nobjects, 1)); 59 62 image[0].tickmarks.Nobjects = Nobjects; 60 63 61 64 if (USE_XWINDOW) Refresh (); 62 63 fcntl (sock, F_SETFL, O_NONBLOCK);64 65 return (TRUE); 65 66 66 } -
trunk/Ohana/src/kapa2/src/PNGit.c
r13320 r13479 1 1 # include "Ximage.h" 2 2 3 int PNGit ( ) {3 int PNGit (int sock) { 4 4 5 5 FILE *f; -
trunk/Ohana/src/kapa2/src/PPMit.c
r13320 r13479 1 1 # include "Ximage.h" 2 2 3 int PPMit ( ) {3 int PPMit (int sock) { 4 4 5 5 FILE *f; -
trunk/Ohana/src/kapa2/src/PSOverlay.c
r13331 r13479 31 31 dY = (image[0].overlay[N].objects[i].dy)/expand; 32 32 33 if (!strcmp (image[0].overlay[N].objects[i].type, "LINE")) { 34 if (((X < Xmin) && (X + dX < Xmin)) || ((X > Xmax) && (X + dX > Xmax)) || 35 ((Y < Ymin) && (Y + dY < Ymin)) || ((Y > Ymax) && (Y + dY > Ymax))) { 36 continue; 37 } 38 fprintf (f, " %6.1f %6.1f %6.1f %6.1f L\n", X + extra, Y + extra, (X+dX + extra), (Y-dY + extra)); 39 continue; 33 switch (image[0].overlay[N].objects[i].type) { 34 case KII_OVERLAY_LINE: 35 if (((X < Xmin) && (X + dX < Xmin)) || ((X > Xmax) && (X + dX > Xmax)) || 36 ((Y < Ymin) && (Y + dY < Ymin)) || ((Y > Ymax) && (Y + dY > Ymax))) { 37 break; 38 } 39 fprintf (f, " %6.1f %6.1f %6.1f %6.1f L\n", X + extra, Y + extra, (X+dX + extra), (Y-dY + extra)); 40 break; 41 case KII_OVERLAY_TEXT: 42 if (((X < Xmin) && (X + dX < Xmin)) || ((X > Xmax) && (X + dX > Xmax)) || 43 ((Y < Ymin) && (Y + dY < Ymin)) || ((Y > Ymax) && (Y + dY > Ymax))) { 44 break; 45 } 46 fprintf (f, "(%s) %6.1f %6.1f T\n", image[0].overlay[N].objects[i].text, X + extra, Y + extra); 47 break; 48 case KII_OVERLAY_BOX: 49 if (((X - 0.5*dX < Xmin) && (X + 0.5*dX < Xmin)) || ((X - 0.5*dX > Xmax) && (X + 0.5*dX > Xmax)) || 50 ((Y - 0.5*dY < Ymin) && (Y + 0.5*dY < Ymin)) || ((Y - 0.5*dY > Ymax) && (Y + 0.5*dY > Ymax))) { 51 break; 52 } 53 fprintf (f, " %6.1f %6.1f %6.1f %6.1f B\n", (dX + 2*extra), (dY + 2*extra), (X - 0.5*dX - extra), (Y - 0.5*dY - extra)); 54 break; 55 case KII_OVERLAY_CIRCLE: 56 if (((X - dX < Xmin) && (X + dX < Xmin)) || ((X - dX > Xmax) && (X + dX > Xmax)) || 57 ((Y - dY < Ymin) && (Y + dY < Ymin)) || ((Y - dY > Ymax) && (Y + dY > Ymax))) { 58 break; 59 } 60 fprintf (f, " %6.1f %6.1f %6.1f C\n", X, Y, fabs(dX + extra)); 61 break; 62 default: 63 fprintf (stderr, "skipping unknown object\n"); 64 break; 40 65 } 41 if (!strcmp (image[0].overlay[N].objects[i].type, "TEXT")) {42 if (((X < Xmin) && (X + dX < Xmin)) || ((X > Xmax) && (X + dX > Xmax)) ||43 ((Y < Ymin) && (Y + dY < Ymin)) || ((Y > Ymax) && (Y + dY > Ymax))) {44 continue;45 }46 fprintf (f, "(%s) %6.1f %6.1f T\n", image[0].overlay[N].objects[i].text, X + extra, Y + extra);47 continue;48 }49 if (!strcmp (image[0].overlay[N].objects[i].type, "BOX")) {50 if (((X - 0.5*dX < Xmin) && (X + 0.5*dX < Xmin)) || ((X - 0.5*dX > Xmax) && (X + 0.5*dX > Xmax)) ||51 ((Y - 0.5*dY < Ymin) && (Y + 0.5*dY < Ymin)) || ((Y - 0.5*dY > Ymax) && (Y + 0.5*dY > Ymax))) {52 continue;53 }54 fprintf (f, " %6.1f %6.1f %6.1f %6.1f B\n", (dX + 2*extra), (dY + 2*extra), (X - 0.5*dX - extra), (Y - 0.5*dY - extra));55 continue;56 }57 if (!strcmp (image[0].overlay[N].objects[i].type, "CIRCLE")) {58 if (((X - dX < Xmin) && (X + dX < Xmin)) || ((X - dX > Xmax) && (X + dX > Xmax)) ||59 ((Y - dY < Ymin) && (Y + dY < Ymin)) || ((Y - dY > Ymax) && (Y + dY > Ymax))) {60 continue;61 }62 fprintf (f, " %6.1f %6.1f %6.1f C\n", X, Y, fabs(dX + extra));63 continue;64 }65 fprintf (stderr, "don't know %s, skipping\n", image[0].overlay[N].objects[i].type);66 66 } 67 68 67 } -
trunk/Ohana/src/kapa2/src/PSit.c
r13331 r13479 6 6 static Graphic *graphic; 7 7 8 int PScommand ( ) {8 int PScommand (int sock) { 9 9 10 10 int status, scaleMode, pageMode; -
trunk/Ohana/src/kapa2/src/PaintOverlay.c
r13320 r13479 41 41 for a BOX (x, y) is the center, (dx, dy) is the width */ 42 42 43 if (!strcasecmp (image[0].overlay[N].objects[i].type, "LINE")) { 44 XDrawLine (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y, (X+dX), (Y+dY)); 45 continue; 43 switch (image[0].overlay[N].objects[i].type) { 44 case KII_OVERLAY_LINE: 45 XDrawLine (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y, (X+dX), (Y+dY)); 46 break; 47 case KII_OVERLAY_TEXT: 48 XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y, image[0].overlay[N].objects[i].text, strlen(image[0].overlay[N].objects[i].text)); 49 break; 50 case KII_OVERLAY_BOX: 51 dx = MAX (abs(dX),2) / 2; 52 dy = MAX (abs(dY),2) / 2; 53 XDrawRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, (X - dx), (Y - dy), 2*dx, 2*dy); 54 break; 55 case KII_OVERLAY_CIRCLE: 56 dx = MAX (abs(dX),2); 57 dy = MAX (abs(dY),2); 58 XDrawArc (graphic[0].display, graphic[0].window, graphic[0].gc, (X - dx), (Y - dy), 2*dx, 2*dy, 0, 23040); 59 break; 60 default: 61 fprintf (stderr, "skipping unknown object\n"); 62 break; 46 63 } 47 if (!strcasecmp (image[0].overlay[N].objects[i].type, "TEXT")) {48 XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y, image[0].overlay[N].objects[i].text, strlen(image[0].overlay[N].objects[i].text));49 continue;50 }51 if (!strcasecmp (image[0].overlay[N].objects[i].type, "BOX")) {52 dx = MAX (abs(dX),2) / 2;53 dy = MAX (abs(dY),2) / 2;54 XDrawRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, (X - dx), (Y - dy), 2*dx, 2*dy);55 continue;56 }57 if (!strcasecmp (image[0].overlay[N].objects[i].type, "CIRCLE")) {58 dx = MAX (abs(dX),2);59 dy = MAX (abs(dY),2);60 XDrawArc (graphic[0].display, graphic[0].window, graphic[0].gc, (X - dx), (Y - dy), 2*dx, 2*dy, 0, 23040);61 continue;62 }63 fprintf (stderr, "don't know %s, skipping (PO)\n", image[0].overlay[N].objects[i].type);64 64 } 65 65 -
trunk/Ohana/src/kapa2/src/PaintTickmarks.c
r13320 r13479 22 22 dY = image[0].tickmarks.objects[i].dy * Yrange; 23 23 24 if (!strcmp (image[0].tickmarks.objects[i].type, "LINE")) { 25 XDrawLine (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y, (X+dX), (Y+dY)); 26 continue; 24 switch (image[0].overlay[0].objects[i].type) { 25 case KII_OVERLAY_LINE: 26 XDrawLine (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y, (X+dX), (Y+dY)); 27 break; 28 case KII_OVERLAY_TEXT: 29 if (image[0].tickmarks.objects[i].dy == 0) { 30 XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].back); 31 XFillRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y-11, 6*strlen(image[0].tickmarks.objects[i].text), 11); 32 XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore); 33 XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y, image[0].tickmarks.objects[i].text, strlen(image[0].tickmarks.objects[i].text)); 34 } 35 if (image[0].tickmarks.objects[i].dy == 90) { 36 XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].back); 37 XFillRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y-6*strlen(image[0].tickmarks.objects[i].text), 11, 6*strlen(image[0].tickmarks.objects[i].text)); 38 XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore); 39 /* XDrawRotString (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y, image[0].tickmarks.objects[i].text, strlen(image[0].tickmarks.objects[i].text)); */ 40 } 41 break; 42 case KII_OVERLAY_BOX: 43 XDrawRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, (int)(X - 0.5*dX), (int)(Y - 0.5*dY), abs(dX), abs(dY)); 44 break; 45 case KII_OVERLAY_CIRCLE: 46 XDrawArc (graphic[0].display, graphic[0].window, graphic[0].gc, X - dX, Y - dY, abs(2*dX), abs(2*dY), 0, 23040); 47 break; 48 default: 49 fprintf (stderr, "skipping unknown object\n"); 50 break; 27 51 } 28 if (!strcmp (image[0].tickmarks.objects[i].type, "TEXT")) {29 if (image[0].tickmarks.objects[i].dy == 0) {30 XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].back);31 XFillRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y-11, 6*strlen(image[0].tickmarks.objects[i].text), 11);32 XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore);33 XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y, image[0].tickmarks.objects[i].text, strlen(image[0].tickmarks.objects[i].text));34 }35 if (image[0].tickmarks.objects[i].dy == 90) {36 XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].back);37 XFillRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y-6*strlen(image[0].tickmarks.objects[i].text), 11, 6*strlen(image[0].tickmarks.objects[i].text));38 XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore);39 /* XDrawRotString (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y, image[0].tickmarks.objects[i].text, strlen(image[0].tickmarks.objects[i].text)); */40 }41 continue;42 }43 if (!strcmp (image[0].tickmarks.objects[i].type, "BOX")) {44 XDrawRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, (int)(X - 0.5*dX), (int)(Y - 0.5*dY), abs(dX), abs(dY));45 continue;46 }47 if (!strcmp (image[0].tickmarks.objects[i].type, "CIRCLE")) {48 XDrawArc (graphic[0].display, graphic[0].window, graphic[0].gc, X - dX, Y - dY, abs(2*dX), abs(2*dY), 0, 23040);49 continue;50 }51 fprintf (stderr, "don't know %s, skipping (PO)\n", image[0].tickmarks.objects[i].type);52 52 } 53 54 53 XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore); 55 56 54 } -
trunk/Ohana/src/kapa2/src/Reconfig.c
r13320 r13479 25 25 for (i = 0; i < Nsection; i++) { 26 26 section = GetSectionByNumber (i); 27 SetGraphSize (section); 28 SetImageSize (section); 27 SetSectionSizes (section); 29 28 } 30 29 -
trunk/Ohana/src/kapa2/src/Refresh.c
r13320 r13479 21 21 for (i = 0; i < Nsection; i++) { 22 22 section = GetSectionByNumber (i); 23 DrawImage (section->image); 23 24 DrawGraph (section->graph); 24 DrawImage (section->image);25 25 } 26 26 -
trunk/Ohana/src/kapa2/src/Remap16.c
r13320 r13479 1 1 # include "Ximage.h" 2 # define FRAC(a) ((a) - (int)(a)) 2 3 static float slope = 1.0; 4 static float start = 0.0; 5 static int MaxValue = 255; 6 7 // XXX inline this if needed 8 static int PixelLookup(float value) { 9 int out; 10 out = MIN (MAX (slope * value - start, 0), MaxValue); 11 return (out); 12 } 3 13 4 14 void Remap16 (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) { … … 7 17 int i_start, i_end, j_start, j_end; 8 18 int dropback; /* this is a bit of a kludge... */ 9 int dx, dy, DX, DY ;19 int dx, dy, DX, DY, pixelN; 10 20 double expand, Rx, Ry, X, Y; 11 21 int expand_in, expand_out; 12 22 unsigned char *out_pix, *out_pix2, *data; 13 unsigned char *in_pix,*in_pix2;14 unsigned char pixel1[256], pixel2[256] , pixel3[256];23 float *imdata, *in_pix, *in_pix2; 24 unsigned char pixel1[256], pixel2[256]; 15 25 unsigned char pixvalue1, pixvalue2; 16 26 unsigned long back; 17 27 unsigned char back1, back2; 18 28 29 // local array for pixel values (is this working??) 19 30 for (i = 0; i < 256; i++) { /* set up pixel array */ 20 pixel1[i] = 0x0000ff & graphic[0].cmap[i].pixel; 21 pixel2[i] = 0x0000ff & (graphic[0].cmap[i].pixel >> 8); 22 pixel3[i] = 0x0000ff & (graphic[0].cmap[i].pixel >> 16); 31 pixel1[i] = 0x00ff & graphic[0].cmap[i].pixel; 32 pixel2[i] = 0x00ff & (graphic[0].cmap[i].pixel >> 8); 23 33 } 24 34 back = graphic[0].back; … … 26 36 back2 = 0x00ff & (back >> 8); 27 37 38 // define the color transform parameters 39 MaxValue = graphic[0].Npixels - 1; 40 if (image[0].range != 0.0) { 41 slope = graphic[0].Npixels / image[0].range; 42 start = graphic[0].Npixels * image[0].zero / image[0].range; 43 } else { 44 slope = 1.0; 45 start = image[0].zero; 46 } 47 48 // set up expansions 28 49 expand = expand_in = expand_out = 1.0; 29 50 if (image[0].expand == 0) /* set up expansions */ … … 40 61 } 41 62 63 // define the image boundaries 42 64 dx = image[0].picture.dx; 43 65 dy = image[0].picture.dy; … … 76 98 77 99 data = out_pix = (unsigned char *) image[0].picture.data; 78 in_pix = (unsigned char *) (matrix[0].buffer) + DX*(int)MAX(Y,0) + (int)MAX(X,0); 100 imdata = (float *) matrix[0].buffer; 101 in_pix = &imdata[DX*(int)MAX(Y,0) + (int)MAX(X,0)]; 79 102 80 103 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ … … 105 128 if (expand_out == 1) { 106 129 for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix+=2) { 107 out_pix[0] = pixel1[*in_pix2]; 108 out_pix[1] = pixel2[*in_pix2]; 130 pixelN = PixelLookup(*in_pix2); 131 out_pix[0] = pixel1[pixelN]; 132 out_pix[1] = pixel2[pixelN]; 109 133 } 110 134 } 111 135 else { 112 136 for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= 2*expand_out) { 113 pixvalue1 = pixel1[*in_pix2]; 114 pixvalue2 = pixel2[*in_pix2]; 137 pixelN = PixelLookup(*in_pix2); 138 pixvalue1 = pixel1[pixelN]; 139 pixvalue2 = pixel2[pixelN]; 115 140 out_pix2 = out_pix; 116 141 for (jj = 0; jj < expand_out; jj++, out_pix2+=2*(dx-expand_out)) { -
trunk/Ohana/src/kapa2/src/Remap24.c
r13320 r13479 1 1 # include "Ximage.h" 2 # define FRAC(a) ((a) - (int)(a)) 2 3 static float slope = 1.0; 4 static float start = 0.0; 5 static int MaxValue = 255; 6 7 // XXX inline this if needed 8 static int PixelLookup(float value) { 9 int out; 10 out = MIN (MAX (slope * value - start, 0), MaxValue); 11 return (out); 12 } 3 13 4 14 void Remap24 (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) { … … 7 17 int i_start, i_end, j_start, j_end; 8 18 int dropback, extra; /* this is a bit of a kludge... */ 9 int dx, dy, DX, DY ;19 int dx, dy, DX, DY, pixelN; 10 20 double expand, Rx, Ry, X, Y; 11 21 int expand_in, expand_out; 12 22 unsigned char *out_pix, *out_pix2, *data; 13 unsigned char *in_pix,*in_pix2;23 float *imdata, *in_pix, *in_pix2; 14 24 unsigned char pixel1[256], pixel2[256], pixel3[256]; 15 25 unsigned char pixvalue1, pixvalue2, pixvalue3; … … 17 27 unsigned char back1, back2, back3; 18 28 29 // local arrays for pixel values 19 30 for (i = 0; i < 256; i++) { /* set up pixel array */ 20 31 pixel1[i] = 0x0000ff & graphic[0].cmap[i].pixel; … … 27 38 back3 = 0x0000ff & (back >> 16); 28 39 40 // define the color transform parameters 41 MaxValue = graphic[0].Npixels - 1; 42 if (image[0].range != 0.0) { 43 slope = graphic[0].Npixels / image[0].range; 44 start = graphic[0].Npixels * image[0].zero / image[0].range; 45 } else { 46 slope = 1.0; 47 start = image[0].zero; 48 } 49 50 // set up expansions 29 51 expand = expand_in = expand_out = 1.0; 30 52 if (image[0].expand == 0) /* set up expansions */ … … 78 100 79 101 data = out_pix = (unsigned char *) image[0].picture.data; 80 in_pix = (unsigned char *) (matrix[0].buffer) + DX*(int)MAX(Y,0) + (int)MAX(X,0); 102 imdata = (float *) matrix[0].buffer; 103 in_pix = &imdata[DX*(int)MAX(Y,0) + (int)MAX(X,0)]; 81 104 82 105 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ … … 110 133 if (expand_out == 1) { 111 134 for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix+=3) { 112 out_pix[0] = pixel1[*in_pix2]; 113 out_pix[1] = pixel2[*in_pix2]; 114 out_pix[2] = pixel3[*in_pix2]; 135 pixelN = PixelLookup(*in_pix2); 136 out_pix[0] = pixel1[pixelN]; 137 out_pix[1] = pixel2[pixelN]; 138 out_pix[2] = pixel3[pixelN]; 115 139 } 116 } 117 else { 140 } else { 118 141 for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= 3*expand_out) { 119 pixvalue1 = pixel1[*in_pix2]; 120 pixvalue2 = pixel2[*in_pix2]; 121 pixvalue3 = pixel3[*in_pix2]; 142 pixelN = PixelLookup(*in_pix2); 143 pixvalue1 = pixel1[pixelN]; 144 pixvalue2 = pixel2[pixelN]; 145 pixvalue3 = pixel3[pixelN]; 122 146 out_pix2 = out_pix; 123 147 for (jj = 0; jj < expand_out; jj++, out_pix2+=3*(dx-expand_out)+extra) { -
trunk/Ohana/src/kapa2/src/Remap32.c
r13320 r13479 1 1 # include "Ximage.h" 2 # define FRAC(a) ((a) - (int)(a)) 2 3 static float slope = 1.0; 4 static float start = 0.0; 5 static int MaxValue = 255; 6 7 // XXX inline this if needed 8 static int PixelLookup(float value) { 9 int out; 10 out = MIN (MAX (slope * value - start, 0), MaxValue); 11 return (out); 12 } 3 13 4 14 void Remap32 (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) { … … 7 17 int i_start, i_end, j_start, j_end; 8 18 int dropback; /* this is a bit of a kludge... */ 9 int dx, dy, DX, DY ;19 int dx, dy, DX, DY, pixelN; 10 20 double expand, Rx, Ry, X, Y; 11 21 int expand_in, expand_out; 12 22 unsigned int *out_pix, *out_pix2; 13 unsigned char *in_pix,*in_pix2;23 float *imdata, *in_pix, *in_pix2; 14 24 unsigned long pixel[256], pixvalue; 15 25 unsigned long back; 16 26 17 for (i = 0; i < 256; i++) { /* set up pixel array */ 27 // local array for pixel values 28 for (i = 0; i < 256; i++) { 18 29 pixel[i] = graphic[0].cmap[i].pixel; 19 30 } 20 31 back = graphic[0].back; 21 32 33 // define the color transform parameters 34 MaxValue = graphic[0].Npixels - 1; 35 if (image[0].range != 0.0) { 36 slope = graphic[0].Npixels / image[0].range; 37 start = graphic[0].Npixels * image[0].zero / image[0].range; 38 } else { 39 slope = 1.0; 40 start = image[0].zero; 41 } 42 43 // set up expansions 22 44 expand = expand_in = expand_out = 1.0; 23 if (image[0].expand == 0) /* set up expansions */45 if (image[0].expand == 0) 24 46 image[0].expand = 1; 25 47 if (image[0].expand > 0) { … … 34 56 } 35 57 58 // define the image boundaries 36 59 dx = image[0].picture.dx; 37 60 dy = image[0].picture.dy; … … 69 92 70 93 out_pix = (unsigned int *) image[0].picture.data; 71 in_pix = (unsigned char *) (matrix[0].buffer) + DX*(int)MAX(Y,0) + (int)MAX(X,0); 94 imdata = (float *) matrix[0].buffer; 95 in_pix = &imdata[DX*(int)MAX(Y,0) + (int)MAX(X,0)]; 72 96 73 97 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ … … 92 116 if (expand_out == 1) { 93 117 for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) { 94 *out_pix = pixel[*in_pix2]; 118 pixelN = PixelLookup(*in_pix2); 119 *out_pix = pixel[pixelN]; 95 120 } 96 /* *out_pix = *(pixel + *in_pix2); */97 121 } 98 122 else { 99 123 for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) { 100 pixvalue = pixel[*in_pix2]; 124 pixelN = PixelLookup(*in_pix2); 125 pixvalue = pixel[pixelN]; 101 126 out_pix2 = out_pix; 102 127 for (jj = 0; jj < expand_out; jj++, out_pix2+=(dx-expand_out)) { -
trunk/Ohana/src/kapa2/src/Remap8.c
r13320 r13479 1 1 # include "Ximage.h" 2 # define FRAC(a) ((a) - (int)(a)) 2 3 static float slope = 1.0; 4 static float start = 0.0; 5 static int MaxValue = 255; 6 7 // XXX inline this if needed 8 static int PixelLookup(float value) { 9 int out; 10 out = MIN (MAX (slope * value - start, 0), MaxValue); 11 return (out); 12 } 3 13 4 14 void Remap8 (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) { … … 7 17 int i_start, i_end, j_start, j_end; 8 18 int dropback; /* this is a bit of a kludge... */ 9 int dx, dy, DX, DY ;19 int dx, dy, DX, DY, pixelN; 10 20 double expand, Rx, Ry, X, Y; 11 21 int expand_in, expand_out; 12 22 unsigned char *out_pix, *out_pix2; 13 unsigned char*in_pix, *in_pix2;23 float *imdata, *in_pix, *in_pix2; 14 24 unsigned long pixel[256], pixvalue; 15 25 unsigned long back; 16 26 17 for (i = 0; i < 256; i++) { /* set up pixel array */ 27 // local array for pixel values 28 for (i = 0; i < 256; i++) { 18 29 pixel[i] = graphic[0].cmap[i].pixel; 19 30 } 20 31 back = graphic[0].back; 21 32 33 // define the color transform parameters 34 MaxValue = graphic[0].Npixels - 1; 35 if (image[0].range != 0.0) { 36 slope = graphic[0].Npixels / image[0].range; 37 start = graphic[0].Npixels * image[0].zero / image[0].range; 38 } else { 39 slope = 1.0; 40 start = image[0].zero; 41 } 42 43 // set up expansions 22 44 expand = expand_in = expand_out = 1.0; 23 45 if (image[0].expand == 0) /* set up expansions */ … … 34 56 } 35 57 58 // define the image boundaries 36 59 dx = image[0].picture.dx; 37 60 dy = image[0].picture.dy; 38 61 DX = matrix[0].Naxis[0]; 39 62 DY = matrix[0].Naxis[1]; 63 40 64 /* X,Y are the image coordinates of the first image pixel */ 41 65 X = MAX(0.5*(DX - dx*expand) - image[0].X, 0); … … 69 93 70 94 out_pix = (unsigned char *) image[0].picture.data; 71 in_pix = (unsigned char *) matrix[0].buffer + DX*(int)MAX(Y,0) + (int)MAX(X,0); 95 imdata = (float *) matrix[0].buffer; 96 in_pix = &imdata[(int)(DX*(int)MAX(Y,0) + (int)MAX(X,0))]; 72 97 73 98 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ … … 92 117 if (expand_out == 1) { 93 118 for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) { 94 *out_pix = pixel[*in_pix2]; 119 pixelN = PixelLookup(*in_pix2); 120 *out_pix = pixel[pixelN]; 95 121 } 96 /* *out_pix = *(pixel + *in_pix2); */ 97 } 98 else { 122 } else { 99 123 for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) { 100 pixvalue = pixel[*in_pix2]; 124 pixelN = PixelLookup(*in_pix2); 125 pixvalue = pixel[pixelN]; 101 126 out_pix2 = out_pix; 102 127 for (jj = 0; jj < expand_out; jj++, out_pix2+=(dx-expand_out)) { -
trunk/Ohana/src/kapa2/src/Resize.c
r13320 r13479 2 2 3 3 // XXX Should there be a base command + KiiMessage command? 4 int Resize ( ) {4 int Resize (int sock) { 5 5 6 6 int i, Nsection; … … 30 30 for (i = 0; i < Nsection; i++) { 31 31 section = GetSectionByNumber (i); 32 SetGraphSize (section); 33 SetImageSize (section); 32 SetSectionSizes (section); 34 33 } 35 34 -
trunk/Ohana/src/kapa2/src/SaveOverlay.c
r13320 r13479 1 1 # include "Ximage.h" 2 2 3 int SaveOverlay ( ) {3 int SaveOverlay (int sock) { 4 4 5 5 int i, N; 6 char filename[256] ;6 char filename[256], *type; 7 7 FILE *f; 8 8 Section *section; … … 11 11 section = GetActiveSection(); 12 12 image = section->image; 13 if (image == NULL) return (TRUE); 13 14 14 15 KiiScanMessage (sock, "%*s %d %s", &N, filename); … … 21 22 22 23 for (i = 0; i < image[0].overlay[N].Nobjects; i++) { 24 type = KiiOverlayTypeByNumber (image[0].overlay[N].objects[i].type); 25 if (type == NULL) continue; 23 26 fprintf (f, "%s %lf %lf %lf %lf\n", 24 image[0].overlay[N].objects[i].type,27 type, 25 28 image[0].overlay[N].objects[i].x, 26 29 image[0].overlay[N].objects[i].y, … … 31 34 return (TRUE); 32 35 } 36 37 /* this is asymmetric with LoadOverlay.c. In that case, the client reads the file and sends 38 * the overlay objects to kapa. In this case, kapa writes the file directly... 39 */ -
trunk/Ohana/src/kapa2/src/Sections.c
r13320 r13479 24 24 25 25 if (section == NULL) return; 26 if (section[0].graph != NULL)FreeGraph (section[0].graph);27 // if (section[0].image != NULL)FreeImage (section[0].image);28 if (section[0].name != NULL) free(section[0].name);26 FreeGraph (section[0].graph); 27 FreeImage (section[0].image); 28 FREE (section[0].name); 29 29 free (section); 30 30 } … … 42 42 } 43 43 44 // XXX how to set the section type?45 // XXX set active section on Add?46 44 Section *AddSection (char *name, float x, float y, float dx, float dy) { 47 45 … … 116 114 } 117 115 118 int ListSection ( ) {116 int ListSection (int sock) { 119 117 120 118 int i, ThisSection; … … 149 147 return (TRUE); 150 148 } 149 150 void SetSectionSizes (Section *section) { 151 152 SetGraphSize (section); 153 SetImageSize (section); 154 return; 155 } 156 157 // return TRUE even for nonsense cases to avoid quitting kapa 158 int MoveSection (int sock) { 159 160 int i, N; 161 char name[128]; 162 char direction[16]; 163 Section *tmpSection = NULL; 164 165 KiiScanMessage (sock, "%s %s", name, direction); 166 167 N = GetSectionByName (name); 168 if (N < 0) { 169 fprintf (stderr, "section %s not found\n", name); 170 return (TRUE); 171 } 172 173 if (!strcasecmp (direction, "up")) { 174 if (N < 0) return (TRUE); 175 if (N > Nsections - 2) return (TRUE); 176 tmpSection = sections[N]; 177 sections[N] = sections[N+1]; 178 sections[N+1] = tmpSection; 179 Refresh (1); 180 return (TRUE); 181 } 182 183 if (!strcasecmp (direction, "down")) { 184 if (N < 1) return (TRUE); 185 if (N > Nsections - 1) return (TRUE); 186 tmpSection = sections[N]; 187 sections[N] = sections[N-1]; 188 sections[N-1] = tmpSection; 189 Refresh (1); 190 return (TRUE); 191 } 192 193 if (!strcasecmp (direction, "top")) { 194 if (N < 0) return (TRUE); 195 if (N > Nsections - 2) return (TRUE); 196 tmpSection = sections[N]; 197 for (i = N; i < Nsections - 1; i++) { 198 sections[i] = sections[i+1]; 199 } 200 sections[i] = tmpSection; 201 Refresh (1); 202 return (TRUE); 203 } 204 205 if (!strcasecmp (direction, "bottom")) { 206 if (N < 1) return (TRUE); 207 if (N > Nsections - 1) return (TRUE); 208 tmpSection = sections[N]; 209 for (i = N; i >= 1; i--) { 210 sections[i] = sections[i-1]; 211 } 212 sections[i] = tmpSection; 213 Refresh (1); 214 return (TRUE); 215 } 216 fprintf (stderr, "unknown direction %s for MoveSection\n", direction); 217 return (TRUE); 218 } -
trunk/Ohana/src/kapa2/src/SetFont.c
r13320 r13479 1 1 # include "Ximage.h" 2 2 3 int SetFont ( ) {3 int SetFont (int sock) { 4 4 5 5 char name[64]; -
trunk/Ohana/src/kapa2/src/SetGraphSize.c
r13320 r13479 7 7 8 8 int fontsize, bump, Nc; 9 int textpad, textdY, WdY; 9 10 double PADx, PADy, Dx, Dy; 10 11 double PXm, PXp, PYm, PYp; … … 32 33 PYp = (graph[0].axis[2].islabel) ? 4*fontsize : 0; 33 34 34 /* size of the graph in Xwindow coordinates */35 /* basic size of the graph in Xwindow coordinates */ 35 36 X0 = PADx + PXm + (Dx * section[0].x); 36 37 Y0 = PADy + PYm + (Dy * section[0].y); 37 38 dX = (Dx * section[0].dx) - PXp - PXm; 38 39 dY = (Dy * section[0].dy) - PYp - PYm; 40 41 // if we are tied to an image, make mods as needed 42 if (section->image) { 43 textpad = graphic[0].font[0].ascent; 44 textdY = 6*textpad + 7*PAD1; 45 WdY = MAX (ZOOM_Y, textdY + 2*BUTTON_HEIGHT + PAD1); 46 47 switch (section->image->location) { 48 case 1: 49 Y0 = graphic[0].dy * section[0].y + 2*PAD1 + WdY + 2; // tied to image in Y 50 dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD + 1; 51 break; 52 case 3: 53 dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD - PADy - PYm; 54 break; 55 case 2: 56 X0 = graphic[0].dx * section[0].x + 2*PAD1 + ZOOM_X; 57 dX = graphic[0].dx * section[0].dx - 3*PAD1 - ZOOM_X; 58 break; 59 case 4: 60 dX = graphic[0].dx * section[0].dx - 3*PAD1 - ZOOM_X - PADx - PXm; 61 break; 62 } 63 } 39 64 40 65 /* define locations of coordinate axes */ -
trunk/Ohana/src/kapa2/src/SetImageSize.c
r13320 r13479 7 7 void SetImageSize (Section *section) { 8 8 9 int Xs, Ys, Xe, Ye, dX, dY; 10 int textpad, textdY, WdY; 9 11 KapaImageWidget *image; 12 KapaGraphWidget *graph; 10 13 Graphic *graphic; 11 14 … … 13 16 image = section->image; 14 17 if (image == NULL) return; 18 graph = section->graph; 15 19 16 20 graphic = GetGraphic (); 17 21 18 image[0].cmapbar.dx = graphic[0].dx - 2*PAD1; 19 image[0].cmapbar.dy = COLORPAD; 20 image[0].cmapbar.x = PAD1; 21 image[0].cmapbar.y = PAD1; 22 23 image[0].zoom.dx = ZOOM_X; 24 image[0].zoom.dy = ZOOM_Y; 25 image[0].zoom.x = graphic[0].dx - PAD1 - ZOOM_X; 26 image[0].zoom.y = image[0].cmapbar.y + image[0].cmapbar.dy + PAD2; 27 28 image[0].picture.dx = image[0].zoom.x - 2*PAD1 - 25; 29 image[0].picture.dy = graphic[0].dy - 2*PAD1 - PAD2 - COLORPAD - 25; 30 image[0].picture.x = PAD1 + 25; 31 image[0].picture.y = PAD1 + PAD2 + COLORPAD; 32 33 /** everything below is tied in x-dir to the zoom box **/ 34 image[0].text_x = image[0].zoom.x; 35 image[0].text_y = image[0].zoom.y + image[0].zoom.dy + PAD2; 36 37 /* image[0].PS_button.y = graphic[0].dy - BUTTON_HEIGHT - PAD1; */ 38 image[0].PS_button.x = image[0].zoom.x + 5; 39 image[0].PS_button.y = 2*ZOOM_Y; 40 41 /** everything below is tied to the PS_button in y-dir **/ 42 image[0].grey_button.x = image[0].PS_button.x + image[0].PS_button.dx + PAD1; 43 image[0].grey_button.y = image[0].PS_button.y; 44 45 image[0].rainbow_button.x = image[0].grey_button.x + image[0].grey_button.dx + PAD1; 46 image[0].rainbow_button.y = image[0].PS_button.y; 47 48 image[0].puns_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1; 49 image[0].puns_button.y = image[0].PS_button.y; 50 51 image[0].recenter_button.x = image[0].puns_button.x + image[0].puns_button.dx + PAD1; 52 image[0].recenter_button.y = image[0].PS_button.y; 53 54 image[0].overlay_button[0].x = image[0].zoom.x + 5; 55 image[0].overlay_button[0].y = image[0].PS_button.y - BUTTON_HEIGHT - PAD1; 22 /* the image is placed within the graphic window in region specified by section */ 23 Xs = graphic[0].dx * section[0].x; 24 Ys = graphic[0].dy * (1 - section[0].y - section[0].dy); 25 dX = graphic[0].dx * section[0].dx; 26 dY = graphic[0].dy * section[0].dy; 27 28 switch (image[0].location) { 29 case 0: 30 if (section->graph) { 31 image[0].picture.x = graph[0].axis[0].fx; 32 image[0].picture.y = graph[0].axis[1].fy + graph[0].axis[1].dfy; 33 image[0].picture.dx = MAX(graph[0].axis[0].dfx + 1, 1); 34 image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1); 35 } else { 36 image[0].picture.x = Xs + PAD1; 37 image[0].picture.y = Ys + PAD1; 38 image[0].picture.dx = dX - 2*PAD1; 39 image[0].picture.dy = dY - 2*PAD1; 40 } 41 if (USE_XWINDOW) CreatePicture (image, graphic); 42 Remap (graphic, image, &image[0].matrix); 43 return; 44 45 case 1: 46 textpad = graphic[0].font[0].ascent; 47 textdY = 6*textpad + 7*PAD1; 48 WdY = MAX (ZOOM_Y, textdY + 2*BUTTON_HEIGHT + PAD1); 49 50 if (section->graph) { 51 image[0].picture.x = graph[0].axis[0].fx; 52 image[0].picture.y = Ys + 2*PAD1 + COLORPAD; 53 image[0].picture.dx = graph[0].axis[0].dfx; 54 image[0].picture.dy = dY - 5*PAD1 - WdY - COLORPAD; 55 } else { 56 image[0].picture.x = Xs + PAD1; 57 image[0].picture.y = Ys + 2*PAD1 + COLORPAD; 58 image[0].picture.dx = dX - 2*PAD1; 59 image[0].picture.dy = dY - 5*PAD1 - WdY - COLORPAD; 60 } 61 62 image[0].cmapbar.dx = dX - 2*PAD1; 63 image[0].cmapbar.dy = COLORPAD; 64 image[0].cmapbar.x = Xs + PAD1; 65 image[0].cmapbar.y = Ys + PAD1; 66 67 // XXX zoom should scale somewhat with the image? (with a min and a max) 68 // XXX actually, it is limited by the buttons and status region 69 image[0].zoom.dx = ZOOM_X; 70 image[0].zoom.dy = ZOOM_Y; 71 image[0].zoom.x = Xs + PAD1; 72 image[0].zoom.y = image[0].picture.y + image[0].picture.dy + PAD1; 73 74 /** everything below is tied in x-dir to the zoom box **/ 75 image[0].text_x = image[0].zoom.x + image[0].zoom.dx + PAD1; 76 image[0].text_y = image[0].zoom.y; 77 image[0].text_dx = ZOOM_X; 78 image[0].text_dy = 6*textpad + 7*PAD1; 79 80 image[0].overlay_button[0].x = image[0].text_x; 81 image[0].overlay_button[0].y = image[0].text_y + image[0].text_dy + PAD1; 56 82 57 image[0].overlay_button[1].x = image[0].overlay_button[0].x + image[0].overlay_button[0].dx + PAD1; 58 image[0].overlay_button[1].y = image[0].PS_button.y - BUTTON_HEIGHT - PAD1; 59 60 image[0].overlay_button[2].x = image[0].overlay_button[1].x + image[0].overlay_button[1].dx + PAD1; 61 image[0].overlay_button[2].y = image[0].PS_button.y - BUTTON_HEIGHT - PAD1; 62 63 image[0].overlay_button[3].x = image[0].overlay_button[2].x + image[0].overlay_button[2].dx + PAD1; 64 image[0].overlay_button[3].y = image[0].PS_button.y - BUTTON_HEIGHT - PAD1; 65 66 image[0].hms_button.x = image[0].overlay_button[3].x + image[0].overlay_button[3].dx + PAD1; 67 image[0].hms_button.y = image[0].PS_button.y - BUTTON_HEIGHT - PAD1; 83 image[0].overlay_button[1].x = image[0].overlay_button[0].x + image[0].overlay_button[0].dx + PAD1; 84 image[0].overlay_button[1].y = image[0].overlay_button[0].y; 85 86 image[0].overlay_button[2].x = image[0].overlay_button[1].x + image[0].overlay_button[1].dx + PAD1; 87 image[0].overlay_button[2].y = image[0].overlay_button[0].y; 88 89 image[0].overlay_button[3].x = image[0].overlay_button[2].x + image[0].overlay_button[2].dx + PAD1; 90 image[0].overlay_button[3].y = image[0].overlay_button[0].y; 91 92 image[0].hms_button.x = image[0].overlay_button[3].x + image[0].overlay_button[3].dx + PAD1; 93 image[0].hms_button.y = image[0].overlay_button[0].y; 94 95 image[0].PS_button.x = image[0].text_x; 96 image[0].PS_button.y = image[0].overlay_button[0].y + BUTTON_HEIGHT + PAD1; 97 98 /** everything below is tied to the PS_button in y-dir + the neighbor in x-dir **/ 99 image[0].grey_button.x = image[0].PS_button.x + image[0].PS_button.dx + PAD1; 100 image[0].grey_button.y = image[0].PS_button.y; 101 102 image[0].rainbow_button.x = image[0].grey_button.x + image[0].grey_button.dx + PAD1; 103 image[0].rainbow_button.y = image[0].PS_button.y; 104 105 image[0].puns_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1; 106 image[0].puns_button.y = image[0].PS_button.y; 107 108 image[0].recenter_button.x = image[0].puns_button.x + image[0].puns_button.dx + PAD1; 109 image[0].recenter_button.y = image[0].PS_button.y; 110 break; 111 112 case 3: 113 textpad = graphic[0].font[0].ascent; 114 textdY = 6*textpad + 7*PAD1; 115 WdY = MAX (ZOOM_Y, textdY + 2*BUTTON_HEIGHT + PAD1); 116 117 if (section->graph) { 118 image[0].picture.x = graph[0].axis[0].fx; 119 image[0].picture.y = graph[0].axis[1].fy + graph[0].axis[1].dfy; 120 image[0].picture.dx = MAX(graph[0].axis[0].dfx, 1); 121 image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1); 122 } else { 123 image[0].picture.dx = dX - 2*PAD1; 124 image[0].picture.dy = dY - 5*PAD1 - WdY - COLORPAD; 125 image[0].picture.x = Xs + PAD1; 126 image[0].picture.y = Ys + 4*PAD1 + COLORPAD + WdY; 127 } 128 129 image[0].cmapbar.dx = dX - 2*PAD1; 130 image[0].cmapbar.dy = COLORPAD; 131 image[0].cmapbar.x = Xs + PAD1; 132 image[0].cmapbar.y = Ys + PAD1; 133 134 // XXX zoom should scale somewhat with the image? (with a min and a max) 135 // XXX actually, it is limited by the buttons and status region 136 image[0].zoom.dx = ZOOM_X; 137 image[0].zoom.dy = ZOOM_Y; 138 image[0].zoom.x = Xs + PAD1; 139 image[0].zoom.y = Ys + 2*PAD1 + COLORPAD; 140 141 /** everything below is tied in x-dir to the zoom box **/ 142 image[0].text_x = image[0].zoom.x + image[0].zoom.dx + PAD1; 143 image[0].text_y = image[0].zoom.y; 144 image[0].text_dx = ZOOM_X; 145 image[0].text_dy = 6*textpad + 7*PAD1; 146 147 image[0].overlay_button[0].x = image[0].text_x; 148 image[0].overlay_button[0].y = image[0].text_y + image[0].text_dy + PAD1; 149 150 image[0].overlay_button[1].x = image[0].overlay_button[0].x + image[0].overlay_button[0].dx + PAD1; 151 image[0].overlay_button[1].y = image[0].overlay_button[0].y; 152 153 image[0].overlay_button[2].x = image[0].overlay_button[1].x + image[0].overlay_button[1].dx + PAD1; 154 image[0].overlay_button[2].y = image[0].overlay_button[0].y; 155 156 image[0].overlay_button[3].x = image[0].overlay_button[2].x + image[0].overlay_button[2].dx + PAD1; 157 image[0].overlay_button[3].y = image[0].overlay_button[0].y; 158 159 image[0].hms_button.x = image[0].overlay_button[3].x + image[0].overlay_button[3].dx + PAD1; 160 image[0].hms_button.y = image[0].overlay_button[0].y; 161 162 image[0].PS_button.x = image[0].text_x; 163 image[0].PS_button.y = image[0].overlay_button[0].y + BUTTON_HEIGHT + PAD1; 164 165 /** everything below is tied to the PS_button in y-dir + the neighbor in x-dir **/ 166 image[0].grey_button.x = image[0].PS_button.x + image[0].PS_button.dx + PAD1; 167 image[0].grey_button.y = image[0].PS_button.y; 168 169 image[0].rainbow_button.x = image[0].grey_button.x + image[0].grey_button.dx + PAD1; 170 image[0].rainbow_button.y = image[0].PS_button.y; 171 172 image[0].puns_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1; 173 image[0].puns_button.y = image[0].PS_button.y; 174 175 image[0].recenter_button.x = image[0].puns_button.x + image[0].puns_button.dx + PAD1; 176 image[0].recenter_button.y = image[0].PS_button.y; 177 break; 178 179 case 2: 180 181 if (section->graph) { 182 image[0].picture.x = Xs + 2*PAD1 + ZOOM_X; 183 image[0].picture.y = graph[0].axis[1].fy + graph[0].axis[1].dfy; 184 image[0].picture.dx = dX - 3*PAD1 - ZOOM_X; 185 image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1); 186 } else { 187 image[0].picture.dx = dX - 3*PAD1 - ZOOM_X; 188 image[0].picture.dy = dY - 3*PAD1 - COLORPAD; 189 image[0].picture.x = Xs + 2*PAD1 + ZOOM_X; 190 image[0].picture.y = Ys + 2*PAD1 + COLORPAD; 191 } 192 193 image[0].cmapbar.dx = dX - 2*PAD1; 194 image[0].cmapbar.dy = COLORPAD; 195 image[0].cmapbar.x = Xs + PAD1; 196 image[0].cmapbar.y = Ys + PAD1; 197 198 // XXX zoom should scale somewhat with the image? (with a min and a max) 199 // XXX actually, it is limited by the buttons and status region 200 image[0].zoom.dx = ZOOM_X; 201 image[0].zoom.dy = ZOOM_Y; 202 image[0].zoom.x = Xs + PAD1; 203 image[0].zoom.y = image[0].picture.y; 204 205 /** everything below is tied in x-dir to the zoom box **/ 206 textpad = graphic[0].font[0].ascent; 207 image[0].text_x = image[0].zoom.x; 208 image[0].text_y = image[0].zoom.y + image[0].zoom.dy + PAD1; 209 image[0].text_dx = ZOOM_X; 210 image[0].text_dy = 6*textpad + 7*PAD1; 211 212 image[0].overlay_button[0].x = image[0].text_x; 213 image[0].overlay_button[0].y = image[0].text_y + image[0].text_dy + PAD1; 214 215 image[0].overlay_button[1].x = image[0].overlay_button[0].x + image[0].overlay_button[0].dx + PAD1; 216 image[0].overlay_button[1].y = image[0].overlay_button[0].y; 217 218 image[0].overlay_button[2].x = image[0].overlay_button[1].x + image[0].overlay_button[1].dx + PAD1; 219 image[0].overlay_button[2].y = image[0].overlay_button[0].y; 220 221 image[0].overlay_button[3].x = image[0].overlay_button[2].x + image[0].overlay_button[2].dx + PAD1; 222 image[0].overlay_button[3].y = image[0].overlay_button[0].y; 223 224 image[0].hms_button.x = image[0].overlay_button[3].x + image[0].overlay_button[3].dx + PAD1; 225 image[0].hms_button.y = image[0].overlay_button[0].y; 226 227 image[0].PS_button.x = image[0].zoom.x; 228 image[0].PS_button.y = image[0].overlay_button[0].y + BUTTON_HEIGHT + PAD1; 229 230 /** everything below is tied to the PS_button in y-dir + the neighbor in x-dir **/ 231 image[0].grey_button.x = image[0].PS_button.x + image[0].PS_button.dx + PAD1; 232 image[0].grey_button.y = image[0].PS_button.y; 233 234 image[0].rainbow_button.x = image[0].grey_button.x + image[0].grey_button.dx + PAD1; 235 image[0].rainbow_button.y = image[0].PS_button.y; 236 237 image[0].puns_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1; 238 image[0].puns_button.y = image[0].PS_button.y; 239 240 image[0].recenter_button.x = image[0].puns_button.x + image[0].puns_button.dx + PAD1; 241 image[0].recenter_button.y = image[0].PS_button.y; 242 break; 243 244 case 4: 245 246 if (section->graph) { 247 image[0].picture.x = graph[0].axis[0].fx; 248 image[0].picture.y = graph[0].axis[1].fy + graph[0].axis[1].dfy; 249 image[0].picture.dx = dX - 3*PAD1 - ZOOM_X - graph[0].axis[0].fx; 250 image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1); 251 } else { 252 image[0].picture.dx = dX - 3*PAD1 - ZOOM_X; 253 image[0].picture.dy = dY - 3*PAD1 - COLORPAD; 254 image[0].picture.x = Xs + PAD1; 255 image[0].picture.y = Ys + 2*PAD1 + COLORPAD; 256 } 257 258 image[0].cmapbar.dx = dX - 2*PAD1; 259 image[0].cmapbar.dy = COLORPAD; 260 image[0].cmapbar.x = Xs + PAD1; 261 image[0].cmapbar.y = Ys + PAD1; 262 263 // XXX zoom should scale somewhat with the image? (with a min and a max) 264 // XXX actually, it is limited by the buttons and status region 265 image[0].zoom.dx = ZOOM_X; 266 image[0].zoom.dy = ZOOM_Y; 267 image[0].zoom.x = image[0].picture.x + image[0].picture.dx + PAD1; 268 image[0].zoom.y = image[0].picture.y; 269 270 /** everything below is tied in x-dir to the zoom box **/ 271 textpad = graphic[0].font[0].ascent; 272 image[0].text_x = image[0].zoom.x; 273 image[0].text_y = image[0].zoom.y + image[0].zoom.dy + PAD1; 274 image[0].text_dx = ZOOM_X; 275 image[0].text_dy = 6*textpad + 7*PAD1; 276 277 image[0].overlay_button[0].x = image[0].text_x; 278 image[0].overlay_button[0].y = image[0].text_y + image[0].text_dy + PAD1; 279 280 image[0].overlay_button[1].x = image[0].overlay_button[0].x + image[0].overlay_button[0].dx + PAD1; 281 image[0].overlay_button[1].y = image[0].overlay_button[0].y; 282 283 image[0].overlay_button[2].x = image[0].overlay_button[1].x + image[0].overlay_button[1].dx + PAD1; 284 image[0].overlay_button[2].y = image[0].overlay_button[0].y; 285 286 image[0].overlay_button[3].x = image[0].overlay_button[2].x + image[0].overlay_button[2].dx + PAD1; 287 image[0].overlay_button[3].y = image[0].overlay_button[0].y; 288 289 image[0].hms_button.x = image[0].overlay_button[3].x + image[0].overlay_button[3].dx + PAD1; 290 image[0].hms_button.y = image[0].overlay_button[0].y; 291 292 image[0].PS_button.x = image[0].zoom.x; 293 image[0].PS_button.y = image[0].overlay_button[0].y + BUTTON_HEIGHT + PAD1; 294 295 /** everything below is tied to the PS_button in y-dir + the neighbor in x-dir **/ 296 image[0].grey_button.x = image[0].PS_button.x + image[0].PS_button.dx + PAD1; 297 image[0].grey_button.y = image[0].PS_button.y; 298 299 image[0].rainbow_button.x = image[0].grey_button.x + image[0].grey_button.dx + PAD1; 300 image[0].rainbow_button.y = image[0].PS_button.y; 301 302 image[0].puns_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1; 303 image[0].puns_button.y = image[0].PS_button.y; 304 305 image[0].recenter_button.x = image[0].puns_button.x + image[0].puns_button.dx + PAD1; 306 image[0].recenter_button.y = image[0].PS_button.y; 307 break; 308 309 default: 310 abort (); 311 break; 312 } 68 313 69 314 if (USE_XWINDOW) { -
trunk/Ohana/src/kapa2/src/SetLimits.c
r13320 r13479 1 1 # include "Ximage.h" 2 2 3 int SetLimits ( ) {3 int SetLimits (int sock) { 4 4 5 5 int i; … … 14 14 15 15 section = GetActiveSection(); 16 if (section->graph == NULL) return (TRUE); 16 if (section->graph == NULL) { 17 section->graph = InitGraph (); 18 SetSectionSizes (section); 19 } 17 20 graph = section->graph; 18 21 19 22 graph[0].axis[2].min = graph[0].axis[0].min = xmin; 20 23 graph[0].axis[2].max = graph[0].axis[0].max = xmax; … … 32 35 Refresh (1); 33 36 34 return (TRUE); 35 37 return (TRUE); 36 38 } 37 39 38 int GetLimits ( ) {40 int GetLimits (int sock) { 39 41 40 42 double dX, dY; -
trunk/Ohana/src/kapa2/src/SetNormalHints.c
r13320 r13479 17 17 18 18 // XXX : can we drop the position flag 19 sizehints[0].flags = USPosition | USSize | PMinSize; 19 // sizehints[0].flags = USPosition | USSize | PMinSize; 20 sizehints[0].flags = USSize | PMinSize; 20 21 21 22 sizehints[0].base_width = graphic->dx; -
trunk/Ohana/src/kapa2/src/SetSection.c
r13320 r13479 2 2 3 3 // set active section 4 int SetSection ( ) {4 int SetSection (int sock) { 5 5 6 6 int N; -
trunk/Ohana/src/kapa2/src/UpdatePointer.c
r13320 r13479 6 6 int textpad; 7 7 double x, y, z; 8 float *data; 8 9 char line[100]; 9 10 Section *section; … … 13 14 section = GetActiveSection(); 14 15 image = section->image; 16 if (image == NULL) return (TRUE); 17 if (!image[0].location) return (TRUE); 15 18 16 19 if (image[0].MovePointer && InPicture ((XButtonEvent *)event, &image[0].picture)) { 17 20 21 data = (float *) image[0].matrix.buffer; 18 22 Screen_to_Image (&x, &y, (double)event[0].x, (double)event[0].y, image); 19 23 20 if ((x >= 0) && (x < image[0].matrix.Naxis[0]) && (y >= 0) && (y < image[0].matrix.Naxis[1])) { 21 /* 22 X = event[0].x - image[0].picture.x; 23 Y = event[0].y - image[0].picture.y; 24 pix = MIN (MAX (X + Y*image[0].picture.dx, 0), image[0].picture.dx*image[0].picture.dy - 1); 25 z = image[0].range * image[0].picture.data[pix] / image[0].Npixels + image[0].zero; 26 */ 27 z = -1; 28 } 29 else 30 z = -1; 24 z = -1; 25 if (x < 0) goto skip; 26 if (x >= image[0].matrix.Naxis[0]) goto skip; 27 if (y < 0) goto skip; 28 if (y >= image[0].matrix.Naxis[1]) goto skip; 29 z = data[(int)(y)*image[0].matrix.Naxis[0] + (int)(x)]; 30 31 skip: 31 32 image[0].x = x; 32 33 image[0].y = y; … … 43 44 CrossHairs (graphic, image); 44 45 XFlush (graphic[0].display); 45 46 46 } 47 47 … … 54 54 XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore); 55 55 bzero (line, 100); 56 sprintf (line, "%2 5.2f", z);56 sprintf (line, "%22.3f", z); 57 57 XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 58 58 image[0].text_x + PAD1, image[0].text_y + textpad + PAD1, -
trunk/Ohana/src/kapa2/src/UpdateStatusBox.c
r13320 r13479 14 14 XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].back); 15 15 XFillRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, 16 image[0].text_x, image[0].text_y, ZOOM_X, 6*textpad+7*PAD1);16 image[0].text_x, image[0].text_y, image[0].text_dx, image[0].text_dy); 17 17 XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore); 18 18 XDrawRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, 19 image[0].text_x, image[0].text_y, ZOOM_X, 6*textpad+7*PAD1);19 image[0].text_x, image[0].text_y, image[0].text_dx, image[0].text_dy); 20 20 21 21 bzero (line, 100); … … 31 31 32 32 bzero (line, 100); 33 sprintf (line, "(%s) ", image[0]. buffer_name);33 sprintf (line, "(%s) ", image[0].name); 34 34 XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 35 35 image[0].text_x + PAD1, image[0].text_y + 6*textpad + 6*PAD1, line, 25); … … 38 38 XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].back); 39 39 XFillRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, 40 image[0].text_x + 1, image[0].text_y + 1, ZOOM_X - 2, 3*textpad+3*PAD1 +1);40 image[0].text_x+1, image[0].text_y+1, image[0].text_dx-2, image[0].text_dy-2); 41 41 XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore); 42 42 } 43 43 bzero (line, 100); 44 sprintf (line, "%2 5.3f", z);44 sprintf (line, "%22.3f", z); 45 45 XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 46 46 image[0].text_x + PAD1, image[0].text_y + textpad + PAD1, line, strlen(line)); 47 47 48 48 bzero (line, 100); 49 sprintf (line, "%1 2.1f %12.1f", x, y);49 sprintf (line, "%10.1f %10.1f", x, y); 50 50 XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 51 51 image[0].text_x + PAD1, image[0].text_y + 2*textpad + 2*PAD1, line, strlen(line)); … … 53 53 bzero (line, 100); 54 54 if (image[0].DecimalDegrees) { 55 sprintf (line, "%1 2.6f %12.6f", ra, dec);55 sprintf (line, "%10.6f %10.6f", ra, dec); 56 56 } else { 57 57 hh_hms (line, ra, dec, ':'); -
trunk/Ohana/src/kapa2/src/bDrawIt.c
r13320 r13479 22 22 section = GetSectionByNumber (i); 23 23 bDrawGraph (section->graph); 24 // bDrawImage (section-> graph);24 // bDrawImage (section->image); 25 25 } 26 26 -
trunk/Ohana/src/kapa2/src/bDrawOverlay.c
r13320 r13479 23 23 expand = fabs((double)image[0].expand); 24 24 } 25 /*26 X = 0.5*image[0].matrix.Naxis[0] - expand*((int)(0.5*image[0].picture.dx + 0.5) - 0.0) - image[0].X;27 Y = 0.5*image[0].matrix.Naxis[1] - expand*((int)(0.5*image[0].picture.dy + 0.5) - 0.0) - image[0].Y;28 X0 = (image[0].X + 1 - (int)(0.5*image[0].matrix.Naxis[0] + 0.5) - X + (int)X)/expand + image[0].picture.x + 0.5*image[0].picture.dx;29 Y0 = (image[0].Y + 1 - (int)(0.5*image[0].matrix.Naxis[1] + 0.5) - Y + (int)Y)/expand + image[0].picture.y + 0.5*image[0].picture.dy;30 */31 25 32 26 Image_to_Screen (&X0, &Y0, 0.0, 0.0, image); … … 62 56 for a BOX (x, y) is the center, (dx, dy) is the width */ 63 57 64 if (!strcasecmp (image[0].overlay[N].objects[i].type, "LINE")) { 65 bDrawLine (X, Y, (X+dX), (Y+dY)); 66 continue; 58 switch (image[0].overlay[N].objects[i].type) { 59 case KII_OVERLAY_LINE: 60 bDrawLine (X, Y, (X+dX), (Y+dY)); 61 break; 62 case KII_OVERLAY_TEXT: 63 bDrawRotText (X, Y, image[0].overlay[N].objects[i].text, 8, 0.0); 64 break; 65 case KII_OVERLAY_BOX: 66 dx = MAX (abs(dX),2) / 2; 67 dy = MAX (abs(dY),2) / 2; 68 bDrawRectOpen ((X-dx), (Y-dy), (X+dx), (Y+dy)); 69 // bDrawRectOpen ((X-dx), (Y-dy), (X), (Y)); 70 break; 71 case KII_OVERLAY_CIRCLE: 72 dx = MAX (abs(dX),2); 73 dy = MAX (abs(dY),2); 74 bDrawArc (X, Y, dx, dy, 0, 360); 75 break; 76 default: 77 fprintf (stderr, "skipping unknown object\n"); 78 break; 67 79 } 68 if (!strcasecmp (image[0].overlay[N].objects[i].type, "TEXT")) {69 bDrawRotText (X, Y, image[0].overlay[N].objects[i].text, 8, 0.0);70 continue;71 }72 if (!strcasecmp (image[0].overlay[N].objects[i].type, "BOX")) {73 dx = MAX (abs(dX),2) / 2;74 dy = MAX (abs(dY),2) / 2;75 bDrawRectOpen ((X-dx), (Y-dy), (X+dx), (Y+dy));76 // bDrawRectOpen ((X-dx), (Y-dy), (X), (Y));77 continue;78 }79 if (!strcasecmp (image[0].overlay[N].objects[i].type, "CIRCLE")) {80 dx = MAX (abs(dX),2);81 dy = MAX (abs(dY),2);82 bDrawArc (X, Y, dx, dy, 0, 360);83 continue;84 }85 fprintf (stderr, "don't know %s, skipping (PO)\n", image[0].overlay[N].objects[i].type);86 80 } 87 81 -
trunk/Ohana/src/kapa2/src/kapa.c
r13320 r13479 7 7 SetUpGraphic (&argc, argv); 8 8 9 // XXX get socket connection here?10 11 9 InitLayout (argc, argv); 12 10 EventLoop (); -
trunk/Ohana/src/kii/event/CheckPipe.c
r5700 r13479 123 123 } 124 124 125 /* is this no longer used ? 125 126 if (!strcmp (buffer, "NPIX")) { 126 127 sprintf (buffer, "NPIX: %8d", layout[0].Npixels); … … 128 129 return (TRUE); 129 130 } 131 */ 130 132 131 133 fprintf (stderr, "unknown signal %s\n", buffer); -
trunk/Ohana/src/libkapa/Makefile
r12879 r13479 29 29 $(SRC)/KiiConvert.$(ARCH).o \ 30 30 $(SRC)/KapaWindow.$(ARCH).o \ 31 $(SRC)/KapaColors.$(ARCH).o 31 $(SRC)/KapaColors.$(ARCH).o \ 32 $(SRC)/KapaOpen.$(ARCH).o 32 33 33 34 DRAW = \ -
trunk/Ohana/src/libkapa/include/kapa.h
r13326 r13479 2 2 # define KAPA_H 3 3 4 /* linux is happy with this, not solaris */ 5 # include <netinet/ip.h> 6 # include <netdb.h> 7 # include <arpa/inet.h> 8 9 # include <sys/types.h> 10 # include <sys/socket.h> 4 11 # include <X11/Xlib.h> 5 12 # include <png.h> 6 13 # include <dvo.h> 14 15 typedef struct sockaddr_in KapaSockAddress; 7 16 8 17 typedef struct { … … 11 20 int Nx; 12 21 int Ny; 13 char *file;14 char *name;15 22 } KiiImage; 16 23 17 24 typedef struct { 18 double zero; 19 double range; 20 int logflux; 21 } KiiDisplayMode; 25 float x; 26 float y; 27 float dx; 28 float dy; 29 int type; 30 } KiiOverlayBase; 22 31 23 32 typedef struct { … … 73 82 74 83 typedef struct { 84 int logflux; 85 double zero, range; 86 char name[1024]; 87 char file[1024]; 88 } KapaImageData; 89 90 typedef struct { 75 91 int dx, dy, ascent; 76 92 unsigned char *bits; … … 98 114 int KiiSendData (int device, char *data, int Nbytes); 99 115 char *KiiRecvData (int device); 116 int KiiWaitAnswer (int device, char *expect); 100 117 101 118 /* KiiOpen.c */ … … 105 122 106 123 /* KiiPicture.c */ 107 int KiiNewPicture1D (int fd, KiiImage *image, K iiDisplayMode *mode, Coords *coords);108 int KiiNewPicture2D (int fd, KiiImage *image, K iiDisplayMode *mode, Coords *coords);124 int KiiNewPicture1D (int fd, KiiImage *image, KapaImageData *data, Coords *coords); 125 int KiiNewPicture2D (int fd, KiiImage *image, KapaImageData *data, Coords *coords); 109 126 110 127 /* KiiOverlay.c */ … … 125 142 int KiiCursorOn (int fd); 126 143 int KiiCursorOff (int fd); 127 int KiiCursorRead (int fd, double *x, double *y, char *key);144 int KiiCursorRead (int fd, double *x, double *y, double *z, double *r, double *d, char *key); 128 145 129 146 /* KapaWindow.c */ … … 131 148 int KiiCenter (int fd, double x, double y, int zoom); 132 149 int KapaBox (int fd, Graphdata *graphdata); 133 int KapaClear (int fd, int ClearSection); 150 int KapaClearCurrentPlot (int fd); 151 int KapaClearPlots (int fd); 152 int KapaClearSections (int fd); 153 int KapaClearImage (int fd); 134 154 int KapaInitGraph (Graphdata *graphdata); 135 155 int KapaPrepPlot (int fd, int Npts, Graphdata *graphmode); 136 int KapaPlotVector (int fd, int Npts, float *values );156 int KapaPlotVector (int fd, int Npts, float *values, char *type); 137 157 int KapaSetFont (int fd, char *name, int size); 138 158 int KapaSendLabel (int fd, char *string, int mode); … … 142 162 int KapaSelectSection (int fd, char *name); 143 163 int KapaGetSection (int fd, char *name); 164 int KapaMoveSection (int fd, char *name, char *direction); 165 int KapaSetGraphData (int fd, Graphdata *graphmode); 166 int KapaGetGraphData (int fd, Graphdata *graphmode); 167 int KapaSetImageData (int fd, KapaImageData *graphmode); 168 int KapaGetImageData (int fd, KapaImageData *graphmode); 144 169 145 170 /* KapaColors */ … … 196 221 int bDrawRotBitmap (int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale); 197 222 223 /* Kapa Socket functions */ 224 int KapaOpen (char *kapa_exec, char *kapa_name); 225 int KapaServerInit (KapaSockAddress *Address); 226 int KapaServerWait (int InitSocket, KapaSockAddress *Address); 227 int KapaDefineValidIP (char *ipstring); 228 int KapaClientSocket (char *hostname); 229 198 230 /* define Kapa names for shared functions */ 199 # define KapaOpen(p,n) KiiOpen(p,n)231 // # define KapaOpen(p,n) KiiOpen(p,n) 200 232 # define KapaResize(fd,Nx,Ny) KiiResize(fd,Nx,Ny) 201 233 # define KapaCenter(fd,x,y,z) KiiResize(fd,x,y,z) -
trunk/Ohana/src/libkapa/src/IOfuncs.c
r13326 r13479 1 1 # include <kapa_internal.h> 2 3 /** these function expect to operate with a BLOCKing socket **/ 2 4 3 5 /* why is this not defined in stdarg.h for linux/x64? */ … … 61 63 status = read (device, buffer, 16); 62 64 buffer[16] = 0; 65 if (status != 16) fprintf (stderr, "dropped message length\n"); 63 66 64 67 /* find the message length, allocate space */ … … 71 74 message[status] = 0; 72 75 /* make the string easy to parse */ 76 77 // fprintf (stderr, "recv: %s\n", message); 73 78 74 79 /* scan the incoming message */ … … 104 109 105 110 write (device, string, length); 111 112 // fprintf (stderr, "send: %s\n", string); 113 106 114 free (string); 107 115 return (TRUE); … … 111 119 int KiiScanCommand (int device, int length, char *format, ...) { 112 120 113 int Nbytes,status;114 char * buffer, *message;121 int status; 122 char *message; 115 123 va_list argp; 116 124 … … 118 126 119 127 /* read Nbytes from the device */ 120 status = read (device, message, Nbytes); 121 if (status != Nbytes) fprintf (stderr, "Kii/Kapa comm error\n"); 122 message[status] = 0; 123 /* make the string easy to parse */ 128 status = read (device, message, length); 129 130 if (status != length) { 131 fprintf (stderr, "Kii/Kapa comm error\n"); 132 return (0); 133 } 134 message[status] = 0; // make the string easy to parse 124 135 125 136 /* scan the incoming message */ 126 137 va_start (argp, format); 127 Nbytes =vsscanf (message, format, argp);138 vsscanf (message, format, argp); 128 139 va_end (argp); 129 140 130 return ( status);141 return (1); 131 142 } 143 144 int KiiWaitAnswer (int device, char *expect) { 145 146 int Nbytes; 147 char *answer; 148 149 Nbytes = strlen (expect); 150 ALLOCATE (answer, char, Nbytes + 1); 151 152 KiiScanCommand (device, Nbytes, "%s", answer); 153 if (strcmp (answer, expect)) { 154 fprintf (stderr, "unexpected response %s, expected %s\n", answer, expect); 155 REALLOCATE (answer, char, 128); 156 Nbytes = read (device, answer, 127); 157 answer[Nbytes] = 0; 158 fprintf (stderr, "extra data in buffer: %d bytes\n", Nbytes); 159 fprintf (stderr, "garbage: %s\n", answer); 160 return (FALSE); 161 } 162 return (TRUE); 163 } -
trunk/Ohana/src/libkapa/src/KapaOpen.c
r13344 r13479 30 30 if (status == -1) { 31 31 if (errno == EADDRINUSE) { 32 close (InitSocket); 32 33 Address[0].sin_port ++; 33 34 if (Address[0].sin_port > MY_PORT + 10) exit (2); … … 74 75 } 75 76 if (!status) return (-1); 76 77 /* this is a blocking wait; use in a separate thread */78 // fcntl (InitSocket, F_SETFL, !O_NONBLOCK);79 77 80 78 if (DEBUG) fprintf (stderr, "init sock: %d, len: %d\n", InitSocket, length); … … 119 117 accepted: 120 118 if (DEBUG) fprintf (stderr, "connection accepted\n"); 121 // fcntl (BindSocket, F_SETFL, O_NONBLOCK);122 119 return (BindSocket); 123 120 } … … 194 191 if (DEBUG) fprintf (stderr, "error connecting: %d\n", errno); 195 192 if (errno == ECONNREFUSED) { 193 close (InitSocket); 196 194 Address.sin_port ++; 197 195 if (Address.sin_port > MY_PORT + 10) return (-1); … … 204 202 if (DEBUG) fprintf (stderr, "connected on port: %d\n", Address.sin_port); 205 203 if (DEBUG) fprintf (stderr, "connected\n"); 206 fcntl (InitSocket, F_SETFL, O_NONBLOCK); 204 205 // the client uses a BLOCKing socket by default 206 fcntl (InitSocket, F_SETFL, !O_NONBLOCK); 207 207 return (InitSocket); 208 208 } … … 225 225 sprintf (line, "%s &", kapa_exec); 226 226 } else { 227 sprintf (line, "%s -name %s&", kapa_exec, kapa_name);227 sprintf (line, "%s -name '%s' &", kapa_exec, kapa_name); 228 228 } 229 229 system (line); -
trunk/Ohana/src/libkapa/src/KapaWindow.c
r10923 r13479 1 1 # include <kapa_internal.h> 2 3 int KiiCenter (int fd, double x, double y, int zoom) { 4 5 KiiSendCommand (fd, 4, "CENT"); 6 KiiSendMessage (fd, "%8.3f %8.3f %8d ", x, y, zoom); 7 KiiWaitAnswer (fd, "DONE"); 8 9 return (TRUE); 10 } 2 11 3 12 int KiiResize (int fd, int Nx, int Ny) { … … 5 14 KiiSendCommand (fd, 4, "RSIZ"); 6 15 KiiSendMessage (fd, "%d %d", Nx, Ny); 7 return (TRUE); 8 } 9 10 int KiiCenter (int fd, double x, double y, int zoom) { 11 12 KiiSendCommand (fd, 4, "CENT"); 13 KiiSendMessage (fd, "%8.3f %8.3f %8d ", x, y, zoom); 16 KiiWaitAnswer (fd, "DONE"); 14 17 return (TRUE); 15 18 } … … 18 21 19 22 KiiSendCommand (fd, 4, "DBOX"); 20 21 23 KiiSendMessage (fd, "%12.6g %12.6g %12.6g %12.6g", 22 24 graphdata[0].xmin, graphdata[0].xmax, graphdata[0].ymin, graphdata[0].ymax); 23 25 24 26 KiiSendMessage (fd, "%s %s %s", graphdata[0].axis, graphdata[0].labels, graphdata[0].ticks); 25 return (TRUE); 26 } 27 28 int KapaClear (int fd, int ClearSection) { 29 30 if (ClearSection) { 31 KiiSendCommand (fd, 4, "ERAS"); 32 } else { 33 KiiSendCommand (fd, 4, "ERSS"); 34 } 27 KiiWaitAnswer (fd, "DONE"); 28 return (TRUE); 29 } 30 31 int KapaClearCurrentPlot (int fd) { 32 33 KiiSendCommand (fd, 4, "ERSC"); 34 KiiWaitAnswer (fd, "DONE"); 35 return (TRUE); 36 } 37 38 int KapaClearPlots (int fd) { 39 40 KiiSendCommand (fd, 4, "ERSP"); 41 KiiWaitAnswer (fd, "DONE"); 42 return (TRUE); 43 } 44 45 int KapaClearSections (int fd) { 46 47 KiiSendCommand (fd, 4, "ERSS"); 48 KiiWaitAnswer (fd, "DONE"); 49 return (TRUE); 50 } 51 52 int KapaClearImage (int fd) { 53 54 KiiSendCommand (fd, 4, "ERSI"); 55 KiiWaitAnswer (fd, "DONE"); 56 return (TRUE); 57 } 58 59 int KapaSetToolbox (int fd, int location) { 60 61 KiiSendCommand (fd, 4, "TOOL"); 62 KiiSendMessage (fd, "%d", location); 63 KiiWaitAnswer (fd, "DONE"); 35 64 return (TRUE); 36 65 } … … 62 91 } 63 92 64 int KapaPrepPlot (int fd, int Npts, Graphdata * graphmode) {93 int KapaPrepPlot (int fd, int Npts, Graphdata *data) { 65 94 66 95 /* tell kapa to look for the incoming image */ 67 96 KiiSendCommand (fd, 4, "PLOT"); 68 97 69 /* send Xgraphthe plot details */98 /* send kapa the plot details */ 70 99 KiiSendMessage (fd, "%8d %8d %d %d %d %d %d %f %f", 71 Npts, graphmode[0].style,72 graphmode[0].ptype, graphmode[0].ltype,73 graphmode[0].etype, graphmode[0].ebar, graphmode[0].color,74 graphmode[0].lweight, graphmode[0].size);100 Npts, data[0].style, 101 data[0].ptype, data[0].ltype, 102 data[0].etype, data[0].ebar, data[0].color, 103 data[0].lweight, data[0].size); 75 104 KiiSendMessage (fd, "%g %g %g %g", 76 graphmode[0].xmin, graphmode[0].xmax, 77 graphmode[0].ymin, graphmode[0].ymax); 78 return (TRUE); 79 } 80 81 int KapaPlotVector (int fd, int Npts, float *values) { 105 data[0].xmin, data[0].xmax, 106 data[0].ymin, data[0].ymax); 107 KiiWaitAnswer (fd, "DONE"); 108 return (TRUE); 109 } 110 111 int KapaSetGraphData (int fd, Graphdata *data) { 112 113 /* tell kapa to look for the incoming image */ 114 KiiSendCommand (fd, 4, "SSTY"); 115 116 /* send kapa the plot details */ 117 KiiSendMessage (fd, "%8d %d %d %d %d %d %f %f", 118 data[0].style, 119 data[0].ptype, data[0].ltype, 120 data[0].etype, data[0].ebar, data[0].color, 121 data[0].lweight, data[0].size); 122 123 KiiSendMessage (fd, "%g %g %g %g", 124 data[0].xmin, data[0].xmax, 125 data[0].ymin, data[0].ymax); 126 127 KiiSendMessage (fd, "%g %g %g %g", 128 data[0].coords.pc1_1, data[0].coords.pc2_2, 129 data[0].coords.pc1_2, data[0].coords.pc2_1); 130 131 KiiSendMessage (fd, "%d %d %s", 132 data[0].flipeast, data[0].flipnorth, 133 data[0].coords.ctype); 134 135 KiiSendMessage (fd, "%g %g %g %g %g %g", 136 data[0].coords.crval1, 137 data[0].coords.crval2, 138 data[0].coords.crpix1, 139 data[0].coords.crpix2, 140 data[0].coords.cdelt1, 141 data[0].coords.cdelt2); 142 143 KiiWaitAnswer (fd, "DONE"); 144 return (TRUE); 145 } 146 147 int KapaGetGraphData (int fd, Graphdata *data) { 148 149 /* tell kapa to look for the incoming image */ 150 KiiSendCommand (fd, 4, "GSTY"); 151 152 /* send kapa the plot details */ 153 KiiScanMessage (fd, "%d %d %d %d %d %d %lf %lf", 154 &data[0].style, 155 &data[0].ptype, &data[0].ltype, 156 &data[0].etype, &data[0].ebar, &data[0].color, 157 &data[0].lweight, &data[0].size); 158 159 KiiScanMessage (fd, "%lf %lf %lf %lf", 160 &data[0].xmin, &data[0].xmax, 161 &data[0].ymin, &data[0].ymax); 162 163 KiiScanMessage (fd, "%f %f %f %f", 164 &data[0].coords.pc1_1, &data[0].coords.pc2_2, 165 &data[0].coords.pc1_2, &data[0].coords.pc2_1); 166 167 KiiScanMessage (fd, "%d %d %s", 168 &data[0].flipeast, &data[0].flipnorth, 169 data[0].coords.ctype); 170 171 KiiScanMessage (fd, "%lf %lf %f %f %f %f", 172 &data[0].coords.crval1, 173 &data[0].coords.crval2, 174 &data[0].coords.crpix1, 175 &data[0].coords.crpix2, 176 &data[0].coords.cdelt1, 177 &data[0].coords.cdelt2); 178 179 KiiWaitAnswer (fd, "DONE"); 180 return (TRUE); 181 } 182 183 int KapaSetImageData (int fd, KapaImageData *data) { 184 185 /* tell kapa to look for the incoming image */ 186 KiiSendCommand (fd, 4, "SIMD"); 187 188 /* send kapa the plot details */ 189 KiiSendMessage (fd, "%g %g %s %s", 190 data[0].zero, data[0].range, data[0].name, data[0].file); 191 192 KiiWaitAnswer (fd, "DONE"); 193 return (TRUE); 194 } 195 196 int KapaGetImageData (int fd, KapaImageData *data) { 197 198 /* tell kapa to look for the incoming image */ 199 KiiSendCommand (fd, 4, "GIMD"); 200 201 KiiScanMessage (fd, "%lf %lf %s %s", 202 &data[0].zero, &data[0].range, data[0].name, data[0].file); 203 204 KiiWaitAnswer (fd, "DONE"); 205 return (TRUE); 206 } 207 208 int KapaPlotVector (int fd, int Npts, float *values, char *type) { 82 209 83 210 int Nbytes; 211 int swap; 212 213 # ifdef BYTE_SWAP 214 swap = 1; 215 # else 216 swap = 0; 217 # endif 84 218 85 219 Nbytes = Npts * sizeof (float); 220 221 if (!strcmp(type, "x")) goto valid; 222 if (!strcmp(type, "y")) goto valid; 223 if (!strcmp(type, "z")) goto valid; 224 if (!strcmp(type, "dym")) goto valid; 225 if (!strcmp(type, "dyp")) goto valid; 226 if (!strcmp(type, "dxm")) goto valid; 227 if (!strcmp(type, "dxp")) goto valid; 228 return (FALSE); 229 230 valid: 231 KiiSendCommand (fd, 4, "PLOB"); 232 KiiSendMessage (fd, "%s %d %d %d", type, Npts, Nbytes, swap); 233 86 234 write (fd, values, Nbytes); 235 KiiWaitAnswer (fd, "DONE"); 87 236 return (TRUE); 88 237 } … … 93 242 KiiSendCommand (fd, 16, "%s", name); 94 243 KiiSendCommand (fd, 16, "%d", size); 244 KiiWaitAnswer (fd, "DONE"); 95 245 return (TRUE); 96 246 } 97 247 98 248 int KapaSendLabel (int fd, char *string, int mode) { 99 249 100 250 KiiSendCommand (fd, 4, "LABL"); 101 251 KiiSendMessage (fd, "%6d", mode); 102 252 KiiSendData (fd, string, strlen(string)); 253 KiiWaitAnswer (fd, "DONE"); 103 254 return (TRUE); 104 255 } … … 109 260 KiiSendMessage (fd, "%f %f %f", x, y, angle); 110 261 KiiSendData (fd, string, strlen(string)); 111 return (TRUE); 112 } 113 114 int KapaSetLimits (int fd, Graphdata *graphmode) { 262 KiiWaitAnswer (fd, "DONE"); 263 return (TRUE); 264 } 265 266 int KapaSetLimits (int fd, Graphdata *data) { 115 267 116 268 KiiSendCommand (fd, 4, "SLIM"); 117 KiiSendMessage (fd, "%g %g %g %g ", graphmode[0].xmin, graphmode[0].xmax, graphmode[0].ymin, graphmode[0].ymax); 269 KiiSendMessage (fd, "%g %g %g %g ", data[0].xmin, data[0].xmax, data[0].ymin, data[0].ymax); 270 KiiWaitAnswer (fd, "DONE"); 271 return (TRUE); 272 } 273 274 // for now, this just gets the dimensions 275 int KapaGetLimits (int fd, float *dx, float *dy) { 276 277 KiiSendCommand (fd, 4, "GLIM"); 278 KiiScanMessage (fd, "%f %f", dx, dy); 279 KiiWaitAnswer (fd, "DONE"); 118 280 return (TRUE); 119 281 } … … 128 290 section[0].dx, 129 291 section[0].dy); 292 KiiWaitAnswer (fd, "DONE"); 293 return (TRUE); 294 } 295 296 int KapaMoveSection (int fd, char *name, char *direction) { 297 298 if (!strcasecmp(direction, "up")) goto valid; 299 if (!strcasecmp(direction, "down")) goto valid; 300 if (!strcasecmp(direction, "top")) goto valid; 301 if (!strcasecmp(direction, "bottom")) goto valid; 302 303 fprintf (stderr, "unexpected direction %s\n", direction); 304 return (FALSE); 305 306 valid: 307 KiiSendCommand (fd, 4, "MSEC"); 308 KiiSendMessage (fd, "%s %s", name, direction); 309 KiiWaitAnswer (fd, "DONE"); 130 310 return (TRUE); 131 311 } … … 135 315 KiiSendCommand (fd, 4, "SSEC"); 136 316 KiiSendMessage (fd, "%s", name); 317 KiiWaitAnswer (fd, "DONE"); 137 318 return (TRUE); 138 319 } … … 142 323 KiiSendCommand (fd, 4, "LSEC"); 143 324 KiiSendMessage (fd, "%s", name); 144 return (TRUE); 145 } 325 KiiWaitAnswer (fd, "DONE"); 326 return (TRUE); 327 } -
trunk/Ohana/src/libkapa/src/KiiConvert.c
r12892 r13479 3 3 int KiiJPEG (int fd, const char *filename) { 4 4 5 char buffer[20];6 7 5 KiiSendCommand (fd, 4, "JPEG"); 8 6 KiiSendMessage (fd, "%s", filename); 9 10 /* block for the response, which says the operation completed */ 11 read (fd, buffer, 4); 7 KiiWaitAnswer (fd, "DONE"); 12 8 return (TRUE); 13 9 } … … 15 11 int KapaPNG (int fd, const char *filename) { 16 12 17 char buffer[20];18 19 13 KiiSendCommand (fd, 4, "PNGF"); 20 14 KiiSendMessage (fd, "%s", filename); 21 22 /* block for the response, which says the operation completed */ 23 read (fd, buffer, 4); 15 KiiWaitAnswer (fd, "DONE"); 24 16 return (TRUE); 25 17 } … … 27 19 int KapaPPM (int fd, const char *filename) { 28 20 29 char buffer[20];30 31 21 KiiSendCommand (fd, 4, "PPMF"); 32 22 KiiSendMessage (fd, "%s", filename); 33 34 /* block for the response, which says the operation completed */ 35 read (fd, buffer, 4); 23 KiiWaitAnswer (fd, "DONE"); 36 24 return (TRUE); 37 25 } … … 39 27 int KiiPS (int fd, const char *filename, int scaleMode, int pageMode, char *pagename) { 40 28 41 char buffer[20];42 43 /* the default operation */44 29 KiiSendCommand (fd, 4, "PSIT"); 45 46 30 KiiSendMessage (fd, "%s %s %d %d", filename, pagename, scaleMode, pageMode); 47 48 /* block for the response, which says the operation completed */ 49 read (fd, buffer, 4); 31 KiiWaitAnswer (fd, "DONE"); 50 32 return (TRUE); 51 33 } -
trunk/Ohana/src/libkapa/src/KiiCursor.c
r5848 r13479 2 2 3 3 int KiiCursorOn (int fd) { 4 write (fd, "CURS", 4); /* ask Source to look for the keystrokes */ 4 5 KiiSendCommand (fd, 4, "CURS"); 6 KiiWaitAnswer (fd, "DONE"); 5 7 return (TRUE); 6 8 } 7 9 8 10 int KiiCursorOff (int fd) { 9 write (fd, "NCUR", 4); /* ask Source to look for the keystrokes */ 11 12 KiiSendCommand (fd, 4, "NCUR"); 13 KiiWaitAnswer (fd, "DONE"); 10 14 return (TRUE); 11 15 } 12 16 13 int KiiCursorRead (int fd, double *x, double *y, char *key) {17 int KiiCursorRead (int fd, double *x, double *y, double *z, double *r, double *d, char *key) { 14 18 15 char buffer[40]; 16 17 bzero (buffer, 40); 18 read (fd, buffer, 40); 19 buffer[39] = 0; 20 21 sscanf (buffer, "%s %lf %lf", key, x, y); 19 KiiScanMessage (fd, "%s %lf %lf %lf %lf %lf", key, x, y, z, r, d); 22 20 if (ispunct(key[0])) strcpy (key, "_"); 23 24 21 return (TRUE); 25 22 } -
trunk/Ohana/src/libkapa/src/KiiOverlay.c
r13327 r13479 50 50 } 51 51 52 int KiiLoadOverlay (int fd, KiiOverlay *overlay, int Noverlay, char *overname) {52 int KiiLoadOverlayOld (int fd, KiiOverlay *overlay, int Noverlay, char *overname) { 53 53 54 54 int i, n, Nline; … … 84 84 85 85 free (buffer); 86 KiiWaitAnswer (fd, "DONE"); 86 87 87 88 /* this is very inefficient: 128 bytes per object vs 17 as binary, plus the 88 89 conversions back and forth 89 90 */ 91 92 return (TRUE); 93 } 94 95 int KiiLoadOverlay (int fd, KiiOverlay *overlay, int Noverlay, char *overname) { 96 97 int i, overnum, Ntextdata, NTEXTDATA, Ntext, Nchar; 98 char *textdata; 99 KiiOverlayBase *buffer; 100 101 Ntext = 0; 102 KiiSelectOverlay (overname, &overnum); 103 104 Ntextdata = 0; 105 NTEXTDATA = 1024; 106 ALLOCATE (textdata, char, 1024); 107 108 // we send the position information as a binary block 109 ALLOCATE (buffer, KiiOverlayBase, Noverlay); 110 for (i = 0; i < Noverlay; i++) { 111 buffer[i].x = overlay[i].x; 112 buffer[i].y = overlay[i].y; 113 buffer[i].dx = overlay[i].dx; 114 buffer[i].dy = overlay[i].dy; 115 buffer[i].type = overlay[i].type; 116 if (buffer[i].type == KII_OVERLAY_TEXT) { 117 Ntext ++; 118 Nchar = strlen(overlay[i].text) + 1; 119 if (Ntextdata + Nchar >= NTEXTDATA) { 120 NTEXTDATA += 1024; 121 REALLOCATE (textdata, char, NTEXTDATA); 122 } 123 sprintf (&textdata[Ntextdata], "%s\n", overlay[i].text); 124 Ntextdata += Nchar; 125 } 126 } 127 128 KiiSendCommand (fd, 4, "LOAD"); 129 KiiSendMessage (fd, "%d %d %d %d", overnum, Noverlay, Ntext, Ntextdata); 130 131 // we could break this into segments if we want to trap an interrupt, but why bother? 132 Nchar = write (fd, buffer, Noverlay*sizeof(KiiOverlayBase)); 133 fprintf (stderr, "sent %d of %d bytes\n", Nchar, Noverlay*sizeof(KiiOverlayBase)); 134 KiiWaitAnswer (fd, "DONE"); 135 136 write (fd, textdata, Ntextdata); 137 KiiWaitAnswer (fd, "DONE"); 138 139 free (buffer); 140 free (textdata); 141 142 KiiWaitAnswer (fd, "DONE"); 90 143 return (TRUE); 91 144 } … … 97 150 KiiSelectOverlay (overname, &n); 98 151 99 KiiSendCommand (fd, 4, "ER AS");152 KiiSendCommand (fd, 4, "ERSO"); 100 153 KiiSendCommand (fd, 16, "OVERLAY %7d ", n); 101 154 KiiWaitAnswer (fd, "DONE"); 102 155 return (TRUE); 103 156 } … … 116 169 117 170 KiiSendMessage (fd, "FILE: %d %s", n, file); 171 KiiWaitAnswer (fd, "DONE"); 118 172 return (TRUE); 119 173 } -
trunk/Ohana/src/libkapa/src/KiiPicture.c
r5852 r13479 1 1 # include <kapa_internal.h> 2 2 3 int KiiNewPicture1D (int fd, KiiImage *image, K iiDisplayMode *mode, Coords *coords) {3 int KiiNewPicture1D (int fd, KiiImage *image, KapaImageData *data, Coords *coords) { 4 4 5 5 int i; 6 6 int Npix, Ncolors, NNcolors, size; 7 7 float *in, min, max; 8 char *out, *outbuffer , *root;8 char *out, *outbuffer; 9 9 double a1, a2; 10 10 11 11 Npix = image[0].Nx*image[0].Ny; 12 12 13 KiiSendCommand (fd, 4, "READ"); /* tell Ximage to look for the incoming image */ 13 KiiSendCommand (fd, 4, "READ"); /* tell kapa to look for the incoming image */ 14 KiiScanMessage (fd, "%d", &Ncolors); 15 16 in = image[0].data1d; 17 18 /* these are for a future upgrade */ 19 min = max = 0.0; 20 size = Npix*sizeof(float); 21 22 /* done with the conversion, now send kapa the converted picture */ 23 KiiSendMessage (fd, "%8d %8d", image[0].Nx, image[0].Ny); 24 KiiSendMessage (fd, "-32 1 0.0 1.0"); 25 KiiSendMessage (fd, "%f %f %s %s", data[0].zero, data[0].range, data[0].name, data[0].file); 26 KiiSendMessage (fd, "%f %f %d ", min, max, size); 27 KiiSendMessage (fd, "%f %f %g %g %g ", coords[0].crval1, coords[0].crpix1, coords[0].cdelt1, coords[0].pc1_1, coords[0].pc1_2); 28 KiiSendMessage (fd, "%f %f %g %g %g ", coords[0].crval2, coords[0].crpix2, coords[0].cdelt2, coords[0].pc2_1, coords[0].pc2_2); 29 KiiSendMessage (fd, "%s", coords[0].ctype); 30 31 /* send the image data */ 32 write (fd, image[0].data1d, size); 33 34 KiiWaitAnswer (fd, "DONE"); 35 return (TRUE); 36 } 37 38 int KiiNewPicture1D_8bit (int fd, KiiImage *image, KapaImageData *data, Coords *coords) { 39 40 int i; 41 int Npix, Ncolors, NNcolors, size; 42 float *in, min, max; 43 char *out, *outbuffer; 44 double a1, a2; 45 46 Npix = image[0].Nx*image[0].Ny; 47 48 KiiSendCommand (fd, 4, "READ"); /* tell kapa to look for the incoming image */ 14 49 KiiScanMessage (fd, "%d", &Ncolors); 15 50 … … 22 57 /* define color table, */ 23 58 NNcolors = Ncolors - 1; 24 if ( mode[0].logflux) {25 mode[0].range = MAX (2, mode[0].range);26 a1 = Ncolors / log10 ( mode[0].range);27 a2 = mode[0].zero;59 if (data[0].logflux) { 60 data[0].range = MAX (2, data[0].range); 61 a1 = Ncolors / log10 (data[0].range); 62 a2 = data[0].zero; 28 63 for (i = 0; i < Npix; i++, in++, out++) { 29 64 *out = (char) MIN (a1 * log10 (MAX (*in - a2, 1.0)), NNcolors); 30 65 } 31 66 } else { 32 a1 = Ncolors / mode[0].range;33 a2 = Ncolors * mode[0].zero / mode[0].range;67 a1 = Ncolors / data[0].range; 68 a2 = Ncolors * data[0].zero / data[0].range; 34 69 for (i = 0; i < Npix; i++, in++, out++) { 35 70 *out = (char) MIN (MAX (a1 * *in - a2, 0), NNcolors); … … 41 76 size = Npix*sizeof(char); 42 77 43 /* done with the conversion, now send Ximagethe converted picture */78 /* done with the conversion, now send kapa the converted picture */ 44 79 KiiSendMessage (fd, "%8d %8d", image[0].Nx, image[0].Ny); 45 80 KiiSendMessage (fd, "8 1 0.0 1.0"); 46 KiiSendMessage (fd, "%f %f ", mode[0].zero, mode[0].range);81 KiiSendMessage (fd, "%f %f %s %s", data[0].zero, data[0].range, data[0].name, data[0].file); 47 82 KiiSendMessage (fd, "%f %f %d ", min, max, size); 48 83 KiiSendMessage (fd, "%f %f %g %g %g ", coords[0].crval1, coords[0].crpix1, coords[0].cdelt1, coords[0].pc1_1, coords[0].pc1_2); 49 84 KiiSendMessage (fd, "%f %f %g %g %g ", coords[0].crval2, coords[0].crpix2, coords[0].cdelt2, coords[0].pc2_1, coords[0].pc2_2); 50 51 /* send the filename */ 52 root = filerootname (image[0].file); 53 KiiSendMessage (fd, "%s %s %s ", coords[0].ctype, root, image[0].name); 54 free (root); 85 KiiSendMessage (fd, "%s", coords[0].ctype); 55 86 56 87 /* send the image data */ … … 58 89 free (outbuffer); 59 90 91 KiiWaitAnswer (fd, "DONE"); 60 92 return (TRUE); 61 93 } 62 94 63 int KiiNewPicture2D (int fd, KiiImage *image, K iiDisplayMode *mode, Coords *coords) {95 int KiiNewPicture2D (int fd, KiiImage *image, KapaImageData *data, Coords *coords) { 64 96 65 97 int i, j; 66 98 int Npix, Ncolors, NNcolors, size; 67 99 float *in, min, max; 68 char *out, *outbuffer, *root; 69 char buffer[1024]; 100 char *out, *outbuffer; 70 101 double a1, a2; 71 102 72 103 Npix = image[0].Nx*image[0].Ny; 73 104 74 KiiSendCommand (fd, 4, "READ"); /* tell Ximage to look for the incoming image */ 75 76 /* convert from (float *) to 1 byte chars -- depends on how many colors Kii owns */ 77 /* use this response as a handshake test */ 78 read (fd, buffer, 16); 79 sscanf (buffer, "%*s %d", &Ncolors); 105 KiiSendCommand (fd, 4, "READ"); /* tell kapa to look for the incoming image */ 106 KiiScanMessage (fd, "%d", &Ncolors); 80 107 81 108 ALLOCATE (outbuffer, char, Npix); … … 86 113 /* define color table, */ 87 114 NNcolors = Ncolors - 1; 88 if ( mode[0].logflux) {89 mode[0].range = MAX (2, mode[0].range);90 a1 = Ncolors / log10 ( mode[0].range);91 a2 = mode[0].zero;115 if (data[0].logflux) { 116 data[0].range = MAX (2, data[0].range); 117 a1 = Ncolors / log10 (data[0].range); 118 a2 = data[0].zero; 92 119 for (j = 0; j < image[0].Ny; j++) { 93 120 in = image[0].data2d[j]; … … 97 124 } 98 125 } else { 99 a1 = Ncolors / mode[0].range;100 a2 = Ncolors * mode[0].zero / mode[0].range;126 a1 = Ncolors / data[0].range; 127 a2 = Ncolors * data[0].zero / data[0].range; 101 128 for (j = 0; j < image[0].Ny; j++) { 102 129 in = image[0].data2d[j]; … … 111 138 size = Npix*sizeof(char); 112 139 113 /* done with the conversion, now send Ximage the converted picture */ 114 KiiSendMessage (fd, "%8d %8d 8 1 %f %f", image[0].Nx, image[0].Ny, 0.0, 1.0); 115 KiiSendMessage (fd, "%f %f %f %f %d ", mode[0].zero, mode[0].range, min, max, size); 140 /* done with the conversion, now send kapa the converted picture */ 141 KiiSendMessage (fd, "%8d %8d", image[0].Nx, image[0].Ny); 142 KiiSendMessage (fd, "8 1 0.0 1.0"); 143 KiiSendMessage (fd, "%f %f %s %s", data[0].zero, data[0].range, data[0].name, data[0].file); 144 KiiSendMessage (fd, "%f %f %d ", min, max, size); 116 145 KiiSendMessage (fd, "%f %f %g %g %g ", coords[0].crval1, coords[0].crpix1, coords[0].cdelt1, coords[0].pc1_1, coords[0].pc1_2); 117 146 KiiSendMessage (fd, "%f %f %g %g %g ", coords[0].crval2, coords[0].crpix2, coords[0].cdelt2, coords[0].pc2_1, coords[0].pc2_2); 118 119 /* send the filename */ 120 root = filerootname (image[0].file); 121 KiiSendMessage (fd, "%s %s %s ", coords[0].ctype, root, image[0].name); 147 KiiSendMessage (fd, "%s", coords[0].ctype); 122 148 123 149 /* send the image data */ … … 125 151 free (outbuffer); 126 152 153 KiiWaitAnswer (fd, "DONE"); 127 154 return (TRUE); 128 155 } -
trunk/Ohana/src/opihi/cmd.astro/cgrid.c
r7917 r13479 14 14 double x, y; 15 15 Vector Xvec, Yvec; 16 int NorthPole, SouthPole, N, OnPic, LOnPic, status, NELEMENTS, First;16 int kapa, NorthPole, SouthPole, N, OnPic, LOnPic, status, NELEMENTS, First; 17 17 Graphdata graphmode; 18 18 19 if (!style_args (&graphmode, &argc, argv, 0)) return FALSE;19 if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE; 20 20 21 21 if (argc != 1) { … … 23 23 return (FALSE); 24 24 } 25 SetGraph (graphmode);26 25 27 26 /* are we plotting one of the poles? */ … … 392 391 graphmode.ptype = 100; /* connect a pair */ 393 392 graphmode.etype = 0; 394 PrepPlotting (N, &graphmode); 395 PlotVector (N, Xvec.elements); 396 PlotVector (N, Yvec.elements); 393 PlotVectorPair (kapa, N, Xvec.elements, Yvec.elements, &graphmode); 397 394 398 395 free (Xvec.elements); -
trunk/Ohana/src/opihi/cmd.astro/cplot.c
r7917 r13479 3 3 int cplot (int argc, char **argv) { 4 4 5 int i, Npts, status;5 int i, kapa, Npts, status; 6 6 float *x, *y, *r, *d, Rmin, Rmax; 7 7 Vector Xvec, Yvec, *xvec, *yvec; 8 8 Graphdata graphmode; 9 9 10 if (!style_args (&graphmode, &argc, argv, 0)) return FALSE;10 if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE; 11 11 12 12 if (argc != 3) { … … 14 14 return (FALSE); 15 15 } 16 SetGraph (graphmode);17 16 18 17 Rmin = graphmode.coords.crval1 - 182.0; … … 67 66 68 67 graphmode.etype = 0; 69 PrepPlotting (Npts, &graphmode); 70 PlotVector (Npts, Xvec.elements); 71 PlotVector (Npts, Yvec.elements); 68 PlotVectorPair (kapa, Npts, Xvec.elements, Yvec.elements, &graphmode); 72 69 73 70 free (Xvec.elements); -
trunk/Ohana/src/opihi/cmd.astro/czplot.c
r7917 r13479 3 3 int czplot (int argc, char **argv) { 4 4 5 int i, Npts;5 int i, kapa, Npts; 6 6 double min, range, Rmin, Rmax; 7 7 float *in, *out, *r, *d, *x, *y; … … 9 9 Graphdata graphmode; 10 10 11 if (!style_args (&graphmode, &argc, argv, 0)) return FALSE;11 if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE; 12 12 13 13 if (argc != 6) { … … 15 15 return (FALSE); 16 16 } 17 SetGraph (graphmode);18 17 19 18 min = atof(argv[4]); … … 59 58 graphmode.etype = 0; 60 59 Npts = Xvec.Nelements; 61 PrepPlotting (Npts, &graphmode); 62 63 PlotVector (Npts, Xvec.elements); 64 PlotVector (Npts, Yvec.elements); 65 PlotVector (Npts, Zvec.elements); 60 PlotVectorTriplet (kapa, Npts, Xvec.elements, Yvec.elements, Zvec.elements, &graphmode); 66 61 67 62 free (Xvec.elements); -
trunk/Ohana/src/opihi/cmd.astro/gauss.c
r7917 r13479 5 5 char key[20]; 6 6 int i, N, Npix, Nborder, Nspot; 7 double X, Y, Z, max; 8 int Ximage, Nimage; 7 double X, Y, Z, ZP, RA, DEC, max; 8 int kapa; 9 char *name; 9 10 Buffer *buf; 11 KapaImageData data; 10 12 11 Nimage = -1;13 name = NULL; 12 14 if ((N = get_argument (argc, argv, "-n"))) { 13 15 remove_argument (N, &argc, argv); 14 Nimage = atof(argv[N]);16 name = strcreate (argv[N]); 15 17 remove_argument (N, &argc, argv); 16 18 } 17 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 19 if (!GetImageData (&data, &kapa, name)) return (FALSE); 20 FREE (name); 18 21 19 22 Nborder = 3; … … 37 40 } 38 41 39 if ( Ximage< 1) {42 if (kapa < 1) { 40 43 gprint (GP_ERR, "no active TV\n"); 41 44 return (FALSE); … … 48 51 } 49 52 50 if ((buf = SelectBuffer ( GetImageName(), OLDBUFFER, TRUE)) == NULL) return (FALSE);53 if ((buf = SelectBuffer (data.name, OLDBUFFER, TRUE)) == NULL) return (FALSE); 51 54 52 KiiCursorOn ( Ximage);55 KiiCursorOn (kapa); 53 56 54 57 for (i = 0; (i < Nspot) || (Nspot == 0); i++) { 55 KiiCursorRead ( Ximage, &X, &Y, key);58 KiiCursorRead (kapa, &X, &Y, &ZP, &RA, &DEC, key); 56 59 if (!strcasecmp (key, "Q")) break; 57 60 Z = get_aperture_stats (&buf[0].matrix, (int)(X+0.5), (int)(Y+0.5), Npix, Nborder, max); 58 61 } 59 KiiCursorOff ( Ximage);62 KiiCursorOff (kapa); 60 63 return (TRUE); 61 64 } -
trunk/Ohana/src/opihi/cmd.astro/objload.c
r7917 r13479 7 7 int i, N, Objtype, type, Nline, status; 8 8 FILE *f; 9 char *buffer, *line ;10 int Ximage, Nimage, Noverlay, NOVERLAY;9 char *buffer, *line, *name; 10 int kapa, Noverlay, NOVERLAY; 11 11 KiiOverlay *overlay; 12 12 13 Nimage = -1;13 name = NULL; 14 14 if ((N = get_argument (argc, argv, "-n"))) { 15 15 remove_argument (N, &argc, argv); 16 Nimage = atof(argv[N]);16 name = strcreate (argv[N]); 17 17 remove_argument (N, &argc, argv); 18 18 } 19 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 19 if (!GetImage (NULL, &kapa, name)) return (FALSE); 20 FREE (name); 20 21 21 22 Objtype = 0; … … 63 64 free (buffer); 64 65 65 KiiLoadOverlay ( Ximage, overlay, Noverlay, argv[1]);66 KiiLoadOverlay (kapa, overlay, Noverlay, argv[1]); 66 67 67 68 free (overlay); -
trunk/Ohana/src/opihi/cmd.astro/outline.c
r7917 r13479 145 145 /* code to draw dots on Ximage */ 146 146 { 147 int Nimage, Ximage;147 int kapa; 148 148 float xp, yp, x, y; 149 149 float dx, dy, theta, t, dt; … … 151 151 KiiOverlay *overlay; 152 152 153 Nimage = -1; 154 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 153 if (!GetImage (NULL, &kapa, NULL)) return (FALSE); 155 154 156 155 Noverlay = 0; … … 179 178 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 1000); 180 179 } 181 KiiLoadOverlay ( Ximage, overlay, Noverlay, "red");180 KiiLoadOverlay (kapa, overlay, Noverlay, "red"); 182 181 free (overlay); 183 182 } -
trunk/Ohana/src/opihi/cmd.astro/outline2.c
r7917 r13479 303 303 int plot_outline () { 304 304 305 int Nimage, Ximage;305 int kapa; 306 306 float xp, yp, x, y; 307 307 float dx, dy, theta, t, dt; … … 309 309 KiiOverlay *overlay; 310 310 311 Nimage = -1; 312 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 311 if (!GetImage (NULL, &kapa, NULL)) return (FALSE); 313 312 314 313 Noverlay = 0; … … 337 336 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 1000); 338 337 } 339 KiiLoadOverlay ( Ximage, overlay, Noverlay, "red");338 KiiLoadOverlay (kapa, overlay, Noverlay, "red"); 340 339 free (overlay); 341 340 return (TRUE); -
trunk/Ohana/src/opihi/cmd.astro/region.c
r10928 r13479 5 5 char string[256]; 6 6 double Ra, Dec, Radius; 7 double dx, dy; 8 int N, Ngraph, Xgraph; 7 float dx, dy; 8 int N, kapa; 9 char *name; 9 10 Graphdata graphmode; 10 11 11 Ngraph = 0; 12 if (!GetGraph (&graphmode, &Xgraph, &Ngraph)) return (FALSE); 12 name = NULL; 13 if ((N = get_argument (argc, argv, "-n"))) { 14 remove_argument (N, &argc, argv); 15 name = strcreate (argv[N]); 16 remove_argument (N, &argc, argv); 17 } 18 if (!GetGraph (&graphmode, &kapa, name)) return (FALSE); 19 FREE (name); 13 20 14 21 if ((N = get_argument (argc, argv, "-ew"))) { … … 60 67 61 68 /* ask kapa for coordinate limits, so get the right aspect ratio */ 62 KiiSendCommand (Xgraph, 4, "LIMS"); 63 KiiScanMessage (Xgraph, "%lf %lf", &dx, &dy); 69 KapaGetLimits (kapa, &dx, &dy); 64 70 dx = fabs (dx); 65 71 dy = fabs (dy); … … 101 107 graphmode.coords.cdelt1 = graphmode.coords.cdelt2 = 1.0; 102 108 103 KapaClear (Xgraph, TRUE);104 KapaSetLimits ( Xgraph, &graphmode);109 KapaClearSections (kapa); 110 KapaSetLimits (kapa, &graphmode); 105 111 106 112 /* drop this? */ 107 113 sprintf (string, "%8.4f %8.4f (%f)", Ra, Dec, Radius); 108 KapaSendLabel ( Xgraph, string, 2);114 KapaSendLabel (kapa, string, 2); 109 115 110 SetGraph (graphmode); 116 // XXX is this the right thing to be doing? 117 SetGraph (&graphmode); 111 118 return (TRUE); 112 119 } -
trunk/Ohana/src/opihi/cmd.data/box.c
r7917 r13479 3 3 int box (int argc, char **argv) { 4 4 5 int i, N, Ngraph, Xgraph; 5 int i, N, kapa; 6 char *name; 6 7 Graphdata graphmode; 7 8 8 Ngraph = -1;9 name = NULL; 9 10 if ((N = get_argument (argc, argv, "-n"))) { 10 11 remove_argument (N, &argc, argv); 11 Ngraph = atof(argv[N]);12 name = strcreate (argv[N]); 12 13 remove_argument (N, &argc, argv); 13 14 } 14 if (!GetGraph (&graphmode, &Xgraph, &Ngraph)) return (FALSE); 15 if (!GetGraph (&graphmode, &kapa, name)) return (FALSE); 16 FREE (name); 15 17 16 18 strcpy (graphmode.ticks, "2222"); … … 49 51 if (argc != 1) goto usage; 50 52 51 KapaBox ( Xgraph, &graphmode);53 KapaBox (kapa, &graphmode); 52 54 return (TRUE); 53 55 -
trunk/Ohana/src/opihi/cmd.data/center.c
r7917 r13479 5 5 double x, y; 6 6 int zoom; 7 int Ximage, Nimage, N; 7 int kapa, N; 8 char *name; 8 9 9 Nimage = -1;10 name = NULL; 10 11 if ((N = get_argument (argc, argv, "-n"))) { 11 12 remove_argument (N, &argc, argv); 12 Nimage = atof(argv[N]);13 name = strcreate (argv[N]); 13 14 remove_argument (N, &argc, argv); 14 15 } 15 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 16 if (!GetImage (NULL, &kapa, name)) return (FALSE); 17 FREE (name); 16 18 17 19 if ((argc != 3) && (argc != 4)) { … … 25 27 if (argc == 4) zoom = atof (argv[3]); 26 28 27 KiiCenter ( Ximage, x, y, zoom);29 KiiCenter (kapa, x, y, zoom); 28 30 return (TRUE); 29 31 } -
trunk/Ohana/src/opihi/cmd.data/clear.c
r7917 r13479 1 1 # include "data.h" 2 2 3 // default is to clear all plots, but not the sections or the images 3 4 int clear (int argc, char **argv) { 4 5 5 int N, ClearSection; 6 int Ngraph, Xgraph; 6 int N; 7 int kapa; 8 char *name; 7 9 8 Ngraph = -1;10 name = NULL; 9 11 if ((N = get_argument (argc, argv, "-n"))) { 10 12 remove_argument (N, &argc, argv); 11 Ngraph = atof(argv[N]);13 name = strcreate (argv[N]); 12 14 remove_argument (N, &argc, argv); 13 15 } 14 if (!GetGraph (NULL, &Xgraph, &Ngraph)) return (FALSE); 16 if (!GetGraph (NULL, &kapa, name)) return (FALSE); 17 FREE (name); 15 18 16 ClearSection = FALSE; 17 if ((N = get_argument (argc, argv, "-s"))) { 18 remove_argument (N, &argc, argv); 19 ClearSection = TRUE; 19 // clear all sections 20 if ((N = get_argument (argc, argv, "-s")) || 21 (N = get_argument (argc, argv, "-section"))) { 22 KapaClearSections (kapa); 23 return (TRUE); 24 } 25 26 // clear all sections 27 if ((N = get_argument (argc, argv, "-graph"))) { 28 KapaClearCurrentPlot (kapa); 29 return (TRUE); 30 } 31 32 // clear image 33 if ((N = get_argument (argc, argv, "-image"))) { 34 KapaClearImage (kapa); 35 return (TRUE); 20 36 } 21 37 22 38 if (argc != 1) { 23 gprint (GP_ERR, "USAGE: clear [-n Xgraph]\n"); 39 gprint (GP_ERR, "USAGE: clear [-n Xgraph] [-s|-section] [-image] [-graph]\n"); 40 gprint (GP_ERR, " [-s|-section] : clear all sections\n"); 41 gprint (GP_ERR, " [-graph] : clear current graph\n"); 42 gprint (GP_ERR, " [-image] : clear current image\n"); 24 43 return (FALSE); 25 44 } 26 45 27 KapaClear (Xgraph, ClearSection);46 KapaClearPlots (kapa); 28 47 return (TRUE); 29 48 } -
trunk/Ohana/src/opihi/cmd.data/close.c
r6686 r13479 3 3 int close_device (int argc, char **argv) { 4 4 5 int N, Source, Nsource, IsImage; 5 int N, kapa, IsImage; 6 char *name; 6 7 /* close current graphics device */ 7 8 8 Nsource = -1;9 name = NULL; 9 10 if ((N = get_argument (argc, argv, "-n"))) { 10 11 remove_argument (N, &argc, argv); 11 Nsource = atof(argv[N]);12 name = strcreate (argv[N]); 12 13 remove_argument (N, &argc, argv); 13 14 } 14 if ((N = get_argument (argc, argv, "-g"))) {15 remove_argument (N, &argc, argv);16 SetImageDevice (FALSE);17 }18 if ((N = get_argument (argc, argv, "-i"))) {19 remove_argument (N, &argc, argv);20 SetImageDevice (TRUE);21 }22 15 23 IsImage = GetCurrentDevice (); 24 if (IsImage) { 25 if (!GetImage (&Source, &Nsource)) return (FALSE); 26 close_image (Nsource); 27 } else { 28 if (!GetGraph (NULL, &Source, &Nsource)) return (FALSE); 29 close_graph (Nsource); 30 } 16 if (!GetGraph (NULL, &kapa, name)) return (FALSE); 17 18 close_kapa (name); 19 FREE (name); 31 20 32 21 return (TRUE); -
trunk/Ohana/src/opihi/cmd.data/cursor.c
r7917 r13479 3 3 int cursor (int argc, char **argv) { 4 4 5 char string[20], key[20] ;6 int i, N, Nsource, Source, IsImage;5 char string[20], key[20], *name; 6 int i, N, kapa; 7 7 double X, Y, R, D, Z; 8 8 void *oldsignal; 9 Graphdata graphmode;10 Buffer *buf;11 9 12 Nsource = -1; 10 // XXX need to be able to specify graph vs image coords 11 // currently, if only one exists, that frame will be used 12 // if both exist, defaults to ?? 13 // if ((N = get_argument (argc, argv, "-g"))) { 14 // if ((N = get_argument (argc, argv, "-i"))) { 15 16 name = NULL; 13 17 if ((N = get_argument (argc, argv, "-n"))) { 14 18 remove_argument (N, &argc, argv); 15 Nsource = atof(argv[N]);19 name = strcreate (argv[N]); 16 20 remove_argument (N, &argc, argv); 17 21 } 18 if ((N = get_argument (argc, argv, "-g"))) { 19 remove_argument (N, &argc, argv); 20 SetImageDevice (FALSE); 21 } 22 if ((N = get_argument (argc, argv, "-i"))) { 23 remove_argument (N, &argc, argv); 24 SetImageDevice (TRUE); 25 } 26 IsImage = GetCurrentDevice (); 27 if (IsImage) { 28 if (!GetImage (&Source, &Nsource)) return (FALSE); 29 } else { 30 if (!GetGraph (&graphmode, &Source, &Nsource)) return (FALSE); 31 } 22 if (!GetGraphData (NULL, &kapa, name)) return (FALSE); 23 FREE (name); 32 24 33 25 N = 0; … … 39 31 } 40 32 41 buf = NULL; 42 if (IsImage) buf = SelectBuffer (GetImageName(), OLDBUFFER, FALSE); 43 44 KiiCursorOn (Source); 33 KiiCursorOn (kapa); 45 34 46 35 oldsignal = signal (SIGINT, handle_interrupt); 47 36 interrupt = FALSE; 48 Z = -1.0; 37 49 38 for (i = 0; ((i < N) || (N == 0)) && !interrupt; i++) { 50 KiiCursorRead (Source, &X, &Y, key); 39 40 KiiCursorRead (kapa, &X, &Y, &Z, &R, &D, key); 51 41 52 42 sprintf (string, "X%s", key); … … 54 44 sprintf (string, "Y%s", key); 55 45 set_variable (string, Y); 46 sprintf (string, "Z%s", key); 47 set_variable (string, Z); 48 sprintf (string, "R%s", key); 49 set_variable (string, R); 50 sprintf (string, "D%s", key); 51 set_variable (string, D); 52 56 53 set_str_variable ("KEY", key); 57 54 58 if (IsImage) { 59 if (buf != NULL) { 60 Z = gfits_get_matrix_value (&buf[0].matrix, (int) X, (int) Y); 61 } 62 gprint (GP_LOG, "%s %f %f %f\n", key, X, Y, Z); 63 } else { 64 XY_to_RD (&R, &D, X, Y, &graphmode.coords); 65 sprintf (string, "R%s", key); 66 set_variable (string, R); 67 sprintf (string, "D%s", key); 68 set_variable (string, D); 69 gprint (GP_LOG, "%s %f %f\n", key, X, Y); 70 } 55 gprint (GP_LOG, "%s %f %f %f %f %f\n", key, X, Y, Z, R, D); 56 71 57 if (!strcasecmp (key, "Q")) break; 72 58 } 73 59 74 60 signal (SIGINT, oldsignal); 75 KiiCursorOff ( Source);61 KiiCursorOff (kapa); 76 62 return (TRUE); 77 63 } -
trunk/Ohana/src/opihi/cmd.data/device.c
r7917 r13479 3 3 int device (int argc, char **argv) { 4 4 5 int N, Source, Nsource, IsImage; 5 int N, kapa, IsImage; 6 char *name;; 6 7 /* set / get current graphics device */ 7 8 8 Nsource = -1;9 name = NULL; 9 10 if ((N = get_argument (argc, argv, "-n"))) { 10 11 remove_argument (N, &argc, argv); 11 Nsource = atof(argv[N]);12 name = strcreate (argv[N]); 12 13 remove_argument (N, &argc, argv); 13 14 } 14 if ((N = get_argument (argc, argv, "-g"))) {15 remove_argument (N, &argc, argv);16 SetImageDevice (FALSE);17 }18 if ((N = get_argument (argc, argv, "-i"))) {19 remove_argument (N, &argc, argv);20 SetImageDevice (TRUE);21 }22 15 23 IsImage = GetCurrentDevice (); 24 if (IsImage) { 25 if (!GetImage (&Source, &Nsource)) return (FALSE); 26 gprint (GP_ERR, "kii %d\n", Nsource); 16 if (name == NULL) { 17 name = GetKapaName (); 18 if (name == NULL) { 19 gprint (GP_ERR, "no device defined\n"); 20 return (NULL); 21 } 27 22 } else { 28 if (!GetGraph (NULL, &Source, &Nsource)) return (FALSE); 29 gprint (GP_ERR, "kapa %d\n", Nsource); 23 if (!GetGraph (NULL, &kapa, name)) return (FALSE); 30 24 } 25 gprint (GP_ERR, "kapa %s\n", name); 31 26 32 27 return (TRUE); -
trunk/Ohana/src/opihi/cmd.data/dot.c
r7917 r13479 3 3 int dot (int argc, char **argv) { 4 4 5 int kapa; 5 6 Graphdata graphmode; 6 7 float x, y; 7 8 8 if (!style_args (&graphmode, &argc, argv, -1)) return FALSE;9 if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE; 9 10 10 11 if (argc != 3) { … … 15 16 y = atof(argv[2]); 16 17 17 /* set plotting options (these are sticky) */18 SetGraph (graphmode);19 20 18 /* set point style and errorbar mode (these are NOT sticky) */ 21 19 graphmode.style = 2; 22 20 graphmode.etype = 0; 23 21 24 if (!PrepPlotting (1, &graphmode)) return (FALSE); 25 26 PlotVector (1, &x); 27 PlotVector (1, &y); 22 if (!KapaPrepPlot (kapa, 1, &graphmode)) return (FALSE); 23 KapaPlotVector (kapa, 1, &x, "x"); 24 KapaPlotVector (kapa, 1, &y, "y"); 28 25 29 26 return (TRUE); -
trunk/Ohana/src/opihi/cmd.data/erase.c
r7917 r13479 4 4 5 5 int i, N; 6 int Ximage, Nimage; 6 int kapa; 7 char *name; 7 8 8 Nimage = -1;9 name = NULL; 9 10 if ((N = get_argument (argc, argv, "-n"))) { 10 11 remove_argument (N, &argc, argv); 11 Nimage = atof(argv[N]);12 name = strcreate (argv[N]); 12 13 remove_argument (N, &argc, argv); 13 14 } 14 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 15 if (!GetImage (NULL, &kapa, name)) return (FALSE); 16 FREE (name); 15 17 16 18 if (argc < 2) { … … 22 24 for (i = 1; i < argc; i++) { 23 25 if (!(strcasecmp (argv[i], "all"))) { 24 KiiEraseOverlay ( Ximage, "red");25 KiiEraseOverlay ( Ximage, "green");26 KiiEraseOverlay ( Ximage, "blue");27 KiiEraseOverlay ( Ximage, "yellow");26 KiiEraseOverlay (kapa, "red"); 27 KiiEraseOverlay (kapa, "green"); 28 KiiEraseOverlay (kapa, "blue"); 29 KiiEraseOverlay (kapa, "yellow"); 28 30 continue; 29 31 } … … 32 34 return (FALSE); 33 35 } 34 KiiEraseOverlay ( Ximage, argv[i]);36 KiiEraseOverlay (kapa, argv[i]); 35 37 } 36 38 return (TRUE); -
trunk/Ohana/src/opihi/cmd.data/grid.c
r7917 r13479 3 3 int grid (int argc, char **argv) { 4 4 5 int j, N, MinorTick, MajorTick;5 int j, kapa, N, MinorTick, MajorTick; 6 6 Vector Xvec, Yvec; 7 7 double range, lrange, factor, mantis, fmantis, power, major, minor, first, next; 8 8 Graphdata graphmode; 9 int Ngraph; 10 11 Ngraph = -1; 12 if ((N = get_argument (argc, argv, "-n"))) { 13 remove_argument (N, &argc, argv); 14 Ngraph = atof (argv[N]); 15 remove_argument (N, &argc, argv); 16 } 17 if (!GetGraph (&graphmode, NULL, &Ngraph)) return (FALSE); 9 10 if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE); 18 11 19 12 MajorTick = TRUE; … … 200 193 graphmode.ptype = 100; /* connect a pair */ 201 194 graphmode.etype = 0; 202 PrepPlotting (N, &graphmode); 203 PlotVector (N, Xvec.elements); 204 PlotVector (N, Yvec.elements); 195 PlotVectorPair (kapa, N, Xvec.elements, Yvec.elements, &graphmode); 205 196 206 197 free (Xvec.elements); -
trunk/Ohana/src/opihi/cmd.data/init.c
r10997 r13479 235 235 int i; 236 236 237 InitGraph (); 238 InitImage (); 237 InitKapa (); 239 238 InitQueues (); 240 239 -
trunk/Ohana/src/opihi/cmd.data/jpeg.c
r7917 r13479 4 4 5 5 char filename[1024]; 6 int N, Source, Nsource, IsImage, IsPNG; 6 int N, kapa, IsImage, IsPNG, IsPPM; 7 char *name; 7 8 8 9 if ((N = get_argument (argc, argv, "--help"))) { … … 12 13 13 14 /* image type */ 14 IsP NG = TRUE;15 IsPPM = IsPNG = FALSE; 15 16 if ((N = get_argument (argc, argv, "-ppm"))) { 16 17 remove_argument (N, &argc, argv); 17 IsP NG = FALSE;18 IsPPM = TRUE; 18 19 } 20 if ((N = get_argument (argc, argv, "-png"))) { 21 remove_argument (N, &argc, argv); 22 IsPNG = TRUE; 23 } 24 if (!strcmp (argv[0], "png")) IsPNG = TRUE; 25 if (!strcmp (argv[0], "ppm")) IsPPM = TRUE; 19 26 20 27 /* file name */ … … 27 34 28 35 /* display source */ 29 Nsource = -1;36 name = NULL; 30 37 if ((N = get_argument (argc, argv, "-n"))) { 31 38 remove_argument (N, &argc, argv); 32 Nsource = atof(argv[N]);39 name = strcreate (argv[N]); 33 40 remove_argument (N, &argc, argv); 34 41 } 42 43 /* XXX output png / jpeg needs to include both graph and image 44 if available. this is a poor mix of data representations 45 (png for image / jpeg for plots) 35 46 if ((N = get_argument (argc, argv, "-g"))) { 36 remove_argument (N, &argc, argv);37 SetImageDevice (FALSE);38 }39 47 if ((N = get_argument (argc, argv, "-i"))) { 40 remove_argument (N, &argc, argv); 41 SetImageDevice (TRUE); 42 } 43 IsImage = GetCurrentDevice (); 44 if (IsImage) { 45 if (!GetImage (&Source, &Nsource)) return (FALSE); 46 if (!filename[0]) strcpy (filename, "Ximage.jpg"); 47 KiiJPEG (Source, filename); 48 } else { 49 if (!GetGraph (NULL, &Source, &Nsource)) return (FALSE); 50 if (!filename[0]) strcpy (filename, "Xgraph.png"); 51 if (IsPNG) { 52 KapaPNG (Source, filename); 53 } else { 54 KapaPPM (Source, filename); 55 } 48 */ 49 50 if (!GetGraph (NULL, &kapa, name)) return (FALSE); 51 if (!IsPNG && !IsPPM) { 52 if (!filename[0]) strcpy (filename, "kapa.jpg"); 53 KiiJPEG (kapa, filename); 54 } 55 if (IsPNG) { 56 if (!filename[0]) strcpy (filename, "kapa.png"); 57 KapaPNG (kapa, filename); 58 } 59 if (IsPPM) { 60 if (!filename[0]) strcpy (filename, "kapa.ppm"); 61 KapaPPM (kapa, filename); 56 62 } 57 63 return (TRUE); -
trunk/Ohana/src/opihi/cmd.data/labels.c
r7917 r13479 4 4 5 5 char name[64]; 6 int N, size, Xgraph;6 int N, size, kapa; 7 7 8 if (!GetGraph (NULL, & Xgraph, NULL)) return (FALSE);8 if (!GetGraph (NULL, &kapa, NULL)) return (FALSE); 9 9 10 10 if (get_argument (argc, argv, "-h")) { … … 36 36 size = atof (argv[N]); 37 37 remove_argument (N, &argc, argv); 38 KapaSetFont ( Xgraph, name, size);38 KapaSetFont (kapa, name, size); 39 39 } 40 40 41 41 if ((N = get_argument (argc, argv, "-x"))) { 42 42 remove_argument (N, &argc, argv); 43 KapaSendLabel ( Xgraph, argv[N], 0);43 KapaSendLabel (kapa, argv[N], 0); 44 44 remove_argument (N, &argc, argv); 45 45 } … … 47 47 if ((N = get_argument (argc, argv, "-y"))) { 48 48 remove_argument (N, &argc, argv); 49 KapaSendLabel ( Xgraph, argv[N], 1);49 KapaSendLabel (kapa, argv[N], 1); 50 50 remove_argument (N, &argc, argv); 51 51 } … … 53 53 if ((N = get_argument (argc, argv, "+x"))) { 54 54 remove_argument (N, &argc, argv); 55 KapaSendLabel ( Xgraph, argv[N], 2);55 KapaSendLabel (kapa, argv[N], 2); 56 56 remove_argument (N, &argc, argv); 57 57 } … … 59 59 if ((N = get_argument (argc, argv, "+y"))) { 60 60 remove_argument (N, &argc, argv); 61 KapaSendLabel ( Xgraph, argv[N], 3);61 KapaSendLabel (kapa, argv[N], 3); 62 62 remove_argument (N, &argc, argv); 63 63 } … … 65 65 if ((N = get_argument (argc, argv, "-ul"))) { 66 66 remove_argument (N, &argc, argv); 67 KapaSendLabel ( Xgraph, argv[N], 4);67 KapaSendLabel (kapa, argv[N], 4); 68 68 remove_argument (N, &argc, argv); 69 69 } … … 71 71 if ((N = get_argument (argc, argv, "-ur"))) { 72 72 remove_argument (N, &argc, argv); 73 KapaSendLabel ( Xgraph, argv[N], 5);73 KapaSendLabel (kapa, argv[N], 5); 74 74 remove_argument (N, &argc, argv); 75 75 } … … 77 77 if ((N = get_argument (argc, argv, "-ll"))) { 78 78 remove_argument (N, &argc, argv); 79 KapaSendLabel ( Xgraph, argv[N], 6);79 KapaSendLabel (kapa, argv[N], 6); 80 80 remove_argument (N, &argc, argv); 81 81 } … … 83 83 if ((N = get_argument (argc, argv, "-lr"))) { 84 84 remove_argument (N, &argc, argv); 85 KapaSendLabel ( Xgraph, argv[N], 7);85 KapaSendLabel (kapa, argv[N], 7); 86 86 remove_argument (N, &argc, argv); 87 87 } -
trunk/Ohana/src/opihi/cmd.data/limits.c
r7917 r13479 4 4 5 5 int N, APPLY; 6 int Ngraph, Xgraph; 6 int kapa; 7 char *name; 7 8 Graphdata graphmode; 8 9 Vector *xvec, *yvec; … … 15 16 APPLY = TRUE; 16 17 } 17 18 Ngraph = -1; 18 name = NULL; 19 19 if ((N = get_argument (argc, argv, "-n"))) { 20 20 remove_argument (N, &argc, argv); 21 Ngraph = atof(argv[N]);21 name = strcreate (argv[N]); 22 22 remove_argument (N, &argc, argv); 23 23 } 24 if (!GetGraph (&graphmode, &Xgraph, &Ngraph)) return (FALSE); 24 if (!GetGraph (&graphmode, &kapa, name)) return (FALSE); 25 FREE (name); 25 26 26 27 if (argc == 1) { 27 gprint (GP_ERR, "limits: %f %f %f %f [-a] [-n Xgraph]\n",28 gprint (GP_ERR, "limits: %f %f %f %f [-a] [-n device]\n", 28 29 graphmode.xmin, graphmode.xmax, 29 30 graphmode.ymin, graphmode.ymax); … … 71 72 success: 72 73 SetLimits (xvec, yvec, &graphmode); 73 if (APPLY) KapaSetLimits ( Xgraph, &graphmode);74 if (APPLY) KapaSetLimits (kapa, &graphmode); 74 75 return (TRUE); 75 76 } -
trunk/Ohana/src/opihi/cmd.data/line.c
r12332 r13479 3 3 int line (int argc, char **argv) { 4 4 5 int kapa; 5 6 Graphdata graphmode; 6 7 float x[2], y[2]; 7 8 8 if (!style_args (&graphmode, &argc, argv, -1)) return FALSE;9 if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE; 9 10 10 11 if (argc != 6) { … … 17 18 y[1] = atof(argv[5]); 18 19 19 SetGraph (graphmode);20 21 20 /* set point style and errorbar mode (these are NOT sticky) */ 22 21 graphmode.style = 0; 23 22 graphmode.etype = 0; 24 23 25 if (!PrepPlotting (2, &graphmode)) return (FALSE); 26 27 PlotVector (2, x); 28 PlotVector (2, y); 24 if (!KapaPrepPlot (kapa, 2, &graphmode)) return (FALSE); 25 KapaPlotVector (kapa, 2, x, "x"); 26 KapaPlotVector (kapa, 2, y, "y"); 29 27 30 28 return (TRUE); 31 32 29 } -
trunk/Ohana/src/opihi/cmd.data/load.c
r7917 r13479 4 4 5 5 int i, N, n, ISCEL; 6 int Ximage, Nimage, Noverlay, NOVERLAY;6 int kapa, Noverlay, NOVERLAY; 7 7 char *c, type[10], string[128], line[1024]; 8 8 double x, y, dx, dy, x1, y1; 9 9 double dra, ddec, ra1, dec1, ra, dec; 10 10 FILE *f; 11 char *buffer ;11 char *buffer, *name; 12 12 Coords coords; 13 13 Buffer *buf; 14 14 KiiOverlay *overlay; 15 KapaImageData data; 15 16 16 Nimage = -1;17 name = NULL; 17 18 if ((N = get_argument (argc, argv, "-n"))) { 18 19 remove_argument (N, &argc, argv); 19 Nimage = atof(argv[N]);20 name = strcreate (argv[N]); 20 21 remove_argument (N, &argc, argv); 21 22 } 22 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 23 if (!GetImageData (&data, &kapa, name)) return (FALSE); 24 FREE (name); 23 25 24 26 ISCEL = FALSE; … … 45 47 46 48 if (ISCEL) { 47 if ((buf = SelectBuffer ( GetImageName(), OLDBUFFER, TRUE)) == NULL) return (FALSE);49 if ((buf = SelectBuffer (data.name, OLDBUFFER, TRUE)) == NULL) return (FALSE); 48 50 GetCoords (&coords, &buf[0].header); 49 51 } … … 125 127 } 126 128 127 KiiLoadOverlay ( Ximage, overlay, Noverlay, argv[1]);129 KiiLoadOverlay (kapa, overlay, Noverlay, argv[1]); 128 130 129 131 for (i = 0; i < Noverlay; i++) { -
trunk/Ohana/src/opihi/cmd.data/plot.c
r7917 r13479 3 3 int plot (int argc, char **argv) { 4 4 5 int N, Npts;5 int kapa, N, Npts; 6 6 Graphdata graphmode; 7 7 Vector *xvec, *yvec, *dxmvec, *dxpvec, *dymvec, *dypvec; 8 8 9 if (!style_args (&graphmode, &argc, argv, -1)) return FALSE;9 if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE; 10 10 11 11 /* decide on error bars */ … … 36 36 return (FALSE); 37 37 } 38 SetGraph (graphmode);39 38 40 39 /* set errorbar mode (these are NOT sticky) */ … … 57 56 if (Npts == 0) return (TRUE); 58 57 59 if (! PrepPlotting (Npts, &graphmode)) return (FALSE);58 if (!KapaPrepPlot (kapa, Npts, &graphmode)) return (FALSE); 60 59 61 PlotVector (Npts, xvec[0].elements);62 PlotVector (Npts, yvec[0].elements);60 KapaPlotVector (kapa, Npts, xvec[0].elements, "x"); 61 KapaPlotVector (kapa, Npts, yvec[0].elements, "y"); 63 62 if (graphmode.etype & 0x01) { 64 PlotVector (Npts, dymvec[0].elements);65 PlotVector (Npts, dypvec[0].elements);63 KapaPlotVector (kapa, Npts, dymvec[0].elements, "dym"); 64 KapaPlotVector (kapa, Npts, dypvec[0].elements, "dyp"); 66 65 } 67 66 if (graphmode.etype & 0x02) { 68 PlotVector (Npts, dxmvec[0].elements);69 PlotVector (Npts, dxpvec[0].elements);67 KapaPlotVector (kapa, Npts, dxmvec[0].elements, "dxm"); 68 KapaPlotVector (kapa, Npts, dxpvec[0].elements, "dxp"); 70 69 } 71 72 70 return (TRUE); 73 74 71 } -
trunk/Ohana/src/opihi/cmd.data/point.c
r7917 r13479 4 4 5 5 int N, celestial, pixscale; 6 int Ximage, Nimage;6 int kapa; 7 7 double ra, dec, dra, ddec; 8 8 double x1, y1, ra1, dec1; 9 char *name; 9 10 Coords coords; 10 11 Buffer *buf; 11 12 KiiOverlay overlay; 13 KapaImageData data; 12 14 13 Nimage = -1;15 name = NULL; 14 16 if ((N = get_argument (argc, argv, "-n"))) { 15 17 remove_argument (N, &argc, argv); 16 Nimage = atof(argv[N]);18 name = strcreate (argv[N]); 17 19 remove_argument (N, &argc, argv); 18 20 } 19 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 20 21 if (!GetImageData (&data, &kapa, name)) return (FALSE); 22 FREE (name); 23 21 24 celestial = FALSE; 22 25 if ((N = get_argument (argc, argv, "-c"))) { … … 37 40 38 41 if (celestial) { 39 if ((buf = SelectBuffer ( GetImageName(), OLDBUFFER, TRUE)) == NULL) return (FALSE);42 if ((buf = SelectBuffer (data.name, OLDBUFFER, TRUE)) == NULL) return (FALSE); 40 43 GetCoords (&coords, &buf[0].header); 41 44 } … … 66 69 } 67 70 overlay.type = KiiOverlayTypeByName (argv[2]); 68 KiiLoadOverlay ( Ximage, &overlay, 1, argv[1]);71 KiiLoadOverlay (kapa, &overlay, 1, argv[1]); 69 72 return (TRUE); 70 73 } -
trunk/Ohana/src/opihi/cmd.data/ps.c
r12892 r13479 3 3 int ps (int argc, char **argv) { 4 4 5 char filename[1024], pagename[1024] ;6 int N, Source, Nsource, scaleMode, pageMode, IsImage;5 char filename[1024], pagename[1024], *name; 6 int N, kapa, scaleMode, pageMode, IsImage; 7 7 8 8 if ((N = get_argument (argc, argv, "--help"))) goto help; … … 44 44 45 45 /* which tool */ 46 Nsource = -1;46 name = NULL; 47 47 if ((N = get_argument (argc, argv, "-n"))) { 48 48 remove_argument (N, &argc, argv); 49 Nsource = atof(argv[N]);49 name = strcreate (argv[N]); 50 50 remove_argument (N, &argc, argv); 51 51 } 52 /* which device */ 53 if ((N = get_argument (argc, argv, "-g"))) { 54 remove_argument (N, &argc, argv); 55 SetImageDevice (FALSE); 56 } 57 if ((N = get_argument (argc, argv, "-i"))) { 58 remove_argument (N, &argc, argv); 59 SetImageDevice (TRUE); 60 } 61 52 62 53 if ((argc > 1) && filename[0]) goto help; 63 54 64 55 if (argc > 1) strcpy (filename, argv[1]); 65 56 66 IsImage = GetCurrentDevice (); 67 if (IsImage) { 68 if (!GetImage (&Source, &Nsource)) return (FALSE); 69 if (!filename[0]) strcpy (filename, "Ximage.ps"); 70 } else { 71 if (!GetGraph (NULL, &Source, &Nsource)) return (FALSE); 72 if (!filename[0]) strcpy (filename, "Xgraph.ps"); 73 } 57 // get the connection to kapa, false if none available 58 if (!GetGraphData (NULL, &kapa, name)) return (FALSE); 59 FREE (name); 60 61 if (!filename[0]) strcpy (filename, "kapa.ps"); 74 62 75 63 /* tell Ximage/Xgraph to ps the image */ 76 KiiPS ( Source, filename, scaleMode, pageMode, pagename);64 KiiPS (kapa, filename, scaleMode, pageMode, pagename); 77 65 return (TRUE); 78 66 -
trunk/Ohana/src/opihi/cmd.data/rd.c
r13107 r13479 59 59 60 60 /* find matrix, free old data */ 61 if ((buf = SelectBuffer (argv[1], ANYBUFFER, TRUE)) == NULL) return (FALSE); 61 if ((buf = SelectBuffer (argv[1], ANYBUFFER, TRUE)) == NULL) { 62 fclose (f); 63 return (FALSE); 64 } 62 65 gfits_free_matrix (&buf[0].matrix); 63 66 gfits_free_header (&buf[0].header); … … 79 82 gprint (GP_ERR, "entry in %s not found\n", argv[2]); 80 83 DeleteBuffer (buf); 84 fclose (f); 81 85 return (FALSE); 82 86 } … … 99 103 DeleteBuffer (buf); 100 104 free (CCDKeyword); 105 fclose (f); 101 106 return (FALSE); 102 107 } … … 105 110 DeleteBuffer (buf); 106 111 free (CCDKeyword); 112 fclose (f); 107 113 return (FALSE); 108 114 } … … 143 149 buf[0].header.bzero = 0; 144 150 buf[0].header.bscale = 1; 151 fclose (f); 145 152 return (TRUE); 146 153 } … … 152 159 gprint (GP_ERR, "-plane is too large: %d total planes\n", Nplane); 153 160 DeleteBuffer (buf); 161 fclose (f); 154 162 return (FALSE); 155 163 } -
trunk/Ohana/src/opihi/cmd.data/resize.c
r7917 r13479 5 5 char *end; 6 6 double NX, NY; 7 int N, Source, Nsource, IsImage; 7 int N, kapa; 8 char *name; 8 9 9 10 /* display source */ 10 Nsource = -1;11 name = NULL; 11 12 if ((N = get_argument (argc, argv, "-n"))) { 12 13 remove_argument (N, &argc, argv); 13 Nsource = atof(argv[N]);14 name = strcreate (argv[N]); 14 15 remove_argument (N, &argc, argv); 15 16 } 16 if ((N = get_argument (argc, argv, "-g"))) { 17 remove_argument (N, &argc, argv); 18 SetImageDevice (FALSE); 19 } 20 if ((N = get_argument (argc, argv, "-i"))) { 21 remove_argument (N, &argc, argv); 22 SetImageDevice (TRUE); 23 } 24 IsImage = GetCurrentDevice (); 25 if (IsImage) { 26 if (!GetImage (&Source, &Nsource)) return (FALSE); 27 } else { 28 if (!GetGraph (NULL, &Source, &Nsource)) return (FALSE); 29 } 17 if (!GetImage (NULL, &kapa, name)) return (FALSE); 18 FREE (name); 30 19 31 20 if (argc != 3) { … … 49 38 if (!strcmp (end, "cm")) { NY *= 38; } 50 39 51 KiiResize ( Source, NX, NY);40 KiiResize (kapa, NX, NY); 52 41 return (TRUE); 53 42 } -
trunk/Ohana/src/opihi/cmd.data/save.c
r7917 r13479 4 4 5 5 int N, celestial; 6 int Ximage, Nimage; 6 int kapa; 7 char *name; 7 8 8 Nimage = -1;9 name = NULL; 9 10 if ((N = get_argument (argc, argv, "-n"))) { 10 11 remove_argument (N, &argc, argv); 11 Nimage = atof(argv[N]);12 name = strcreate (argv[N]); 12 13 remove_argument (N, &argc, argv); 13 14 } 14 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 15 if (!GetImage (NULL, &kapa, name)) return (FALSE); 16 FREE (name); 15 17 16 18 celestial = FALSE; … … 26 28 } 27 29 28 KiiSaveOverlay ( Ximage, celestial, argv[1], argv[2]);30 KiiSaveOverlay (kapa, celestial, argv[1], argv[2]); 29 31 return (TRUE); 30 32 } -
trunk/Ohana/src/opihi/cmd.data/section.c
r7917 r13479 1 1 # include "data.h" 2 3 enum {NONE, LIST, UP, DOWN, TOP, BOTTOM, TOOL}; 2 4 3 5 int section (int argc, char **argv) { 4 6 5 int N, List;6 int Ngraph, Xgraph;7 int N, action, kapa; 8 char *name, *location; 7 9 Graphdata graphmode; 8 10 KapaSection section; 9 11 10 List = FALSE;12 action = NONE; 11 13 if ((N = get_argument (argc, argv, "-list"))) { 14 action = LIST; 12 15 remove_argument (N, &argc, argv); 13 List = TRUE; 16 } 17 if ((N = get_argument (argc, argv, "-up"))) { 18 action = UP; 19 remove_argument (N, &argc, argv); 20 } 21 if ((N = get_argument (argc, argv, "-down"))) { 22 action = DOWN; 23 remove_argument (N, &argc, argv); 24 } 25 if ((N = get_argument (argc, argv, "-top"))) { 26 action = TOP; 27 remove_argument (N, &argc, argv); 28 } 29 if ((N = get_argument (argc, argv, "-bottom"))) { 30 action = BOTTOM; 31 remove_argument (N, &argc, argv); 32 } 33 if ((N = get_argument (argc, argv, "-imtool"))) { 34 action = TOOL; 35 remove_argument (N, &argc, argv); 36 location = argv[N]; 37 remove_argument (N, &argc, argv); 14 38 } 15 39 16 Ngraph = -1;40 name = NULL; 17 41 if ((N = get_argument (argc, argv, "-n"))) { 18 42 remove_argument (N, &argc, argv); 19 Ngraph = atof(argv[N]);43 name = strcreate (argv[N]); 20 44 remove_argument (N, &argc, argv); 21 45 } 22 if (!GetGraph (&graphmode, &Xgraph, &Ngraph)) return (FALSE); 46 if (!GetGraph (&graphmode, &kapa, name)) return (FALSE); 47 FREE (name); 23 48 24 49 /* list sections */ 25 if (argc == 1) { 26 KapaGetSection (Xgraph, "*"); 27 gprint (GP_ERR, "USAGE: section name [x y dx dy]\n"); 50 if ((argc == 1) && (action == NONE)) { 51 KapaGetSection (kapa, "*"); 52 gprint (GP_ERR, "USAGE: section name [x y dx dy] [options]\n"); 53 gprint (GP_ERR, "OPTIONS: -list : show properties of all sections\n"); 54 gprint (GP_ERR, " -up : move section up in display stack\n"); 55 gprint (GP_ERR, " -down : move section down in display stack\n"); 56 gprint (GP_ERR, " -top : move section to top of display stack\n"); 57 gprint (GP_ERR, " -bottom : move section to bottom of display stack\n"); 58 gprint (GP_ERR, " -imtool (position) : set location of image zoom / status box\n"); 59 gprint (GP_ERR, " (position may be: -x, +x, -y, +y, none)\n"); 28 60 return (TRUE); 29 61 } … … 31 63 if (argc == 2) { 32 64 /* select / show section */ 33 if (List) { 34 KapaGetSection (Xgraph, argv[1]); 35 } else { 36 KapaSelectSection (Xgraph, argv[1]); 65 switch (action) { 66 case NONE: 67 KapaSelectSection (kapa, argv[1]); 68 break; 69 70 case UP: 71 KapaMoveSection (kapa, argv[1], "up"); 72 break; 73 case DOWN: 74 KapaMoveSection (kapa, argv[1], "down"); 75 break; 76 case TOP: 77 KapaMoveSection (kapa, argv[1], "top"); 78 break; 79 case BOTTOM: 80 KapaMoveSection (kapa, argv[1], "bottom"); 81 break; 82 83 case TOOL: 84 if (!strcmp(location, "-x")) { 85 KapaSetToolbox (kapa, 1); 86 break; 87 } 88 if (!strcmp(location, "+x")) { 89 KapaSetToolbox (kapa, 3); 90 break; 91 } 92 if (!strcmp(location, "-y")) { 93 KapaSetToolbox (kapa, 2); 94 break; 95 } 96 if (!strcmp(location, "+y")) { 97 KapaSetToolbox (kapa, 4); 98 break; 99 } 100 if (!strcmp(location, "none")) { 101 KapaSetToolbox (kapa, 0); 102 break; 103 } 104 gprint (GP_ERR, "unknown toolbox location %s\n", location); 105 gprint (GP_ERR, "valid values: -x, +x, -y, +y, none\n"); 106 return (FALSE); 107 108 case LIST: 109 KapaGetSection (kapa, argv[1]); 110 break; 37 111 } 38 112 return (TRUE); … … 46 120 section.dx = atof (argv[4]); 47 121 section.dy = atof (argv[5]); 48 KapaSetSection ( Xgraph, §ion);122 KapaSetSection (kapa, §ion); 49 123 return (TRUE); 50 124 } 51 125 gprint (GP_ERR, "USAGE: section name [x y dx dy]\n"); 126 gprint (GP_ERR, "USAGE: section name [-list] [-up] [-down] [-top] [-bottom]\n"); 52 127 return (FALSE); 53 128 } -
trunk/Ohana/src/opihi/cmd.data/style.c
r7917 r13479 3 3 int style (int argc, char **argv) { 4 4 5 Graphdata graphmode; 5 int kapa; 6 Graphdata data; 6 7 7 if (!style_args (& graphmode, &argc, argv, -1)) return FALSE;8 if (!style_args (&data, &argc, argv, &kapa)) return FALSE; 8 9 9 10 if (argc > 1) { … … 11 12 return (FALSE); 12 13 } 13 SetGraph (graphmode);14 KapaSetGraphData (kapa, &data); 14 15 15 16 return (TRUE); -
trunk/Ohana/src/opihi/cmd.data/textline.c
r7917 r13479 6 6 char name[64]; 7 7 double x, y, angle; 8 int Ngraph, Xgraph;8 int kapa; 9 9 Graphdata graphmode; 10 10 11 Ngraph = -1; 12 if ((N = get_argument (argc, argv, "-n"))) { 13 remove_argument (N, &argc, argv); 14 Ngraph = atof (argv[N]); 15 remove_argument (N, &argc, argv); 16 } 17 if (!GetGraph (&graphmode, &Xgraph, &Ngraph)) return (FALSE); 11 if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE); 18 12 19 13 if ((N = get_argument (argc, argv, "-fn"))) { … … 23 17 size = atof (argv[N]); 24 18 remove_argument (N, &argc, argv); 25 KapaSetFont ( Xgraph, name, size);19 KapaSetFont (kapa, name, size); 26 20 } 27 21 … … 58 52 } 59 53 60 KapaSendTextline ( Xgraph, argv[3], x, y, angle);54 KapaSendTextline (kapa, argv[3], x, y, angle); 61 55 return (TRUE); 62 56 } -
trunk/Ohana/src/opihi/cmd.data/tv.c
r7917 r13479 3 3 int tv (int argc, char **argv) { 4 4 5 int N, Ximage, Nimage; 5 int N, kapa; 6 char *name, *file; 6 7 Coords coords; 7 8 Buffer *buf; 8 9 KiiImage image; 9 K iiDisplayMode mode;10 KapaImageData data; 10 11 11 Nimage = -1;12 name = NULL; 12 13 if ((N = get_argument (argc, argv, "-n"))) { 13 14 remove_argument (N, &argc, argv); 14 Nimage = atof(argv[N]);15 name = strcreate (argv[N]); 15 16 remove_argument (N, &argc, argv); 16 17 } 17 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 18 if (!GetImage (&data, &kapa, name)) return (FALSE); 19 FREE (name); 18 20 19 21 /* shell exits on pipe close, FIX */ 20 22 if ((N = get_argument (argc, argv, "-kill"))) { 21 KiiClose (Ximage); 22 Ximage = 0; 23 KiiClose (kapa); 23 24 return (TRUE); 24 25 } 25 26 26 mode.logflux = FALSE;27 data.logflux = FALSE; 27 28 if ((N = get_argument (argc, argv, "-log"))) { 28 29 remove_argument (N, &argc, argv); 29 mode.logflux = TRUE;30 data.logflux = TRUE; 30 31 } 31 32 33 // use the currently-set zero,range values if not supplied 32 34 if ((argc != 2) && (argc != 4)) { 33 35 gprint (GP_ERR, "USAGE: tv <buffer> [zero range] [-n Nimage] [-log] [-kill]\n"); … … 35 37 } 36 38 37 GetImageScale (&mode.zero, &mode.range);38 39 if (argc == 4) { 39 mode.zero = atof (argv[2]); 40 mode.range = atof (argv[3]); 41 if (mode.range == 0.0) mode.range = 0.001; 42 SetImageScale (mode.zero, mode.range); 40 data.zero = atof (argv[2]); 41 data.range = atof (argv[3]); 42 if (data.range == 0.0) data.range = 0.001; 43 43 } 44 44 … … 49 49 image.Nx = buf[0].matrix.Naxis[0]; 50 50 image.Ny = buf[0].matrix.Naxis[1]; 51 image.file = buf[0].file;52 image.name = buf[0].name;53 51 54 KiiNewPicture1D (Ximage, &image, &mode, &coords); 52 // send only the root of the file, not the full path 53 file = filerootname (buf[0].file); 54 strcpy (data.file, file); 55 free (file); 55 56 56 SetImageName (argv[1]); 57 strcpy (data.name, argv[1]); 58 59 KiiNewPicture1D (kapa, &image, &data, &coords); 60 57 61 set_str_variable ("TV", argv[1]); 58 62 return (TRUE); 59 63 } 60 61 62 /*63 projections and coordinates:64 65 IRAS:66 CTYPE1 = 'LL ' /TANGENT PLANE (L)67 CRVAL1 = 0.100000D+02 /R.A. OF MAP CENTER *** SEE COMMENT68 CDELT1 = -0.133333D-01 /SEPARATION IN L (DEG)69 CRPIX1 = 128 /MAPCENTER IN L70 CROTA1 = 0.000000E+00 /NO ROTATION71 72 CTYPE2 = 'MM ' /TANGENT PLANE (M)73 CRVAL2 = 0.410000D+02 /DEC. OF MAP CENTER *** SEE COMMENT74 CDELT2 = 0.133333D-01 /SEPARATION IN M (DEG)75 CRPIX2 = 128 /MAP CENTER IN M76 CROTA2 = 0.000000E+00 /NO ROTATION77 78 HIRAS:79 CTYPE1 = 'RA---TAN ' / PRIMARY AXIS NAME80 CRVAL1 = 1.000000000000E+01 / PRIMARY REFERENCE VALUE81 CDELT1 = -5.555555555556E-03 / PRIMARY PIXEL SEPARATION82 CRPIX1 = 2.560000000000E+02 / PRIMARY REFERENCE PIXEL83 CUNIT1 = 'DEGREE ' / PRIMARY AXIS UNITS84 85 CDELT2 = 5.555555555556E-03 / PRIMARY PIXEL SEPARATION86 CRPIX2 = 2.560000000000E+02 / PRIMARY REFERENCE PIXEL87 CRVAL2 = 4.100000000000E+01 / PRIMARY REFERENCE VALUE88 CTYPE2 = 'DEC--TAN ' / PRIMARY AXIS NAME89 CUNIT2 = 'DEGREE ' / PRIMARY AXIS UNITS90 91 PROJTYPE= 'GNOMON '92 COORDSYS= 'EQUATORIAL '93 94 gene (small FOV linear):95 RA_O96 RA_X97 RA_Y98 DEC_O99 DEC_X100 DEC_Y101 102 103 */104 105 # ifdef NEWTVMODE106 {107 double *pixvalues, slope;108 109 ALLOCATE (pixvalues, double, Ncolors + 1);110 range = fabs (range);111 for (i = 0; i < Ncolors + 1; i++) {112 if (ISLOG) {113 pixvalues[i] = i*range / NNcol + zero;114 }115 if (!ISLOG) {116 pixvalues[i] = pow (10.0, i*log10(range - 1.0) / NNcol) + zero - 1.0;117 }118 }119 for (j = 0; j < Npix; j++, in++, out++) {120 if (*in < pixvalues[0]) {121 i = 0;122 } else {123 if (*in > pixvalues[NNcol]) {124 i = NNcol;125 } else {126 for (i = 0; (*in < pixvalues[i]) || (*in > pixvalues[i+1]); ) {127 slope = 1.0 / (pixvalues[i+1] - pixvalues[i]);128 i = MIN (MAX (0, i + (*in - pixvalues[i]) * slope), NNcol);129 }130 }131 }132 /* for (i = 0; (i < Ncolors - 1) && (pixvalues[i] < *in); i++); */133 *out = i;134 }135 free (pixvalues);136 }137 # endif -
trunk/Ohana/src/opihi/cmd.data/tvcontour.c
r7917 r13479 58 58 float *v00, *v01, *v10, *v11; 59 59 float *Vout, *Vin, *matrix; 60 int Ximage, Nimage, N, Noverlay, NOVERLAY; 60 char *name; 61 int kapa, N, Noverlay, NOVERLAY; 61 62 Buffer *buf; 62 63 KiiOverlay *overlay; 63 64 64 Nimage = -1;65 name = NULL; 65 66 if ((N = get_argument (argc, argv, "-n"))) { 66 67 remove_argument (N, &argc, argv); 67 Nimage = atof(argv[N]);68 name = strcreate (argv[N]); 68 69 remove_argument (N, &argc, argv); 69 70 } 70 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 71 if (!GetImage (NULL, &kapa, name)) return (FALSE); 72 FREE (name); 71 73 72 74 if ((argc != 4) && (argc != 5)) { … … 277 279 } 278 280 279 KiiLoadOverlay ( Ximage, overlay, Noverlay, argv[2]);281 KiiLoadOverlay (kapa, overlay, Noverlay, argv[2]); 280 282 free (overlay); 281 283 -
trunk/Ohana/src/opihi/cmd.data/tvgrid.c
r7917 r13479 11 11 char format[16]; 12 12 Coords coords; 13 int Ximage, Nimage, N, Noverlay, NOVERLAY; 13 int kapa, N, Noverlay, NOVERLAY; 14 char *name; 14 15 Buffer *buf; 15 16 KiiOverlay *overlay; 16 17 17 Nimage = -1;18 name = NULL; 18 19 if ((N = get_argument (argc, argv, "-n"))) { 19 20 remove_argument (N, &argc, argv); 20 Nimage = atof(argv[N]);21 name = strcreate (argv[N]); 21 22 remove_argument (N, &argc, argv); 22 23 } 23 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 24 24 if (!GetImage (NULL, &kapa, name)) return (FALSE); 25 FREE (name); 26 25 27 if (argc != 3) { 26 28 gprint (GP_ERR, "USAGE: tvgrid (overlay) (buffer)\n"); … … 144 146 } 145 147 146 # if (0) 147 /* write the labels on the axes */ 148 dDEC = fabs(dec1 - dec0) / 100; 149 for (ra = dRA * ((int)(MIN(ra0, ra1)/dRA) + 1); ra < MAX(ra0, ra1); ra += dRA) { 150 RD_to_XY (&x0, &y0, ra + 0.1*dRA, MIN(dec0, dec1), &coords); 151 sprintf (label, format, ra); 152 sprintf (buffer, "%15s %20.10f %20.10f %20.10f %20.10f ", "TEXT", x0, y0, (double)(strlen(label) + 1), 0.0); 153 write (Ximage, buffer, 128); 154 write (Ximage, label, strlen(label) + 1); 155 RD_to_XY (&x0, &y0, ra, MIN(dec0, dec1), &coords); 156 for (dec = MIN(dec0, dec1) + dDEC; dec < MAX(dec0,dec1); dec += dDEC) { 157 RD_to_XY (&x1, &y1, ra, dec, &coords); 158 sprintf (buffer, "%15s %20.10f %20.10f %20.10f %20.10f ", "LINE", x0, y0, (x1 - x0), (y1 - y0)); 159 write (Ximage, buffer, 128); 160 x0 = x1; 161 y0 = y1; 162 } 163 } 164 # endif 165 166 KiiLoadOverlay (Ximage, overlay, Noverlay, argv[1]); 148 KiiLoadOverlay (kapa, overlay, Noverlay, argv[1]); 167 149 free (overlay); 168 150 -
trunk/Ohana/src/opihi/cmd.data/vload.c
r7917 r13479 4 4 5 5 int i, N, Noverlay; 6 int Ximage, Nimage, type; 6 int kapa, type; 7 char *name; 7 8 double dx, dy, size; 8 9 KiiOverlay *overlay; 9 10 Vector *vecx, *vecy; 10 11 11 Nimage = -1;12 name = NULL; 12 13 if ((N = get_argument (argc, argv, "-n"))) { 13 14 remove_argument (N, &argc, argv); 14 Nimage = atof(argv[N]);15 name = strcreate (argv[N]); 15 16 remove_argument (N, &argc, argv); 16 17 } 17 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 18 if (!GetImage (NULL, &kapa, name)) return (FALSE); 19 FREE (name); 18 20 19 21 type = KII_OVERLAY_BOX; … … 65 67 } 66 68 67 KiiLoadOverlay ( Ximage, overlay, Noverlay, argv[1]);69 KiiLoadOverlay (kapa, overlay, Noverlay, argv[1]); 68 70 free (overlay); 69 71 return (TRUE); -
trunk/Ohana/src/opihi/cmd.data/zplot.c
r7917 r13479 3 3 int zplot (int argc, char **argv) { 4 4 5 int i, N, Npts, Ngraph;5 int i, kapa, N, Npts; 6 6 float *in, *out; 7 7 double min, range; … … 9 9 Vector *xvec, *yvec, *zvec, Zvec; 10 10 11 Ngraph = -1; 12 if ((N = get_argument (argc, argv, "-n"))) { 13 remove_argument (N, &argc, argv); 14 Ngraph = atof (argv[N]); 15 remove_argument (N, &argc, argv); 16 } 17 if (!GetGraph (&graphmode, NULL, &Ngraph)) return (FALSE); 11 if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE); 18 12 19 13 if (argc != 6) { … … 51 45 graphmode.etype = 0; /* no errorbars */ 52 46 Npts = xvec[0].Nelements; 53 PrepPlotting (Npts, &graphmode); 54 55 PlotVector (Npts, xvec[0].elements); 56 PlotVector (Npts, yvec[0].elements); 57 PlotVector (Npts, Zvec.elements); 47 PlotVectorTriplet (kapa, Npts, xvec[0].elements, yvec[0].elements, Zvec.elements, &graphmode); 58 48 59 49 free (Zvec.elements); -
trunk/Ohana/src/opihi/dimm/dimm.c.in
r12280 r13479 50 50 /* add program-dependent exit functions here */ 51 51 void cleanup () { 52 QuitImage (); 53 QuitGraph (); 52 QuitKapa (); 54 53 return; 55 54 } -
trunk/Ohana/src/opihi/dvo/ImageSelection.c
r7917 r13479 20 20 21 21 if (RegionSelect) { 22 Ngraph = 0;23 if (!GetGraphData (&graphsky, NULL, &Ngraph)) {22 // how does this know which sky plot to use? 23 if (!GetGraphData (&graphsky, NULL, NULL)) { 24 24 gprint (GP_ERR, "region display not available\n"); 25 25 return (FALSE); -
trunk/Ohana/src/opihi/dvo/Makefile
r12842 r13479 21 21 $(SRC)/init.$(ARCH).o \ 22 22 $(SRC)/ImageOps.$(ARCH).o \ 23 $(SRC)/ImageSelection.$(ARCH).o \23 $(SRC)/ImageSelection.$(ARCH).o \ 24 24 $(SRC)/LoadImages.$(ARCH).o \ 25 25 $(SRC)/cmpReadFile.$(ARCH).o \ 26 $(SRC)/compare.$(ARCH).o \26 $(SRC)/compare.$(ARCH).o \ 27 27 $(SRC)/match_image.$(ARCH).o \ 28 $(SRC)/photometry.$(ARCH).o \28 $(SRC)/photometry.$(ARCH).o \ 29 29 $(SRC)/dvomisc.$(ARCH).o \ 30 30 $(SRC)/region_list.$(ARCH).o \ 31 $(SRC)/dvomisc.$(ARCH).o \ 32 $(SRC)/dbBooleanCond.$(ARCH).o \ 33 $(SRC)/dbCheckStack.$(ARCH).o \ 34 $(SRC)/dbCmdlineFields.$(ARCH).o \ 35 $(SRC)/dbExtractAverages.$(ARCH).o \ 36 $(SRC)/dbExtractMeasures.$(ARCH).o \ 37 $(SRC)/dbFields.$(ARCH).o \ 38 $(SRC)/dbRPN.$(ARCH).o \ 39 $(SRC)/dbStackMath.$(ARCH).o \ 40 $(SRC)/dbStackOps.$(ARCH).o \ 31 41 $(SRC)/dvo.$(ARCH).o 32 42 -
trunk/Ohana/src/opihi/dvo/avextract.c
r12332 r13479 3 3 int avextract (int argc, char **argv) { 4 4 5 int i, j, m, N, NPTS, param;5 int i, j, n, m, Npts, NPTS, last, Nfields, Nreturn, Ncstack, Nstack; 6 6 int Nsecfilt, mode; 7 7 char *RegionName, *RegionList, *p; 8 char **cstack; 9 float *values; 8 10 9 11 Catalog catalog; 10 12 SkyList *skylist; 11 13 PhotCode *code; 12 Vector *vec; 14 Vector **vec; 15 16 dbField *fields; 17 dbStack *stack; 13 18 14 19 /* defaults */ … … 24 29 Nsecfilt = GetPhotcodeNsecfilt (); 25 30 26 / * interpret command-line options */27 SetSelectionParam (0);31 // remove skyregion options 32 // XXX this needs to explicitly handle -qregion and -skyregion 28 33 if (!SetRegionSelection (&argc, argv, &RegionName, &RegionList)) goto escape; 29 if (!SetPhotSelections (&argc, argv, 1)) goto usage;30 34 31 /* interpret required command-line arguments: mextract (value) */ 32 if (argc != 2) { goto usage; } 33 param = GetAverageParam (argv[1]); 34 if (param == AVE_ZERO) { 35 if (!GetPhotcodeInfo (argv[1], &code, &mode)) { 36 GetAverageParamHelp (); 37 goto escape; 38 } 39 param = AVE_MAG; 40 for (p = argv[1]; *p != 0; p++) { 41 if (*p == '.') *p = ':'; 42 } 43 } 44 if (!TestPhotSelections (&code, &mode, param)) goto escape; 35 // command-line is of the form: avextract field,field, field [where (field op value)...] 36 37 // parse the fields to be extracted and returned 38 fields = dbCmdlineFields (argc, argv, DVO_TABLE_AVERAGE, &last, &Nfields); 39 if (fields == NULL) return (FALSE); 40 41 // parse the remainder of the line as a boolean math expression 42 cstack = isolate_elements (argc-last, &argv[last], &Ncstack); 43 44 // construct the db Boolean math stack (frees cstack) 45 stack = dbRPN (Ncstack, cstack, &Nstack); 46 47 Nreturn = Nfields; 48 dbCheckStack (stack, Nstack, DVO_TABLE_AVERAGE, &fields, &Nfields); 49 // XXX handle errors 45 50 46 51 /* load region corresponding to selection above */ 47 52 if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape; 48 53 49 /* create storage vector */ 50 N = 0; 54 /* create output storage vectors */ 55 ALLOCATE (values, float, Nfields); 56 ALLOCATE (vec, Vector *, Nreturn); 57 for (i = 0; i < Nreturn; i++) { 58 if ((vec[i] = SelectVector (fields[i].name, ANYVECTOR, TRUE)) == NULL) goto escape; 59 } 60 61 Npts = 0; 51 62 NPTS = 1; 52 if ((vec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto escape;53 63 54 64 // XXX need to add interrupt test to this loop … … 68 78 for (j = 0; j < catalog.Naverage; j++) { 69 79 m = catalog.average[j].offset; 70 vec[0].elements[N] = ExtractAverages (code, mode, &catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], param); 71 N++; 72 CHECK_REALLOCATE (vec[0].elements, float, NPTS, N, 2000); 80 // extract the relevant values 81 // XXX for measure values, this could be optimized for one loop over measures... 82 for (n = 0; n < Nfields; n++) { 83 values[n] = dbExtractAverages (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]); 84 } 85 // test the conditional statement 86 if (!dbBooleanCond (stack, Nstack, values)) continue; 87 for (n = 0; n < Nreturn; n++) { 88 vec[n][0].elements[Npts] = values[n]; 89 } 90 Npts++; 91 if (Npts >= NPTS) { 92 NPTS += 2000; 93 for (n = 0; n < Nreturn; n++) { 94 REALLOCATE (vec[n][0].elements, float, NPTS); 95 } 96 } 73 97 } 74 98 dvo_catalog_free (&catalog); 75 99 } 76 vec[0].Nelements = N; 77 REALLOCATE (vec[0].elements, float, MAX(1,N)); 100 for (n = 0; n < Nreturn; n++) { 101 vec[n][0].Nelements = Npts; 102 REALLOCATE (vec[n][0].elements, float, MAX(1,Npts)); 103 } 104 105 // XXX free fields and stack 78 106 79 107 SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL))); -
trunk/Ohana/src/opihi/dvo/catalog.c
r12332 r13479 28 28 int Ngraph; 29 29 30 Ngraph = 0; 31 if (!GetGraph (&graphmode, NULL, &Ngraph)) return (FALSE); 30 if (!GetGraph (&graphmode, NULL, NULL)) return (FALSE); 32 31 33 32 VarConfig ("GSCDIR", "%s", gscdir); … … 392 391 PrepPlotting (N, &graphmode); 393 392 394 PlotVector (N, Xvec.elements );395 PlotVector (N, Yvec.elements );396 PlotVector (N, Zvec.elements );393 PlotVector (N, Xvec.elements, "x"); 394 PlotVector (N, Yvec.elements, "y"); 395 PlotVector (N, Zvec.elements, "z"); 397 396 398 397 free (Xvec.elements); -
trunk/Ohana/src/opihi/dvo/cmpload.c
r7917 r13479 8 8 int i, Noverlay, NOVERLAY, Nstar, N, Nin, Nextra, Objtype, type; 9 9 int doneread, done, Nskip, Nbytes, nbytes, Ninstar; 10 char *c, *c2 ;10 char *c, *c2, *name; 11 11 double dtmp; 12 12 FILE *f; 13 13 char *buffer; 14 int Ximage, Nimage;14 int kapa; 15 15 Header header; 16 16 KiiOverlay *overlay; 17 17 18 Nimage = -1;18 name = NULL; 19 19 if ((N = get_argument (argc, argv, "-n"))) { 20 20 remove_argument (N, &argc, argv); 21 Nimage = atof(argv[N]);21 name = strcreate (argv[N]); 22 22 remove_argument (N, &argc, argv); 23 23 } 24 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 24 if (!GetImage (NULL, &kapa, name)) return (FALSE); 25 FREE (name); 25 26 26 27 Objtype = 0; … … 131 132 fclose (f); 132 133 133 KiiLoadOverlay ( Ximage, overlay, Noverlay, argv[1]);134 KiiLoadOverlay (kapa, overlay, Noverlay, argv[1]); 134 135 free (overlay); 135 136 -
trunk/Ohana/src/opihi/dvo/dmt.c
r12332 r13479 4 4 int dmt (int argc, char **argv) { 5 5 6 int i, m, k, N, Ngraph, SaveVectors;6 int i, m, k, N, kapa, SaveVectors; 7 7 int Nsec, Nsecfilt, NPTS; 8 8 double Radius; … … 38 38 } 39 39 40 Ngraph = 0; 41 if (!GetGraphData (&graphsky, NULL, &Ngraph)) return (FALSE); 40 // XXX this needs to be fixed: how to access different graphs at once? 41 gprint (GP_ERR, "ERROR: this function is currently disabled\n"); 42 return (FALSE); 43 if (!GetGraphData (&graphsky, &kapa, NULL)) return (FALSE); 42 44 if (!GetGraph (&graphmode, NULL, NULL)) return (FALSE); 43 45 … … 142 144 } else { 143 145 graphmode.style = 2; /* set style to points */ 144 PrepPlotting (N, &graphmode); 145 146 PlotVector (N, Xvec.elements); 147 PlotVector (N, Yvec.elements); 146 PlotVector (kapa, N, Xvec.elements, Yvec.elements, &graphmode); 148 147 149 148 free (Xvec.elements); -
trunk/Ohana/src/opihi/dvo/dvo.c.in
r12280 r13479 55 55 /* add program-dependent exit functions here */ 56 56 void cleanup () { 57 QuitImage (); 58 QuitGraph (); 57 QuitKapa (); 59 58 return; 60 59 } -
trunk/Ohana/src/opihi/dvo/extract.c
r12332 r13479 31 31 RegionFile *regions; 32 32 33 Ngraph = 0; 34 if (!GetGraphData (&graphmode, NULL, &Ngraph)) return (FALSE); 33 if (!GetGraphData (&graphmode, NULL, NULL)) return (FALSE); 35 34 if (!InitPhotcodes ()) return (FALSE); 36 35 -
trunk/Ohana/src/opihi/dvo/fitcolors.c
r12332 r13479 20 20 float *out, *colorFit, *deltaFit, dColor, C0, C1; 21 21 float minDelta, maxDelta, minColor, maxColor; 22 int fd, Npx, Npy, NPX, NPY, Nplot, PLOT;22 int kapa, Npx, Npy, NPX, NPY, Nplot, PLOT; 23 23 Graphdata graphdata; 24 24 KapaSection section; … … 86 86 87 87 if (PLOT) { 88 if (!GetGraph (&graphdata, & fd, NULL)) return (FALSE);88 if (!GetGraph (&graphdata, &kapa, NULL)) return (FALSE); 89 89 Nplot = 0; 90 90 Npx = Npy = 0; … … 95 95 graphdata.style = 2; 96 96 graphdata.ptype = 2; 97 KapaClear (fd, TRUE);98 KapaSetFont ( fd, "helvetica", 14);97 KapaClearSections (kapa); 98 KapaSetFont (kapa, "helvetica", 14); 99 99 100 100 ALLOCATE (colorFit, float, 11); … … 301 301 strcpy (graphdata.labels, "1100"); 302 302 } 303 KapaSetSection ( fd, §ion);304 KapaSetLimits ( fd, &graphdata);305 KapaBox ( fd, &graphdata);306 KapaPrepPlot ( fd, Npts, &graphdata);307 KapaPlotVector ( fd, Npts, xvec[0].elements);308 KapaPlotVector ( fd, Npts, yvec[0].elements);303 KapaSetSection (kapa, §ion); 304 KapaSetLimits (kapa, &graphdata); 305 KapaBox (kapa, &graphdata); 306 KapaPrepPlot (kapa, Npts, &graphdata); 307 KapaPlotVector (kapa, Npts, xvec[0].elements, "x"); 308 KapaPlotVector (kapa, Npts, yvec[0].elements, "y"); 309 309 310 310 for (i = 0; i < 11; i++) { … … 313 313 graphdata.style = 0; 314 314 graphdata.color = KapaColorByName ("red"); 315 KapaPrepPlot ( fd, 11, &graphdata);316 KapaPlotVector ( fd, 11, colorFit);317 KapaPlotVector ( fd, 11, deltaFit);318 319 KapaSetFont ( fd, "helvetica", 8);315 KapaPrepPlot (kapa, 11, &graphdata); 316 KapaPlotVector (kapa, 11, colorFit, "x"); 317 KapaPlotVector (kapa, 11, deltaFit, "y"); 318 319 KapaSetFont (kapa, "helvetica", 8); 320 320 sprintf (label, "%s", code[0][0].name); 321 KapaSendTextline ( fd, label, 0.2*maxColor + 0.8*minColor, 0.8*maxDelta + 0.2*minDelta, 0.0);321 KapaSendTextline (kapa, label, 0.2*maxColor + 0.8*minColor, 0.8*maxDelta + 0.2*minDelta, 0.0); 322 322 sprintf (label, "%s", code[1][0].name); 323 KapaSendTextline ( fd, label, 0.2*maxColor + 0.8*minColor, 0.2*maxDelta + 0.8*minDelta, 0.0);324 KapaSetFont ( fd, "helvetica", 14);323 KapaSendTextline (kapa, label, 0.2*maxColor + 0.8*minColor, 0.2*maxDelta + 0.8*minDelta, 0.0); 324 KapaSetFont (kapa, "helvetica", 14); 325 325 326 326 graphdata.style = 2; … … 336 336 Npy = 0; 337 337 sprintf (filename, "%s.%02d.png", plotname, Nplot); 338 KapaPNG ( fd, filename);339 KapaClear (fd, TRUE);338 KapaPNG (kapa, filename); 339 KapaClearSections (kapa); 340 340 Nplot++; 341 341 } -
trunk/Ohana/src/opihi/dvo/fitsed.c
r12332 r13479 31 31 float *fitmags, *fiterrs, *wavecode, *vegaToAB; 32 32 float color; 33 double X, Y ;34 int fd, PLOT;33 double X, Y, ZP, RA, DEC; 34 int kapa, PLOT; 35 35 int Nrow, NROW, idx, Nfilter, start, row; 36 36 unsigned short colorP, colorM, code, USNOred, USNOblu; … … 157 157 158 158 if (PLOT) { 159 if (!GetGraph (&graphdata, & fd, NULL)) return (FALSE);159 if (!GetGraph (&graphdata, &kapa, NULL)) return (FALSE); 160 160 SetLimitsRaw (wavecode, NULL, Nfilter, &graphdata); 161 161 graphdata.style = 2; 162 162 graphdata.ptype = 2; 163 KapaClear (fd, TRUE);163 KapaClearSections (kapa); 164 164 magSection.name = strcreate ("mag"); 165 165 magSection.x = 0; … … 173 173 resSection.dy = 0.5; 174 174 175 KapaSetFont ( fd, "helvetica", 14);175 KapaSetFont (kapa, "helvetica", 14); 176 176 ALLOCATE (fitmags, float, Nfilter); 177 177 ALLOCATE (fiterrs, float, Nfilter); … … 261 261 SWAP (graphdata.ymin, graphdata.ymax); 262 262 263 KapaClear (fd, TRUE);264 KapaSetSection ( fd, &magSection);265 KapaSetLimits ( fd, &graphdata);266 KapaBox ( fd, &graphdata);263 KapaClearSections (kapa); 264 KapaSetSection (kapa, &magSection); 265 KapaSetLimits (kapa, &graphdata); 266 KapaBox (kapa, &graphdata); 267 267 graphdata.color = KapaColorByName ("blue"); 268 268 graphdata.etype = 0; 269 KapaPrepPlot ( fd, Nfilter, &graphdata);270 KapaPlotVector ( fd, Nfilter, wavecode);271 KapaPlotVector ( fd, Nfilter, SEDtable[minFit.row][0].mags);269 KapaPrepPlot (kapa, Nfilter, &graphdata); 270 KapaPlotVector (kapa, Nfilter, wavecode, "x"); 271 KapaPlotVector (kapa, Nfilter, SEDtable[minFit.row][0].mags, "y"); 272 272 graphdata.color = KapaColorByName ("red"); 273 273 graphdata.etype = 1; … … 279 279 fiterrs[j] = sourceError.mags[j]; 280 280 } 281 KapaPrepPlot ( fd, Nfilter, &graphdata);282 KapaPlotVector ( fd, Nfilter, wavecode);283 KapaPlotVector ( fd, Nfilter, fitmags);284 KapaPlotVector ( fd, Nfilter, fiterrs);285 KapaPlotVector ( fd, Nfilter, fiterrs);286 KapaSendLabel ( fd, "model,fit (mags)", 1);281 KapaPrepPlot (kapa, Nfilter, &graphdata); 282 KapaPlotVector (kapa, Nfilter, wavecode, "x"); 283 KapaPlotVector (kapa, Nfilter, fitmags, "y"); 284 KapaPlotVector (kapa, Nfilter, fiterrs, "dym"); 285 KapaPlotVector (kapa, Nfilter, fiterrs, "dyp"); 286 KapaSendLabel (kapa, "model,fit (mags)", 1); 287 287 288 288 sprintf (line, "star: %10.6f %10.6f T: %5.0fK A_V|: %4.2f M_D|: %5.2f &sc&h^2|: %5.2f", 289 289 catalog.average[i].R, catalog.average[i].D, 290 290 SEDtable[minFit.row][0].Temp, SEDtable[minFit.row][0].Av, minFit.Md, minFit.chisq); 291 KapaSendLabel ( fd, line, 2);292 KapaSendLabel ( fd, "model,fit (mags)", 1);293 294 KapaSetSection ( fd, &resSection);291 KapaSendLabel (kapa, line, 2); 292 KapaSendLabel (kapa, "model,fit (mags)", 1); 293 294 KapaSetSection (kapa, &resSection); 295 295 graphdata.ymin = -1.0; 296 296 graphdata.ymax = +1.0; 297 KapaSetLimits ( fd, &graphdata);298 KapaBox ( fd, &graphdata);297 KapaSetLimits (kapa, &graphdata); 298 KapaBox (kapa, &graphdata); 299 299 graphdata.color = KapaColorByName ("red"); 300 300 graphdata.etype = 1; … … 307 307 fiterrs[j] = sourceError.mags[j]; 308 308 } 309 KapaPrepPlot ( fd, Nfilter, &graphdata);310 KapaPlotVector ( fd, Nfilter, wavecode);311 KapaPlotVector ( fd, Nfilter, fitmags);312 KapaPlotVector ( fd, Nfilter, fiterrs);313 KapaPlotVector ( fd, Nfilter, fiterrs);314 KapaSendLabel ( fd, "wavelength (nm)", 0);315 KapaSendLabel ( fd, "resid (mags)", 1);316 317 KiiCursorOn ( fd);318 while (KiiCursorRead ( fd, &X, &Y, key)) {309 KapaPrepPlot (kapa, Nfilter, &graphdata); 310 KapaPlotVector (kapa, Nfilter, wavecode, "x"); 311 KapaPlotVector (kapa, Nfilter, fitmags, "y"); 312 KapaPlotVector (kapa, Nfilter, fiterrs, "dym"); 313 KapaPlotVector (kapa, Nfilter, fiterrs, "dyp"); 314 KapaSendLabel (kapa, "wavelength (nm)", 0); 315 KapaSendLabel (kapa, "resid (mags)", 1); 316 317 KiiCursorOn (kapa); 318 while (KiiCursorRead (kapa, &X, &Y, &ZP, &RA, &DEC, key)) { 319 319 gprint (GP_ERR, "window: %f %f (%s)\n", X, Y, key); 320 320 if (!strcasecmp (key, "Q")) { 321 KiiCursorOff ( fd);321 KiiCursorOff (kapa); 322 322 break; 323 323 } 324 324 if (!strcasecmp (key, "ESCAPE")) { 325 KiiCursorOff ( fd);325 KiiCursorOff (kapa); 326 326 goto escape; 327 327 } -
trunk/Ohana/src/opihi/dvo/images.c
r12753 r13479 14 14 int WITH_MOSAIC, SOLO_MOSAIC, HIDDEN; 15 15 time_t tzero, tend; 16 int N, NPTS, n, npts, Npts ;16 int N, NPTS, n, npts, Npts, kapa; 17 17 Vector Xvec, Yvec; 18 18 double r[8], d[8], x[8], y[8], Rmin, Rmax, Rmid, trange, Radius; … … 22 22 int typehash; 23 23 24 if (!style_args (&graphmode, &argc, argv, 0)) return FALSE;24 if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE; 25 25 26 26 WITH_MOSAIC = FALSE; … … 101 101 return (FALSE); 102 102 } 103 SetGraph (graphmode);104 103 105 104 /* it is not an error for the database not to have any images */ … … 282 281 graphmode.ptype = 100; /* connect pairs of points */ 283 282 graphmode.etype = 0; 284 PrepPlotting (N, &graphmode); 285 PlotVector (N, Xvec.elements); 286 PlotVector (N, Yvec.elements); 283 PlotVectorPair (kapa, N, Xvec.elements, Yvec.elements, &graphmode); 287 284 } 288 285 -
trunk/Ohana/src/opihi/dvo/imbox.c
r12332 r13479 3 3 int imbox (int argc, char **argv) { 4 4 5 int j, Nskip, status, InPic, flipped;5 int j, kapa, Nskip, status, InPic, flipped; 6 6 Vector Xvec, Yvec; 7 7 double r, d, x[4], y[4], Rmin, Rmax, Rmid; … … 12 12 FILE *f; 13 13 14 if (!style_args (&graphmode, &argc, argv, 0)) return FALSE;14 if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE; 15 15 16 16 if (argc != 2) { … … 18 18 return (FALSE); 19 19 } 20 SetGraph (graphmode);21 20 22 21 f = fopen (argv[1], "r"); … … 77 76 graphmode.ptype = 100; /* connect pairs of points */ 78 77 graphmode.etype = 0; 79 PrepPlotting (8, &graphmode); 80 PlotVector (8, Xvec.elements); 81 PlotVector (8, Yvec.elements); 78 PlotVectorPair (kapa, 8, Xvec.elements, Yvec.elements, &graphmode); 82 79 } 83 80 skip: -
trunk/Ohana/src/opihi/dvo/imdense.c
r7917 r13479 5 5 6 6 long A, B; 7 int i, N, Nimage, status, NPTS, Ngraph;7 int i, kapa, N, Nimage, status, NPTS; 8 8 double r, d, x, y, Rmin, Rmax; 9 9 Vector Xvec, Yvec; 10 10 Image *image; 11 11 Graphdata graphmode; 12 13 if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE; 12 14 13 15 /* need options to list only images in region and only images in a time range */ … … 17 19 return (FALSE); 18 20 } 19 Ngraph = 0;20 if (!GetGraph (&graphmode, NULL, &Ngraph)) return (FALSE);21 21 22 22 if ((image = LoadImages (&Nimage)) == NULL) return (FALSE); … … 62 62 graphmode.style = 2; /* points */ 63 63 graphmode.etype = 0; 64 PrepPlotting (N, &graphmode); 65 PlotVector (N, Xvec.elements); 66 PlotVector (N, Yvec.elements); 64 PlotVectorPair (kapa, N, Xvec.elements, Yvec.elements, &graphmode); 67 65 } 68 66 -
trunk/Ohana/src/opihi/dvo/imextract.c
r12729 r13479 5 5 int imextract (int argc, char **argv) { 6 6 7 int i, j, Nimage, mode, N, Ngraph,PhotcodeSelect;7 int i, j, Nimage, mode, N, PhotcodeSelect; 8 8 int TimeSelect, RegionSelect, *subset, Nsubset, TimeFormat, FlagSelect, FlagValue; 9 9 double x, y, ra, dec, t, trange; … … 15 15 Vector *vec; 16 16 17 Ngraph = 0; 18 if (!GetGraphData (&graphsky, NULL, &Ngraph)) return (FALSE); 17 if (!GetGraphData (&graphsky, NULL, NULL)) return (FALSE); 19 18 if (!InitPhotcodes ()) return (FALSE); 20 19 -
trunk/Ohana/src/opihi/dvo/imlist.c
r12332 r13479 8 8 double r, d, trange, t; 9 9 char *name; 10 int Ngraph;11 10 Image *image; 12 11 Graphdata graphmode; 13 12 PhotCode *PhotcodeValue; 14 13 15 Ngraph = 0; 16 if (!GetGraphData (&graphmode, NULL, &Ngraph)) return (FALSE); 14 if (!GetGraphData (&graphmode, NULL, NULL)) return (FALSE); 17 15 18 16 TimeSelect = FALSE; -
trunk/Ohana/src/opihi/dvo/imstats.c
r12332 r13479 3 3 int imstats (int argc, char **argv) { 4 4 5 int i, Nimage, N;6 int Mcal, AutoLimits , Ngraph;5 int i, kapa, Nimage, N; 6 int Mcal, AutoLimits; 7 7 double r, d; 8 8 Image *image; … … 10 10 Graphdata graphmode; 11 11 12 Ngraph = -1; 13 if ((N = get_argument (argc, argv, "-n"))) { 14 remove_argument (N, &argc, argv); 15 Ngraph = atof (argv[N]); 16 remove_argument (N, &argc, argv); 17 } 18 if (!GetGraph (&graphmode, NULL, &Ngraph)) return (FALSE); 12 if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE); 19 13 20 14 Mcal = TRUE; … … 60 54 graphmode.style = 2; 61 55 graphmode.etype = 0; 62 PrepPlotting (Nimage, &graphmode); 63 PlotVector (Nimage, Xvec.elements); 64 PlotVector (Nimage, Yvec.elements); 56 PlotVectorPair (kapa, Nimage, Xvec.elements, Yvec.elements, &graphmode); 65 57 66 58 free (Xvec.elements); -
trunk/Ohana/src/opihi/dvo/lcat.c
r7917 r13479 8 8 struct stat filestat; 9 9 Graphdata graphmode; 10 int Ngraph;11 10 SkyTable *sky; 12 11 SkyList *skylist; 13 12 14 Ngraph = 0; 15 if (!GetGraphData (&graphmode, NULL, &Ngraph)) return (FALSE); 13 if (!GetGraphData (&graphmode, NULL, NULL)) return (FALSE); 16 14 17 15 ShowAll = FALSE; -
trunk/Ohana/src/opihi/dvo/lcurve.c
r12332 r13479 6 6 double Ra, Dec, Radius, Radius2, r; 7 7 float *RA, *DEC; 8 int Ngraph, Xgraph, TimeFormat;8 int kapa, TimeFormat; 9 9 int Nstars, found, AutoLimits, ErrorBars, GalMag, AbsPhot, SaveVectors; 10 10 int i, j, m, N, NPTS, *N1; … … 19 19 20 20 if (!InitPhotcodes ()) return (FALSE); 21 22 Ngraph = -1; 23 if ((N = get_argument (argc, argv, "-n"))) { 24 remove_argument (N, &argc, argv); 25 Ngraph = atof (argv[N]); 26 remove_argument (N, &argc, argv); 27 } 28 if (!GetGraph (&graphmode, &Xgraph, &Ngraph)) return (FALSE); 21 if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE); 29 22 30 23 AutoLimits = FALSE; … … 161 154 graphmode.etype = 0; 162 155 163 PrepPlotting (N, &graphmode);164 PlotVector (N, Xvec.elements);165 PlotVector (N, Yvec.elements);156 KapaPrepPlot (kapa, N, &graphmode); 157 KapaPlotVector (kapa, N, Xvec.elements, "x"); 158 KapaPlotVector (kapa, N, Yvec.elements, "y"); 166 159 if (ErrorBars) { 167 PlotVector (N, dYvec.elements);168 PlotVector (N, dYvec.elements);160 KapaPlotVector (kapa, N, dYvec.elements, "dym"); 161 KapaPlotVector (kapa, N, dYvec.elements, "dyp"); 169 162 } 170 163 … … 175 168 timeptr[0].tm_year, timeptr[0].tm_mon+1, timeptr[0].tm_mday); 176 169 free (p); 177 KapaSendLabel ( Xgraph, string, 0);170 KapaSendLabel (kapa, string, 0); 178 171 179 172 free (RA); -
trunk/Ohana/src/opihi/dvo/mextract.c
r12332 r13479 3 3 int mextract (int argc, char **argv) { 4 4 5 int i, j, k, m, N, N1, NPTS;5 int i, j, k, m, n, N, N1, Npts, NPTS, last, Nfields, Nreturn, Ncstack, Nstack; 6 6 int param, mode, Nsecfilt; 7 7 char *RegionName, *RegionList, *p; 8 8 double *M1; 9 char **cstack; 10 float *values; 9 11 10 PhotCode *code;11 12 Catalog catalog; 12 13 SkyList *skylist; 13 Vector *vec; 14 PhotCode *code; 15 Vector **vec; 16 17 dbField *fields; 18 dbStack *stack; 14 19 15 20 /* defaults */ … … 24 29 if (!InitPhotcodes ()) goto escape; 25 30 Nsecfilt = GetPhotcodeNsecfilt (); 31 32 // init locally static variables (time refs) 33 dbExtractMeasuresInit(); 26 34 27 / * interpret command-line options */28 SetSelectionParam (0);35 // remove skyregion options 36 // XXX this needs to explicitly handle -qregion and -skyregion 29 37 if (!SetRegionSelection (&argc, argv, &RegionName, &RegionList)) goto escape; 30 if (!SetPhotSelections (&argc, argv, 1)) goto usage;31 38 32 /* interpret required command-line arguments: mextract (value) */ 33 if (argc != 2) goto usage; 34 param = GetMeasureParam (argv[1]); 35 if (param == MEAS_ZERO) { 36 if (!GetPhotcodeInfo (argv[1], &code, &mode)) { 37 GetMeasureParam ("help"); 38 goto escape; 39 } 40 param = MEAS_MAG; 41 for (p = argv[1]; *p != 0; p++) { 42 if (*p == '.') *p = ':'; 43 } 44 } 45 if (!TestPhotSelections (&code, &mode, MEAS_ZERO)) goto escape; 39 // command-line is of the form: avextract field,field, field [where (field op value)...] 40 41 // parse the fields to be extracted and returned 42 fields = dbCmdlineFields (argc, argv, DVO_TABLE_MEASURE, &last, &Nfields); 43 if (fields == NULL) return (FALSE); 44 45 // parse the remainder of the line as a boolean math expression 46 cstack = isolate_elements (argc-last, &argv[last], &Ncstack); 47 48 // construct the db Boolean math stack (frees cstack) 49 stack = dbRPN (Ncstack, cstack, &Nstack); 50 51 Nreturn = Nfields; 52 dbCheckStack (stack, Nstack, DVO_TABLE_MEASURE, &fields, &Nfields); 53 // XXX handle errors 46 54 47 55 /* load region corresponding to selection above */ 48 56 if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape; 49 if (!SetImageSelection (param, ((RegionName == NULL) && (RegionList == NULL)))) goto escape; 57 58 // XXX is this still needed? 59 // if (!SetImageSelection (param, ((RegionName == NULL) && (RegionList == NULL)))) goto escape; 50 60 51 61 /* create storage vector */ 52 N = 0; 62 ALLOCATE (values, float, Nfields); 63 ALLOCATE (vec, Vector *, Nreturn); 64 for (i = 0; i < Nreturn; i++) { 65 if ((vec[i] = SelectVector (fields[i].name, ANYVECTOR, TRUE)) == NULL) goto escape; 66 } 67 68 Npts = 0; 53 69 NPTS = 1; 54 if ((vec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto escape;55 70 71 // XXX need to add interrupt test to this loop 56 72 for (i = 0; i < skylist[0].Nregions; i++) { 73 /* lock, load, unlock catalog */ 57 74 catalog.filename = skylist[0].filename[i]; 58 75 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF; … … 69 86 70 87 for (j = 0; j < catalog.Naverage; j++) { 71 M1 = NULL;72 88 m = catalog.average[j].offset; 73 M1 = ExtractMeasures (code, mode, &catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &N1, param); 74 for (k = 0; k < N1; k++) { 75 vec[0].elements[N] = M1[k]; 76 N++; 77 CHECK_REALLOCATE (vec[0].elements, float, NPTS, N, 2000); 89 for (k = 0; k < catalog.average[j].Nm; k++, m++) { 90 91 // extract the relevant values for this measurement 92 for (n = 0; n < Nfields; n++) { 93 values[n] = dbExtractMeasures (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]); 94 } 95 96 // test the conditional statement 97 if (!dbBooleanCond (stack, Nstack, values)) continue; 98 for (n = 0; n < Nreturn; n++) { 99 vec[n][0].elements[Npts] = values[n]; 100 } 101 Npts++; 102 if (Npts >= NPTS) { 103 NPTS += 2000; 104 for (n = 0; n < Nreturn; n++) { 105 REALLOCATE (vec[n][0].elements, float, NPTS); 106 } 107 } 78 108 } 79 if (M1 != NULL) free (M1);80 109 } 81 110 dvo_catalog_free (&catalog); 82 111 } 83 vec[0].Nelements = N; 84 REALLOCATE (vec[0].elements, float, MAX(1,N)); 112 for (n = 0; n < Nreturn; n++) { 113 vec[n][0].Nelements = Npts; 114 REALLOCATE (vec[n][0].elements, float, MAX(1,Npts)); 115 } 116 117 // XXX free fields and stack 85 118 86 119 FreeImageSelection (); -
trunk/Ohana/src/opihi/dvo/paverage.c
r12332 r13479 5 5 6 6 FILE *f; 7 int i, j, Narg, Npts, NPTS, status, VERBOSE;7 int i, j, kapa, Narg, Npts, NPTS, status, VERBOSE; 8 8 int Nsecfilt, Nsec; 9 9 double Mz, Mr, mag; … … 23 23 Nsecfilt = GetPhotcodeNsecfilt (); 24 24 25 if (!style_args (&graphmode, &argc, argv, 0)) return FALSE;25 if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE; 26 26 27 27 f = (FILE *) NULL; … … 82 82 return (FALSE); 83 83 } 84 SetGraph (graphmode);85 84 graphmode.style = 2; /* set style to points */ 86 85 graphmode.size = -1; /* point size determined by Zvec */ … … 141 140 } 142 141 if (Npts > NCHUNK) { 143 PlotVectorTriplet ( Npts, Xvec, Yvec, Zvec, &graphmode);142 PlotVectorTriplet (kapa, Npts, Xvec, Yvec, Zvec, &graphmode); 144 143 Npts = 0; 145 144 } … … 147 146 dvo_catalog_free (&catalog); 148 147 } 149 if (Npts > 0) PlotVectorTriplet ( Npts, Xvec, Yvec, Zvec, &graphmode);148 if (Npts > 0) PlotVectorTriplet (kapa, Npts, Xvec, Yvec, Zvec, &graphmode); 150 149 151 150 free (Xvec); -
trunk/Ohana/src/opihi/dvo/pcat.c
r7917 r13479 6 6 7 7 double Radius; 8 int i, j, N, Nregions, ShowAll, NPTS, Npts, leftside;8 int i, j, kapa, N, Nregions, ShowAll, NPTS, Npts, leftside; 9 9 RegionFile *regions; 10 10 char filename[128]; … … 14 14 double X[4], Y[4], Rmin, Rmax, Rmid; 15 15 char catdir[256]; 16 int Ngraph,VERBOSE;16 int VERBOSE; 17 17 18 18 VarConfig ("CATDIR", "%s", catdir); … … 33 33 return (FALSE); 34 34 } 35 Ngraph = 0; 36 if (!GetGraph (&graphmode, NULL, &Ngraph)) return (FALSE); 35 if (!GetGraph (&graphmode, &kapa, NULL)) return (FALSE); 37 36 38 37 Radius = MAX (fabs(graphmode.xmax), fabs(graphmode.ymax)); … … 84 83 graphmode.ptype = 100; /* connect pairs of points */ 85 84 graphmode.etype = 0; 86 PrepPlotting (Npts, &graphmode); 87 PlotVector (Npts, Xvec.elements); 88 PlotVector (Npts, Yvec.elements); 85 PlotVectorPair (kapa, Npts, Xvec.elements, Yvec.elements, &graphmode); 89 86 } 90 87 -
trunk/Ohana/src/opihi/dvo/photometry.c
r12730 r13479 174 174 } 175 175 176 // XXX moved to dbFields 177 # if (0) 176 178 int GetMagMode (char *string) { 177 179 … … 188 190 return (mode); 189 191 } 192 # endif 190 193 191 194 int GetMeasureParam (char *parname) { -
trunk/Ohana/src/opihi/dvo/pmeasure.c
r12332 r13479 5 5 6 6 FILE *f; 7 int i, j, k, m, Narg, Npts, NPTS, status, VERBOSE;7 int i, j, k, m, kapa, Narg, Npts, NPTS, status, VERBOSE; 8 8 double Mz, Mr, mag; 9 9 double Radius, Rmin, Rmax, R, D; … … 19 19 20 20 if (!InitPhotcodes ()) return (FALSE); 21 if (!style_args (&graphmode, &argc, argv, 0)) return FALSE;21 if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE; 22 22 23 23 f = (FILE *) NULL; … … 75 75 return (FALSE); 76 76 } 77 SetGraph (graphmode);78 77 graphmode.style = 2; /* set style to points */ 79 78 graphmode.size = -1; /* point size determined by Zvec */ … … 144 143 } 145 144 if (Npts > NCHUNK) { 146 PlotVectorTriplet ( Npts, Xvec, Yvec, Zvec, &graphmode);145 PlotVectorTriplet (kapa, Npts, Xvec, Yvec, Zvec, &graphmode); 147 146 Npts = 0; 148 147 } … … 151 150 dvo_catalog_free (&catalog); 152 151 } 153 if (Npts > 0) PlotVectorTriplet ( Npts, Xvec, Yvec, Zvec, &graphmode);152 if (Npts > 0) PlotVectorTriplet (kapa, Npts, Xvec, Yvec, Zvec, &graphmode); 154 153 155 154 free (Xvec); -
trunk/Ohana/src/opihi/dvo/procks.c
r7917 r13479 16 16 FILE *f; 17 17 Vector Xvec, Yvec; 18 int i, j, N, NROCKS;18 int kapa, i, j, N, NROCKS; 19 19 int N0, N1, SpeedClip, Reload; 20 20 unsigned int t0, t1; … … 23 23 Graphdata graphmode; 24 24 char rockcat[256]; 25 int Ngraph;26 25 27 Ngraph = 0;28 26 VarConfig ("ROCK_CATALOG", "%s", rockcat); 29 if (!GetGraph (&graphmode, NULL, &Ngraph)) return (FALSE);27 if (!GetGraph (&graphmode, &kapa, NULL)) return (FALSE); 30 28 31 29 f = (FILE *) NULL; … … 115 113 graphmode.style = 2; /* set style to points */ 116 114 graphmode.etype = 0; /* no errorbars */ 117 PrepPlotting (N, &graphmode); 118 119 PlotVector (N, Xvec.elements); 120 PlotVector (N, Yvec.elements); 115 PlotVectorPair (kapa, N, Xvec.elements, Yvec.elements, &graphmode); 121 116 122 117 /* now plot vectors between two extrema */ … … 148 143 graphmode.ptype = 100; /* connect pairs */ 149 144 graphmode.etype = 0; /* no errorbars */ 150 PrepPlotting (N, &graphmode); 151 152 PlotVector (N, Xvec.elements); 153 PlotVector (N, Yvec.elements); 145 146 PlotVectorPair (kapa, N, Xvec.elements, Yvec.elements, &graphmode); 154 147 155 148 free (Xvec.elements); -
trunk/Ohana/src/opihi/dvo/region_list.c
r7917 r13479 95 95 96 96 double Radius; 97 int Ngraph;98 97 Graphdata graphsky; 99 98 SkyList *skylist; … … 121 120 } 122 121 123 Ngraph = 0; 124 if (!GetGraphData (&graphsky, NULL, &Ngraph)) { 122 if (!GetGraphData (&graphsky, NULL, NULL)) { 125 123 gprint (GP_ERR, "region display not available\n"); 126 124 return (NULL); -
trunk/Ohana/src/opihi/dvo/scripts/navigate
r10847 r13479 11 11 $KEY = "none" 12 12 while ("$KEY" != "q") 13 cursor -g113 cursor 1 14 14 15 15 # help list … … 147 147 $ok = $KEY 148 148 echo "type 'd' again at endpoint" 149 cursor -g1149 cursor 1 150 150 $r1 = $R$KEY 151 151 $d1 = $D$KEY … … 168 168 $ok = $KEY 169 169 echo "type 'z' again at radius" 170 cursor -g1170 cursor 1 171 171 $r1 = $R$KEY 172 172 $d1 = $D$KEY … … 400 400 if ("$KEY" == "p") 401 401 echo "P - new coords; p - old coords" 402 cursor -g1402 cursor 1 403 403 exec echo $Rp $Dp $RP $DP >> fix.coords 404 404 end -
trunk/Ohana/src/opihi/dvo/showtile.c
r7917 r13479 5 5 int showtile (int argc, char **argv) { 6 6 7 int Nd, N, NPTS, Ngraph, status, i, InPic;7 int kapa, Nd, N, NPTS, status, i, InPic; 8 8 Graphdata graphmode; 9 9 Coords coords; … … 13 13 14 14 /* show tile pattern in viewed region */ 15 16 Ngraph = 0; 17 if (!GetGraph (&graphmode, NULL, &Ngraph)) return (FALSE); 15 if (!GetGraph (&graphmode, &kapa, NULL)) return (FALSE); 18 16 19 17 if (argc != 1) { … … 88 86 graphmode.ptype = 100; /* connect pairs of points */ 89 87 graphmode.etype = 0; 90 PrepPlotting (N, &graphmode); 91 PlotVector (N, Xvec.elements); 92 PlotVector (N, Yvec.elements); 88 PlotVectorPair (kapa, N, Xvec.elements, Yvec.elements, &graphmode); 93 89 } 94 90 -
trunk/Ohana/src/opihi/dvo/simage.c
r7917 r13479 12 12 Header header; 13 13 Coords coords; 14 int i, j, Nstars, nstars, Nbytes, nbytes, Npts, N;14 int i, j, kapa, Nstars, nstars, Nbytes, nbytes, Npts, N; 15 15 Graphdata graphmode; 16 int Ngraph;17 16 18 Ngraph = 0; 19 if (!GetGraph (&graphmode, NULL, &Ngraph)) return (FALSE); 17 if (!GetGraph (&graphmode, &kapa, NULL)) return (FALSE); 20 18 21 19 zero = 17.0; … … 156 154 graphmode.etype = 0; 157 155 Npts = Xvec.Nelements; 158 PrepPlotting (Npts, &graphmode);159 156 160 PlotVector (Npts, Xvec.elements); 161 PlotVector (Npts, Yvec.elements); 162 PlotVector (Npts, Zvec.elements); 157 PlotVectorTriplet (kapa, Npts, Xvec.elements, Yvec.elements, Zvec.elements, &graphmode); 163 158 164 159 free (Xvec.elements); -
trunk/Ohana/src/opihi/dvo/skycat.c
r8328 r13479 6 6 7 7 double Radius; 8 int i, j, N, Nregions, ShowAll, NPTS, Npts, leftside, Depth, VERBOSE;8 int i, j, N, Nregions, kapa, ShowAll, NPTS, Npts, leftside, Depth, VERBOSE; 9 9 struct stat filestat; 10 10 Vector Xvec, Yvec; … … 32 32 } 33 33 34 if (!style_args (&graphmode, &argc, argv, 0)) return FALSE;34 if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE; 35 35 36 36 if (argc != 1) { … … 38 38 return (FALSE); 39 39 } 40 SetGraph (graphmode);41 40 42 41 Radius = MAX (fabs(graphmode.xmax), fabs(graphmode.ymax)); … … 97 96 graphmode.ptype = 100; /* connect pairs of points */ 98 97 graphmode.etype = 0; 99 PrepPlotting (Npts, &graphmode); 100 PlotVector (Npts, Xvec.elements); 101 PlotVector (Npts, Yvec.elements); 98 PlotVectorPair (kapa, Npts, Xvec.elements, Yvec.elements, &graphmode); 102 99 } 103 100 -
trunk/Ohana/src/opihi/include/data.h
r11007 r13479 162 162 void SetLimitsRaw PROTO((float *xvec, float *yvec, int Npts, Graphdata *graphmode)); 163 163 void ApplyLimits PROTO((int Xgraph, Graphdata *graphmode, int apply)); 164 int style_args PROTO((Graphdata *graphmode, int *argc, char **argv, int Nforce));164 int style_args PROTO((Graphdata *graphmode, int *argc, char **argv, int *kapa)); 165 165 166 166 int read_table_vectors (int argc, char **argv, char *extname); -
trunk/Ohana/src/opihi/include/display.h
r12332 r13479 5 5 # define DISPLAY_H 6 6 7 # if (0) 8 typedef struct { 9 double xmin, xmax, ymin, ymax; 10 int style, ptype, ltype, etype, ebar, color; 11 double lweight, size; 12 Coords coords; 13 int flipeast, flipnorth; 14 char axis[8], labels[8], ticks[8]; 15 } Graphdata; 16 # endif 7 /*** kapa graph functions ***/ 8 int PlotVectorPair PROTO((int kapa, int Npts, float *xValues, float *yValues, Graphdata *graphmode)); 9 int PlotVectorTriplet PROTO((int kapa, int Npts, float *xValues, float *yValues, float *zValues, Graphdata *graphmode)); 10 int GetGraphData PROTO((Graphdata *data, int *kapa, char *name)); 11 int GetGraph PROTO((Graphdata *data, int *kapa, char *name)); 12 int SetGraph PROTO((Graphdata *data)); 17 13 18 /*** plotting functions ***/ 19 int GetCurrentDevice PROTO((void)); 20 int PrepPlotting PROTO((int Npts, Graphdata *graphmode)); 21 int PlotVector PROTO((int, float *)); 22 int PlotVectorTriplet PROTO((int N, float *xValues, float *yValues, float *zValues, Graphdata *graphmode)); 23 int GetGraphData PROTO((Graphdata *data, int *sock, int *N)); 24 int GetGraph PROTO((Graphdata *data, int *socket, int *N)); 25 void InitGraph PROTO((void)); 26 int open_graph PROTO((int N)); 27 int close_graph PROTO((int N)); 28 void QuitGraph PROTO((void)); 29 void SetGraph PROTO((Graphdata data)); 30 void XGraphDead PROTO((int input)); 31 int GetColor PROTO((char *name)); 14 /*** kapa image functions */ 15 int GetImageData PROTO((KapaImageData *data, int *kapa, char *name)); 16 int GetImage PROTO((KapaImageData *data, int *kapa, char *name)); 17 int SetImage PROTO((KapaImageData *data)); 32 18 33 /* image (tv) functions */ 34 int GetImage PROTO((int *socket, int *N)); 35 char *GetImageName PROTO((void)); 36 void GetImageScale PROTO((double *zero, double *range)); 37 void InitImage PROTO((void)); 38 int open_image PROTO((int N)); 39 int close_image PROTO((int N)); 40 void QuitImage PROTO((void)); 41 void SetImageDevice PROTO((int state)); 42 void SetImageName PROTO((char *name)); 43 void SetImageScale PROTO((double zero, double range)); 44 void XImageDead PROTO((int input)); 45 int SelectOverlay PROTO((char *name, int *number)); 19 void QuitKapa PROTO(()); 20 void InitKapa PROTO(()); 21 int open_kapa PROTO((int entry)); 22 int close_kapa PROTO((char *name)); 23 int AddKapaDevice PROTO((char *name)); 24 int DelKapaDevice PROTO((char *name)); 25 int FindKapaDevice PROTO((char *name)); 26 char *GetKapaName PROTO(()); 46 27 47 28 /* calling program need to define a function 'get_variable' which -
trunk/Ohana/src/opihi/include/dvoshell.h
r7960 r13479 7 7 8 8 /* magnitude types */ 9 enum {MAG_NONE, MAG_INST, MAG_CAT, MAG_SYS, MAG_REL, MAG_CAL, MAG_AVE, MAG_REF };9 enum {MAG_NONE, MAG_INST, MAG_CAT, MAG_SYS, MAG_REL, MAG_CAL, MAG_AVE, MAG_REF, MAG_ERR, MAG_CHISQ}; 10 10 11 /* measure params */11 /* measure fields */ 12 12 enum {MEAS_ZERO, MEAS_RA, MEAS_DEC, MEAS_MAG, MEAS_dMAG, MEAS_MINST, MEAS_MCAT, 13 13 MEAS_MSYS, MEAS_MREL, MEAS_MCAL, MEAS_PHOTCODE, MEAS_TIME, MEAS_dR, MEAS_dD, 14 14 MEAS_FWHM, MEAS_DOPHOT, MEAS_XCCD, MEAS_YCCD, MEAS_XMOSAIC, MEAS_YMOSAIC, MEAS_FLAGS, MEAS_EXPTIME, MEAS_AIRMASS}; 15 15 16 /* average params */16 /* average fields */ 17 17 enum {AVE_ZERO, AVE_RA, AVE_DEC, AVE_RA_ERR, AVE_DEC_ERR, AVE_U_RA, AVE_U_DEC, 18 18 AVE_U_RA_ERR, AVE_U_DEC_ERR, AVE_PAR, AVE_PAR_ERR, AVE_MAG, AVE_REF, AVE_dMAG, 19 19 AVE_Xm, AVE_Xp, AVE_NMEAS, AVE_NMISS, AVE_TYPE, AVE_NPHOT, AVE_NCODE, AVE_NCRIT, 20 20 AVE_FLAG, AVE_TYPEFRAC}; 21 22 enum {DVO_TABLE_AVERAGE, DVO_TABLE_MEASURE}; 23 24 // a single db field 25 typedef struct { 26 char *name; 27 int extract; 28 int table; 29 int ID; 30 int magMode; 31 PhotCode *photcode; 32 } dbField; 33 34 // db boolean operations 35 typedef struct { 36 char *name; 37 char type; 38 int field; 39 float Float; 40 } dbStack; 21 41 22 42 typedef struct { … … 96 116 int RD_to_XYpic PROTO((double *x, double *y, double r, double d, Coords *coords, double Rmin, double Rmax, double Rmid, int *leftside)); 97 117 118 // dvo DB field functions 119 dbField *dbCmdlineFields PROTO((int argc, char **argv, int table, int *last, int *nfields)); 120 dbStack *dbRPN PROTO((int argc, char **argv, int *nstack)); 121 int dbCheckStack PROTO((dbStack *stack, int Nstack, int table, dbField **inFields, int *Nfields)); 122 int dbBooleanCond PROTO((dbStack *inStack, int NinStack, float *fields)); 123 void dbInitStack PROTO((dbStack *stack)); 124 void dbFreeStack PROTO((dbStack *stack, int Nstack)); 125 void dbFreeEntry PROTO((dbStack *stack)); 126 127 dbStack *dbBinary PROTO((dbStack *V1, dbStack *V2, char *op, float *fields)); 128 dbStack *dbUnary PROTO((dbStack *V1, char *op, float *fields)); 129 130 int GetMagMode PROTO((char *string)); 131 PhotCode *ParsePhotcodeField PROTO((char *field, int *mode, int def)); 132 int ParseMeasureField PROTO((dbField *field, char *fieldName)); 133 int ParseAverageField PROTO((dbField *field, char *fieldName)); 134 135 double dbExtractAverages PROTO((Average *average, SecFilt *secfilt, Measure *measure, dbField *field)); 136 double dbExtractMeasures PROTO((Average *average, SecFilt *secfilt, Measure *measure, dbField *field)); 137 void dbExtractMeasuresInit PROTO(()); 138 98 139 # endif -
trunk/Ohana/src/opihi/lib.data/Makefile
r12879 r13479 29 29 $(SDIR)/gaussian.$(ARCH).o \ 30 30 $(SDIR)/graphtools.$(ARCH).o \ 31 $(SDIR)/open_graph.$(ARCH).o \32 $(SDIR)/open_image.$(ARCH).o \33 31 $(SDIR)/queues.$(ARCH).o \ 34 32 $(SDIR)/PlotVectors.$(ARCH).o \ 33 $(SDIR)/open_kapa.$(ARCH).o \ 35 34 $(SDIR)/style_args.$(ARCH).o 35 36 #$(SDIR)/open_graph.$(ARCH).o \ 37 #$(SDIR)/open_image.$(ARCH).o \ 36 38 37 39 # dependancy rules for include files ######################## -
trunk/Ohana/src/opihi/lib.data/PlotVectors.c
r10795 r13479 1 1 # include "display.h" 2 2 3 static int Xgraph; 3 int PlotVectorPair (int kapa, int Npts, float *xValues, float *yValues, Graphdata *graphmode) { 4 4 5 int PrepPlotting (int Npts, Graphdata *graphmode) { 5 KapaPrepPlot (kapa, Npts, graphmode); 6 KapaPlotVector (kapa, Npts, xValues, "x"); 7 KapaPlotVector (kapa, Npts, yValues, "y"); 6 8 7 if (!GetGraph (NULL, &Xgraph, NULL)) return (FALSE);8 9 /* tell kapa to look for the incoming image */10 KiiSendCommand (Xgraph, 4, "PLOT");11 12 /* send Xgraph the plot details */13 KiiSendMessage (Xgraph, "%8d %8d %d %d %d %d %d %f %f",14 Npts, graphmode[0].style,15 graphmode[0].ptype, graphmode[0].ltype,16 graphmode[0].etype, graphmode[0].ebar, graphmode[0].color,17 graphmode[0].lweight, graphmode[0].size);18 KiiSendMessage (Xgraph, "%g %g %g %g",19 graphmode[0].xmin, graphmode[0].xmax,20 graphmode[0].ymin, graphmode[0].ymax);21 9 return (TRUE); 22 10 } 23 11 24 int PlotVector (int Npts, float *values) {12 int PlotVectorTriplet (int kapa, int Npts, float *xValues, float *yValues, float *zValues, Graphdata *graphmode) { 25 13 26 int Nbytes; 14 KapaPrepPlot (kapa, Npts, graphmode); 15 KapaPlotVector (kapa, Npts, xValues, "x"); 16 KapaPlotVector (kapa, Npts, yValues, "y"); 17 KapaPlotVector (kapa, Npts, zValues, "z"); 27 18 28 Nbytes = Npts * sizeof (float);29 write (Xgraph, values, Nbytes);30 19 return (TRUE); 31 20 } 32 33 int PlotVectorPair (int N, float *xValues, float *yValues, Graphdata *graphmode) {34 35 PrepPlotting (N, graphmode);36 PlotVector (N, xValues);37 PlotVector (N, yValues);38 39 return (TRUE);40 }41 42 int PlotVectorTriplet (int N, float *xValues, float *yValues, float *zValues, Graphdata *graphmode) {43 44 PrepPlotting (N, graphmode);45 PlotVector (N, xValues);46 PlotVector (N, yValues);47 PlotVector (N, zValues);48 49 return (TRUE);50 }51 52 /* we don't use GetGraph in PlotVector because it flushes the connection */ -
trunk/Ohana/src/opihi/lib.data/graphtools.c
r7680 r13479 33 33 graphmode[0].ymax = maxY + 0.05*range; 34 34 } 35 SetGraph (graphmode [0]);35 SetGraph (graphmode); 36 36 37 37 set_variable ("XMIN", graphmode[0].xmin); … … 73 73 graphmode[0].ymax = maxY + 0.05*range; 74 74 } 75 SetGraph (graphmode [0]);75 SetGraph (graphmode); 76 76 77 77 set_variable ("XMIN", graphmode[0].xmin); -
trunk/Ohana/src/opihi/lib.data/open_image.c
r7938 r13479 122 122 return (Ximbuffer[Active]); 123 123 } 124 124 125 // leave this information on kapa, request when needed? 125 126 void SetImageScale (double zero, double range) { 126 127 Xzero[Active] = zero; -
trunk/Ohana/src/opihi/lib.data/open_kapa.c
r13344 r13479 1 1 # include "display.h" 2 2 # include "shell.h" 3 # include <assert.h> 4 3 5 4 6 /* kapa support for the new version of kapa (v2.0), which has both graph and image … … 9 11 10 12 /* list of available socket connections */ 11 static int Active; // currently active socket (not device)13 static int Active; // currently active socket entry (index value, not socket value) 12 14 static int *Socket = NULL; // list of available sockets 13 static int *Device = NULL; // list of device numbers for each socked14 static int N socket= 0; // number of available sockets / devices15 static char **Device = NULL; // list of device names for each socket 16 static int Ndevice = 0; // number of available sockets / devices 15 17 16 18 void InitKapa () { 17 19 18 Active = -1; // -1 is the INVALID entry 19 Nsocket = 0; // number of defined sockets 20 ALLOCATE (Device, int, 1); 21 ALLOCATE (Socket, int, 1); 22 Device[Active] = 0; 23 Socket[Active] = 0; 24 } 25 26 // returns the number of the requested device, or -1 if not found 27 int FindKapaDevice (int thisDevice) { 20 Active = -1; // -1 is the INVALID entry 21 Ndevice = 0; // number of defined sockets 22 ALLOCATE (Device, char *, 1); // for future REALLOCATE calls 23 ALLOCATE (Socket, int, 1); // for future REALLOCATE calls 24 } 25 26 // add new device name if not found 27 int AddKapaDevice (char *name) { 28 29 int N; 30 31 N = FindKapaDevice (name); 32 if (N != -1) return (N); 33 N = Ndevice; 34 Ndevice ++; 35 REALLOCATE (Device, char *, Ndevice); 36 REALLOCATE (Socket, int, Ndevice); 37 Device[N] = strcreate (name); 38 Socket[N] = -1; 39 return (N); 40 } 41 42 // delete device by name, close if not closed 43 int DelKapaDevice (char *name) { 44 45 int i, N; 46 47 N = FindKapaDevice (name); 48 if (N == -1) return (FALSE); 49 50 if (Socket[N] != -1) close (Socket[N]); 51 free (Device[N]); 52 for (i = N; i < Ndevice - 1; i++) { 53 Device[i] = Device[i+1]; 54 Socket[i] = Socket[i+1]; 55 } 56 57 if (N == Active) { 58 Active = -1; 59 } 60 61 Ndevice --; 62 REALLOCATE (Device, char *, Ndevice); 63 REALLOCATE (Socket, int, Ndevice); 64 65 return (TRUE); 66 } 67 68 // returns the entry of the requested device, or -1 if not found 69 int FindKapaDevice (char *name) { 28 70 29 71 int i; 30 72 31 for (i = 0; i < Nsocket; i++) {32 if (Device[i] == thisDevice) { 33 return (i);34 }73 if (name == NULL) return (-1); 74 75 for (i = 0; i < Ndevice; i++) { 76 if (!strcmp(Device[i], name)) return (i); 35 77 } 36 78 return (-1); 37 79 } 38 80 39 // set the active device to the given device number, open if needed40 int open_kapa (int thisDevice) {41 42 int fd , entry;43 char *kapa_exec, name[16];81 // set the active device to the given device, open if needed 82 int open_kapa (int entry) { 83 84 int fd; 85 char *kapa_exec, *kapa_name; 44 86 45 87 // find the given device number, or create. set this to active 46 entry = FindKapaDevice (thisDevice); 47 if (entry < 0) { 48 Active = Nsocket; 49 Nsocket ++; 50 REALLOCATE (Device, int, Nsocket); 51 REALLOCATE (Socket, int, Nsocket); 52 Device[Active] = -1; 53 Socket[Active] = -1; 54 } else { 55 Active = entry; 56 } 88 assert (entry >= 0); 89 assert (entry < Ndevice); 57 90 58 91 // if the (now) active socket is not open, open it 59 if (Socket[ Active] < 0) {92 if (Socket[entry] < 0) { 60 93 kapa_exec = get_variable ("KAPA"); 61 94 if (kapa_exec == (char *) NULL) { … … 65 98 66 99 // KAPA may be either kapa://host or /path/to/program 67 68 snprintf ( name, 16, "[%d]", thisDevice);69 fd = KapaOpen (kapa_exec, name);100 ALLOCATE (kapa_name, char, strlen(Device[entry]) + 5); 101 snprintf (kapa_name, strlen(Device[entry]) + 5, "[%s]", Device[entry]); 102 fd = KapaOpen (kapa_exec, kapa_name); 70 103 free (kapa_exec); 104 free (kapa_name); 71 105 72 106 if (fd < 0) { 73 gprint (GP_ERR, "error starting kapa\n"); 74 // delete the active entry 107 gprint (GP_ERR, "error starting kapa device %s\n", Device[entry]); 75 108 return (FALSE); 76 109 } 77 Device[Active] = thisDevice; 78 Socket[Active] = fd; 110 Socket[entry] = fd; 79 111 } 80 return (TRUE); 81 } 82 83 /**************** graph ops */ 84 85 // XXX for now, use a local variable. later: get from kapa 86 static Graphdata graphdata; 87 88 void InitGraph () { 89 graphdata.xmin = graphdata.ymin = 0.0; 90 graphdata.xmax = graphdata.ymax = 1.0; 91 graphdata.style = graphdata.ptype = 0; 92 graphdata.ltype = graphdata.color = 0; 93 graphdata.etype = graphdata.ebar = 0; 94 graphdata.lweight = graphdata.size = 1.0; 95 96 graphdata.coords.pc1_1 = graphdata.coords.pc2_2 = 1.0; 97 graphdata.coords.pc1_2 = graphdata.coords.pc2_1 = 0.0; 98 strcpy (graphdata.coords.ctype, "RA---LIN"); 99 graphdata.coords.crval1 = 0.0; 100 graphdata.coords.crval2 = 0.0; 101 graphdata.coords.crpix1 = 0.0; 102 graphdata.coords.crpix2 = 0.0; 103 graphdata.coords.cdelt1 = graphdata.coords.cdelt2 = 1.0; 104 graphdata.flipeast = TRUE; 105 graphdata.flipnorth = FALSE; 106 strcpy (graphdata.axis, "2222"); 107 strcpy (graphdata.ticks, "2222"); 108 strcpy (graphdata.labels, "2222"); 109 } 110 111 # if (0) 112 /* test Xgraph[0], flush junk from pipe */ 113 signal (SIGPIPE, XGraphDead); 114 fcntl (Socket[n], F_SETFL, O_NONBLOCK); 115 for (i = 0; (read (Socket[n], buffer, 64) > 0) && (i < 20); i++); 116 fcntl (Socket[n], F_SETFL, !O_NONBLOCK); 117 # endif 118 119 /* return pointers for current Xgraph, set if desired, test, open if needed */ 120 int GetGraph (Graphdata *data, int *fd, int *dev) { 121 122 int thisDevice; 123 124 SetImageDevice (FALSE); 125 if (dev == NULL) { 126 if (Active < 0) { 127 thisDevice = 0; 112 Active = entry; 113 return (TRUE); 114 } 115 116 /**************** graph specific ops *******************/ 117 118 // return the current device name, if set 119 char *GetKapaName () { 120 if (Active < 0) return NULL; 121 return Device[Active]; 122 } 123 124 /* return pointers for named device or current; open if needed */ 125 // if fd == NULL, don't return the value 126 // if name == NULL, use the currently active device 127 int GetGraph (Graphdata *data, int *fd, char *name) { 128 129 int entry; 130 131 if (name == NULL) { 132 if (Active < 0) { 133 entry = AddKapaDevice ("0"); 128 134 } else { 129 thisDevice = Device[Active];130 } 131 } else { 132 thisDevice = *dev;133 } 134 135 if (!open_kapa ( thisDevice)) {136 return (FALSE); 137 } 138 139 if (data != NULL) *data = graphdata;135 entry = Active; 136 } 137 } else { 138 entry = AddKapaDevice (name); 139 } 140 141 if (!open_kapa (entry)) { 142 return (FALSE); 143 } 144 145 if (data != NULL) KapaGetGraphData (Socket[Active], data); 140 146 if (fd != NULL) *fd = Socket[Active]; 141 147 … … 143 149 } 144 150 145 /* return pointers for given Xgraph, don't set or open */ 146 int GetGraphData (Graphdata *data, int *fd, int *dev) { 147 148 int n; 149 150 if (dev == NULL) { 151 if (Active < 0) { 152 gprint (GP_ERR, "invalid Xgraph window %d\n", *dev); 153 return (FALSE); 154 } 155 *fd = Socket[Active]; 156 return (TRUE); 157 } 158 159 n = FindKapaDevice (*dev); 160 if (n < 0) { 161 gprint (GP_ERR, "invalid Xgraph window %d\n", *dev); 162 return (FALSE); 163 } 164 165 Active = n; 166 151 /* return pointers for given kapa, don't set or open */ 152 int GetGraphData (Graphdata *data, int *fd, char *name) { 153 154 int entry; 155 156 if (name == NULL) { 157 if (Active < 0) { 158 gprint (GP_ERR, "no active kapa window\n"); 159 return (FALSE); 160 } 161 entry = Active; 162 } else { 163 entry = FindKapaDevice (name); 164 if (entry < 0) { 165 gprint (GP_ERR, "invalid kapa window %s\n", name); 166 return (FALSE); 167 } 168 } 169 170 if (fd != NULL) *fd = Socket[entry]; 171 if (data != NULL) KapaGetGraphData (Socket[entry], data); 172 return (TRUE); 173 } 174 175 /* assign given values to current kapa */ 176 int SetGraph (Graphdata *data) { 177 if (Active < 0) { 178 gprint (GP_ERR, "no active kapa window\n"); 179 return (FALSE); 180 } 181 if (Socket[Active] == -1) { 182 gprint (GP_ERR, "no active kapa window\n"); 183 return (FALSE); 184 } 185 KapaSetGraphData (Socket[Active], data); 186 } 187 188 /************* image ops ***********/ 189 190 /* return pointers for current Ximage, set if desired, test, open if needed */ 191 int GetImage (KapaImageData *data, int *fd, char *name) { 192 193 int entry; 194 195 if (name == NULL) { 196 if (Active < 0) { 197 entry = AddKapaDevice ("0"); 198 } else { 199 entry = Active; 200 } 201 } else { 202 entry = AddKapaDevice (name); 203 } 204 205 if (!open_kapa (entry)) { 206 return (FALSE); 207 } 208 209 if (data != NULL) KapaGetImageData (Socket[Active], data); 167 210 if (fd != NULL) *fd = Socket[Active]; 168 if (data != NULL) *data = graphdata; 169 170 return (TRUE); 171 } 172 173 /* assign given values to current Xgraph */ 174 void SetGraph (Graphdata data) { 175 graphdata = data; 176 } 177 178 /** internal tracking of current active device type **/ 179 /* drop this stuff */ 180 static int IsImage = FALSE; 181 182 int GetCurrentDevice () { 183 return (IsImage); 184 } 185 186 void SetImageDevice (int state) { 187 IsImage = state; 188 } 189 190 /************* image ops ***********/ 191 // XXX for now, use local static: 192 193 static char Ximbuffer[512]; 194 static double Xzero; 195 static double Xrange; 196 197 void InitImage () { 198 Xzero = 0; 199 Xrange = 1024; 200 strcpy (Ximbuffer, "none"); 201 } 202 203 /* return pointers for current Ximage, set if desired, test, open if needed */ 204 int GetImage (int *fd, int *N) { 205 int status; 206 status = GetGraph (NULL, fd, N); 207 return (status); 208 } 209 210 void SetImageName (char *name) { 211 strcpy (Ximbuffer, name); 212 } 213 214 char *GetImageName () { 215 return (Ximbuffer); 216 } 217 218 // leave this information on kapa, request when needed? 219 void SetImageScale (double zero, double range) { 220 Xzero = zero; 221 Xrange = range; 222 } 223 void GetImageScale (double *zero, double *range) { 224 *zero = Xzero; 225 *range = Xrange; 226 } 211 212 return (TRUE); 213 } 214 215 /* return pointers for given kapa, don't set or open */ 216 int GetImageData (KapaImageData *data, int *fd, char *name) { 217 218 int entry; 219 220 if (name == NULL) { 221 if (Active < 0) { 222 gprint (GP_ERR, "no active kapa window\n"); 223 return (FALSE); 224 } 225 entry = Active; 226 } else { 227 entry = FindKapaDevice (name); 228 if (entry < 0) { 229 gprint (GP_ERR, "invalid kapa window %s\n", name); 230 return (FALSE); 231 } 232 } 233 234 if (fd != NULL) *fd = Socket[entry]; 235 if (data != NULL) KapaGetImageData (Socket[entry], data); 236 return (TRUE); 237 } 238 239 /* assign given values to current kapa */ 240 int SetImage (KapaImageData *data) { 241 if (Active < 0) { 242 gprint (GP_ERR, "no active kapa window\n"); 243 return (FALSE); 244 } 245 if (Socket[Active] == -1) { 246 gprint (GP_ERR, "no active kapa window\n"); 247 return (FALSE); 248 } 249 KapaSetImageData (Socket[Active], data); 250 } 251 252 int close_kapa (char *name) { 253 254 int N; 255 256 N = FindKapaDevice (name); 257 if (N == -1) { 258 if (Active < 0) return (FALSE); 259 name = Device[Active]; 260 } 261 DelKapaDevice (name); 262 return (TRUE); 263 } 264 265 void QuitKapa () { 266 267 int i; 268 269 for (i = 0; i < Ndevice; i++) { 270 if (Socket[i] != -1) close (Socket[i]); 271 if (Device[i] != NULL) free (Device[i]); 272 } 273 REALLOCATE (Socket, int, 1); 274 REALLOCATE (Device, char *, 1); 275 276 Ndevice = 0; 277 Active = -1; 278 } -
trunk/Ohana/src/opihi/lib.data/style_args.c
r7917 r13479 2 2 # include "display.h" 3 3 4 int style_args (Graphdata *graphmode, int *argc, char **argv, int Nforce) {4 int style_args (Graphdata *graphmode, int *argc, char **argv, int *kapa) { 5 5 6 int N, Ngraph; 7 char *name; 6 int N; 7 char *colorName; 8 char *kapaName; 8 9 9 Ngraph = -1;10 kapaName = NULL; 10 11 if ((N = get_argument (*argc, argv, "-n"))) { 11 12 remove_argument (N, argc, argv); 12 Ngraph = atof(argv[N]);13 kapaName = strcreate (argv[N]); 13 14 remove_argument (N, argc, argv); 14 15 } 15 if ( Nforce != -1) Ngraph = Nforce;16 if (!GetGraph (graphmode, NULL, &Ngraph)) return (FALSE);16 if (!GetGraph (graphmode, kapa, kapaName)) return (FALSE); 17 FREE (kapaName); 17 18 18 19 if (*argc == 1) { 19 name = KapaColorName (graphmode[0].color); 20 gprint (GP_ERR, "current style (%d): -x %d -c %s -pt %d -lt %d -lw %f -sz %f\n", Ngraph, 21 graphmode[0].style, name, graphmode[0].ptype, 20 kapaName = GetKapaName(); 21 colorName = KapaColorName (graphmode[0].color); 22 gprint (GP_ERR, "current style (%s): -x %d -c %s -pt %d -lt %d -lw %f -sz %f\n", kapaName, 23 graphmode[0].style, colorName, graphmode[0].ptype, 22 24 graphmode[0].ltype, graphmode[0].lweight, 23 25 graphmode[0].size); -
trunk/Ohana/src/opihi/lib.shell/BufferOps.c
r9275 r13479 195 195 } 196 196 197 int SelectOverlay (char *name, int *number) {198 199 *number = -1;200 if (!strcmp (name, "red") || !strcmp (name, "0"))201 *number = 0;202 if (!strcmp (name, "green") || !strcmp (name, "1"))203 *number = 1;204 if (!strcmp (name, "blue") || !strcmp (name, "2"))205 *number = 2;206 if (!strcmp (name, "yellow") || !strcmp (name, "3"))207 *number = 3;208 209 if (*number < 0) {210 gprint (GP_ERR, "valid overlays may be: red (0), green (1), blue (2), yellow (3)\n");211 return (FALSE);212 }213 else {214 return (TRUE);215 }216 }217 218 197 void dump_buffers (int n) { 219 198 -
trunk/Ohana/src/opihi/lib.shell/startup.c
r12902 r13479 43 43 else 44 44 set_str_variable ("HOME", home); 45 set_str_variable ("KII", "kii");46 45 set_str_variable ("KAPA", "kapa"); 47 46 set_variable ("PID", getpid()); -
trunk/Ohana/src/opihi/mana/mana.c.in
r12280 r13479 51 51 /* add program-dependent exit functions here */ 52 52 void cleanup () { 53 QuitImage (); 54 QuitGraph (); 53 QuitKapa (); 55 54 return; 56 55 } -
trunk/Ohana/src/opihi/mana/opihi.c
r10647 r13479 64 64 /* add program-dependent exit functions here */ 65 65 void cleanup () { 66 /* -libdisplay 67 QuitImage (); 68 QuitGraph (); */ 66 QuitKapa (); 69 67 return; 70 68 } -
trunk/Ohana/src/opihi/pantasks/pantasks.c.in
r12280 r13479 64 64 /* add program-dependent exit functions here */ 65 65 void cleanup () { 66 QuitImage (); 67 QuitGraph (); 66 QuitKapa (); 68 67 QuitController (); 69 68 return; -
trunk/Ohana/src/opihi/pantasks/pantasks_client.c.in
r12280 r13479 54 54 /* add program-dependent exit functions here */ 55 55 void cleanup () { 56 QuitImage (); 57 QuitGraph (); 56 QuitKapa (); 58 57 return; 59 58 } -
trunk/Ohana/src/opihi/pantasks/pantasks_server.c
r11890 r13479 74 74 /* add program-dependent exit functions here */ 75 75 void cleanup () { 76 // QuitImage (); 77 // QuitGraph (); 78 // QuitController (); 76 QuitKapa (); 77 QuitController (); 79 78 return; 80 79 } -
trunk/Ohana/src/relastro/src/plotstuff.c
r12892 r13479 21 21 int open_graph (int N) { 22 22 23 Xgraph[N] = KiiOpen ("kapa", NULL); 23 char name[100]; 24 25 sprintf (name, "gastro [%d]", N); 26 Xgraph[N] = KapaOpen ("kapa", name); 27 24 28 if (Xgraph[N] < 0) { 25 29 fprintf (stderr, "error starting kapa\n"); … … 59 63 if (Xgraph[N] < 1) if (!open_graph(N)) return; 60 64 61 KapaClear (Xgraph[N], TRUE);65 KapaClearSections (Xgraph[N]); 62 66 63 KiiSendCommand (Xgraph[N], 4, "PLOT"); 64 65 /* send Xgraph the plot details */ 66 KiiSendMessage (Xgraph[N], "%8d %8d %d %d %d %d %d %f %f", 67 Npts, graphmode[0].style, 68 graphmode[0].ptype, graphmode[0].ltype, 69 graphmode[0].etype, graphmode[0].ebar, graphmode[0].color, 70 graphmode[0].lweight, graphmode[0].size); 71 KiiSendMessage (Xgraph[N], "%g %g %g %g", 72 graphmode[0].xmin, graphmode[0].xmax, 73 graphmode[0].ymin, graphmode[0].ymax); 74 67 KapaPrepPlot (Xgraph[N], Npts, graphmode); 75 68 return; 76 69 } … … 83 76 } 84 77 85 void PlotVector (int Npts, double *vect, int mode, int N ) {78 void PlotVector (int Npts, double *vect, int mode, int N, char *type) { 86 79 87 80 float *values; … … 95 88 } 96 89 97 Nbytes = Npts * sizeof (float); 98 write (Xgraph[N], values, Nbytes); 90 KapaPlotVector (Xgraph[N], Npts, values, type); 99 91 free (values); 100 92 return; … … 123 115 124 116 PrepPlotting (N, graphdata, 0); 125 PlotVector (N, xlist, 0, 0 );126 PlotVector (N, ylist, 1, 0 );117 PlotVector (N, xlist, 0, 0, "x"); 118 PlotVector (N, ylist, 1, 0, "y"); 127 119 if (label != NULL) PlotLabel (label, 0); 128 120 DonePlotting (graphdata, 0); -
trunk/Ohana/src/relphot/src/plotstuff.c
r12892 r13479 21 21 int open_graph (int N) { 22 22 23 Xgraph[N] = KiiOpen ("kapa", NULL); 23 char name[100]; 24 25 sprintf (name, "gastro [%d]", N); 26 Xgraph[N] = KapaOpen ("kapa", name); 27 24 28 if (Xgraph[N] < 0) { 25 29 fprintf (stderr, "error starting kapa\n"); … … 59 63 if (Xgraph[N] < 1) if (!open_graph(N)) return; 60 64 61 KapaClear (Xgraph[N], TRUE);65 KapaClearSections (Xgraph[N]); 62 66 63 KiiSendCommand (Xgraph[N], 4, "PLOT"); 64 65 /* send Xgraph the plot details */ 66 KiiSendMessage (Xgraph[N], "%8d %8d %d %d %d %d %d %f %f", 67 Npts, graphmode[0].style, 68 graphmode[0].ptype, graphmode[0].ltype, 69 graphmode[0].etype, graphmode[0].ebar, graphmode[0].color, 70 graphmode[0].lweight, graphmode[0].size); 71 KiiSendMessage (Xgraph[N], "%g %g %g %g", 72 graphmode[0].xmin, graphmode[0].xmax, 73 graphmode[0].ymin, graphmode[0].ymax); 74 67 KapaPrepPlot (Xgraph[N], Npts, graphmode); 75 68 return; 76 69 } … … 83 76 } 84 77 85 void PlotVector (int Npts, double *vect, int mode, int N ) {78 void PlotVector (int Npts, double *vect, int mode, int N, char *type) { 86 79 87 80 float *values; … … 95 88 } 96 89 97 Nbytes = Npts * sizeof (float); 98 write (Xgraph[N], values, Nbytes); 90 KapaPlotVector (Xgraph[N], Npts, values, type); 99 91 free (values); 100 92 return; … … 123 115 124 116 PrepPlotting (N, graphdata, 0); 125 PlotVector (N, xlist, 0, 0 );126 PlotVector (N, ylist, 1, 0 );117 PlotVector (N, xlist, 0, 0, "x"); 118 PlotVector (N, ylist, 1, 0, "y"); 127 119 if (label != NULL) PlotLabel (label, 0); 128 120 DonePlotting (graphdata, 0); -
trunk/Ohana/src/uniphot/src/plotstuff.c
r4797 r13479 13 13 int open_graph (int N) { 14 14 15 int i, InitSocket, status, addreslen; 16 struct sockaddr_un Address; 17 char temp[100], *display_name; 18 char socket_name[100]; 19 FILE *f; 15 char name[100]; 20 16 21 17 active = N; 22 sprintf (socket_name, "/tmp/kapa%d", N); 23 sprintf (temp, "rm -f %s", socket_name); 24 system (temp); 25 26 strcpy (Address.sun_path, socket_name); 27 Address.sun_family = AF_UNIX; 28 InitSocket = socket (AF_UNIX, SOCK_STREAM, 0); 29 status = bind (InitSocket, &Address, sizeof (Address)); 30 status = listen (InitSocket, 1); 31 32 sprintf (temp, "kapa %s &", socket_name); 33 # ifndef DEBUG 34 system (temp); 35 # else 36 fprintf (stderr, "start kapa, press return: %s\n", temp); 37 fscanf (stdin, "%d", &i); 38 # endif 39 40 addreslen = sizeof (Address); 41 Xgraph[N] = accept (InitSocket, &Address, &addreslen); 18 19 sprintf (name, "gastro [%d]", N); 20 Xgraph[N] = KapaOpen ("kapa", name); 21 42 22 if (Xgraph[N] < 0) { 43 23 fprintf (stderr, "error starting kapa\n"); 44 24 return (FALSE); 45 25 } 46 else { 47 return (TRUE); 48 } 49 26 return (TRUE); 50 27 } 51 28 52 29 void DonePlotting (Graphdata *graphmode, int N) { 53 char buffer[65], buffer2[65];54 30 55 31 if (Xgraph[N] == 0) return; 56 57 write (Xgraph[N], "DBOX", 4); 58 sprintf (buffer, "%f %f %f %f", graphmode[0].xmin, graphmode[0].xmax, graphmode[0].ymin, graphmode[0].ymax); 59 sprintf (buffer2, "NBYTES: %6d", strlen (buffer)); 60 write (Xgraph[N], buffer2, 16); 61 write (Xgraph[N], buffer, strlen (buffer)); 62 63 sprintf (buffer, "%s %s %s", "2222", "2222", "2222"); 64 sprintf (buffer2, "NBYTES: %6d", strlen (buffer)); 65 write (Xgraph[N], buffer2, 16); 66 write (Xgraph[N], buffer, strlen (buffer)); 67 } 68 69 void JpegPlot (Graphdata *graphmode, int N, char *filename) { 70 char buffer[65], buffer2[65]; 71 72 if (Xgraph[N] == 0) return; 73 74 write (Xgraph[N], "PNGF", 4); 75 sprintf (buffer, "LEN: %11d", strlen (filename)); 76 write (Xgraph[N], buffer, 16); 77 write (Xgraph[N], filename, strlen (filename)); 78 read (Xgraph[N], buffer, 4); 79 } 80 81 void PSPlot (Graphdata *graphmode, int N, char *filename) { 82 char buffer[65], buffer2[65]; 83 84 if (Xgraph[N] == 0) return; 85 86 write (Xgraph[N], "PSIT", 4); 87 sprintf (buffer, "LEN: %11d", strlen (filename)); 88 write (Xgraph[N], buffer, 16); 89 write (Xgraph[N], filename, strlen (filename)); 90 read (Xgraph[N], buffer, 4); 32 KapaBox (Xgraph[N], graphmode); 33 return; 91 34 } 92 35 93 36 void PrepPlotting (int Npts, Graphdata *graphmode, int N) { 94 37 95 int i, status;96 char buffer[128], buffer2[128];97 98 38 active = N; 99 39 if (Npts < 1) return; 100 40 101 if (Xgraph[N] < 1) if (!open_graph(N)) return; 41 KapaPrepPlot (Xgraph[N], Npts, graphmode); 42 } 102 43 103 /* test Xgraph[N], flush junk from pipe */ 104 signal (SIGPIPE, XDead); 105 fcntl (Xgraph[N], F_SETFL, O_NONBLOCK); 106 for (i = 0; (read (Xgraph[N], buffer, 64) > 0) && (i < 20); i++); 107 fcntl (Xgraph[N], F_SETFL, !O_NONBLOCK); 108 109 write (Xgraph[N], "ERAS", 4); 110 111 /* tell kapa to look for the incoming image */ 112 status = write (Xgraph[N], "PLOT", 4); 44 void PlotVector (int Npts, float *vect, int mode, int N) { 113 45 114 /* send Xgraph[N] the plot details */ 115 sprintf (buffer, "%8d %8d %d %d %d %d %f %f", 116 Npts, graphmode[0].style, 117 graphmode[0].ptype, graphmode[0].ltype, 118 graphmode[0].etype, graphmode[0].color, 119 graphmode[0].lweight, graphmode[0].size); 120 sprintf (buffer2, "NBYTES: %6d", strlen (buffer)); 121 write (Xgraph[N], buffer2, 16); 122 write (Xgraph[N], buffer, strlen (buffer)); 123 124 sprintf (buffer, "%f %f %f %f", 125 graphmode[0].xmin, graphmode[0].xmax, 126 graphmode[0].ymin, graphmode[0].ymax); 127 sprintf (buffer2, "NBYTES: %6d", strlen (buffer)); 128 write (Xgraph[N], buffer2, 16); 129 write (Xgraph[N], buffer, strlen (buffer)); 46 int Nbytes; 130 47 48 if (Npts < 1) return; 49 active = N; 50 KapaPlotVector (Xgraph[N], Npts, vect); 131 51 } 132 52 … … 137 57 if (Xgraph[N] == 0) return; 138 58 139 write (Xgraph[N], "LABL", 4); 140 sprintf (buffer, " %6d %6d", strlen (string), 2); 141 write (Xgraph[N], buffer, 16); 142 write (Xgraph[N], string, strlen (string)); 59 KapaSendLabel (Xgraph[N[, string, 4); 143 60 } 144 61 145 void Plot Vector (int Npts, double *vect, int mode,int N) {62 void PlotReset (int N) { 146 63 147 float *values;148 int i , Nbytes;64 char buffer[128]; 65 int i; 149 66 150 active = N; 151 if (Npts < 1) return; 67 /* test Xgraph[N], flush junk from pipe */ 68 signal (SIGPIPE, XDead); 69 fcntl (Xgraph[N], F_SETFL, O_NONBLOCK); 70 for (i = 0; (read (Xgraph[N], buffer, 64) > 0) && (i < 20); i++); 71 fcntl (Xgraph[N], F_SETFL, !O_NONBLOCK); 72 73 if (Xgraph[N] < 1) if (!open_graph(N)) return; 74 KapaClearSections (Xgraph[N]); 75 } 152 76 153 ALLOCATE (values, float, Npts); 154 for (i = 0; i < Npts; i++) { 155 values[i] = vect[i]; 156 } 77 void JpegPlot (Graphdata *graphmode, int N, char *filename) { 157 78 158 Nbytes = Npts * sizeof (float); 159 write (Xgraph[N], values, Nbytes); 160 free (values); 79 if (Xgraph[N] == 0) return; 161 80 81 KapaPNG (Xgraph[N], filename); 82 return; 83 } 84 85 void PSPlot (Graphdata *graphmode, int N, char *filename) { 86 87 if (Xgraph[N] == 0) return; 88 89 KiiPS (Xgraph[N], filename, TRUE, KAPA_PS_NEWPLOT, "default"); 90 return; 162 91 } 163 92
Note:
See TracChangeset
for help on using the changeset viewer.
