Changeset 13402
- Timestamp:
- May 16, 2007, 3:19:08 PM (19 years ago)
- Location:
- branches/kapa-mods-2007-05/Ohana/src
- Files:
-
- 1 added
- 18 edited
-
gastro/src/plotstuff.c (modified) (3 diffs)
-
gastro2/src/plotstuff.c (modified) (5 diffs)
-
kapa2/include/prototypes.h (modified) (1 diff)
-
kapa2/src/CheckPipe.c (modified) (4 diffs)
-
kapa2/src/EraseImage.c (added)
-
kii/event/CheckPipe.c (modified) (2 diffs)
-
libkapa/doc/api.txt (modified) (1 diff)
-
libkapa/include/kapa.h (modified) (1 diff)
-
libkapa/src/IOfuncs.c (modified) (1 diff)
-
libkapa/src/KapaWindow.c (modified) (11 diffs)
-
libkapa/src/KiiConvert.c (modified) (4 diffs)
-
libkapa/src/KiiCursor.c (modified) (1 diff)
-
libkapa/src/KiiOverlay.c (modified) (3 diffs)
-
libkapa/src/KiiPicture.c (modified) (2 diffs)
-
opihi/cmd.astro/region.c (modified) (2 diffs)
-
opihi/lib.data/PlotVectors.c (modified) (3 diffs)
-
relastro/src/plotstuff.c (modified) (3 diffs)
-
relphot/src/plotstuff.c (modified) (3 diffs)
-
uniphot/src/plotstuff.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/kapa-mods-2007-05/Ohana/src/gastro/src/plotstuff.c
r12332 r13402 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 ("kapa2", 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];79 80 38 active = N; 81 39 if (Npts < 1) return; 82 40 83 /* test Xgraph[N], flush junk from pipe */ 84 signal (SIGPIPE, XDead); 85 fcntl (Xgraph[N], F_SETFL, O_NONBLOCK); 86 for (i = 0; (read (Xgraph[N], buffer, 64) > 0) && (i < 20); i++); 87 fcntl (Xgraph[N], F_SETFL, !O_NONBLOCK); 88 89 if (Xgraph[N] < 1) if (!open_graph(N)) return; 90 91 /* tell kapa to look for the incoming image */ 92 status = write (Xgraph[N], "PLOT", 4); 93 94 /* send Xgraph[N] the plot details */ 95 sprintf (buffer, "%8d %8d %d %d %d %d %f %f ", 96 Npts, graphmode[0].style, 97 graphmode[0].ptype, graphmode[0].ltype, 98 graphmode[0].etype, graphmode[0].color, 99 graphmode[0].lweight, graphmode[0].size); 100 sprintf (buffer2, "NBYTES: %6d ", (unsigned int) strlen (buffer)); 101 write (Xgraph[N], buffer2, 16); 102 write (Xgraph[N], buffer, strlen (buffer)); 103 104 sprintf (buffer, "%f %f %f %f ", 105 graphmode[0].xmin, graphmode[0].xmax, 106 graphmode[0].ymin, graphmode[0].ymax); 107 sprintf (buffer2, "NBYTES: %6d ", (unsigned int) strlen (buffer)); 108 write (Xgraph[N], buffer2, 16); 109 write (Xgraph[N], buffer, strlen (buffer)); 110 41 KapaPrepPlot (Xgraph[N], Npts, graphmode); 111 42 } 112 43 … … 116 47 117 48 if (Npts < 1) return; 118 119 49 active = N; 120 Nbytes = Npts * sizeof (float); 121 write (Xgraph[N], vect, Nbytes); 122 50 KapaPlotVector (Xgraph[N], Npts, vect); 123 51 } 124 52 … … 135 63 136 64 if (Xgraph[N] < 1) if (!open_graph(N)) return; 137 138 write (Xgraph[N], "ERAS", 4); 65 KapaClear (Xgraph[N], TRUE); 66 } 139 67 140 }141 68 /* include these lines to plot a pair of vectors: 142 69 -
branches/kapa-mods-2007-05/Ohana/src/gastro2/src/plotstuff.c
r12332 r13402 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 ("kapa2", 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 … … 61 30 char buffer[65], buffer2[65]; 62 31 63 write (Xgraph[N], "DBOX", 4); 64 sprintf (buffer, "%f %f %f %f", graphmode[0].xmin, graphmode[0].xmax, graphmode[0].ymin, graphmode[0].ymax); 65 sprintf (buffer2, "NBYTES: %6d", (unsigned int) strlen (buffer)); 66 write (Xgraph[N], buffer2, 16); 67 write (Xgraph[N], buffer, strlen (buffer)); 68 69 sprintf (buffer, "%s %s %s", "2222", "2222", "2222"); 70 sprintf (buffer2, "NBYTES: %6d", (unsigned int) strlen (buffer)); 71 write (Xgraph[N], buffer2, 16); 72 write (Xgraph[N], buffer, strlen (buffer)); 32 KapaBox (Xgraph[N], graphmode); 73 33 } 74 34 … … 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 KapaClear (Xgraph[N], TRUE); 68 } 139 69 140 }141 70 /* include these lines to plot a pair of vectors: 142 71 -
branches/kapa-mods-2007-05/Ohana/src/kapa2/include/prototypes.h
r13344 r13402 61 61 int ErasePlots PROTO((void)); 62 62 int EraseSections PROTO((void)); 63 int EraseImage PROTO((void)); 63 64 64 65 int LoadVectorData PROTO((int sock, KapaGraphWidget *graph, int N, char *type)); -
branches/kapa-mods-2007-05/Ohana/src/kapa2/src/CheckPipe.c
r13394 r13402 15 15 16 16 int status; 17 char buffer[32];17 char word[5]; 18 18 19 19 // check if we have a valid connection. if not, see if we can get one … … 26 26 27 27 /***** read (4 byte) message word from socket ****/ 28 status = read (sock, buffer, 4);29 buffer[4] = 0;28 status = read (sock, word, 4); 29 word[4] = 0; 30 30 switch (status) { 31 31 case -1: /* no input from pipe: continue */ … … 49 49 /***** handle different messages ****/ 50 50 if (ACTIVE_CURSOR) { 51 if (strcmp ( buffer, "NCUR")) {52 fprintf (stderr, "wrong end message %s\n", buffer);51 if (strcmp (word, "NCUR")) { 52 fprintf (stderr, "wrong end message %s\n", word); 53 53 return (TRUE); 54 54 } … … 57 57 } 58 58 59 if (!strcmp ( buffer, "QUIT")) return (FALSE);60 61 if (!strcmp ( buffer, "CURS")) {59 if (!strcmp (word, "QUIT")) return (FALSE); 60 61 if (!strcmp (word, "CURS")) { 62 62 ACTIVE_CURSOR = TRUE; 63 63 return (TRUE); 64 64 } 65 65 66 if (!strcmp ( buffer, "PSIT")) {66 if (!strcmp (word, "PSIT")) { 67 67 status = PScommand (sock); 68 write (sock, "DONE", 4);69 return (status); 70 } 71 72 if (!strcmp ( buffer, "PNGF")) {68 KiiSendCommand (sock, 4, "DONE"); 69 return (status); 70 } 71 72 if (!strcmp (word, "PNGF")) { 73 73 status = PNGit (sock); 74 write (sock, "DONE", 4);75 return (status); 76 } 77 78 if (!strcmp ( buffer, "PPMF")) {74 KiiSendCommand (sock, 4, "DONE"); 75 return (status); 76 } 77 78 if (!strcmp (word, "PPMF")) { 79 79 status = PPMit (sock); 80 write (sock, "DONE", 4);81 return (status); 82 } 83 84 if (!strcmp ( buffer, "DBOX")) {80 KiiSendCommand (sock, 4, "DONE"); 81 return (status); 82 } 83 84 if (!strcmp (word, "DBOX")) { 85 85 status = LoadFrame (sock); 86 return (status); 87 } 88 89 if (!strcmp (buffer, "PLOT")) { 86 KiiSendCommand (sock, 4, "DONE"); 87 return (status); 88 } 89 90 if (!strcmp (word, "PLOT")) { 90 91 status = LoadObject (sock); 91 return (status); 92 } 93 94 if (!strcmp (buffer, "LABL")) { 92 KiiSendCommand (sock, 4, "DONE"); 93 return (status); 94 } 95 96 if (!strcmp (word, "LABL")) { 95 97 status = LoadLabels (sock); 96 return (TRUE); 97 } 98 99 if (!strcmp (buffer, "PTXT")) { 98 KiiSendCommand (sock, 4, "DONE"); 99 return (TRUE); 100 } 101 102 if (!strcmp (word, "PTXT")) { 100 103 status = LoadTextlines (sock); 101 return (TRUE); 102 } 103 104 if (!strcmp (buffer, "RSIZ")) { 104 KiiSendCommand (sock, 4, "DONE"); 105 return (TRUE); 106 } 107 108 if (!strcmp (word, "RSIZ")) { 105 109 status = Resize (sock); 106 return (status); 107 } 108 109 if (!strcmp (buffer, "LIMS")) { 110 KiiSendCommand (sock, 4, "DONE"); 111 return (status); 112 } 113 114 if (!strcmp (word, "LIMS")) { 110 115 GetLimits (sock); 111 return (TRUE); 112 } 113 114 if (!strcmp (buffer, "SLIM")) { 116 KiiSendCommand (sock, 4, "DONE"); 117 return (TRUE); 118 } 119 120 if (!strcmp (word, "SLIM")) { 115 121 status = SetLimits (sock); 116 return (TRUE); 117 } 118 119 if (!strcmp (buffer, "SSEC")) { 122 KiiSendCommand (sock, 4, "DONE"); 123 return (TRUE); 124 } 125 126 if (!strcmp (word, "SSEC")) { 120 127 status = SetSection (sock); 121 return (TRUE); 122 } 123 124 if (!strcmp (buffer, "LSEC")) { 128 KiiSendCommand (sock, 4, "DONE"); 129 return (TRUE); 130 } 131 132 if (!strcmp (word, "LSEC")) { 125 133 status = ListSection (sock); 126 return (TRUE); 127 } 128 129 if (!strcmp (buffer, "DSEC")) { 134 KiiSendCommand (sock, 4, "DONE"); 135 return (TRUE); 136 } 137 138 if (!strcmp (word, "DSEC")) { 130 139 status = DefineSection (sock); 131 return (TRUE); 132 } 133 134 if (!strcmp (buffer, "FONT")) { 140 KiiSendCommand (sock, 4, "DONE"); 141 return (TRUE); 142 } 143 144 if (!strcmp (word, "FONT")) { 135 145 status = SetFont (sock); 146 KiiSendCommand (sock, 4, "DONE"); 136 147 return (TRUE); 137 148 } 138 149 139 150 /* Erase Section */ 140 if (!strcmp ( buffer, "ERSC")) {151 if (!strcmp (word, "ERSC")) { 141 152 status = EraseCurrentPlot (); 142 return (status); 143 } 144 145 /* Erase Section */ 146 if (!strcmp (buffer, "ERAS")) { 153 KiiSendCommand (sock, 4, "DONE"); 154 return (status); 155 } 156 157 /* Erase Plots */ 158 if (!strcmp (word, "ERSP")) { 147 159 status = ErasePlots (); 148 return (status); 149 } 150 151 /* Don't Erase Section */ 152 if (!strcmp (buffer, "ERSS")) { 160 KiiSendCommand (sock, 4, "DONE"); 161 return (status); 162 } 163 164 /* Erase Sections */ 165 if (!strcmp (word, "ERSS")) { 153 166 status = EraseSections (); 154 return (status); 155 } 156 157 158 if (!strcmp (buffer, "READ")) { 167 KiiSendCommand (sock, 4, "DONE"); 168 return (status); 169 } 170 171 /* Erase Image */ 172 if (!strcmp (word, "ERSI")) { 173 status = EraseImage (); 174 KiiSendCommand (sock, 4, "DONE"); 175 return (status); 176 } 177 178 /* Erase Overlay for this section */ 179 if (!strcmp (word, "ERSO")) { 180 status = EraseOverlay (sock); 181 KiiSendCommand (sock, 4, "DONE"); 182 return (status); 183 } 184 185 if (!strcmp (word, "READ")) { 159 186 status = LoadPicture (sock); 160 return (status); 161 } 162 163 // XXX duplicate Command word 164 if (!strcmp (buffer, "ERAS")) { 165 status = EraseOverlay (sock); 166 return (status); 167 } 168 169 if (!strcmp (buffer, "LOAD")) { 187 KiiSendCommand (sock, 4, "DONE"); 188 return (status); 189 } 190 191 if (!strcmp (word, "LOAD")) { 170 192 status = LoadOverlay (sock); 171 return (status); 172 } 173 174 if (!strcmp (buffer, "TICK")) { 193 KiiSendCommand (sock, 4, "DONE"); 194 return (status); 195 } 196 197 /* this is not currently used? 198 tickmarks were equivalent to the overlays, but fixed wrt the window. 199 this functionality is probably supplanted by the graph 200 if (!strcmp (word, "TICK")) { 175 201 status = LoadTickmarks (sock); 176 return (status); 177 } 178 179 if (!strcmp (buffer, "SAVE")) { 202 KiiSendCommand (sock, 4, "DONE"); 203 return (status); 204 } 205 */ 206 207 if (!strcmp (word, "SAVE")) { 180 208 status = SaveOverlay (sock); 181 return (status); 182 } 183 184 if (!strcmp (buffer, "CSVE")) { 209 KiiSendCommand (sock, 4, "DONE"); 210 return (status); 211 } 212 213 if (!strcmp (word, "CSVE")) { 185 214 status = CSaveOverlay (sock); 186 return (status); 187 } 188 189 if (!strcmp (buffer, "JPEG")) { 215 KiiSendCommand (sock, 4, "DONE"); 216 return (status); 217 } 218 219 if (!strcmp (word, "JPEG")) { 190 220 status = JPEGit24 (sock); 191 write (sock, "DONE", 4);192 return (status); 193 } 194 195 if (!strcmp ( buffer, "CENT")) {221 KiiSendCommand (sock, 4, "DONE"); 222 return (status); 223 } 224 225 if (!strcmp (word, "CENT")) { 196 226 status = Center (sock); 197 return (status); 198 } 199 200 if (!strcmp (buffer, "NPIX")) { 227 KiiSendCommand (sock, 4, "DONE"); 228 return (status); 229 } 230 231 if (!strcmp (word, "NPIX")) { 201 232 GetPixelCount (sock); 202 return (TRUE); 203 } 204 205 fprintf (stderr, "unknown signal %s\n", buffer); 233 KiiSendCommand (sock, 4, "DONE"); 234 return (TRUE); 235 } 236 237 fprintf (stderr, "unknown signal %s\n", word); 206 238 207 239 return (TRUE); -
branches/kapa-mods-2007-05/Ohana/src/kii/event/CheckPipe.c
r13287 r13402 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); -
branches/kapa-mods-2007-05/Ohana/src/libkapa/doc/api.txt
r13401 r13402 1 1 2 COMM | Kapa Function | libkapa API 3 ----------------------------------- 4 NCUR | !ACTIVE_CURSOR | KiiCursorOff 5 QUIT | Quit | 6 CURS 7 PSIT 8 PNGF 9 PPMF 10 DBOX 11 PLOT 12 LABL 13 PTXT 14 RSIZ 15 LIMS 16 SLIM 17 SSEC 18 LSEC 19 DSEC 20 FONT 21 ERSC 22 ERAS 23 ERSS 24 READ 25 ERAS 26 LOAD 27 TICK 28 SAVE 29 CSVE 30 JPEG 31 CENT 32 NPIX 2 COMM | Kapa Function | libkapa file | libkapa API 3 ----------------------------------------------------- 4 DBOX | LoadFrame | KapaWindow.c | KapaBox 5 ERSP | ErasePlots | KapaWindow.c | KapaClearPlots 6 ERSS | EraseSections | KapaWindow.c | KapaClearSections 7 ERSI | EraseImage | KapaWindow.c | KapaClearImage 8 ERSC | EraseCurrentPlot | KapaWindow.c | KapaClearCurrentPlot 9 LSEC | ListSection | KapaWindow.c | KapaGetSection 10 PNGF | PNGit | KiiConvert.c | KapaPNG 11 PPMF | PPMit | KiiConvert.c | KapaPPM 12 PLOT | LoadObject | KapaWindow.c | KapaPrepPlot 13 SSEC | SetSection | KapaWindow.c | KapaSelectSection 14 LABL | LoadLabels | KapaWindow.c | KapaSendLabel 15 PTXT | LoadTextlines | KapaWindow.c | KapaSendTextline 16 FONT | SetFont | KapaWindow.c | KapaSetFont 17 SLIM | SetLimits | KapaWindow.c | KapaSetLimits 18 DSEC | DefineSection | KapaWindow.c | KapaSetSection 19 CENT | Center | KapaWindow.c | KiiCenter 20 QUIT | Quit | KiiOpen.c | KiiClose 21 NCUR | !ACTIVE_CURSOR | KiiCursor.c | KiiCursorOff 22 CURS | +ACTIVE_CURSOR | KiiCursor.c | KiiCursorOn 23 ERSO | EraseOverlay | KiiOverlay.c | KiiEraseOverlay 24 JPEG | JPEGit24 | KiiConvert.c | KiiJPEG 25 LOAD | LoadOverlay | KiiOverlay.c | KiiLoadOverlay 26 READ | LoadPicture | KiiPicture.c | KiiNewPicture1D 27 READ | LoadPicture | KiiPicture.c | KiiNewPicture2D 28 PSIT | PScommand | KiiConvert.c | KiiPS 29 RSIZ | Resize | KapaWindow.c | KiiResize 30 SAVE | SaveOverlay | KiiOverlay.c | KiiSaveOverlay 31 CSVE | CSaveOverlay | KiiOverlay.c | KiiSaveOverlay 32 LIMS | GetLimits | KapaWindow.c | KapaGetLimits 33 34 TICK | LoadTickmarks | XXX not used 35 NPIX | GetPixelCount | XXX not used? -
branches/kapa-mods-2007-05/Ohana/src/libkapa/include/kapa.h
r13344 r13402 140 140 int KiiCenter (int fd, double x, double y, int zoom); 141 141 int KapaBox (int fd, Graphdata *graphdata); 142 int KapaClear (int fd, int ClearSection); 142 int KapaClearCurrentPlot (int fd); 143 int KapaClearPlots (int fd); 144 int KapaClearSections (int fd); 145 int KapaClearImage (int fd); 143 146 int KapaInitGraph (Graphdata *graphdata); 144 147 int KapaPrepPlot (int fd, int Npts, Graphdata *graphmode); -
branches/kapa-mods-2007-05/Ohana/src/libkapa/src/IOfuncs.c
r13344 r13402 116 116 117 117 ALLOCATE (message, char, length + 1); 118 fcntl (device, F_SETFL, !O_NONBLOCK); // block until we get the response?? 118 119 119 120 /* read Nbytes from the device */ 120 121 status = read (device, message, length); 121 if (status != length) fprintf (stderr, "Kii/Kapa comm error\n"); 122 message[status] = 0; 123 /* make the string easy to parse */ 122 fcntl (device, F_SETFL, O_NONBLOCK); // unblock 123 124 if (status != length) { 125 fprintf (stderr, "Kii/Kapa comm error\n"); 126 return (0); 127 } 128 message[status] = 0; // make the string easy to parse 124 129 125 130 /* scan the incoming message */ 126 131 va_start (argp, format); 127 status =vsscanf (message, format, argp);132 vsscanf (message, format, argp); 128 133 va_end (argp); 129 134 130 return ( status);135 return (1); 131 136 } -
branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KapaWindow.c
r10923 r13402 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 KiiScanCommand (fd, 4, "%s", word); 8 if (strcmp (word, "DONE")) { 9 fprintf (stderr, "unexpected response %s\n", word); 10 return (FALSE); 11 } 12 13 return (TRUE); 14 } 2 15 3 16 int KiiResize (int fd, int Nx, int Ny) { … … 5 18 KiiSendCommand (fd, 4, "RSIZ"); 6 19 KiiSendMessage (fd, "%d %d", Nx, Ny); 7 return (TRUE); 8 } 9 10 int KiiCenter (int fd, double x, double y, int zoom) { 11 12 KiiSendCommand (fd, 4, "CENT"); 13 KiiSendMessage (fd, "%8.3f %8.3f %8d ", x, y, zoom); 20 KiiScanCommand (fd, 4, "%s", word); 21 if (strcmp (word, "DONE")) { 22 fprintf (stderr, "unexpected response %s\n", word); 23 return (FALSE); 24 } 25 14 26 return (TRUE); 15 27 } … … 23 35 24 36 KiiSendMessage (fd, "%s %s %s", graphdata[0].axis, graphdata[0].labels, graphdata[0].ticks); 25 return (TRUE); 26 } 27 28 int KapaClear (int fd, int ClearSection) { 29 30 if (ClearSection) { 31 KiiSendCommand (fd, 4, "ERAS"); 32 } else { 33 KiiSendCommand (fd, 4, "ERSS"); 37 KiiScanCommand (fd, 4, "%s", word); 38 if (strcmp (word, "DONE")) { 39 fprintf (stderr, "unexpected response %s\n", word); 40 return (FALSE); 41 } 42 43 return (TRUE); 44 } 45 46 int KapaClearCurrentPlot (int fd) { 47 48 KiiSendCommand (fd, 4, "ERSC"); 49 KiiScanCommand (fd, 4, "%s", word); 50 if (strcmp (word, "DONE")) { 51 fprintf (stderr, "unexpected response %s\n", word); 52 return (FALSE); 53 } 54 return (TRUE); 55 } 56 57 int KapaClearPlots (int fd) { 58 59 KiiSendCommand (fd, 4, "ERSP"); 60 KiiScanCommand (fd, 4, "%s", word); 61 if (strcmp (word, "DONE")) { 62 fprintf (stderr, "unexpected response %s\n", word); 63 return (FALSE); 64 } 65 return (TRUE); 66 } 67 68 int KapaClearSections (int fd) { 69 70 KiiSendCommand (fd, 4, "ERSS"); 71 KiiScanCommand (fd, 4, "%s", word); 72 if (strcmp (word, "DONE")) { 73 fprintf (stderr, "unexpected response %s\n", word); 74 return (FALSE); 75 } 76 return (TRUE); 77 } 78 79 int KapaClearImage (int fd) { 80 81 KiiSendCommand (fd, 4, "ERSI"); 82 KiiScanCommand (fd, 4, "%s", word); 83 if (strcmp (word, "DONE")) { 84 fprintf (stderr, "unexpected response %s\n", word); 85 return (FALSE); 34 86 } 35 87 return (TRUE); … … 76 128 graphmode[0].xmin, graphmode[0].xmax, 77 129 graphmode[0].ymin, graphmode[0].ymax); 130 131 KiiScanCommand (fd, 4, "%s", word); 132 if (strcmp (word, "DONE")) { 133 fprintf (stderr, "unexpected response %s\n", word); 134 return (FALSE); 135 } 136 78 137 return (TRUE); 79 138 } … … 93 152 KiiSendCommand (fd, 16, "%s", name); 94 153 KiiSendCommand (fd, 16, "%d", size); 154 155 KiiScanCommand (fd, 4, "%s", word); 156 if (strcmp (word, "DONE")) { 157 fprintf (stderr, "unexpected response %s\n", word); 158 return (FALSE); 159 } 160 95 161 return (TRUE); 96 162 } … … 101 167 KiiSendMessage (fd, "%6d", mode); 102 168 KiiSendData (fd, string, strlen(string)); 169 170 KiiScanCommand (fd, 4, "%s", word); 171 if (strcmp (word, "DONE")) { 172 fprintf (stderr, "unexpected response %s\n", word); 173 return (FALSE); 174 } 175 103 176 return (TRUE); 104 177 } … … 109 182 KiiSendMessage (fd, "%f %f %f", x, y, angle); 110 183 KiiSendData (fd, string, strlen(string)); 184 185 KiiScanCommand (fd, 4, "%s", word); 186 if (strcmp (word, "DONE")) { 187 fprintf (stderr, "unexpected response %s\n", word); 188 return (FALSE); 189 } 190 111 191 return (TRUE); 112 192 } … … 116 196 KiiSendCommand (fd, 4, "SLIM"); 117 197 KiiSendMessage (fd, "%g %g %g %g ", graphmode[0].xmin, graphmode[0].xmax, graphmode[0].ymin, graphmode[0].ymax); 198 199 KiiScanCommand (fd, 4, "%s", word); 200 if (strcmp (word, "DONE")) { 201 fprintf (stderr, "unexpected response %s\n", word); 202 return (FALSE); 203 } 204 205 return (TRUE); 206 } 207 208 // for now, this just gets the dimensions 209 int KapaGetLimits (int fd, float *dx, float *dy) { 210 211 KiiSendCommand (kapa, 4, "LIMS"); 212 KiiScanMessage (kapa, "%lf %lf", dx, dy); 213 214 KiiScanCommand (fd, 4, "%s", word); 215 if (strcmp (word, "DONE")) { 216 fprintf (stderr, "unexpected response %s\n", word); 217 return (FALSE); 218 } 219 118 220 return (TRUE); 119 221 } … … 128 230 section[0].dx, 129 231 section[0].dy); 232 233 KiiScanCommand (fd, 4, "%s", word); 234 if (strcmp (word, "DONE")) { 235 fprintf (stderr, "unexpected response %s\n", word); 236 return (FALSE); 237 } 238 130 239 return (TRUE); 131 240 } … … 135 244 KiiSendCommand (fd, 4, "SSEC"); 136 245 KiiSendMessage (fd, "%s", name); 246 247 KiiScanCommand (fd, 4, "%s", word); 248 if (strcmp (word, "DONE")) { 249 fprintf (stderr, "unexpected response %s\n", word); 250 return (FALSE); 251 } 252 137 253 return (TRUE); 138 254 } … … 142 258 KiiSendCommand (fd, 4, "LSEC"); 143 259 KiiSendMessage (fd, "%s", name); 144 return (TRUE); 145 } 260 261 KiiScanCommand (fd, 4, "%s", word); 262 if (strcmp (word, "DONE")) { 263 fprintf (stderr, "unexpected response %s\n", word); 264 return (FALSE); 265 } 266 267 return (TRUE); 268 } -
branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiConvert.c
r12892 r13402 9 9 10 10 /* block for the response, which says the operation completed */ 11 read (fd, buffer, 4); 11 KiiScanCommand (fd, 4, "%s", word); 12 if (strcmp (word, "DONE")) { 13 fprintf (stderr, "unexpected response %s\n", word); 14 return (FALSE); 15 } 12 16 return (TRUE); 13 17 } … … 21 25 22 26 /* block for the response, which says the operation completed */ 23 read (fd, buffer, 4); 27 KiiScanCommand (fd, 4, "%s", word); 28 if (strcmp (word, "DONE")) { 29 fprintf (stderr, "unexpected response %s\n", word); 30 return (FALSE); 31 } 24 32 return (TRUE); 25 33 } … … 33 41 34 42 /* block for the response, which says the operation completed */ 35 read (fd, buffer, 4); 43 KiiScanCommand (fd, 4, "%s", word); 44 if (strcmp (word, "DONE")) { 45 fprintf (stderr, "unexpected response %s\n", word); 46 return (FALSE); 47 } 36 48 return (TRUE); 37 49 } … … 47 59 48 60 /* block for the response, which says the operation completed */ 49 read (fd, buffer, 4); 61 KiiScanCommand (fd, 4, "%s", word); 62 if (strcmp (word, "DONE")) { 63 fprintf (stderr, "unexpected response %s\n", word); 64 return (FALSE); 65 } 50 66 return (TRUE); 51 67 } -
branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiCursor.c
r5848 r13402 2 2 3 3 int KiiCursorOn (int fd) { 4 write (fd, "CURS", 4); /* ask Source to look for the keystrokes */ 4 KiiSendCommand (fd, 4, "CURS"); 5 KiiScanCommand (fd, 4, "%s", word); 6 if (strcmp (word, "DONE")) { 7 fprintf (stderr, "unexpected response %s\n", word); 8 return (FALSE); 9 } 5 10 return (TRUE); 6 11 } 7 12 8 13 int KiiCursorOff (int fd) { 9 write (fd, "NCUR", 4); /* ask Source to look for the keystrokes */ 14 KiiSendCommand (fd, 4, "NCUR"); 15 KiiScanCommand (fd, 4, "%s", word); 16 if (strcmp (word, "DONE")) { 17 fprintf (stderr, "unexpected response %s\n", word); 18 return (FALSE); 19 } 10 20 return (TRUE); 11 21 } -
branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiOverlay.c
r13334 r13402 88 88 conversions back and forth 89 89 */ 90 KiiScanCommand (fd, 4, "%s", word); 91 if (strcmp (word, "DONE")) { 92 fprintf (stderr, "unexpected response %s\n", word); 93 return (FALSE); 94 } 90 95 return (TRUE); 91 96 } … … 97 102 KiiSelectOverlay (overname, &n); 98 103 99 KiiSendCommand (fd, 4, "ER AS");104 KiiSendCommand (fd, 4, "ERSO"); 100 105 KiiSendCommand (fd, 16, "OVERLAY %7d ", n); 101 106 107 KiiScanCommand (fd, 4, "%s", word); 108 if (strcmp (word, "DONE")) { 109 fprintf (stderr, "unexpected response %s\n", word); 110 return (FALSE); 111 } 102 112 return (TRUE); 103 113 } … … 116 126 117 127 KiiSendMessage (fd, "FILE: %d %s", n, file); 128 129 KiiScanCommand (fd, 4, "%s", word); 130 if (strcmp (word, "DONE")) { 131 fprintf (stderr, "unexpected response %s\n", word); 132 return (FALSE); 133 } 118 134 return (TRUE); 119 135 } -
branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiPicture.c
r5852 r13402 58 58 free (outbuffer); 59 59 60 KiiScanCommand (fd, 4, "%s", word); 61 if (strcmp (word, "DONE")) { 62 fprintf (stderr, "unexpected response %s\n", word); 63 return (FALSE); 64 } 60 65 return (TRUE); 61 66 } … … 125 130 free (outbuffer); 126 131 132 KiiScanCommand (fd, 4, "%s", word); 133 if (strcmp (word, "DONE")) { 134 fprintf (stderr, "unexpected response %s\n", word); 135 return (FALSE); 136 } 127 137 return (TRUE); 128 138 } -
branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.astro/region.c
r13391 r13402 5 5 char string[256]; 6 6 double Ra, Dec, Radius; 7 doubledx, dy;7 float dx, dy; 8 8 int N, kapa; 9 9 char *name; … … 67 67 68 68 /* ask kapa for coordinate limits, so get the right aspect ratio */ 69 KiiSendCommand (kapa, 4, "LIMS"); 70 KiiScanMessage (kapa, "%lf %lf", &dx, &dy); 69 KapaGetLimits (kapa, &dx, &dy); 71 70 dx = fabs (dx); 72 71 dy = fabs (dy); -
branches/kapa-mods-2007-05/Ohana/src/opihi/lib.data/PlotVectors.c
r13391 r13402 6 6 7 7 if (!GetGraph (NULL, &kapa, NULL)) return (FALSE); 8 9 /* tell kapa to look for the incoming image */ 10 KiiSendCommand (kapa, 4, "PLOT"); 11 12 /* send kapa the plot details */ 13 KiiSendMessage (kapa, "%8d %8d %d %d %d %d %d %f %f", 14 Npts, graphmode[0].style, 15 graphmode[0].ptype, graphmode[0].ltype, 16 graphmode[0].etype, graphmode[0].ebar, graphmode[0].color, 17 graphmode[0].lweight, graphmode[0].size); 18 KiiSendMessage (kapa, "%g %g %g %g", 19 graphmode[0].xmin, graphmode[0].xmax, 20 graphmode[0].ymin, graphmode[0].ymax); 8 KapaPrepPlot (kapa, Npts, graphmode); 21 9 return (TRUE); 22 10 } … … 24 12 int PlotVector (int Npts, float *values) { 25 13 26 int Nbytes; 27 28 Nbytes = Npts * sizeof (float); 29 write (kapa, values, Nbytes); 14 KapaPlotVector (kapa, Npts, values); 30 15 return (TRUE); 31 16 } … … 33 18 int PlotVectorPair (int N, float *xValues, float *yValues, Graphdata *graphmode) { 34 19 35 PrepPlotting (N, graphmode);36 PlotVector (N, xValues);37 PlotVector (N, yValues);20 PrepPlotting (N, graphmode); 21 PlotVector (N, xValues); 22 PlotVector (N, yValues); 38 23 39 return (TRUE);24 return (TRUE); 40 25 } 41 26 42 27 int PlotVectorTriplet (int N, float *xValues, float *yValues, float *zValues, Graphdata *graphmode) { 43 28 44 PrepPlotting (N, graphmode);45 PlotVector (N, xValues);46 PlotVector (N, yValues);47 PlotVector (N, zValues);29 PrepPlotting (N, graphmode); 30 PlotVector (N, xValues); 31 PlotVector (N, yValues); 32 PlotVector (N, zValues); 48 33 49 return (TRUE);34 return (TRUE); 50 35 } 51 36 52 37 /* we don't use GetGraph in PlotVector because it flushes the connection */ 38 /* PlotVector currently operates on the static identified socket 39 rather than the currently active socket -- must be preceeded by PrepPlotting */ -
branches/kapa-mods-2007-05/Ohana/src/relastro/src/plotstuff.c
r12892 r13402 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 ("kapa2", name); 27 24 28 if (Xgraph[N] < 0) { 25 29 fprintf (stderr, "error starting kapa\n"); … … 61 65 KapaClear (Xgraph[N], TRUE); 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 } … … 95 88 } 96 89 97 Nbytes = Npts * sizeof (float); 98 write (Xgraph[N], values, Nbytes); 90 KapaPlotVector (Xgraph[N], Npts, values); 99 91 free (values); 100 92 return; -
branches/kapa-mods-2007-05/Ohana/src/relphot/src/plotstuff.c
r12892 r13402 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 ("kapa2", name); 27 24 28 if (Xgraph[N] < 0) { 25 29 fprintf (stderr, "error starting kapa\n"); … … 61 65 KapaClear (Xgraph[N], TRUE); 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 } … … 95 88 } 96 89 97 Nbytes = Npts * sizeof (float); 98 write (Xgraph[N], values, Nbytes); 90 KapaPlotVector (Xgraph[N], Npts, values); 99 91 free (values); 100 92 return; -
branches/kapa-mods-2007-05/Ohana/src/uniphot/src/plotstuff.c
r4797 r13402 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 ("kapa2", 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 KapaClear (Xgraph[N], TRUE); 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.
