annotate GEMBASSY-1.0.3/include/gplot.c @ 0:8300eb051bea draft

Initial upload
author ktnyt
date Fri, 26 Jun 2015 05:19:29 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1 /******************************************************************************
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2 ** @source GEMBASSY plot routines
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3 **
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
4 ** @version 1.0
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
5 ** @modified December 27 2012 Hidetoshi Itaya Created this file
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
6 ** @@
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
7 **
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
8 ** This library is free software; you can redistribute it and/or
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
9 ** modify it under the terms of the GNU Library General Public
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
10 ** License as published by the Free Software Foundation; either
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
11 ** version 2 of the License, or (at your option) any later version.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
12 **
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
13 ** This library is distributed in the hope that it will be useful,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
16 ** Library General Public License for more details.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
17 **
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
18 ** You should have received a copy of the GNU Library General Public
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
19 ** License along with this library; if not, write to the
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
20 ** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
21 ** Boston, MA 02111-1307, USA.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
22 ******************************************************************************/
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
23
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
24
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
25 #include "gplot.h"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
26
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
27
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
28
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
29
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
30 /* @funclist gPlotFilebuff ****************************************************
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
31 **
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
32 ** Retrieves data from file buffer and plots the data using gPlotData
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
33 **
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
34 ******************************************************************************/
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
35
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
36 AjBool gPlotFilebuff(AjPFilebuff buff, AjPGraph graphs, gPlotParams *gpp)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
37 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
38 AjPStr line = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
39 AjPPStr temp = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
40 AjPPStr name = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
41 ajint i = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
42 ajint j = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
43 ajint col = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
44 ajint flag = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
45 float **data = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
46
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
47 while(ajBuffreadLine(buff, &line))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
48 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
49
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
50 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
51 ** Allocate first time only
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
52 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
53
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
54 if(!col)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
55 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
56 col = ajStrCalcCountC(line, ",") + 1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
57
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
58 if((temp = (AjPPStr)malloc(sizeof(AjPStr) * col)) == NULL)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
59 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
60 return ajFalse;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
61 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
62
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
63 if((name = (AjPPStr)malloc(sizeof(AjPStr) * col)) == NULL)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
64 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
65 AJFREE(temp);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
66 return ajFalse;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
67 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
68
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
69 if((data = (float**)malloc(sizeof(float*) * col)) == NULL)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
70 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
71 AJFREE(temp);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
72 AJFREE(name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
73 return ajFalse;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
74 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
75 for(i = 0; i < col; ++i)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
76 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
77 if((data[i] = (float*)malloc(sizeof(float))) == NULL){
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
78 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
79 AJFREE(temp);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
80 AJFREE(name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
81 for(j = 0; j < i; ++j)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
82 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
83 AJFREE(data[j]);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
84 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
85 AJFREE(data);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
86 return ajFalse;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
87 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
88 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
89 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
90 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
91
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
92 ajStrExchangeCC(&line, ",", "\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
93 ajStrParseSplit(line, &temp);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
94
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
95 for(i = 0; i < col; ++i)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
96 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
97 if((data[i] = (float*)realloc(data[i], sizeof(float) * (j + 1))) == NULL)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
98 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
99 AJFREE(temp);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
100 AJFREE(name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
101 for(j = 0; j < i; ++j)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
102 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
103 AJFREE(data[j]);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
104 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
105 AJFREE(data);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
106 return ajFalse;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
107 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
108
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
109 ajStrRemoveLastNewline(&(temp[i]));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
110 if(ajStrIsFloat(temp[i]))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
111 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
112 ajStrToFloat(temp[i], &(data[i][j]));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
113 ++flag;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
114 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
115 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
116 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
117 name[i] = ajStrNewS(temp[i]);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
118 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
119 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
120 j = flag ? j + 1 : j;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
121 flag = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
122 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
123
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
124 (*gpp).data = data;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
125 (*gpp).setNum = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
126 (*gpp).dataNum = j;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
127 (*gpp).typeNum = col;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
128 if(!(*gpp).names)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
129 (*gpp).names = name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
130
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
131 if(j < 2)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
132 gPlotFlip(gpp);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
133
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
134 gPlotData(graphs, gpp);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
135
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
136 for(i = 0; i < (*gpp).typeNum; ++i)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
137 AJFREE((*gpp).data[i]);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
138 AJFREE((*gpp).data);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
139
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
140 data = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
141
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
142 ajStrDel(&line);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
143
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
144 return ajTrue;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
145 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
146
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
147
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
148
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
149
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
150 /* @funclist gPlotData ********************************************************
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
151 **
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
152 ** Function to plot from given data
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
153 **
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
154 ******************************************************************************/
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
155
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
156 AjBool gPlotData(AjPGraph graphs, gPlotParams *gpp)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
157 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
158 AjPGraphdata gd = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
159
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
160 float min = 0.0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
161 float max = 0.0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
162 float dif = 0.0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
163 ajint i;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
164 ajint j;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
165
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
166 ajint setNum = (*gpp).setNum;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
167 ajint dataNum = (*gpp).dataNum;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
168 ajint typeNum = (*gpp).typeNum;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
169 AjPStr title = (*gpp).title;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
170 AjPStr xlab = (*gpp).xlab;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
171 AjPStr ylab = (*gpp).ylab;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
172 AjPPStr names = (*gpp).names;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
173 float **data = (*gpp).data;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
174
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
175 float x[dataNum];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
176 float y[dataNum];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
177 float begin = data[0][0];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
178 float end = data[0][dataNum-1];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
179 float range = end - begin;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
180
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
181 int c[] = {1,3,9,13};
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
182
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
183 for(i = 1; i < typeNum; ++i)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
184 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
185 for(j = 0; j < dataNum; ++j)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
186 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
187 min = (min < data[i][j]) ? min : data[i][j];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
188 max = (max > data[i][j]) ? max : data[i][j];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
189 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
190 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
191
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
192 dif = (min == max) ? 20 : max - min;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
193 max += dif / 20;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
194 min -= dif / 20;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
195
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
196 for(i = 1; i < typeNum; ++i)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
197 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
198 gd = ajGraphdataNewI(dataNum);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
199
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
200 ajGraphdataSetColour(gd, c[i-1]);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
201 ajGraphdataSetMinmax(gd, begin, end, min, max);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
202 ajGraphdataSetTruescale(gd, begin, end, min, max);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
203 ajGraphdataSetTypeC(gd, "Multi 2D Plot");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
204
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
205 for(j = 0; j < dataNum; ++j)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
206 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
207 x[j] = data[0][j];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
208 y[j] = data[i][j];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
209 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
210
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
211 ajGraphdataAddXY(gd, x, y);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
212 ajGraphDataAdd(graphs, gd);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
213
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
214 if(typeNum > 2)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
215 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
216 float len = 0.0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
217
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
218 for(j = 1; j < typeNum; ++j)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
219 len = (len < (float)ajStrGetLen(names[j])) ?
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
220 (float)ajStrGetLen(names[j]) : len;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
221
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
222 ajGraphAddLine(graphs,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
223 range * 7.4/8 + begin, dif * (8.6-i*0.3)/8 + min,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
224 range * 7.8/8 + begin, dif * (8.6-i*0.3)/8 + min,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
225 c[i-1]);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
226 ajGraphAddTextScaleS(graphs,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
227 range * (7.3/8 - len*1/144) + begin,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
228 dif * (8.6-i*0.3)/8 + min,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
229 0, 0.4,
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
230 names[i]);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
231 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
232
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
233 gd = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
234 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
235
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
236 ajGraphxySetXstartF(graphs, begin);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
237 ajGraphxySetXendF(graphs, end);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
238 ajGraphxySetYstartF(graphs, min - ((max - min) / 10));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
239 ajGraphxySetYendF(graphs, max + ((max - min) / 10));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
240
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
241 //ajGraphSetTitleS(graphs, title);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
242 ajGraphSetXlabelS(graphs, xlab);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
243 ajGraphSetYlabelS(graphs, ylab);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
244 ajGraphxySetflagOverlay(graphs, ajTrue);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
245
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
246 ajGraphxyDisplay(graphs, AJFALSE);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
247 ajGraphicsClose();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
248
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
249 return ajTrue;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
250 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
251
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
252
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
253
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
254
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
255 /* @funclist gPlotFlip ********************************************************
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
256 **
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
257 ** Function to flip x and y data
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
258 **
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
259 ******************************************************************************/
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
260
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
261 AjBool gPlotFlip(gPlotParams *gpp)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
262 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
263 ajint setNum = (*gpp).setNum;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
264 ajint dataNum = (*gpp).typeNum;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
265 ajint typeNum = (*gpp).dataNum;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
266 float **data = (*gpp).data;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
267
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
268 float **newdata;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
269 ajint i;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
270 ajint j;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
271
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
272 if((newdata = (float**)malloc(sizeof(float*) * typeNum)) == NULL)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
273 return ajFalse;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
274 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
275 for(i = 0; i < typeNum + 1; ++i)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
276 if((newdata[i] = (float*)malloc(sizeof(float))) == NULL)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
277 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
278 AJFREE(newdata);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
279 return ajFalse;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
280 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
281
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
282 for(i = 0; i < dataNum; ++i){
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
283 if((newdata[0] = (float*)realloc(newdata[0],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
284 sizeof(float) * (i + 1))) == NULL)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
285 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
286 for(j = 0; j < i; ++j)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
287 AJFREE(newdata[j]);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
288 AJFREE(newdata);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
289 return ajFalse;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
290 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
291 if((newdata[1] = (float*)realloc(newdata[1],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
292 sizeof(float) * (i + 1))) == NULL)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
293 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
294 for(j = 0; j < i; ++j)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
295 AJFREE(newdata[j]);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
296 AJFREE(newdata);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
297 return ajFalse;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
298 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
299 newdata[0][i] = i;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
300 newdata[1][i] = data[i][0];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
301 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
302
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
303 for(i = 0; i < dataNum; ++i)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
304 {
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
305 AJFREE((*gpp).data[i]);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
306 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
307 AJFREE((*gpp).data);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
308
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
309 (*gpp).dataNum = dataNum;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
310 (*gpp).typeNum = 2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
311 (*gpp).data = newdata;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
312
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
313 return ajTrue;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
314 }