source: anr/gantt.l @ 226

Last change on this file since 226 was 151, checked in by coach, 14 years ago

IA: added kind in delivrable tables

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