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 | |
---|
42 | typedef struct _Tlivrable { |
---|
43 | int tn,stn,dn,vn; // task, sub-task, number |
---|
44 | char v; // 0, 1, 2, ..., F |
---|
45 | char* title; |
---|
46 | int bm,em; // mois de bebut et de fin |
---|
47 | // these fields are filled by the program for data[tn][0][0][0] |
---|
48 | double task_y; // top of task |
---|
49 | double task_dy; // bot of task is task_y+task_dy |
---|
50 | double task_y_del; // delivrables start at task_y+task_y_del |
---|
51 | // these fields are filled by the program for data[tn][stn][dn][0] |
---|
52 | struct _Tlivrable |
---|
53 | **vers; // null termiated (vers[i] = &data[tn][stn][dn][i]) |
---|
54 | int nbvers; // nombre de vers |
---|
55 | double height; // height of livrable |
---|
56 | // int del_bm,del_em; // mois de bebut et de fin cummule |
---|
57 | // these fields are filled by the program for all elements |
---|
58 | int nbTitleLines; |
---|
59 | char* titleLines[5]; // null termiated |
---|
60 | } Tlivrable; |
---|
61 | |
---|
62 | #define T_MAX 10 |
---|
63 | #define S_MAX 10 |
---|
64 | #define D_MAX 10 |
---|
65 | #define V_MAX 10 |
---|
66 | typedef struct _Tdata { |
---|
67 | FILE* os; |
---|
68 | Tlivrable* ls[T_MAX][S_MAX][D_MAX][V_MAX]; |
---|
69 | } Tdata; |
---|
70 | Tdata data_org; |
---|
71 | Tdata* curr; |
---|
72 | |
---|
73 | Tdata* data_new(int *tnplus, int *tnmoins) |
---|
74 | { |
---|
75 | int i,skip; |
---|
76 | int tn,stn,dn,v; |
---|
77 | Tdata* data = malloc(sizeof(*data)); |
---|
78 | memset(data,0,sizeof(*data)); |
---|
79 | for (tn=0 ; tn<T_MAX ; tn++) |
---|
80 | for (stn=0; stn<S_MAX; stn++) |
---|
81 | for (dn=0; dn<D_MAX; dn++) |
---|
82 | for (v=0; v<V_MAX; v++) { |
---|
83 | if ( data_org.ls[tn][stn][dn][v]==0 ) continue; |
---|
84 | // tnplus treatment |
---|
85 | skip = 0; |
---|
86 | if (tnplus!=0) { |
---|
87 | skip=1; |
---|
88 | for (i=0 ; tnplus[i]!=-1 ; i++) { |
---|
89 | if ( tnplus[i]==data_org.ls[tn][stn][dn][v]->tn ) { |
---|
90 | skip=0; |
---|
91 | break; |
---|
92 | } } } |
---|
93 | if (skip) continue; |
---|
94 | // tnmoins treatment |
---|
95 | skip = 0; |
---|
96 | if (tnmoins!=0) { |
---|
97 | for (i=0 ; tnmoins[i]!=-1 ; i++) { |
---|
98 | //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]); |
---|
99 | if ( tnmoins[i]==data_org.ls[tn][stn][dn][v]->tn ) { |
---|
100 | skip=1; |
---|
101 | break; |
---|
102 | } } } |
---|
103 | //fprintf(stderr,"selected: [tn][stn][dn][v]=%d,%d,%d,%d skip=%d\n",tn,stn,dn,v,skip); |
---|
104 | if (skip) continue; |
---|
105 | Tlivrable* l=malloc(sizeof(*l)); |
---|
106 | *l = *data_org.ls[tn][stn][dn][v]; |
---|
107 | data->ls[tn][stn][dn][v] = l; |
---|
108 | fprintf(stderr,"selected: [tn][stn][dn][v]=%d,%d,%d,%d\n",tn,stn,dn,v); |
---|
109 | } |
---|
110 | return data; |
---|
111 | } |
---|
112 | |
---|
113 | int milestones[100]; |
---|
114 | |
---|
115 | char* gen_label_base(char* buf,Tlivrable*p) |
---|
116 | { sprintf(buf,"D%d%d%d",p->tn,p->stn,p->dn); return buf; } |
---|
117 | char* gen_label_vers(char* buf,Tlivrable*p) |
---|
118 | { if (p->nbvers<=1) strcpy(buf,""); else sprintf(buf,"V%c",p->v); return buf; } |
---|
119 | char* gen_label_full(char* buf,Tlivrable*p) |
---|
120 | { char b[100],v[100]; gen_label_base(b,p); gen_label_vers(v,p); |
---|
121 | sprintf(buf,"%s%s%s",b,*v?"-":"",v); return buf; } |
---|
122 | |
---|
123 | void print_put(double x,double y, const char* object) |
---|
124 | { fprintf(curr->os,"\\put(%.2f,%.2f){%s}\n",x,y,object); } |
---|
125 | void print_hline(double x,double y, double len, const char* color) |
---|
126 | { |
---|
127 | char object[1024]; |
---|
128 | if (color!=0) { fprintf(curr->os,"\\bgroup\\color{%s}\n",color); } |
---|
129 | sprintf(object,"\\line(1,0){%.2f}",len); |
---|
130 | print_put(x,y,object); |
---|
131 | if (color!=0) { fprintf(curr->os,"\\egroup\n"); } |
---|
132 | } |
---|
133 | void print_vline(double x,double y, double len, const char* color) |
---|
134 | { |
---|
135 | char object[1024]; |
---|
136 | if (color!=0) { fprintf(curr->os,"\\bgroup\\color{%s}\n",color); } |
---|
137 | sprintf(object,"\\line(0,1){%.2f}",len); |
---|
138 | print_put(x,y,object); |
---|
139 | if (color!=0) { fprintf(curr->os,"\\egroup\n"); } |
---|
140 | } |
---|
141 | void print_box( |
---|
142 | int filled, char* vers, // vers may be 0, |
---|
143 | double x,double y, double dx, double dy, |
---|
144 | const char* boxcolor, // may be 0 (default COLOR_BOX_HEAVY) |
---|
145 | const char* bgcolor, // may be 0 (not set) |
---|
146 | const char* textcolor // may be 0 (black) |
---|
147 | ){ |
---|
148 | double tn=.4; |
---|
149 | char object[1024]; |
---|
150 | if ( boxcolor==0 ) boxcolor = COLOR_BOX_HEAVY; |
---|
151 | if ( filled==1 ) { |
---|
152 | sprintf(object, |
---|
153 | "\\fcolorbox{black}{%s}{\\makebox(%.2f,%.2f){}}", |
---|
154 | boxcolor,dx-2-tn,dy-2-tn); |
---|
155 | print_put(x,y+1,object); |
---|
156 | } else { |
---|
157 | double tn2=tn/2; |
---|
158 | double e=.1; |
---|
159 | fprintf(curr->os,"\\bgroup\\color{%s}\n",boxcolor); |
---|
160 | fprintf(curr->os,"\\linethickness{%.2fmm}\n",tn); |
---|
161 | print_hline(x+tn2-e ,y, dx ,0); |
---|
162 | print_hline(x+tn2-e ,y+dy, dx ,0); |
---|
163 | print_vline(x+tn-e ,y+e, dy-2*e ,0); |
---|
164 | print_vline(x+dx-2*e,y+e, dy-2*e ,0); |
---|
165 | fprintf(curr->os,"\\egroup\n"); |
---|
166 | } |
---|
167 | if (vers) { |
---|
168 | sprintf(object,"\\begin{tiny}\\textbf{%s}\\end{tiny}",vers); |
---|
169 | print_put(x+1,y+.5,object); |
---|
170 | } |
---|
171 | } |
---|
172 | |
---|
173 | void gen_titleLines(Tlivrable*p) |
---|
174 | { |
---|
175 | const char* macro="\\ganttlf"; |
---|
176 | char* pc = p->title; |
---|
177 | char* pc2; |
---|
178 | |
---|
179 | if (pc==0) return; |
---|
180 | |
---|
181 | while ( (pc2=strstr(pc,macro))!=0 ) { |
---|
182 | char c = *pc2; |
---|
183 | *pc2 = 0; |
---|
184 | p->titleLines[p->nbTitleLines]=strdup(pc); |
---|
185 | p->nbTitleLines+=1; |
---|
186 | *pc2=c; |
---|
187 | pc=pc2+strlen(macro); |
---|
188 | } |
---|
189 | p->titleLines[p->nbTitleLines]=strdup(pc); |
---|
190 | p->nbTitleLines+=1; |
---|
191 | } |
---|
192 | %} |
---|
193 | |
---|
194 | %option noyywrap |
---|
195 | |
---|
196 | %% |
---|
197 | int tn,stn,dn,v,bm,em; char* title; |
---|
198 | #.*\n ; |
---|
199 | T=[0-9]+ { tn=atoi(yytext+2); } |
---|
200 | T=D[0-9]+ { tn=atoi(yytext+3); } |
---|
201 | S=[0-9]+ { stn=atoi(yytext+2); } |
---|
202 | D=[0-9]+ { dn=atoi(yytext+2); } |
---|
203 | V=V. { v=yytext[3]; } |
---|
204 | V= { v='F'; } |
---|
205 | ML=[0-9]+ { |
---|
206 | int i; |
---|
207 | for (i=0 ; milestones[i]!=0 ; i++); |
---|
208 | milestones[i] = atoi(yytext+3); |
---|
209 | } |
---|
210 | |
---|
211 | BM=[0-9]+ { bm=atoi(yytext+3); } |
---|
212 | EM=[0-9]+ { em=atoi(yytext+3); } |
---|
213 | TITLE=.*\n { |
---|
214 | char* pc=yytext+6; |
---|
215 | yytext[yyleng-1]=0; |
---|
216 | while ( *pc==' ' || *pc=='\t' ) pc+=1; |
---|
217 | title=strdup(pc); |
---|
218 | Tlivrable* p= (Tlivrable*) calloc(sizeof(*p),1); |
---|
219 | p->tn = tn; |
---|
220 | p->stn = stn; |
---|
221 | p->dn = dn; |
---|
222 | p->v = v; |
---|
223 | p->title = title; |
---|
224 | p->bm = bm; |
---|
225 | p->em = em; |
---|
226 | gen_titleLines(p); |
---|
227 | |
---|
228 | for (v=0; data_org.ls[tn][stn][dn][v]!=0 ; v++); |
---|
229 | data_org.ls[tn][stn][dn][v] = p; |
---|
230 | fprintf(stderr,"ADDED: %d %d %d %d\n",tn,stn,dn,v); |
---|
231 | //{int i,tn=0; fprintf(stderr,"CURR:t=%d:: ",tn); for (i=0; i<S_MAX ; i++) fprintf(stderr,"%d:%p ",i,data[tn][i][0][0]); fprintf(stderr,"\n"); } |
---|
232 | } |
---|
233 | .|\n ; |
---|
234 | %% |
---|
235 | |
---|
236 | void prepare0(Tdata* data) |
---|
237 | { |
---|
238 | int tn,stn,v; |
---|
239 | int i0,i1,i; |
---|
240 | for (tn=0 ; tn<T_MAX ; tn++) |
---|
241 | for (stn=0; stn<S_MAX; stn++) { |
---|
242 | //fprintf(stderr,"AVANT:t=%d:%d:: ",tn,stn); for (i=0; i<D_MAX ; i++) |
---|
243 | //fprintf(stderr,"%d:%p ",i,data->ls[tn][stn][i][0]); fprintf(stderr,"\n"); |
---|
244 | while (1) { |
---|
245 | for (i0=0 ; i0<D_MAX ; i0++) |
---|
246 | if (data->ls[tn][stn][i0][0] == 0) break; |
---|
247 | for (i1=i0+1 ; i1<D_MAX ; i1++) |
---|
248 | if (data->ls[tn][stn][i1][0] != 0) break; |
---|
249 | if (i1>=D_MAX) break; |
---|
250 | // shift |
---|
251 | for (i=0 ; (i1+i)<D_MAX ; i++) |
---|
252 | for (v=0;v<V_MAX;v+=1) { |
---|
253 | data->ls[tn][stn][i0+i][v] = data->ls[tn][stn][i1+i][v]; |
---|
254 | data->ls[tn][stn][i1+i][v] = 0; |
---|
255 | } |
---|
256 | } |
---|
257 | //fprintf(stderr,"AVANT:t=%d:%d:: ",tn,stn); for (i=0; i<D_MAX ; i++) |
---|
258 | //fprintf(stderr,"%d:%p ",i,data->ls[tn][stn][i][0]); fprintf(stderr,"\n"); |
---|
259 | } |
---|
260 | } |
---|
261 | void prepare1(Tdata* data) |
---|
262 | { |
---|
263 | int tn,dn,v; |
---|
264 | int i0,i1,i; |
---|
265 | for (tn=0 ; tn<T_MAX ; tn++) { |
---|
266 | //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"); |
---|
267 | while (1) { |
---|
268 | for (i0=0 ; i0<S_MAX ; i0++) |
---|
269 | if (data->ls[tn][i0][0][0] == 0) break; |
---|
270 | for (i1=i0+1 ; i1<S_MAX ; i1++) |
---|
271 | if (data->ls[tn][i1][0][0] != 0) break; |
---|
272 | //fprintf(stderr,"%d %d %d\n",tn,i0,i1); |
---|
273 | if (i1>=S_MAX) break; |
---|
274 | // shift |
---|
275 | for (i=0 ; (i1+i)<S_MAX ; i++) |
---|
276 | for (dn=0;dn<D_MAX;dn+=1) |
---|
277 | for (v=0;v<V_MAX;v+=1) { |
---|
278 | data->ls[tn][i0+i][dn][v] = data->ls[tn][i1+i][dn][v]; |
---|
279 | data->ls[tn][i1+i][dn][v] = 0; |
---|
280 | } |
---|
281 | } |
---|
282 | //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"); |
---|
283 | } |
---|
284 | } |
---|
285 | void prepare2(Tdata* data) |
---|
286 | { |
---|
287 | int tn0,tn1,stn,dn,vn; |
---|
288 | int moved=1; |
---|
289 | while (moved) { |
---|
290 | moved=0; |
---|
291 | for (tn0=0 ; tn0<T_MAX ; tn0++) |
---|
292 | if (data->ls[tn0][0][0][0] == 0) break; |
---|
293 | for (tn1=tn0+1 ; tn1<T_MAX ; tn1++) |
---|
294 | if (data->ls[tn1][0][0][0] != 0) break; |
---|
295 | if (tn1==T_MAX) break; |
---|
296 | for (stn=0 ; stn<S_MAX ; stn++) |
---|
297 | for (dn=0;dn<D_MAX;dn+=1) |
---|
298 | for (vn=0;vn<V_MAX;vn+=1) { |
---|
299 | data->ls[tn0][stn][dn][vn] = data->ls[tn1][stn][dn][vn]; |
---|
300 | data->ls[tn1][stn][dn][vn] = 0; |
---|
301 | } |
---|
302 | moved=1; |
---|
303 | } |
---|
304 | } |
---|
305 | |
---|
306 | void prepare3(Tdata* data) |
---|
307 | { |
---|
308 | int tn,stn,dn,vn; |
---|
309 | for (tn=0 ; tn<T_MAX ; tn++) |
---|
310 | for (stn=0; stn<S_MAX; stn++) |
---|
311 | for (dn=0; dn<D_MAX; dn++) { |
---|
312 | Tlivrable* p = data->ls[tn][stn][dn][0]; |
---|
313 | if (p==0) continue; |
---|
314 | p->nbvers=0 ; |
---|
315 | for (vn=0 ; vn<V_MAX ; vn+=1) |
---|
316 | if (data->ls[tn][stn][dn][vn]!=0) p->nbvers+=1; |
---|
317 | p->vers=(Tlivrable**)malloc(sizeof(*p->vers)*(p->nbvers+1)); |
---|
318 | for (vn=0 ; vn<p->nbvers ; vn+=1) { |
---|
319 | p->vers[vn] = data->ls[tn][stn][dn][vn]; |
---|
320 | data->ls[tn][stn][dn][vn]->nbvers = p->nbvers; |
---|
321 | } |
---|
322 | p->vers[vn] = 0; |
---|
323 | p->height = 1.0*DELIVRABLE_HEIGHT; |
---|
324 | if (p->nbTitleLines>=1) { |
---|
325 | double h=0; |
---|
326 | h += p->vers[p->nbvers-1]->nbTitleLines*DELIVRABLE_TITLEHEIGHT; |
---|
327 | h += (p->vers[p->nbvers-1]->nbTitleLines-1)*(DELIVRABLE_TITLEHEIGHT/5.); |
---|
328 | if ( h>p->height) p->height=h; |
---|
329 | } |
---|
330 | } |
---|
331 | } |
---|
332 | |
---|
333 | double task_livrable_height(int tn, double* delivrable_y) |
---|
334 | { |
---|
335 | int stn,dn,nblivrables=0; |
---|
336 | double height=0; |
---|
337 | height += TASK_TITLEHEIGHT ; |
---|
338 | *delivrable_y = height; |
---|
339 | for (stn=0 ; curr->ls[tn][stn][0][0]!=0 ; stn++) |
---|
340 | for (dn=0 ; curr->ls[tn][stn][dn][0]!=0 ; dn++) { |
---|
341 | nblivrables += 1; |
---|
342 | height+=curr->ls[tn][stn][dn][0]->height; |
---|
343 | } |
---|
344 | height += DELIVRABLE_VSEP/2; |
---|
345 | height += (nblivrables-1)*DELIVRABLE_VSEP; |
---|
346 | height += DELIVRABLE_VSEP/2; |
---|
347 | return height; |
---|
348 | } |
---|
349 | |
---|
350 | void task_box(double pictwidth) |
---|
351 | { |
---|
352 | int tn; |
---|
353 | for ( tn=0 ; curr->ls[tn][0][0][0]!=0 ; tn++ ) { |
---|
354 | const char* color= (tn%2)!=0 ? TASK_BGC1 : TASK_BGC0 ; |
---|
355 | fprintf(curr->os, |
---|
356 | "\\put(%.2f,%.2f){\\fcolorbox{black}{%s}{\\makebox(%5.2f,%5.2f){}}}\n", |
---|
357 | 0.0,curr->ls[tn][0][0][0]->task_y, |
---|
358 | color, |
---|
359 | pictwidth,curr->ls[tn][0][0][0]->task_dy |
---|
360 | ); |
---|
361 | } |
---|
362 | } |
---|
363 | |
---|
364 | void month_grid(double x, double y, double dx, double dy) |
---|
365 | { |
---|
366 | int i; |
---|
367 | for (i=0 ; i<=36 ; i+=1,x+=PICT_MONTHWIDTH) { |
---|
368 | if ( (i%3)!=0 ) continue; |
---|
369 | fprintf(curr->os, |
---|
370 | "\\put(%5.1f,%5.1f){\\line(0,1){%5.1f}}\\put(%5.1f,%5.1f){%d}\n", |
---|
371 | x,y,dy-PICT_MONTHWIDTH-PICT_VSEP, |
---|
372 | x-2,y+dy-PICT_MONTHHEIGHT, |
---|
373 | i |
---|
374 | ); |
---|
375 | } |
---|
376 | } |
---|
377 | |
---|
378 | void print_milestones(double x, double y, double dx, double dy) |
---|
379 | { |
---|
380 | int i; |
---|
381 | double tn=.3; |
---|
382 | //x=x-tn/2; |
---|
383 | fprintf(curr->os,"\\bgroup\n"); |
---|
384 | fprintf(curr->os,"\\color{red}\n"); |
---|
385 | fprintf(curr->os,"\\linethickness{%.2fmm}\n",tn); |
---|
386 | for (i=0 ; milestones[i]!=0 ; i+=1) { |
---|
387 | double xx= x + milestones[i]*PICT_MONTHWIDTH; |
---|
388 | print_vline(xx,y,dy-PICT_MONTHWIDTH-PICT_VSEP,0); |
---|
389 | } |
---|
390 | fprintf(curr->os,"\\egroup\n"); |
---|
391 | } |
---|
392 | |
---|
393 | double delivrable( |
---|
394 | double label_x, double box_x, double title_x, |
---|
395 | double y, |
---|
396 | int tn, int stn, int dn) |
---|
397 | { |
---|
398 | Tlivrable* top=curr->ls[tn][stn][dn][0]; |
---|
399 | Tlivrable* last=curr->ls[tn][stn][dn][top->nbvers-1]; |
---|
400 | char tmp[1000],label[1000],title[1000]; |
---|
401 | double y0; |
---|
402 | int v; |
---|
403 | double label_dx = DELIVRABLE_LABELWIDTH ; |
---|
404 | double label_dy = DELIVRABLE_LABELHEIGHT ; |
---|
405 | double boxx,box_dx; |
---|
406 | double box_dy = DELIVRABLE_BOXHEIGHT ; |
---|
407 | double title_dx = DELIVRABLE_LABELWIDTH ; |
---|
408 | double title_dy = DELIVRABLE_TITLEHEIGHT ; |
---|
409 | |
---|
410 | //print_hline(0,y,180,0); |
---|
411 | gen_label_base(label,top); |
---|
412 | // y -= DELIVRABLE_HEIGHT; |
---|
413 | y -= top->height ; |
---|
414 | //print_hline(0,y,180,0); |
---|
415 | fprintf(curr->os,"%% Delivrable %s (tn=%d stn=%d dn=%d\n",label,tn,stn,dn); |
---|
416 | |
---|
417 | // print label |
---|
418 | //y0 = (DELIVRABLE_HEIGHT-DELIVRABLE_LABELHEIGHT)/2; |
---|
419 | y0 = (top->height-DELIVRABLE_LABELHEIGHT)/2; |
---|
420 | sprintf(tmp,"\\ganttlabelstyle{%s}",label); |
---|
421 | print_put(label_x,y+y0,tmp); |
---|
422 | // print title |
---|
423 | if (last->nbTitleLines==1) { |
---|
424 | y0 = (DELIVRABLE_HEIGHT-DELIVRABLE_TITLEHEIGHT)/2; |
---|
425 | y0 += DELIVRABLE_TITLEHEIGHT/5. ; |
---|
426 | sprintf(tmp,"\\gantttitlestyle{%s}",last->title); |
---|
427 | print_put(title_x,y+y0,tmp); |
---|
428 | } else if (last->nbTitleLines>1) { |
---|
429 | int i; |
---|
430 | // y0 = (DELIVRABLE_HEIGHT-DELIVRABLE_TITLEHEIGHT)/2; |
---|
431 | y0=DELIVRABLE_TITLEHEIGHT/5.; |
---|
432 | sprintf(tmp,"\\gantttitlestyle{\\shortstack[l]{%s",last->titleLines[0]); |
---|
433 | for (i=1 ; i<last->nbTitleLines ; i+=1) { |
---|
434 | strcat(tmp,"\\\\"); |
---|
435 | strcat(tmp,last->titleLines[i]); |
---|
436 | } |
---|
437 | strcat(tmp,"}}"); |
---|
438 | print_put(title_x,y+y0,tmp); |
---|
439 | } |
---|
440 | |
---|
441 | // print box |
---|
442 | //y0 = (DELIVRABLE_HEIGHT-DELIVRABLE_BOXHEIGHT)/2; |
---|
443 | y0 = (top->height-DELIVRABLE_BOXHEIGHT)/2; |
---|
444 | if ( last==top ) { |
---|
445 | Tlivrable* l=top; |
---|
446 | boxx = box_x + l->bm*PICT_MONTHWIDTH ; |
---|
447 | box_dx = (l->em - l->bm) * PICT_MONTHWIDTH; |
---|
448 | print_box(1,0,boxx,y+y0,box_dx,box_dy,COLOR_BOX_LIGHT,0,0); |
---|
449 | print_box(0,0,boxx,y+y0,box_dx,box_dy,0,0,0); |
---|
450 | } else for (v=0 ; v<top->nbvers ; v+=1) { |
---|
451 | Tlivrable* l=curr->ls[tn][stn][dn][v] ; |
---|
452 | gen_label_vers(tmp,l); |
---|
453 | boxx = box_x + l->bm*PICT_MONTHWIDTH ; |
---|
454 | box_dx = (l->em - l->bm) * PICT_MONTHWIDTH; |
---|
455 | print_box(1,0,boxx,y+y0,box_dx,box_dy,COLOR_BOX_LIGHT,0,0); |
---|
456 | print_box(0,tmp,boxx,y+y0,box_dx,box_dy,0,0,0); |
---|
457 | } |
---|
458 | y -= DELIVRABLE_VSEP; |
---|
459 | return y; |
---|
460 | } |
---|
461 | |
---|
462 | void task_delivrable(double label_x, double box_x, double title_x, int tn) |
---|
463 | { |
---|
464 | int stn,dn; |
---|
465 | Tlivrable* task=curr->ls[tn][0][0][0]; |
---|
466 | double y = task->task_y+task->task_dy-task->task_y_del; |
---|
467 | char tmp[1000]; |
---|
468 | sprintf(tmp,"\\textbf{Task-%d \\textit{%s}}",task->tn,task_names[task->tn]); |
---|
469 | print_put(label_x/2,y+(TASK_TITLEHEIGHT-TASK_TITLEFONTHEIGHT)/2,tmp); |
---|
470 | |
---|
471 | //y += DELIVRABLE_VSEP/2. ; |
---|
472 | for (stn=0 ; curr->ls[tn][stn][0][0]!=0 ; stn++) |
---|
473 | for (dn=0 ; curr->ls[tn][stn][dn][0]!=0 ; dn++) { |
---|
474 | y=delivrable(label_x,box_x,title_x,y,tn,stn,dn); |
---|
475 | } |
---|
476 | } |
---|
477 | |
---|
478 | void do_gantt(const char* fn, int* tnplus, int* tnmoins) |
---|
479 | { |
---|
480 | int tn; |
---|
481 | double pictwidth, pictheight; |
---|
482 | double gantt_x,gantt_y; |
---|
483 | double gantt_dx,gantt_dy; |
---|
484 | |
---|
485 | double label_x,title_x; |
---|
486 | curr = data_new(tnplus,tnmoins); |
---|
487 | if ( (curr->os=fopen(fn,"w"))==0 ) { |
---|
488 | fprintf(stderr,"can not open %s file for writing.\n",fn); |
---|
489 | fprintf(stderr,"generation of %s graph is skipped.\n",fn); |
---|
490 | return; |
---|
491 | } |
---|
492 | prepare0(curr); |
---|
493 | prepare1(curr); |
---|
494 | prepare2(curr); |
---|
495 | prepare3(curr); |
---|
496 | |
---|
497 | pictheight=0 ; |
---|
498 | pictheight += PICT_BOTSEP ; |
---|
499 | for ( tn=0 ; curr->ls[tn][0][0][0]!=0 ; tn++ ); |
---|
500 | for ( tn=tn-1 ; tn>=0 ; tn-- ) { |
---|
501 | double offset; |
---|
502 | curr->ls[tn][0][0][0]->task_y = pictheight; |
---|
503 | curr->ls[tn][0][0][0]->task_dy = task_livrable_height(tn,&offset); |
---|
504 | curr->ls[tn][0][0][0]->task_y_del = offset; |
---|
505 | pictheight += curr->ls[tn][0][0][0]->task_dy; |
---|
506 | pictheight += TASK_VSEP; |
---|
507 | } |
---|
508 | pictheight += PICT_MONTHHEIGHT; |
---|
509 | pictheight += PICT_TOPSEP ; |
---|
510 | gantt_y = PICT_BOTSEP ; |
---|
511 | gantt_dy = pictheight-PICT_TOPSEP-PICT_BOTSEP ; |
---|
512 | |
---|
513 | pictwidth=0; |
---|
514 | pictwidth += PICT_LEFTSEP; |
---|
515 | label_x = pictwidth; |
---|
516 | pictwidth += DELIVRABLE_LABELWIDTH; |
---|
517 | pictwidth += PICT_HSEP; |
---|
518 | gantt_x = pictwidth ; |
---|
519 | gantt_dx = 36*PICT_MONTHWIDTH ; |
---|
520 | pictwidth += gantt_dx ; |
---|
521 | pictwidth += PICT_HSEP; |
---|
522 | title_x = pictwidth; |
---|
523 | pictwidth += DELIVRABLE_TITLEWIDTH; |
---|
524 | pictwidth += PICT_RIGHTSEP; |
---|
525 | |
---|
526 | fprintf(curr->os,"\\setlength{\\unitlength}{1.0mm}\n"); |
---|
527 | fprintf(curr->os,"\\begin{picture}(%.1f,%.1f)\n",pictwidth,pictheight); |
---|
528 | //print_hline(0,0,pictwidth,0); |
---|
529 | //print_hline(0,pictheight,pictwidth,0); |
---|
530 | task_box(pictwidth); |
---|
531 | month_grid(gantt_x,gantt_y,gantt_dx,gantt_dy); |
---|
532 | for ( tn=0 ; curr->ls[tn][0][0][0]!=0 ; tn++ ) { |
---|
533 | task_delivrable(label_x,gantt_x,title_x,tn); |
---|
534 | } |
---|
535 | |
---|
536 | print_milestones(gantt_x,0,gantt_dx,gantt_dy+gantt_y); |
---|
537 | fprintf(curr->os,"\\end{picture}\n"); |
---|
538 | } |
---|
539 | |
---|
540 | int main() |
---|
541 | { |
---|
542 | int tnplus[10] = { 0, 6, 7, -1 }; |
---|
543 | int tnmoins[10] = { 0, 6, 7, -1 }; |
---|
544 | |
---|
545 | yylex(); |
---|
546 | do_gantt("gantt.tex",0,0); |
---|
547 | do_gantt("gantt1.tex",tnplus,0); |
---|
548 | do_gantt("gantt2.tex",0,tnmoins); |
---|
549 | |
---|
550 | return 0; |
---|
551 | } |
---|