6 my($grid_Y_size)=225; # xfig
7 my($grid_X_size)=100550; # xfig
14 open INPUT, $filename;
16 while (defined($line=<INPUT>)) {
19 my($event,$date,$id,$type,$father,@name) = split(/\s+/,$line);
21 $Cat{$id}{name}="@name ";
22 $Cat{$id}{name}=~s/\"//g;
23 $Cat{$id}{father}=$father;
24 $Cat{$id}{type}=$type;
25 $Cat{$id}{date}=$date;
34 my($filename,$Cat)=@_;
37 open INPUT, $filename;
39 while (defined($line=<INPUT>)) {
41 if($line =~ /^11\s/) {
42 my($event,$date,$type,$id,$state) = split(/\s+/,$line);
43 push @{$$Cat{$id}{state}}, [$date,$state];
45 if($line =~ /^12\s/) {
46 my($event,$date,$type,$id) = split(/\s+/,$line);
47 push @{$$Cat{$id}{state}}, [$date];
58 open INPUT, $filename;
60 while (defined($line=<INPUT>)) {
62 if($line =~ /^16\s/) {
63 my($event,$date,$type,$father,$channel,$src,$key) = split(/\t+/,$line);
64 $link{$key}{src}=$src;
65 $link{$key}{src_date}=$date;
67 if($line =~ /^17\s/) {
68 my($event,$date,$type,$father,$channel,$dst,$key) = split(/\t+/,$line);
69 $link{$key}{dst}=$dst;
70 $link{$key}{dst_date}=$date;
83 foreach $cat (keys %$Cat) {
84 if($$Cat{$cat}{father} eq $root) {
85 push @childs, build_cat_tree($cat,$Cat);
87 # print "$$Cat{$cat}{name}\t\t $Cat{$cat}{father}\n";
90 return [$root,@childs];
94 my($tree,$cat_list)=@_;
95 my($root) = shift @$tree;
98 push @$cat_list,$root;
100 foreach $u (@$tree) {
101 build_cat_list($u,$cat_list);
103 unshift @$tree, $root;
107 sub set_cat_position {
108 my($Cat,$cat_list)=@_;
111 foreach $cat (@$cat_list) {
112 if(defined($$Cat{$cat}{state})) {
113 $$Cat{$cat}{Y_min} = $i;
114 $$Cat{$cat}{Y_max} = $i+1;
123 $fig->{object} = 'compound'; # Compound
124 $fig->{elements} = [];
125 $fig->{version} = 3.2;
126 $fig->{orientation} = 'Landscape';
127 $fig->{justification} = 'Center';
128 $fig->{units} = 'Metric';
129 $fig->{papersize} = 'A4';
130 $fig->{magnification} = '100.00';
131 $fig->{multiplepage} = 'Single';
132 $fig->{transparent} = '-2';
133 $fig->{resolution} = '1200';
134 $fig->{coordsystem} = '2';
135 $fig->{filename} = $filename;
140 my($fig,$Cat,$Link)=@_;
142 foreach $cat (keys %$Cat) {
143 next unless (defined($$Cat{$cat}{Y_min}) &&
144 defined($$Cat{$cat}{Y_max}));
145 my($text) = new XFig ('text');
146 $text->{'text'} = "$$Cat{$$Cat{$cat}{father}}{name}"."$$Cat{$cat}{name}";
147 $text->{'y'} = ($$Cat{$cat}{Y_min}+$$Cat{$cat}{Y_max})/2*$grid_Y_size+68;
150 foreach $cat (keys %$Cat) {
151 next unless (defined($$Cat{$cat}{Y_min}) &&
152 defined($$Cat{$cat}{Y_max}));
155 foreach $e (@{$$Cat{$cat}{state}}) {
156 my($new_date,$state) = ($$e[0],$$e[1]);
157 if(defined($state)) {
160 my($old_event) = pop @states;
161 my($old_date) = $$old_event[0];
162 $state = $$old_event[1];
164 my($line) = new XFig ('polyline');
166 $line->{'depth'} = 50; # line
167 $line->{'subtype'} = 1; # line
168 $line->{'points'} = [ [$old_date*$grid_X_size, $$Cat{$cat}{Y_min}*$grid_Y_size],
169 [$new_date*$grid_X_size, $$Cat{$cat}{Y_min}*$grid_Y_size],
170 [$new_date*$grid_X_size, $$Cat{$cat}{Y_max}*$grid_Y_size],
171 [$old_date*$grid_X_size, $$Cat{$cat}{Y_max}*$grid_Y_size] ];
172 $line->{'areafill'} = 20;
174 $line->{'fillcolor'} = 1;
175 } elsif ($state eq "E") {
176 $line->{'fillcolor'} = 2;
177 } elsif ($state eq "B") {
178 $line->{'fillcolor'} = 3;
179 } elsif ($state eq "C") {
180 $line->{'fillcolor'} = 4;
187 foreach $link (keys %$Link) {
188 my($line) = new XFig ('polyline');
189 my($src_date)=$$Link{$link}{src_date};
190 my($src)=$$Link{$link}{src};
191 my($dst_date)=$$Link{$link}{dst_date};
192 my($dst)=$$Link{$link}{dst};
193 $line->{'subtype'} = 1; # line
195 print STDERR "$link: $src ($src_date) -> $dst ($dst_date)\n";
197 print STDERR "$$Cat{$src}{name} -> $$Cat{$dst}{name}\n";
198 $line->{'points'} = [ [$src_date*$grid_X_size,
199 ($$Cat{$src}{Y_min}+$$Cat{$src}{Y_max})/2*$grid_Y_size],
200 [$dst_date*$grid_X_size,
201 ($$Cat{$dst}{Y_min}+$$Cat{$dst}{Y_max})/2*$grid_Y_size] ];
202 $line->{'forwardarrow'} = ['1', '1', '1.00', '60.00', '120.00'];
208 my($Cat) = read_cat($ARGV[0]);
209 my($cat_tree)=build_cat_tree("0",$Cat);
210 read_event($ARGV[0],$Cat);
211 my($Link)=read_link($ARGV[0]);
212 # print Dumper($cat_tree);
213 # print Dumper($Cat);
215 build_cat_list($cat_tree,$cat_list);
218 print "@$cat_list \n";
220 set_cat_position($Cat,$cat_list);
222 my($fig)=create_fig("toto.fig");
223 draw_cat($fig,$Cat,$Link);
225 system "fig2dev -L pdf toto.fig toto.pdf";