1 | %{ |
---|
2 | #define COLOR_Milestone "gtcMilestone" |
---|
3 | #define COLOR_BOX_HEAVY "gtcBoxHeavy" |
---|
4 | #define COLOR_BOX_LIGHT "gtcBoxLight" |
---|
5 | |
---|
6 | #define PICT_TOPSEP 0.0 |
---|
7 | #define PICT_BOTSEP 3.0 |
---|
8 | #define PICT_LEFTSEP 3.0 |
---|
9 | #define PICT_RIGHTSEP 3.0 |
---|
10 | #define PICT_VSEP 2.0 |
---|
11 | #define PICT_HSEP 2.0 |
---|
12 | |
---|
13 | #define PICT_MONTHHEIGHT 5 // police height |
---|
14 | #define PICT_MONTHWIDTH (10./3.) |
---|
15 | |
---|
16 | #define TASK_VSEP 2 |
---|
17 | #define TASK_BGC0 "gtcTaskBG0" |
---|
18 | #define TASK_BGC1 "gtcTaskBG1" |
---|
19 | #define TASK_TITLEHEIGHT 6. |
---|
20 | #define TASK_TITLEFONTHEIGHT 2. |
---|
21 | |
---|
22 | #define DELIVRABLE_VSEP 1 |
---|
23 | #define DELIVRABLE_HEIGHT 3 |
---|
24 | #define DELIVRABLE_LABELWIDTH 10 |
---|
25 | #define DELIVRABLE_LABELHEIGHT DELIVRABLE_HEIGHT |
---|
26 | #define DELIVRABLE_TITLEWIDTH 35 |
---|
27 | #define DELIVRABLE_TITLEHEIGHT DELIVRABLE_HEIGHT |
---|
28 | #define DELIVRABLE_BOXHEIGHT (DELIVRABLE_HEIGHT) |
---|
29 | |
---|
30 | char* task_names[] = { |
---|
31 | "Project management", |
---|
32 | "Backbone infrastructure", |
---|
33 | "System generation", |
---|
34 | "HAS front-end", |
---|
35 | "HAS back-end", |
---|
36 | "PC/FPGA communication middleware", |
---|
37 | "Industrial demonstrators", |
---|
38 | "Dissemination", |
---|
39 | 0 |
---|
40 | }; |
---|
41 | struct partner_def { char *key, *name, *file; } partner_table[] = { |
---|
42 | { "UNKNOW", "relax", 0, }, |
---|
43 | { "irisa", "irisa", "table_irisa.tex" }, |
---|
44 | { "lip", "lip", "table_lip.tex" }, |
---|
45 | { "tima", "tima", "table_tima.tex" }, |
---|
46 | { "ubs", "ubs", "table_ubs.tex" }, |
---|
47 | { "upmc", "upmc", "table_upmc.tex" }, |
---|
48 | { "altera", "altera", "table_altera.tex" }, |
---|
49 | { "xilinx", "xilinx", "table_xilinx.tex" }, |
---|
50 | { "bull", "bull", "table_bull.tex" }, |
---|
51 | { "thales", "thales", "table_thales.tex" }, |
---|
52 | { "zied", "zied", "table_zied.tex" }, |
---|
53 | { "navtel", "navtel", "table_navtel.tex" }, |
---|
54 | { 0, 0, 0 }, |
---|
55 | }; |
---|
56 | |
---|
57 | typedef struct _Tlivrable { |
---|
58 | int tn,stn,dn,vn; // task, sub-task, number |
---|
59 | char v; // 0, 1, 2, ..., F |
---|
60 | char* title; |
---|
61 | int bm,em; // mois de bebut et de fin |
---|
62 | double hman[3]; // nombre de mh par an |
---|
63 | int partner; // index dans partner_table |
---|
64 | // these fields are filled by the program for data[tn][0][0][0] |
---|
65 | double task_y; // top of task |
---|
66 | double task_dy; // bot of task is task_y+task_dy |
---|
67 | double task_y_del; // delivrables start at task_y+task_y_del |
---|
68 | double nbma[3]; // durée en mois par annee |
---|
69 | // these fields are filled by the program for data[tn][stn][dn][0] |
---|
70 | struct _Tlivrable |
---|
71 | **vers; // null termiated (vers[i] = &data[tn][stn][dn][i]) |
---|
72 | int nbvers; // nombre de vers |
---|
73 | double height; // height of livrable |
---|
74 | // int del_bm,del_em; // mois de bebut et de fin cummule |
---|
75 | // these fields are filled by the program for all elements |
---|
76 | int nbTitleLines; |
---|
77 | char* titleLines[5]; // null termiated |
---|
78 | } Tlivrable; |
---|
79 | |
---|
80 | #define T_MAX 10 |
---|
81 | #define S_MAX 10 |
---|
82 | #define D_MAX 10 |
---|
83 | #define V_MAX 10 |
---|
84 | typedef struct _Tdata { |
---|
85 | FILE* os; |
---|
86 | Tlivrable* ls[T_MAX][S_MAX][D_MAX][V_MAX]; |
---|
87 | } Tdata; |
---|
88 | Tdata data_org; |
---|
89 | Tdata* curr; |
---|
90 | |
---|
91 | Tdata* data_new(int *tnplus, int *tnmoins) |
---|
92 | { |
---|
93 | int i,skip; |
---|
94 | int tn,stn,dn,v; |
---|
95 | Tdata* data = malloc(sizeof(*data)); |
---|
96 | memset(data,0,sizeof(*data)); |
---|
97 | for (tn=0 ; tn<T_MAX ; tn++) |
---|
98 | for (stn=0; stn<S_MAX; stn++) |
---|
99 | for (dn=0; dn<D_MAX; dn++) |
---|
100 | for (v=0; v<V_MAX; v++) { |
---|
101 | if ( data_org.ls[tn][stn][dn][v]==0 ) continue; |
---|
102 | // tnplus treatment |
---|
103 | skip = 0; |
---|
104 | if (tnplus!=0) { |
---|
105 | skip=1; |
---|
106 | for (i=0 ; tnplus[i]!=-1 ; i++) { |
---|
107 | if ( tnplus[i]==data_org.ls[tn][stn][dn][v]->tn ) { |
---|
108 | skip=0; |
---|
109 | break; |
---|
110 | } } } |
---|
111 | if (skip) continue; |
---|
112 | // tnmoins treatment |
---|
113 | skip = 0; |
---|
114 | if (tnmoins!=0) { |
---|
115 | for (i=0 ; tnmoins[i]!=-1 ; i++) { |
---|
116 | //fprintf(stderr,"i=%d data_org.ls[tn][stn][dn][v]->tn=%d tnmoins[i]=%d\n",i,data_org.ls[tn][stn][dn][v]->tn,tnmoins[i]); |
---|
117 | if ( tnmoins[i]==data_org.ls[tn][stn][dn][v]->tn ) { |
---|
118 | skip=1; |
---|
119 | break; |
---|
120 | } } } |
---|
121 | //fprintf(stderr,"selected: [tn][stn][dn][v]=%d,%d,%d,%d skip=%d\n",tn,stn,dn,v,skip); |
---|
122 | if (skip) continue; |
---|
123 | Tlivrable* l=malloc(sizeof(*l)); |
---|
124 | *l = *data_org.ls[tn][stn][dn][v]; |
---|
125 | data->ls[tn][stn][dn][v] = l; |
---|
126 | //fprintf(stderr,"selected: [tn][stn][dn][v]=%d,%d,%d,%d\n",tn,stn,dn,v); |
---|
127 | } |
---|
128 | return data; |
---|
129 | } |
---|
130 | |
---|
131 | int milestones[100]; |
---|
132 | |
---|
133 | char* gen_label_base(char* buf,Tlivrable*p) |
---|
134 | { sprintf(buf,"D%d%d%d",p->tn,p->stn,p->dn); return buf; } |
---|
135 | char* gen_label_vers(char* buf,Tlivrable*p) |
---|
136 | { if (p->nbvers<=1) strcpy(buf,""); else sprintf(buf,"V%c",p->v); return buf; } |
---|
137 | char* gen_label_full(char* buf,Tlivrable*p) |
---|
138 | { char b[100],v[100]; gen_label_base(b,p); gen_label_vers(v,p); |
---|
139 | sprintf(buf,"%s%s%s",b,*v?"-":"",v); return buf; } |
---|
140 | |
---|
141 | void print_put(double x,double y, const char* object) |
---|
142 | { fprintf(curr->os,"\\put(%.2f,%.2f){%s}\n",x,y,object); } |
---|
143 | void print_hline(double x,double y, double len, const char* color) |
---|
144 | { |
---|
145 | char object[1024]; |
---|
146 | if (color!=0) { fprintf(curr->os,"\\bgroup\\color{%s}\n",color); } |
---|
147 | sprintf(object,"\\line(1,0){%.2f}",len); |
---|
148 | print_put(x,y,object); |
---|
149 | if (color!=0) { fprintf(curr->os,"\\egroup\n"); } |
---|
150 | } |
---|
151 | void print_vline(double x,double y, double len, const char* color) |
---|
152 | { |
---|
153 | char object[1024]; |
---|
154 | if (color!=0) { fprintf(curr->os,"\\bgroup\\color{%s}\n",color); } |
---|
155 | sprintf(object,"\\line(0,1){%.2f}",len); |
---|
156 | print_put(x,y,object); |
---|
157 | if (color!=0) { fprintf(curr->os,"\\egroup\n"); } |
---|
158 | } |
---|
159 | void print_box( |
---|
160 | int filled, char* vers, // vers may be 0, |
---|
161 | double x,double y, double dx, double dy, |
---|
162 | const char* boxcolor, // may be 0 (default COLOR_BOX_HEAVY) |
---|
163 | const char* bgcolor, // may be 0 (not set) |
---|
164 | const char* textcolor // may be 0 (black) |
---|
165 | ){ |
---|
166 | double tn=.4; |
---|
167 | char object[1024]; |
---|
168 | if ( boxcolor==0 ) boxcolor = COLOR_BOX_HEAVY; |
---|
169 | if ( filled==1 ) { |
---|
170 | sprintf(object, |
---|
171 | "\\fcolorbox{black}{%s}{\\makebox(%.2f,%.2f){}}", |
---|
172 | boxcolor,dx-2-tn,dy-2-tn); |
---|
173 | print_put(x,y+1,object); |
---|
174 | } else { |
---|
175 | double tn2=tn/2; |
---|
176 | double e=.1; |
---|
177 | fprintf(curr->os,"\\bgroup\\color{%s}\n",boxcolor); |
---|
178 | fprintf(curr->os,"\\linethickness{%.2fmm}\n",tn); |
---|
179 | print_hline(x+tn2-e ,y, dx ,0); |
---|
180 | print_hline(x+tn2-e ,y+dy, dx ,0); |
---|
181 | print_vline(x+tn-e ,y+e, dy-2*e ,0); |
---|
182 | print_vline(x+dx-2*e,y+e, dy-2*e ,0); |
---|
183 | fprintf(curr->os,"\\egroup\n"); |
---|
184 | } |
---|
185 | if (vers) { |
---|
186 | sprintf(object,"\\begin{tiny}\\textbf{%s}\\end{tiny}",vers); |
---|
187 | print_put(x+1,y+.5,object); |
---|
188 | } |
---|
189 | } |
---|
190 | |
---|
191 | void gen_titleLines(Tlivrable*p) |
---|
192 | { |
---|
193 | const char* macro="\\ganttlf"; |
---|
194 | char* pc = p->title; |
---|
195 | char* pc2; |
---|
196 | |
---|
197 | if (pc==0) return; |
---|
198 | |
---|
199 | while ( (pc2=strstr(pc,macro))!=0 ) { |
---|
200 | char c = *pc2; |
---|
201 | *pc2 = 0; |
---|
202 | p->titleLines[p->nbTitleLines]=strdup(pc); |
---|
203 | p->nbTitleLines+=1; |
---|
204 | *pc2=c; |
---|
205 | pc=pc2+strlen(macro); |
---|
206 | } |
---|
207 | p->titleLines[p->nbTitleLines]=strdup(pc); |
---|
208 | p->nbTitleLines+=1; |
---|
209 | } |
---|
210 | %} |
---|
211 | |
---|
212 | %option noyywrap |
---|
213 | |
---|
214 | %% |
---|
215 | int tn,stn,dn,v,bm,em; char* title; |
---|
216 | double an[3]; |
---|
217 | char* an_comment; |
---|
218 | int partner; |
---|
219 | #.*\n ; |
---|
220 | T=[0-9]+ { tn=atoi(yytext+2); } |
---|
221 | S=[0-9]+ { stn=atoi(yytext+2); } |
---|
222 | D=[0-9]+ { dn=atoi(yytext+2); } |
---|
223 | V=V[1-8F] { v=yytext[3]; } |
---|
224 | ML=[0-9]+ { |
---|
225 | int i; |
---|
226 | for (i=0 ; milestones[i]!=0 ; i++); |
---|
227 | milestones[i] = atoi(yytext+3); |
---|
228 | } |
---|
229 | BM=[0-9]+ { bm=atoi(yytext+3); } |
---|
230 | EM=[0-9]+ { em=atoi(yytext+3); } |
---|
231 | R=none { an[0]=0; an[1]=0; an[2]=0; an_comment=0; } |
---|
232 | R=[0-9:.]+ { |
---|
233 | char tmp[1000]; |
---|
234 | int status = sscanf(yytext+2,"%lf:%lf:%lf:%s",an+0,an+1,an+2,tmp); |
---|
235 | if (status<3) { |
---|
236 | fprintf(stderr,"%s: is not resource definition, expected format \"N:N:N\" (near D%d%d%d-V%c)\n", |
---|
237 | yytext+2,tn,stn,dn,v); |
---|
238 | an[0]=0; an[1]=0; an[2]=0; an_comment=0; |
---|
239 | } else if (status==3) { |
---|
240 | an_comment = 0; |
---|
241 | } else |
---|
242 | an_comment = strdup(tmp); |
---|
243 | } |
---|
244 | PART="{"[^}]+"}" { |
---|
245 | int i; |
---|
246 | partner=-1; |
---|
247 | for (i=0; partner_table[i].key!=0 ; i++) { |
---|
248 | if (strstr(yytext,partner_table[i].key)!=0 ) { |
---|
249 | partner=i; |
---|
250 | break; |
---|
251 | } |
---|
252 | } |
---|
253 | if ( partner==-1 ) { |
---|
254 | fprintf(stderr,"%s: does not contains a partner key (near D%d%d%d-V%c)\n", |
---|
255 | yytext+5,tn,stn,dn,v); |
---|
256 | partner=0; |
---|
257 | } |
---|
258 | } |
---|
259 | TITLE=.*\n { |
---|
260 | char* pc=yytext+6; |
---|
261 | yytext[yyleng-1]=0; |
---|
262 | while ( *pc==' ' || *pc=='\t' ) pc+=1; |
---|
263 | title=strdup(pc); |
---|
264 | Tlivrable* p= (Tlivrable*) calloc(sizeof(*p),1); |
---|
265 | p->tn = tn; |
---|
266 | p->stn = stn; |
---|
267 | p->dn = dn; |
---|
268 | p->v = v; |
---|
269 | p->hman[0] = an[0]; |
---|
270 | p->hman[1] = an[1]; |
---|
271 | p->hman[2] = an[2]; |
---|
272 | p->partner = partner; |
---|
273 | p->title = title; |
---|
274 | p->bm = bm; |
---|
275 | p->em = em; |
---|
276 | gen_titleLines(p); |
---|
277 | |
---|
278 | for (v=0; data_org.ls[tn][stn][dn][v]!=0 ; v++); |
---|
279 | data_org.ls[tn][stn][dn][v] = p; |
---|
280 | //fprintf(stderr,"ADDED: %d %d %d %d\n",tn,stn,dn,v); |
---|
281 | } |
---|
282 | [ \t\n] ; |
---|
283 | . { fprintf(stderr,"%c: unexpected value in anr.gantt file (near D%d%d%d-V%c)\n", |
---|
284 | *yytext,tn,stn,dn,v); } |
---|
285 | %% |
---|
286 | |
---|
287 | void prepare0(Tdata* data) |
---|
288 | { |
---|
289 | int tn,stn,v; |
---|
290 | int i0,i1,i; |
---|
291 | for (tn=0 ; tn<T_MAX ; tn++) |
---|
292 | for (stn=0; stn<S_MAX; stn++) { |
---|
293 | //fprintf(stderr,"AVANT:t=%d:%d:: ",tn,stn); for (i=0; i<D_MAX ; i++) |
---|
294 | //fprintf(stderr,"%d:%p ",i,data->ls[tn][stn][i][0]); fprintf(stderr,"\n"); |
---|
295 | while (1) { |
---|
296 | for (i0=0 ; i0<D_MAX ; i0++) |
---|
297 | if (data->ls[tn][stn][i0][0] == 0) break; |
---|
298 | for (i1=i0+1 ; i1<D_MAX ; i1++) |
---|
299 | if (data->ls[tn][stn][i1][0] != 0) break; |
---|
300 | if (i1>=D_MAX) break; |
---|
301 | // shift |
---|
302 | for (i=0 ; (i1+i)<D_MAX ; i++) |
---|
303 | for (v=0;v<V_MAX;v+=1) { |
---|
304 | data->ls[tn][stn][i0+i][v] = data->ls[tn][stn][i1+i][v]; |
---|
305 | data->ls[tn][stn][i1+i][v] = 0; |
---|
306 | } |
---|
307 | } |
---|
308 | //fprintf(stderr,"AVANT:t=%d:%d:: ",tn,stn); for (i=0; i<D_MAX ; i++) |
---|
309 | //fprintf(stderr,"%d:%p ",i,data->ls[tn][stn][i][0]); fprintf(stderr,"\n"); |
---|
310 | } |
---|
311 | } |
---|
312 | void prepare1(Tdata* data) |
---|
313 | { |
---|
314 | int tn,dn,v; |
---|
315 | int i0,i1,i; |
---|
316 | for (tn=0 ; tn<T_MAX ; tn++) { |
---|
317 | //fprintf(stderr,"AVANT:t=%d:: ",tn,i0,i1); for (i=0; i<S_MAX ; i++) fprintf(stderr,"%d:%p ",i,data->ls[tn][i][0][0]); fprintf(stderr,"\n"); |
---|
318 | while (1) { |
---|
319 | for (i0=0 ; i0<S_MAX ; i0++) |
---|
320 | if (data->ls[tn][i0][0][0] == 0) break; |
---|
321 | for (i1=i0+1 ; i1<S_MAX ; i1++) |
---|
322 | if (data->ls[tn][i1][0][0] != 0) break; |
---|
323 | //fprintf(stderr,"%d %d %d\n",tn,i0,i1); |
---|
324 | if (i1>=S_MAX) break; |
---|
325 | // shift |
---|
326 | for (i=0 ; (i1+i)<S_MAX ; i++) |
---|
327 | for (dn=0;dn<D_MAX;dn+=1) |
---|
328 | for (v=0;v<V_MAX;v+=1) { |
---|
329 | data->ls[tn][i0+i][dn][v] = data->ls[tn][i1+i][dn][v]; |
---|
330 | data->ls[tn][i1+i][dn][v] = 0; |
---|
331 | } |
---|
332 | } |
---|
333 | //fprintf(stderr,"APRES:t=%d:: ",tn,i0,i1); for (i=0; i<S_MAX ; i++) fprintf(stderr,"%d:%p ",i,data->ls[tn][i][0][0]); fprintf(stderr,"\n"); |
---|
334 | } |
---|
335 | } |
---|
336 | void prepare2(Tdata* data) |
---|
337 | { |
---|
338 | int tn0,tn1,stn,dn,vn; |
---|
339 | int moved=1; |
---|
340 | while (moved) { |
---|
341 | moved=0; |
---|
342 | for (tn0=0 ; tn0<T_MAX ; tn0++) |
---|
343 | if (data->ls[tn0][0][0][0] == 0) break; |
---|
344 | for (tn1=tn0+1 ; tn1<T_MAX ; tn1++) |
---|
345 | if (data->ls[tn1][0][0][0] != 0) break; |
---|
346 | if (tn1==T_MAX) break; |
---|
347 | for (stn=0 ; stn<S_MAX ; stn++) |
---|
348 | for (dn=0;dn<D_MAX;dn+=1) |
---|
349 | for (vn=0;vn<V_MAX;vn+=1) { |
---|
350 | data->ls[tn0][stn][dn][vn] = data->ls[tn1][stn][dn][vn]; |
---|
351 | data->ls[tn1][stn][dn][vn] = 0; |
---|
352 | } |
---|
353 | moved=1; |
---|
354 | } |
---|
355 | } |
---|
356 | |
---|
357 | void prepare3(Tdata* data) |
---|
358 | { |
---|
359 | int tn,stn,dn,vn; |
---|
360 | for (tn=0 ; tn<T_MAX ; tn++) |
---|
361 | for (stn=0; stn<S_MAX; stn++) |
---|
362 | for (dn=0; dn<D_MAX; dn++) { |
---|
363 | Tlivrable* p = data->ls[tn][stn][dn][0]; |
---|
364 | if (p==0) continue; |
---|
365 | p->nbvers=0 ; |
---|
366 | for (vn=0 ; vn<V_MAX ; vn+=1) |
---|
367 | if (data->ls[tn][stn][dn][vn]!=0) p->nbvers+=1; |
---|
368 | p->vers=(Tlivrable**)malloc(sizeof(*p->vers)*(p->nbvers+1)); |
---|
369 | for (vn=0 ; vn<p->nbvers ; vn+=1) { |
---|
370 | p->vers[vn] = data->ls[tn][stn][dn][vn]; |
---|
371 | data->ls[tn][stn][dn][vn]->nbvers = p->nbvers; |
---|
372 | } |
---|
373 | p->vers[vn] = 0; |
---|
374 | p->height = 1.0*DELIVRABLE_HEIGHT; |
---|
375 | if (p->nbTitleLines>=1) { |
---|
376 | double h=0; |
---|
377 | h += p->vers[p->nbvers-1]->nbTitleLines*DELIVRABLE_TITLEHEIGHT; |
---|
378 | h += (p->vers[p->nbvers-1]->nbTitleLines-1)*(DELIVRABLE_TITLEHEIGHT/5.); |
---|
379 | if ( h>p->height) p->height=h; |
---|
380 | } |
---|
381 | Tlivrable* lu= p->vers[p->nbvers-1]; |
---|
382 | int i; |
---|
383 | fprintf(stderr,"--------------------\n"); |
---|
384 | for (i=0 ; i<p->nbvers ; i++) { |
---|
385 | Tlivrable* l= p->vers[i]; |
---|
386 | double bm= l->bm; |
---|
387 | double em= l->em; |
---|
388 | //fprintf(stderr," %d%d%d-V%c: bm=%2.f em=%2.f --> %2.1f %2.1f %2.1f\n",l->tn,l->stn,l->dn,l->v,bm,em, lu->nbma[0],lu->nbma[1],lu->nbma[2]); |
---|
389 | if (bm<12 && em>0) { |
---|
390 | lu->nbma[0] += (em>12?12:em)-bm; |
---|
391 | bm=12; |
---|
392 | } |
---|
393 | if (bm<24 && em>12) { |
---|
394 | lu->nbma[1] += (em>24?24:em)-bm; |
---|
395 | bm=24; |
---|
396 | } |
---|
397 | if (bm<36 && em>24) { |
---|
398 | lu->nbma[2] += em-bm; |
---|
399 | } |
---|
400 | //fprintf(stderr," %d%d%d-V%c: bm=%2.f em=%2.f --> %2.1f %2.1f %2.1f %p\n",l->tn,l->stn,l->dn,l->v,bm,em, lu->nbma[0],lu->nbma[1],lu->nbma[2], lu); |
---|
401 | } |
---|
402 | } |
---|
403 | } |
---|
404 | |
---|
405 | double task_livrable_height(int tn, double* delivrable_y) |
---|
406 | { |
---|
407 | int stn,dn,nblivrables=0; |
---|
408 | double height=0; |
---|
409 | height += TASK_TITLEHEIGHT ; |
---|
410 | *delivrable_y = height; |
---|
411 | for (stn=0 ; curr->ls[tn][stn][0][0]!=0 ; stn++) |
---|
412 | for (dn=0 ; curr->ls[tn][stn][dn][0]!=0 ; dn++) { |
---|
413 | nblivrables += 1; |
---|
414 | height+=curr->ls[tn][stn][dn][0]->height; |
---|
415 | } |
---|
416 | height += DELIVRABLE_VSEP/2; |
---|
417 | height += (nblivrables-1)*DELIVRABLE_VSEP; |
---|
418 | height += DELIVRABLE_VSEP/2; |
---|
419 | return height; |
---|
420 | } |
---|
421 | |
---|
422 | void task_box(double pictwidth) |
---|
423 | { |
---|
424 | int tn; |
---|
425 | for ( tn=0 ; curr->ls[tn][0][0][0]!=0 ; tn++ ) { |
---|
426 | const char* color= (tn%2)!=0 ? TASK_BGC1 : TASK_BGC0 ; |
---|
427 | fprintf(curr->os, |
---|
428 | "\\put(%.2f,%.2f){\\fcolorbox{black}{%s}{\\makebox(%5.2f,%5.2f){}}}\n", |
---|
429 | 0.0,curr->ls[tn][0][0][0]->task_y, |
---|
430 | color, |
---|
431 | pictwidth,curr->ls[tn][0][0][0]->task_dy |
---|
432 | ); |
---|
433 | } |
---|
434 | } |
---|
435 | |
---|
436 | void month_grid(double x, double y, double dx, double dy) |
---|
437 | { |
---|
438 | int i; |
---|
439 | for (i=0 ; i<=36 ; i+=1,x+=PICT_MONTHWIDTH) { |
---|
440 | if ( (i%3)!=0 ) continue; |
---|
441 | fprintf(curr->os, |
---|
442 | "\\put(%5.1f,%5.1f){\\line(0,1){%5.1f}}\\put(%5.1f,%5.1f){%d}\n", |
---|
443 | x,y,dy-PICT_MONTHWIDTH-PICT_VSEP, |
---|
444 | x-2,y+dy-PICT_MONTHHEIGHT, |
---|
445 | i |
---|
446 | ); |
---|
447 | } |
---|
448 | } |
---|
449 | |
---|
450 | void print_milestones(double x, double y, double dx, double dy) |
---|
451 | { |
---|
452 | int i; |
---|
453 | double tn=.3; |
---|
454 | //x=x-tn/2; |
---|
455 | fprintf(curr->os,"\\bgroup\n"); |
---|
456 | fprintf(curr->os,"\\color{red}\n"); |
---|
457 | fprintf(curr->os,"\\linethickness{%.2fmm}\n",tn); |
---|
458 | for (i=0 ; milestones[i]!=0 ; i+=1) { |
---|
459 | double xx= x + milestones[i]*PICT_MONTHWIDTH; |
---|
460 | print_vline(xx,y,dy-PICT_MONTHWIDTH-PICT_VSEP,0); |
---|
461 | } |
---|
462 | fprintf(curr->os,"\\egroup\n"); |
---|
463 | } |
---|
464 | |
---|
465 | double delivrable( |
---|
466 | double label_x, double box_x, double title_x, |
---|
467 | double y, |
---|
468 | int tn, int stn, int dn) |
---|
469 | { |
---|
470 | Tlivrable* top=curr->ls[tn][stn][dn][0]; |
---|
471 | Tlivrable* last=curr->ls[tn][stn][dn][top->nbvers-1]; |
---|
472 | char tmp[1000],label[1000],title[1000]; |
---|
473 | double y0; |
---|
474 | int v; |
---|
475 | double label_dx = DELIVRABLE_LABELWIDTH ; |
---|
476 | double label_dy = DELIVRABLE_LABELHEIGHT ; |
---|
477 | double boxx,box_dx; |
---|
478 | double box_dy = DELIVRABLE_BOXHEIGHT ; |
---|
479 | double title_dx = DELIVRABLE_LABELWIDTH ; |
---|
480 | double title_dy = DELIVRABLE_TITLEHEIGHT ; |
---|
481 | |
---|
482 | //print_hline(0,y,180,0); |
---|
483 | gen_label_base(label,top); |
---|
484 | // y -= DELIVRABLE_HEIGHT; |
---|
485 | y -= top->height ; |
---|
486 | //print_hline(0,y,180,0); |
---|
487 | fprintf(curr->os,"%% Delivrable %s (tn=%d stn=%d dn=%d\n",label,tn,stn,dn); |
---|
488 | |
---|
489 | // print label |
---|
490 | //y0 = (DELIVRABLE_HEIGHT-DELIVRABLE_LABELHEIGHT)/2; |
---|
491 | y0 = (top->height-DELIVRABLE_LABELHEIGHT)/2; |
---|
492 | sprintf(tmp,"\\ganttlabelstyle{%s}",label); |
---|
493 | print_put(label_x,y+y0,tmp); |
---|
494 | // print title |
---|
495 | if (last->nbTitleLines==1) { |
---|
496 | y0 = (DELIVRABLE_HEIGHT-DELIVRABLE_TITLEHEIGHT)/2; |
---|
497 | y0 += DELIVRABLE_TITLEHEIGHT/5. ; |
---|
498 | sprintf(tmp,"\\gantttitlestyle{%s}",last->title); |
---|
499 | print_put(title_x,y+y0,tmp); |
---|
500 | } else if (last->nbTitleLines>1) { |
---|
501 | int i; |
---|
502 | // y0 = (DELIVRABLE_HEIGHT-DELIVRABLE_TITLEHEIGHT)/2; |
---|
503 | y0=DELIVRABLE_TITLEHEIGHT/5.; |
---|
504 | sprintf(tmp,"\\gantttitlestyle{\\shortstack[l]{%s",last->titleLines[0]); |
---|
505 | for (i=1 ; i<last->nbTitleLines ; i+=1) { |
---|
506 | strcat(tmp,"\\\\"); |
---|
507 | strcat(tmp,last->titleLines[i]); |
---|
508 | } |
---|
509 | strcat(tmp,"}}"); |
---|
510 | print_put(title_x,y+y0,tmp); |
---|
511 | } |
---|
512 | |
---|
513 | // print box |
---|
514 | //y0 = (DELIVRABLE_HEIGHT-DELIVRABLE_BOXHEIGHT)/2; |
---|
515 | y0 = (top->height-DELIVRABLE_BOXHEIGHT)/2; |
---|
516 | if ( last==top ) { |
---|
517 | Tlivrable* l=top; |
---|
518 | boxx = box_x + l->bm*PICT_MONTHWIDTH ; |
---|
519 | box_dx = (l->em - l->bm) * PICT_MONTHWIDTH; |
---|
520 | print_box(1,0,boxx,y+y0,box_dx,box_dy,COLOR_BOX_LIGHT,0,0); |
---|
521 | print_box(0,0,boxx,y+y0,box_dx,box_dy,0,0,0); |
---|
522 | } else for (v=0 ; v<top->nbvers ; v+=1) { |
---|
523 | Tlivrable* l=curr->ls[tn][stn][dn][v] ; |
---|
524 | gen_label_vers(tmp,l); |
---|
525 | boxx = box_x + l->bm*PICT_MONTHWIDTH ; |
---|
526 | box_dx = (l->em - l->bm) * PICT_MONTHWIDTH; |
---|
527 | print_box(1,0,boxx,y+y0,box_dx,box_dy,COLOR_BOX_LIGHT,0,0); |
---|
528 | print_box(0,tmp,boxx,y+y0,box_dx,box_dy,0,0,0); |
---|
529 | } |
---|
530 | y -= DELIVRABLE_VSEP; |
---|
531 | return y; |
---|
532 | } |
---|
533 | |
---|
534 | void task_delivrable(double label_x, double box_x, double title_x, int tn) |
---|
535 | { |
---|
536 | int stn,dn; |
---|
537 | Tlivrable* task=curr->ls[tn][0][0][0]; |
---|
538 | double y = task->task_y+task->task_dy-task->task_y_del; |
---|
539 | char tmp[1000]; |
---|
540 | sprintf(tmp,"\\textbf{Task-%d \\textit{%s}}",task->tn,task_names[task->tn]); |
---|
541 | print_put(label_x/2,y+(TASK_TITLEHEIGHT-TASK_TITLEFONTHEIGHT)/2,tmp); |
---|
542 | |
---|
543 | //y += DELIVRABLE_VSEP/2. ; |
---|
544 | for (stn=0 ; curr->ls[tn][stn][0][0]!=0 ; stn++) |
---|
545 | for (dn=0 ; curr->ls[tn][stn][dn][0]!=0 ; dn++) { |
---|
546 | y=delivrable(label_x,box_x,title_x,y,tn,stn,dn); |
---|
547 | } |
---|
548 | } |
---|
549 | |
---|
550 | void do_gantt(const char* fn, int* tnplus, int* tnmoins) |
---|
551 | { |
---|
552 | int tn; |
---|
553 | double pictwidth, pictheight; |
---|
554 | double gantt_x,gantt_y; |
---|
555 | double gantt_dx,gantt_dy; |
---|
556 | |
---|
557 | double label_x,title_x; |
---|
558 | curr = data_new(tnplus,tnmoins); |
---|
559 | if ( (curr->os=fopen(fn,"w"))==0 ) { |
---|
560 | fprintf(stderr,"can not open %s file for writing.\n",fn); |
---|
561 | fprintf(stderr,"generation of %s graph is skipped.\n",fn); |
---|
562 | return; |
---|
563 | } |
---|
564 | prepare0(curr); |
---|
565 | prepare1(curr); |
---|
566 | prepare2(curr); |
---|
567 | prepare3(curr); |
---|
568 | |
---|
569 | pictheight=0 ; |
---|
570 | pictheight += PICT_BOTSEP ; |
---|
571 | for ( tn=0 ; curr->ls[tn][0][0][0]!=0 ; tn++ ); |
---|
572 | for ( tn=tn-1 ; tn>=0 ; tn-- ) { |
---|
573 | double offset; |
---|
574 | curr->ls[tn][0][0][0]->task_y = pictheight; |
---|
575 | curr->ls[tn][0][0][0]->task_dy = task_livrable_height(tn,&offset); |
---|
576 | curr->ls[tn][0][0][0]->task_y_del = offset; |
---|
577 | pictheight += curr->ls[tn][0][0][0]->task_dy; |
---|
578 | pictheight += TASK_VSEP; |
---|
579 | } |
---|
580 | pictheight += PICT_MONTHHEIGHT; |
---|
581 | pictheight += PICT_TOPSEP ; |
---|
582 | gantt_y = PICT_BOTSEP ; |
---|
583 | gantt_dy = pictheight-PICT_TOPSEP-PICT_BOTSEP ; |
---|
584 | |
---|
585 | pictwidth=0; |
---|
586 | pictwidth += PICT_LEFTSEP; |
---|
587 | label_x = pictwidth; |
---|
588 | pictwidth += DELIVRABLE_LABELWIDTH; |
---|
589 | pictwidth += PICT_HSEP; |
---|
590 | gantt_x = pictwidth ; |
---|
591 | gantt_dx = 36*PICT_MONTHWIDTH ; |
---|
592 | pictwidth += gantt_dx ; |
---|
593 | pictwidth += PICT_HSEP; |
---|
594 | title_x = pictwidth; |
---|
595 | pictwidth += DELIVRABLE_TITLEWIDTH; |
---|
596 | pictwidth += PICT_RIGHTSEP; |
---|
597 | |
---|
598 | fprintf(curr->os,"\\setlength{\\unitlength}{1.0mm}\n"); |
---|
599 | fprintf(curr->os,"\\begin{picture}(%.1f,%.1f)\n",pictwidth,pictheight); |
---|
600 | //print_hline(0,0,pictwidth,0); |
---|
601 | //print_hline(0,pictheight,pictwidth,0); |
---|
602 | task_box(pictwidth); |
---|
603 | month_grid(gantt_x,gantt_y,gantt_dx,gantt_dy); |
---|
604 | for ( tn=0 ; curr->ls[tn][0][0][0]!=0 ; tn++ ) { |
---|
605 | task_delivrable(label_x,gantt_x,title_x,tn); |
---|
606 | } |
---|
607 | |
---|
608 | print_milestones(gantt_x,0,gantt_dx,gantt_dy+gantt_y); |
---|
609 | fprintf(curr->os,"\\end{picture}\n"); |
---|
610 | fclose(curr->os); |
---|
611 | curr->os=0; |
---|
612 | } |
---|
613 | |
---|
614 | void do_partner_table(int partner) |
---|
615 | { |
---|
616 | struct partner_def* part = partner_table+partner; |
---|
617 | if ( (curr->os=fopen(part->file,"w"))==0 ) { |
---|
618 | fprintf(stderr,"can not open %s file for writing.\n",part->file); |
---|
619 | fprintf(stderr,"generation of %s partner table is skipped.\n",part->file); |
---|
620 | return; |
---|
621 | } |
---|
622 | fprintf(curr->os,"\\begin{tabular}{|c|p{3.5cm}||r|r|r||r|}\\hline\n"); |
---|
623 | fprintf(curr->os, |
---|
624 | "number & \\multicolumn{1}{c||}{title} & \\multicolumn{3}{c||}{years } & total \\\\\\cline{3-5}\n"); |
---|
625 | fprintf(curr->os, |
---|
626 | " & & \\multicolumn{1}{c|}{1} & \\multicolumn{1}{c|}{2} & " |
---|
627 | "\\multicolumn{1}{c||}{3} & \\\\\\hline\\hline\n"); |
---|
628 | int tn,stn,dn,v=0; |
---|
629 | double an1=0,an2=0,an3=0,an=0; |
---|
630 | int newlineadded=1; |
---|
631 | for (tn=0 ; tn<T_MAX ; tn++) { |
---|
632 | if (curr->ls[tn][0][0][0]==0) break; |
---|
633 | if (tn!=0 && newlineadded==0 ) { |
---|
634 | newlineadded = 1; |
---|
635 | fprintf(curr->os,"\\hline "); |
---|
636 | } |
---|
637 | for (stn=0; stn<S_MAX; stn++) { |
---|
638 | for (dn=0; dn<D_MAX; dn++) { |
---|
639 | Tlivrable* top=curr->ls[tn][stn][dn][v]; |
---|
640 | if (top==0) continue; |
---|
641 | Tlivrable* last=top->vers[top->nbvers-1]; |
---|
642 | if (last->partner!=partner) continue; |
---|
643 | double sum1,sum2,sum3,sum=0; |
---|
644 | sum1 = last->hman[0]; sum +=sum1; |
---|
645 | sum2 = last->hman[1]; sum +=sum2; |
---|
646 | sum3 = last->hman[2]; sum +=sum3; |
---|
647 | char label[1000],title[1000]; |
---|
648 | gen_label_base(label,last); |
---|
649 | sprintf(title,"\\resstablestyletitle{%s}",last->title); |
---|
650 | fprintf(curr->os,"%s & %s & %2.1f & %2.1f & %2.1f & %2.1f \\\\\\hline\n", |
---|
651 | label,title,sum1,sum2,sum3,sum); |
---|
652 | an1 += sum1 ; |
---|
653 | an2 += sum2 ; |
---|
654 | an3 += sum3 ; |
---|
655 | an += sum ; |
---|
656 | newlineadded=0; |
---|
657 | if ( (sum1!=0 && sum1>last->nbma[0] ) || (sum1==0 && last->nbma[0]!=0) ) |
---|
658 | fprintf(stderr,"ERROR: %s:%s probleme sur l'an 1 (in table=%2.1f, in gantt=%2.1f\n", |
---|
659 | part->name,label,sum1,last->nbma[0]); |
---|
660 | if ( (sum2!=0 && sum2>last->nbma[1]) || (sum2==0 && last->nbma[1]!=0) ) |
---|
661 | fprintf(stderr,"ERROR: %s:%s probleme sur l'an 2 (in table=%2.1f, in gantt=%2.1f\n", |
---|
662 | part->name,label,sum2,last->nbma[1]); |
---|
663 | if ( (sum3!=0 && sum3>last->nbma[2]) || (sum3==0 && last->nbma[2]!=0) ) |
---|
664 | fprintf(stderr,"ERROR: %s:%s probleme sur l'an 3 (in table=%2.1f, in gantt=%2.1f\n", |
---|
665 | part->name,label,sum3,last->nbma[2]); |
---|
666 | } |
---|
667 | } |
---|
668 | } |
---|
669 | if ( an!=(an1+an2+an3) ) { |
---|
670 | fprintf(stderr,"bad computation in %s table.\n",part->file); |
---|
671 | } |
---|
672 | fprintf(curr->os,"%s & %s & %2.1f & %2.1f & %2.1f & %2.1f \\\\\\hline\n", |
---|
673 | "","total",an1,an2,an3,an); |
---|
674 | |
---|
675 | fprintf(curr->os,"\\end{tabular}\n"); |
---|
676 | fclose(curr->os); |
---|
677 | curr->os=0; |
---|
678 | } |
---|
679 | |
---|
680 | int main() |
---|
681 | { |
---|
682 | int tnplus[10] = { 0, 6, 7, -1 }; |
---|
683 | int tnmoins[10] = { 0, 6, 7, -1 }; |
---|
684 | |
---|
685 | yylex(); |
---|
686 | do_gantt("gantt.tex",0,0); |
---|
687 | do_gantt("gantt1.tex",tnplus,0); |
---|
688 | do_gantt("gantt2.tex",0,tnmoins); |
---|
689 | |
---|
690 | curr = data_new(0,0); |
---|
691 | prepare0(curr); |
---|
692 | prepare1(curr); |
---|
693 | prepare2(curr); |
---|
694 | prepare3(curr); |
---|
695 | do_partner_table(4); |
---|
696 | do_partner_table(5); |
---|
697 | |
---|
698 | return 0; |
---|
699 | } |
---|