Subversion Repositories wimsdev

Rev

Rev 18381 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
15598 bpr 1
#!/usr/bin/perl
2
 
15612 bpr 3
$nomeprog="make.pl";
15598 bpr 4
 
5
##if ( @ARGV != 1 ){
6
##    die("usage: \"$nomeprog _nomefile_\n");
7
##}
8
 
9
my ($filein,$fileout)=@ARGV;
10
 
11
$status=0;
12
$txtoutput="";
13
@comments=();
14
 
18585 bpr 15
$setup="xrange -10,10 \nyrange -10,10\nhline 0,0,black\nvline 0,0,black";
18381 bpr 16
if ($filein=~/geometry/){
18585 bpr 17
  $setup="xrange -1.5,1.5 \nyrange -1.5,1.5\nhline 0,0,black\nvline 0,0,black\ncircles black,0,0,1";
18
};
19
if ($filein=~/canvasdraw1/) {$setup=""};
20
if ($filein=~/canvasdraw2/) {$setup=""};
21
 
15598 bpr 22
$dimsize="400";
17607 bpr 23
$cellwidth="width:265px";
15598 bpr 24
 
25
open (INPUT,"< $filein") || die("Cannot open in $filein: $!\n");
26
open (OUTPUT,"> $fileout") || die("Cannot open out $fileout: $!\n");
27
 
28
print OUTPUT "<h3>Setup</h3>\n";
17607 bpr 29
print OUTPUT "<div><table><tr><td style=\"$cellwidth\"></td>\n<td style=\"$cellwidth\">\n";
15598 bpr 30
print OUTPUT "canvasdraw\n<pre>canvasdraw{$dimsize,$dimsize}{\n$setup\n...\n}</pre>";
17607 bpr 31
print OUTPUT "</td><td style=\"$cellwidth\">\n";
15598 bpr 32
print OUTPUT "flydraw\n<pre>draw{$dimsize,$dimsize}{\n$setup\n...\n}</pre>";
33
print OUTPUT "</td>\n</tr>\n</table>\n</div>\n";
17607 bpr 34
my @fileid=split("/",$filein);
15598 bpr 35
 
36
print OUTPUT "<h3>Examples</h3>\n";
15615 bpr 37
my $cnt=0;
15598 bpr 38
while (<INPUT>){
39
  chop;
15615 bpr 40
  if($cnt==0){ $cnt=1; next};
15598 bpr 41
  my($riga)=$_;
42
  if ($riga =~ /^:/g){
43
    if($status == 1){
17623 bpr 44
      my $name=$fileid[1] . "_" . $cnt;
17607 bpr 45
      print OUTPUT '<h4>' . $comments[1];
15598 bpr 46
      if($comments[2] ne ""){
47
        print OUTPUT "($comments[2])\n";
48
      }
49
      print OUTPUT "</h4>";
50
      print OUTPUT '<table class="wimsborder">
17607 bpr 51
        <tr><td colspan="3" style="text-align:left"><pre>' . niceprint($txtoutput) . "</pre>";
15598 bpr 52
      print OUTPUT "\n";
53
 
54
      print OUTPUT "</td></tr>\n";
17607 bpr 55
      print OUTPUT "<tr><td style=\"$cellwidth\">\n";
15598 bpr 56
      print OUTPUT "\\canvasdraw{$dimsize,$dimsize}{ \n$setup \n";
57
      print OUTPUT $txtoutput;
17663 bpr 58
      print OUTPUT "}\n</td>\n<td style=\"$cellwidth\">\n";
15598 bpr 59
      print OUTPUT "\\draw{$dimsize,$dimsize}{ \n$setup \n";
60
      print OUTPUT $txtoutput;
17607 bpr 61
      print OUTPUT "}\n</td>\n<td style=\"$cellwidth\">";
62
      print OUTPUT "<object width=\"$dimsize\" height=\"$dimsize\" type=\"application/pdf\" data=\"\\filedir/tikz/$name.pdf\">
63
  <embed width=\"300\" height=\"300\" type=\"application/pdf\" src=\"\\filedir/tikz/$name.pdf\">
64
  </object>\n";
65
      print OUTPUT"\n</td>\n</tr>\n</table>\n";
18357 bpr 66
      if ($filein =~ /object|transf|geometry/) {
17607 bpr 67
      system("../../../../other/bin/flydraw <<@
68
tikzfile files/tikz/$name.tex
69
new $dimsize,$dimsize
70
$setup
71
$txtoutput
72
output files/tikz/$name.gif
73
@");
17623 bpr 74
      }
15598 bpr 75
      $txtoutput="";
17607 bpr 76
      $cnt ++;
15598 bpr 77
    }
78
    $status=1;
79
    @comments=split(":",$_);
80
  } else {
17623 bpr 81
      $txtoutput=$txtoutput."$riga\n";
15598 bpr 82
  }
83
}
84
 
85
sub niceprint {
86
    my($str) = @_ ;
87
    $str =~ s/\\filedir/\\\\filedir/g;
88
    $str =~ s/\$/&\#36;/g ;
89
    return $str;
90
}