Subversion Repositories wimsdev

Rev

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

  1. #!/usr/bin/perl
  2.  
  3. $nomeprog="make.pl";
  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.  
  15. $setup="xrange -10,10 \nyrange -10,10\nhline 0,0,black\nvline 0,0,black";
  16. if ($filein=~/geometry/){
  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.  
  22. $dimsize="400";
  23. $cellwidth="width:265px";
  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";
  29. print OUTPUT "<div><table><tr><td style=\"$cellwidth\"></td>\n<td style=\"$cellwidth\">\n";
  30. print OUTPUT "canvasdraw\n<pre>canvasdraw{$dimsize,$dimsize}{\n$setup\n...\n}</pre>";
  31. print OUTPUT "</td><td style=\"$cellwidth\">\n";
  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";
  34. my @fileid=split("/",$filein);
  35.  
  36. print OUTPUT "<h3>Examples</h3>\n";
  37. my $cnt=0;
  38. while (<INPUT>){
  39.   chop;
  40.   if($cnt==0){ $cnt=1; next};
  41.   my($riga)=$_;
  42.   if ($riga =~ /^:/g){
  43.     if($status == 1){
  44.       my $name=$fileid[1] . "_" . $cnt;
  45.       print OUTPUT '<h4>' . $comments[1];
  46.       if($comments[2] ne ""){
  47.         print OUTPUT "($comments[2])\n";
  48.       }
  49.       print OUTPUT "</h4>";
  50.       print OUTPUT '<table class="wimsborder">
  51.        <tr><td colspan="3" style="text-align:left"><pre>' . niceprint($txtoutput) . "</pre>";
  52.       print OUTPUT "\n";
  53.  
  54.       print OUTPUT "</td></tr>\n";
  55.       print OUTPUT "<tr><td style=\"$cellwidth\">\n";
  56.       print OUTPUT "\\canvasdraw{$dimsize,$dimsize}{ \n$setup \n";
  57.       print OUTPUT $txtoutput;
  58.       print OUTPUT "}\n</td>\n<td style=\"$cellwidth\">\n";
  59.       print OUTPUT "\\draw{$dimsize,$dimsize}{ \n$setup \n";
  60.       print OUTPUT $txtoutput;
  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";
  66.       if ($filein =~ /object|transf|geometry/) {
  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. @");
  74.       }
  75.       $txtoutput="";
  76.       $cnt ++;
  77.     }
  78.     $status=1;
  79.     @comments=split(":",$_);
  80.   } else {
  81.       $txtoutput=$txtoutput."$riga\n";
  82.   }
  83. }
  84.  
  85. sub niceprint {
  86.     my($str) = @_ ;
  87.     $str =~ s/\\filedir/\\\\filedir/g;
  88.     $str =~ s/\$/&\#36;/g ;
  89.     return $str;
  90. }
  91.