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
RevLine 
[34]1%{
[36]2#define COLOR_Milestone  "gtcMilestone"
3#define COLOR_BOX_HEAVY "gtcBoxHeavy"
4#define COLOR_BOX_LIGHT "gtcBoxLight"
[34]5
[51]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
[34]12
13#define PICT_MONTHHEIGHT 5  // police height
14#define PICT_MONTHWIDTH  (10./3.)
15
16#define TASK_VSEP  2
[36]17#define TASK_BGC0       "gtcTaskBG0"
18#define TASK_BGC1       "gtcTaskBG1"
[51]19#define TASK_TITLEHEIGHT 6.
20#define TASK_TITLEFONTHEIGHT 2.
[34]21
22#define DELIVRABLE_VSEP   1
23#define DELIVRABLE_HEIGHT 3
[36]24#define DELIVRABLE_LABELWIDTH  10
[34]25#define DELIVRABLE_LABELHEIGHT DELIVRABLE_HEIGHT
[36]26#define DELIVRABLE_TITLEWIDTH  35
[34]27#define DELIVRABLE_TITLEHEIGHT DELIVRABLE_HEIGHT
[36]28#define DELIVRABLE_BOXHEIGHT   (DELIVRABLE_HEIGHT)
[34]29
[51]30char* task_names[] = {
[59]31    0,
[51]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};
[59]42struct partner_def { char *key, *name, *fnfull, *fnshort; } partner_table[] = {
[147]43    { "UNKNOW" ,"relax"  ,0                             ,0                        },
[121]44    { "irisa"  ,"irisa"  ,"table_inria_cairn_full.tex"  ,"table_inria_cairn_short.tex"  },
[147]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                        },
[52]56};
[51]57
[34]58typedef struct _Tlivrable {
[36]59    int tn,stn,dn,vn;  // task, sub-task, number
60    char v;            // 0, 1, 2, ..., F
[151]61    char* kind;
[34]62    char* title;
[52]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
[36]66    // these fields are filled by the program for data[tn][0][0][0]
[34]67    double task_y;           // top of task
68    double task_dy;          // bot of task is task_y+task_dy
[51]69    double task_y_del;       // delivrables start at task_y+task_y_del
[52]70    double nbma[3];          // durée en mois par annee
[36]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
[34]80} Tlivrable;
81
82#define T_MAX 10
83#define S_MAX 10
84#define D_MAX 10
85#define V_MAX 10
[51]86typedef struct _Tdata {
87    FILE*      os;
88    Tlivrable* ls[T_MAX][S_MAX][D_MAX][V_MAX];
89} Tdata;
90Tdata  data_org;
91Tdata* curr;
[36]92
[51]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;
[52]128//fprintf(stderr,"selected: [tn][stn][dn][v]=%d,%d,%d,%d\n",tn,stn,dn,v);
[51]129    }
130    return data;
131}
132
[36]133int milestones[100];
134
135char* gen_label_base(char* buf,Tlivrable*p)
[75]136    { if (p->dn >=0) sprintf(buf,"D%d%d%d",p->tn,p->stn,p->dn); else sprintf(buf,""); return buf; }
[36]137char* gen_label_vers(char* buf,Tlivrable*p)
[51]138    { if (p->nbvers<=1) strcpy(buf,""); else sprintf(buf,"V%c",p->v); return buf; }
[36]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)
[51]144    { fprintf(curr->os,"\\put(%.2f,%.2f){%s}\n",x,y,object); }
[36]145void print_hline(double x,double y, double len, const char* color)
146{
147    char object[1024];
[51]148    if (color!=0) { fprintf(curr->os,"\\bgroup\\color{%s}\n",color); }
[36]149    sprintf(object,"\\line(1,0){%.2f}",len);
150    print_put(x,y,object);
[51]151    if (color!=0) { fprintf(curr->os,"\\egroup\n"); }
[36]152}
153void print_vline(double x,double y, double len, const char* color)
154{
155    char object[1024];
[51]156    if (color!=0) { fprintf(curr->os,"\\bgroup\\color{%s}\n",color); }
[36]157    sprintf(object,"\\line(0,1){%.2f}",len);
158    print_put(x,y,object);
[51]159    if (color!=0) { fprintf(curr->os,"\\egroup\n"); }
[36]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;
[51]179        fprintf(curr->os,"\\bgroup\\color{%s}\n",boxcolor);
180        fprintf(curr->os,"\\linethickness{%.2fmm}\n",tn);
[36]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);
[51]185        fprintf(curr->os,"\\egroup\n");
[36]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}
[34]212%}
213
214%option noyywrap
215
216%%
[151]217 int tn,stn,dn,v,bm,em; char* title; char* kind;
[52]218 double an[3];
219 char*  an_comment;
220 int    partner;
[34]221#.*\n   ;
[52]222T=[0-9]+  { tn=atoi(yytext+2); }
223S=[0-9]+  { stn=atoi(yytext+2); }
224D=[0-9]+  { dn=atoi(yytext+2); }
[75]225D=none    { dn=-2; }
[52]226V=V[1-8F] { v=yytext[3]; }
[36]227ML=[0-9]+ {
228        int i;
229        for (i=0 ; milestones[i]!=0 ; i++);
230        milestones[i] = atoi(yytext+3);
231    }
[34]232BM=[0-9]+ { bm=atoi(yytext+3); }
233EM=[0-9]+ { em=atoi(yytext+3); }
[52]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) {
[151]239            fprintf(stderr,
240                "%s: is not resource definition, expected format \"N:N:N\" (near D%d%d%d-V%c)\n",
[52]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    }
[151]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    }
[34]274TITLE=.*\n {
275        char* pc=yytext+6;
[36]276        yytext[yyleng-1]=0;
[34]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;
[52]284        p->hman[0] = an[0];
285        p->hman[1] = an[1];
286        p->hman[2] = an[2];
287        p->partner = partner;
[34]288        p->title = title;
289        p->bm = bm;
290        p->em = em;
[151]291        p->kind = kind;
[36]292        gen_titleLines(p);
[34]293
[51]294        for (v=0; data_org.ls[tn][stn][dn][v]!=0 ; v++);
295        data_org.ls[tn][stn][dn][v] = p;
[52]296//fprintf(stderr,"ADDED: %d %d %d %d\n",tn,stn,dn,v);
[151]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;
[34]302    }
[52]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); }
[34]306%%
307
[51]308void prepare0(Tdata* data)
[34]309{
[51]310int tn,stn,v;
[34]311int i0,i1,i;
312    for (tn=0 ; tn<T_MAX ; tn++)
313    for (stn=0; stn<S_MAX; stn++) {
[36]314//fprintf(stderr,"AVANT:t=%d:%d:: ",tn,stn); for (i=0; i<D_MAX ; i++)
[51]315//fprintf(stderr,"%d:%p ",i,data->ls[tn][stn][i][0]); fprintf(stderr,"\n");
[34]316        while (1) {
317            for (i0=0 ; i0<D_MAX ; i0++)
[51]318                if (data->ls[tn][stn][i0][0] == 0) break;
[34]319            for (i1=i0+1 ; i1<D_MAX ; i1++)
[51]320                if (data->ls[tn][stn][i1][0] != 0) break;
[34]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) {
[51]325                    data->ls[tn][stn][i0+i][v] = data->ls[tn][stn][i1+i][v];
326                    data->ls[tn][stn][i1+i][v] = 0;
[34]327                }
328        }
[36]329//fprintf(stderr,"AVANT:t=%d:%d:: ",tn,stn); for (i=0; i<D_MAX ; i++)
[51]330//fprintf(stderr,"%d:%p ",i,data->ls[tn][stn][i][0]); fprintf(stderr,"\n");
[34]331    }
332}
[51]333void prepare1(Tdata* data)
[34]334{
[51]335int tn,dn,v;
[34]336int i0,i1,i;
337    for (tn=0 ; tn<T_MAX ; tn++) {
[51]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");
[34]339        while (1) {
340            for (i0=0 ; i0<S_MAX ; i0++)
[51]341                if (data->ls[tn][i0][0][0] == 0) break;
[34]342            for (i1=i0+1 ; i1<S_MAX ; i1++)
[51]343                if (data->ls[tn][i1][0][0] != 0) break;
[36]344//fprintf(stderr,"%d %d %d\n",tn,i0,i1);
[34]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) {
[51]350                        data->ls[tn][i0+i][dn][v] = data->ls[tn][i1+i][dn][v];
351                        data->ls[tn][i1+i][dn][v] = 0;
[34]352                    }
353        }
[51]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");
[34]355    }
356}
[51]357void prepare2(Tdata* data)
[36]358{
[51]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{
[36]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++) {
[51]384        Tlivrable* p = data->ls[tn][stn][dn][0];
[36]385        if (p==0) continue;
386        p->nbvers=0 ;
387        for (vn=0 ; vn<V_MAX ; vn+=1)
[51]388            if (data->ls[tn][stn][dn][vn]!=0) p->nbvers+=1;
[36]389        p->vers=(Tlivrable**)malloc(sizeof(*p->vers)*(p->nbvers+1));
390        for (vn=0 ; vn<p->nbvers ; vn+=1) {
[51]391            p->vers[vn] = data->ls[tn][stn][dn][vn];
392            data->ls[tn][stn][dn][vn]->nbvers = p->nbvers;
[36]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        }
[52]402        Tlivrable* lu= p->vers[p->nbvers-1];
403        int i;
[147]404//fprintf(stderr,"--------------------\n");
[52]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        }
[36]423    }
424}
[34]425
[51]426double task_livrable_height(int tn, double* delivrable_y)
[34]427{
[36]428int    stn,dn,nblivrables=0;
429double height=0;
[51]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++) {
[36]434            nblivrables += 1;
[51]435            height+=curr->ls[tn][stn][dn][0]->height;
[36]436        }
437        height += DELIVRABLE_VSEP/2;
438        height += (nblivrables-1)*DELIVRABLE_VSEP;
439        height += DELIVRABLE_VSEP/2;
440    return height;
[34]441}
442
443void  task_box(double pictwidth)
444{
445    int tn;
[51]446    for ( tn=0 ; curr->ls[tn][0][0][0]!=0 ; tn++ ) {
[34]447        const char* color= (tn%2)!=0 ? TASK_BGC1 : TASK_BGC0 ;
[51]448        fprintf(curr->os,
[36]449            "\\put(%.2f,%.2f){\\fcolorbox{black}{%s}{\\makebox(%5.2f,%5.2f){}}}\n",
[51]450            0.0,curr->ls[tn][0][0][0]->task_y,
[34]451            color,
[51]452            pictwidth,curr->ls[tn][0][0][0]->task_dy
[34]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;
[51]462        fprintf(curr->os,
[34]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
[36]471void  print_milestones(double x, double y, double dx, double dy)
472{
473    int i;
474    double tn=.3;
475    //x=x-tn/2;
[51]476    fprintf(curr->os,"\\bgroup\n");
477    fprintf(curr->os,"\\color{red}\n");
478    fprintf(curr->os,"\\linethickness{%.2fmm}\n",tn);
[36]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    }
[51]483    fprintf(curr->os,"\\egroup\n");
[36]484}
485
[34]486double delivrable(
487    double label_x, double box_x, double title_x,
488    double y,
489    int tn, int stn, int dn)
490{
[51]491    Tlivrable* top=curr->ls[tn][stn][dn][0];
492    Tlivrable* last=curr->ls[tn][stn][dn][top->nbvers-1];
[36]493    char tmp[1000],label[1000],title[1000];
[34]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 ;
[36]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);
[51]508    fprintf(curr->os,"%% Delivrable %s (tn=%d stn=%d dn=%d\n",label,tn,stn,dn);
[36]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) {
[51]544        Tlivrable* l=curr->ls[tn][stn][dn][v] ;
[36]545        gen_label_vers(tmp,l);
[34]546        boxx = box_x + l->bm*PICT_MONTHWIDTH ;
547        box_dx  = (l->em - l->bm) * PICT_MONTHWIDTH;
[36]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);
[34]550    }
[36]551    y -= DELIVRABLE_VSEP;
[34]552    return y;
553}
554
555void task_delivrable(double label_x, double box_x, double title_x, int tn)
556{
557int stn,dn;
[51]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
[36]564    //y += DELIVRABLE_VSEP/2. ;
[51]565    for (stn=0 ; curr->ls[tn][stn][0][0]!=0 ; stn++)
566        for (dn=0 ; curr->ls[tn][stn][dn][0]!=0 ; dn++) {
[75]567                        if (curr->ls[tn][stn][dn][0]->dn >=0)
568                                y=delivrable(label_x,box_x,title_x,y,tn,stn,dn);
[36]569        }
[34]570}
571
[51]572void do_gantt(const char* fn, int* tnplus, int* tnmoins)
[34]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;
[51]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);
[34]590
591    pictheight=0 ;
592    pictheight += PICT_BOTSEP ;
[51]593    for ( tn=0 ; curr->ls[tn][0][0][0]!=0 ; tn++ );
[34]594    for ( tn=tn-1 ; tn>=0 ; tn-- ) {
[51]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;
[34]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   
[51]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++ ) {
[34]627        task_delivrable(label_x,gantt_x,title_x,tn);
[51]628    }
[36]629
630    print_milestones(gantt_x,0,gantt_dx,gantt_dy+gantt_y);
[51]631    fprintf(curr->os,"\\end{picture}\n");
[52]632    fclose(curr->os);
633    curr->os=0;
[51]634}
[34]635
[59]636void do_partner_table_full(int partner)
[52]637{
638    struct partner_def* part = partner_table+partner;
[59]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);
[52]642        return;
643    }
[123]644    fprintf(curr->os,"\\begin{tabular}{|c|l||r|r|r||r|}\\hline\n");
[52]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;
[54]652    double tsk1,tsk2,tsk3,tsk;
[52]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        }
[54]660                tsk1=tsk2=tsk3=tsk=0;
[52]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);
[54]676                an1 += sum1 ; tsk1 += sum1 ;
677                an2 += sum2 ; tsk2 += sum2 ;
678                an3 += sum3 ; tsk3 += sum3 ;
679                an  += sum  ; tsk  += sum  ;
[52]680                newlineadded=0;
[63]681                if ( sum1==0 && last->nbma[0]!=0)
[145]682                    fprintf(stderr,"ERROR:   %-10s:%s probleme sur l'an 1 (in table=%2.1f, in gantt=%2.1f\n",
[52]683                        part->name,label,sum1,last->nbma[0]);
[145]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",
[63]686                        part->name,label,sum1,last->nbma[0]);
[145]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]);
[63]690                if ( sum2==0 && last->nbma[1]!=0)
[145]691                    fprintf(stderr,"ERROR:   %-10s:%s probleme sur l'an 2 (in table=%2.1f, in gantt=%2.1f\n",
[52]692                        part->name,label,sum2,last->nbma[1]);
[145]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]);
[63]699                if ( sum3==0 && last->nbma[2]!=0)
[145]700                    fprintf(stderr,"ERROR:   %-10s:%s probleme sur l'an 3 (in table=%2.1f, in gantt=%2.1f\n",
[52]701                        part->name,label,sum3,last->nbma[2]);
[145]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",
[63]704                        part->name,label,sum3,last->nbma[2]);
[145]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]);
[52]708            }
709        }
[54]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               
[52]714    }
715    if ( an!=(an1+an2+an3) ) {
[59]716        fprintf(stderr,"bad computation in %s table.\n",part->fnfull);
[52]717    }
[54]718    fprintf(curr->os,"\\hline\n");
[52]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
[59]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
[147]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");
[151]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");
[147]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);
[151]834            sprintf(date,"\\makebox[2mm][r]{%d}",l->em);
835            sprintf(kind,"\\makebox[1mm]{%s}",l->kind);
[147]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);
[151]849             fprintf(curr->os," & %-30s", date);
850             fprintf(curr->os," & %-30s", kind);
[147]851             fprintf(curr->os," & %s", desc);
852             nblines -= 1;
853        }
854    }}}
855    do_livrable_tables_open(nbfile,1);
856}
857
[51]858int main()
859{
[113]860    int tnplus[10] = { 1, 2, 3, 4, -1 };
861    int tnmoins[10] = { 1, 2, 3, 4, -1 };
[51]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
[52]868    curr = data_new(0,0);
869    prepare0(curr);
870    prepare1(curr);
871    prepare2(curr);
872    prepare3(curr);
[147]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);
[113]881    do_partner_table_full(10); do_partner_table_short(10);
[125]882    do_partner_table_full(11); do_partner_table_short(10);
[52]883
[147]884    curr = data_new(0,0);
885    prepare0(curr);
886    prepare1(curr);
887    prepare2(curr);
888    prepare3(curr);
889    do_livrable_tables(66);
[34]890    return 0;
891}
Note: See TracBrowser for help on using the repository browser.