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