version 1.67, 2002/04/24 21:24:40
|
version 1.69, 2002/04/25 17:25:36
|
Line 484 sub end_gnuplot {
|
Line 484 sub end_gnuplot {
|
## Determine filename |
## Determine filename |
my $tmpdir = '/home/httpd/perl/tmp/'; |
my $tmpdir = '/home/httpd/perl/tmp/'; |
my $filename = $ENV{'user.name'}.'_'.$ENV{'user.domain'}. |
my $filename = $ENV{'user.name'}.'_'.$ENV{'user.domain'}. |
'_'.time.'_'.$$.$randnumber.'_plot.data'; |
'_'.time.'_'.$$.$randnumber.'_plot'; |
## Write the plot description to the file |
## Write the plot description to the file |
&write_gnuplot_file($tmpdir,$filename,$target); |
&write_gnuplot_file($tmpdir,$filename,$target); |
$filename = &Apache::lonnet::escape($filename); |
$filename = &Apache::lonnet::escape($filename); |
## return image tag for the plot |
## return image tag for the plot |
if ($target eq 'web') { |
if ($target eq 'web') { |
$result .= <<"ENDIMAGE"; |
$result .= <<"ENDIMAGE"; |
<img src = "/cgi-bin/plot.gif?file=$filename&output=gif" |
<img src = "/cgi-bin/plot.gif?file=$filename.data&output=gif" |
width = "$plot{'width'}" |
width = "$plot{'width'}" |
height = "$plot{'height'}" |
height = "$plot{'height'}" |
align = "$plot{'align'}" |
align = "$plot{'align'}" |
alt = "$plot{'alttag'}" /> |
alt = "$plot{'alttag'}" /> |
ENDIMAGE |
ENDIMAGE |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
&Apache::lonnet::ssi('cgi-bin/plot.gif?file=$filename'. |
&Apache::lonnet::ssi("/cgi-bin/plot.gif?file=$filename&output=eps"); |
'&output=eps'); |
$result = '\\\\ \graphicspath{/home/httpd/perl/tmp/}\fbox{\includegraphics[width=9.0 cm]{'.&Apache::lonnet::unescape($filename).'.eps}} \\\\'; |
$result = "$filename.eps"; |
|
} |
} |
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
$result.=&Apache::edit::tag_end($target,$token); |
$result.=&Apache::edit::tag_end($target,$token); |
Line 992 sub write_gnuplot_file {
|
Line 991 sub write_gnuplot_file {
|
$gnuplot_input .= "set output\n"; |
$gnuplot_input .= "set output\n"; |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
$gnuplot_input .= "set term postscript eps monochrome\n"; |
$gnuplot_input .= "set term postscript eps monochrome\n"; |
$gnuplot_input .= "set output \"/home/httpd/perl/tmp/$filename.eps\"\n"; |
$gnuplot_input .= "set output \"/home/httpd/perl/tmp/". |
|
&Apache::lonnet::unescape($filename).".eps\"\n"; |
} |
} |
# grid |
# grid |
$gnuplot_input .= 'set grid'.$/ if ($plot{'grid'} eq 'on'); |
$gnuplot_input .= 'set grid'.$/ if ($plot{'grid'} eq 'on'); |