--- loncom/xml/lonplot.pm 2003/02/07 22:03:21 1.81 +++ loncom/xml/lonplot.pm 2003/06/10 18:46:02 1.85 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Dynamic plot # -# $Id: lonplot.pm,v 1.81 2003/02/07 22:03:21 albertel Exp $ +# $Id: lonplot.pm,v 1.85 2003/06/10 18:46:02 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -112,7 +112,8 @@ my $words_test = sub {$_[0]=~s/\s+/ ## ## ################################################################### my @gnuplot_edit_order = - qw/alttag bgcolor fgcolor height width font transparent grid samples border align/; + qw/alttag bgcolor fgcolor height width font transparent grid samples + border align texwidth/; my $gnuplot_help_text = <<"ENDPLOTHELP";

@@ -221,7 +222,14 @@ my %gnuplot_defaults = description => 'alignment for image in html', edit_type => 'choice', choices => ['left','right','center'] - } + }, + texwidth => { + default => '93', + test => $int_test, + description => 'Width of plot when printed (mm)', + edit_type => 'entry', + size => '5' + }, ); my %key_defaults = @@ -506,7 +514,8 @@ sub end_gnuplot { ENDIMAGE } elsif ($target eq 'tex') { &Apache::lonnet::ssi("/cgi-bin/plot.gif?file=$filename.data&output=eps"); - $result = '\graphicspath{{/home/httpd/perl/tmp/}}\includegraphics{'.&Apache::lonnet::unescape($filename).'.eps}'; + + $result = '\graphicspath{{/home/httpd/perl/tmp/}}\includegraphics[width='.$plot{'texwidth'}.' mm]{'.&Apache::lonnet::unescape($filename).'.eps}'; } } elsif ($target eq 'edit') { $result.=&Apache::edit::tag_end($target,$token); @@ -798,7 +807,11 @@ sub start_function { my $result=''; if ($target eq 'web' || $target eq 'tex') { if (exists($curves[-1]->{'data'})) { - &Apache::lonxml::warning('Use of precludes use of . The will be omitted in favor of the declaration.'); + &Apache::lonxml::warning + ('Use of the curve function tag precludes use of '. + ' the curve data tag. '. + 'The curve data tag will be omitted in favor of the '. + 'curve function declaration.'); delete $curves[-1]->{'data'} ; } my $function = &Apache::lonxml::get_all_text("/function",$parser); @@ -834,9 +847,11 @@ sub start_data { my $result=''; if ($target eq 'web' || $target eq 'tex') { if (exists($curves[-1]->{'function'})) { - &Apache::lonxml::warning('Use of precludes use of .'. - '. The will be omitted in favor of '. - 'the declaration.'); + &Apache::lonxml::warning + ('Use of the curve function tag precludes use of '. + ' the curve data tag. '. + 'The curve function tag will be omitted in favor of the '. + 'curve data declaration.'); delete($curves[-1]->{'function'}); } my $datatext = &Apache::lonxml::get_all_text("/data",$parser); @@ -860,14 +875,14 @@ sub start_data { # Check that it's non-empty if (! defined($data[$i])) { &Apache::lonxml::warning( - 'undefined value. Replacing with '. + 'undefined curve data value. Replacing with '. ' pi/e = 1.15572734979092'); $data[$i] = 1.15572734979092; } # Check that it's a number if (! &$real_test($data[$i]) & ! &$int_test($data[$i])) { &Apache::lonxml::warning( - 'Bad value of '.$data[$i].' Replacing with '. + 'Bad curve data value of '.$data[$i].' Replacing with '. ' pi/e = 1.15572734979092'); $data[$i] = 1.15572734979092; } @@ -1135,7 +1150,7 @@ sub check_inputs { my $curve; foreach $curve (@curves) { if (!defined($curve->{'function'})&&!defined($curve->{'data'})){ - &Apache::lonxml::warning("One of the curves specified did not contain any or declarations\n"); + &Apache::lonxml::warning("One of the curves specified did not contain any curve data or curve function declarations\n"); return ''; } }