source: anr/gantt.l @ 278

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

Reduced the task number. Suppressed xilinx, navtel and flexra. Added mds.

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