--- loncom/xml/lonplot.pm 2003/09/27 04:08:56 1.91 +++ loncom/xml/lonplot.pm 2004/01/07 18:16:02 1.94 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Dynamic plot # -# $Id: lonplot.pm,v 1.91 2003/09/27 04:08:56 albertel Exp $ +# $Id: lonplot.pm,v 1.94 2004/01/07 18:16:02 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -115,7 +115,7 @@ my $words_test = sub {$_[0]=~s/\s+/ ################################################################### my @gnuplot_edit_order = qw/alttag bgcolor fgcolor height width font transparent grid samples - border align texwidth plottype/; + border align texwidth texfont plottype/; my $gnuplot_help_text = <<"ENDPLOTHELP";

@@ -232,12 +232,19 @@ my %gnuplot_defaults = edit_type => 'entry', size => '5' }, + texfont => { + default => '22', + test => $int_test, + description => 'Font size to use in TeX output (pts):', + edit_type => 'choice', + choices => [qw/10 12 14 16 18 20 22 24 26 28 30 32 34 36/], + }, plottype => { default => 'Cartesian', test => sub {$_[0]=~/^(Polar|Cartesian)$/}, description => 'Plot type:', edit_type => 'choice', - choices => ['Polar','Cartesian'] + choices => ['Cartesian','Polar'] }, ); @@ -652,9 +659,8 @@ sub start_title { &Apache::edit::start_spanning_row(). &Apache::edit::editline('',$text,'',60); } elsif ($target eq 'modified') { - my $text=$$parser[-1]->get_text("/title"); $result.=&Apache::edit::rebuild_tag($token); - $result.=&Apache::edit::modifiedfield($token); + $result.=&Apache::edit::modifiedfield("/title",$parser); } return $result; } @@ -686,9 +692,8 @@ sub start_xlabel { &Apache::edit::start_spanning_row(). &Apache::edit::editline('',$text,'',60); } elsif ($target eq 'modified') { - my $text=$$parser[-1]->get_text("/xlabel"); $result.=&Apache::edit::rebuild_tag($token); - $result.=&Apache::edit::modifiedfield($token); + $result.=&Apache::edit::modifiedfield("/xlabel",$parser); } return $result; } @@ -721,9 +726,8 @@ sub start_ylabel { &Apache::edit::start_spanning_row(). &Apache::edit::editline('',$text,'',60); } elsif ($target eq 'modified') { - my $text=$$parser[-1]->get_text("/ylabel"); $result.=&Apache::edit::rebuild_tag($token); - $result.=&Apache::edit::modifiedfield($token); + $result.=&Apache::edit::modifiedfield("/ylabel",$parser); } return $result; } @@ -763,8 +767,7 @@ sub start_label { &Apache::edit::get_new_args ($token,$parstack,$safeeval,keys(%label_defaults)); $result.=&Apache::edit::rebuild_tag($token); - my $text=$$parser[-1]->get_text("/label"); - $result.=&Apache::edit::modifiedfield($token); + $result.=&Apache::edit::modifiedfield("/label",$parser); } return $result; } @@ -842,8 +845,7 @@ sub start_function { &Apache::edit::editline('',$text,'',60); } elsif ($target eq 'modified') { $result.=&Apache::edit::rebuild_tag($token); - my $text=$$parser[-1]->get_text("/function"); - $result.=&Apache::edit::modifiedfield($token); + $result.=&Apache::edit::modifiedfield("/function",$parser); } return $result; } @@ -920,8 +922,7 @@ sub start_data { &Apache::edit::editline('',$text,'',60); } elsif ($target eq 'modified') { $result.=&Apache::edit::rebuild_tag($token); - my $text=$$parser[-1]->get_text("/data"); - $result.=&Apache::edit::modifiedfield($token); + $result.=&Apache::edit::modifiedfield("/data",$parser); } return $result; } @@ -987,7 +988,7 @@ sub set_defaults { sub get_attributes{ my ($values,$defaults,$parstack,$safeeval,$tag) = @_; foreach my $attr (keys(%{$defaults})) { - if ($attr eq 'texwidth') { + if ($attr eq 'texwidth' || $attr eq 'texfont') { $values->{$attr} = &Apache::lonxml::get_param($attr,$parstack,$safeeval,undef,1); } else { @@ -1014,6 +1015,7 @@ sub write_gnuplot_file { my ($tmpdir,$filename,$target)= @_; my $gnuplot_input = ''; my $curve; + my $pt = $plot{'texfont'}; # Collect all the colors my @Colors; push @Colors, $plot{'bgcolor'}; @@ -1034,7 +1036,7 @@ sub write_gnuplot_file { # set output $gnuplot_input .= "set output\n"; } elsif ($target eq 'tex') { - $gnuplot_input .= "set term postscript eps monochrome solid \"Helvetica\" 25 \n"; + $gnuplot_input .= "set term postscript eps monochrome solid \"Helvetica\" $pt \n"; $gnuplot_input .= "set output \"/home/httpd/perl/tmp/". &Apache::lonnet::unescape($filename).".eps\"\n"; } @@ -1055,9 +1057,9 @@ sub write_gnuplot_file { # title, xlabel, ylabel # titles if ($target eq 'tex') { - $gnuplot_input .= "set title \"$title\" font \"Helvetica,25pt\"\n" if (defined($title)) ; - $gnuplot_input .= "set xlabel \"$xlabel\" font \"Helvetica,25pt\" \n" if (defined($xlabel)); - $gnuplot_input .= "set ylabel \"$ylabel\" font \"Helvetica,25pt\"\n" if (defined($ylabel)); + $gnuplot_input .= "set title \"$title\" font \"Helvetica,".$pt."pt\"\n" if (defined($title)) ; + $gnuplot_input .= "set xlabel \"$xlabel\" font \"Helvetica,".$pt."pt\" \n" if (defined($xlabel)); + $gnuplot_input .= "set ylabel \"$ylabel\" font \"Helvetica,".$pt."pt\"\n" if (defined($ylabel)); } else { $gnuplot_input .= "set title \"$title\" \n" if (defined($title)) ; $gnuplot_input .= "set xlabel \"$xlabel\" \n" if (defined($xlabel)); @@ -1103,7 +1105,7 @@ sub write_gnuplot_file { my $label; foreach $label (@labels) { $gnuplot_input .= 'set label "'.$label->{'text'}.'" at '. - $label->{'xpos'}.','.$label->{'ypos'}.' '.$label->{'justify'}.' font "Helvetica,25pt"'.$/ ; + $label->{'xpos'}.','.$label->{'ypos'}.' '.$label->{'justify'}.' font "Helvetica,'.$pt.'pt"'.$/ ; } if ($target eq 'tex') { $gnuplot_input .="set size 1,".$plot{'height'}/$plot{'width'}*1.38;