version 1.85, 2006/11/07 02:39:58
|
version 1.91, 2008/03/12 02:46:53
|
Line 61 use Apache::File();
|
Line 61 use Apache::File();
|
use Apache::Constants qw(:common :http); |
use Apache::Constants qw(:common :http); |
use Image::Magick; |
use Image::Magick; |
use Apache::lonplot; |
use Apache::lonplot; |
use lib '/home/httpd/lib/perl/'; |
|
use LONCAPA; |
use LONCAPA; |
|
|
|
|
Line 70 my $cgi_id;
|
Line 69 my $cgi_id;
|
my $scale_factor; # image scale factor. |
my $scale_factor; # image scale factor. |
my $label_xscale; # Label scale factor (needed for gnuplot). |
my $label_xscale; # Label scale factor (needed for gnuplot). |
my $label_yscale; |
my $label_yscale; |
|
my $dirty_width_adjust = 5; # Width adjustment for e.g. gnuplot images. |
|
|
BEGIN { |
BEGIN { |
&Apache::lonxml::register('Apache::randomlabel',('randomlabel','labelgroup','location','label','bgimg')); |
&Apache::lonxml::register('Apache::randomlabel',('randomlabel','labelgroup','location','label','bgimg')); |
Line 147 sub start_randomlabel {
|
Line 146 sub start_randomlabel {
|
} elsif ($target eq 'tex' && defined($bgimg)) { |
} elsif ($target eq 'tex' && defined($bgimg)) { |
$result.=&make_eps_image($bgimg,$parstack,$safeeval); |
$result.=&make_eps_image($bgimg,$parstack,$safeeval); |
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
|
my $only = join(',',&Apache::loncommon::filecategorytypes('Pictures')); |
$result.=&Apache::edit::tag_start($target,$token); |
$result.=&Apache::edit::tag_start($target,$token); |
$Apache::edit::bgimgsrc= |
$Apache::edit::bgimgsrc= |
&Apache::lonxml::get_param('bgimg',$parstack,$safeeval); |
&Apache::lonxml::get_param('bgimg',$parstack,$safeeval); |
$Apache::edit::bgimgsrccurdepth=$Apache::lonxml::curdepth; |
$Apache::edit::bgimgsrccurdepth=$Apache::lonxml::curdepth; |
$result.=&Apache::edit::text_arg('Image:','bgimg',$token,75).' '; |
$result.=&Apache::edit::text_arg('Image:','bgimg',$token,75).' '; |
$result.=&Apache::edit::browse('bgimg').' '; |
$result.=&Apache::edit::browse('bgimg',undef,undef,$only).' '; |
$result.=&Apache::edit::search('bgimg').'<br />'. |
$result.=&Apache::edit::search('bgimg').'<br />'. |
&Apache::edit::text_arg('Width(pixel):' ,'width' ,$token,6). |
&Apache::edit::text_arg('Width(pixel):' ,'width' ,$token,6). |
&Apache::edit::text_arg('Height(pixel):','height' ,$token,6). |
&Apache::edit::text_arg('Height(pixel):','height' ,$token,6). |
Line 164 sub start_randomlabel {
|
Line 164 sub start_randomlabel {
|
'height','texwidth'); |
'height','texwidth'); |
if ($constructtag) { |
if ($constructtag) { |
$result = &Apache::edit::rebuild_tag($token); |
$result = &Apache::edit::rebuild_tag($token); |
$result.=&Apache::edit::handle_insert(); |
|
} |
} |
} |
} |
return $result; |
return $result; |
Line 179 sub end_randomlabel {
|
Line 178 sub end_randomlabel {
|
$count = $Apache::randomlabel::obj_cnt; |
$count = $Apache::randomlabel::obj_cnt; |
if( $count != 0) { $args{"cgi.$cgi_id.OBJCOUNT"}=$count; } |
if( $count != 0) { $args{"cgi.$cgi_id.OBJCOUNT"}=$count; } |
$result.='<img src="/adm/randomlabel.png?token='.$cgi_id.'" /><br />'."\n"; |
$result.='<img src="/adm/randomlabel.png?token='.$cgi_id.'" /><br />'."\n"; |
&Apache::lonnet::appenv(%args); |
&Apache::lonnet::appenv(\%args); |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
$result='\end{picture}\\\\'; |
$result='\end{picture}\\\\'; |
$result.= ' \vskip -'.$height_param.' mm } \\\\ '; |
$result.= ' \vskip -'.$height_param.' mm } \\\\ '; |
Line 268 sub end_bgimg {
|
Line 267 sub end_bgimg {
|
&Apache::lonxml::debug("height $height_param"); |
&Apache::lonxml::debug("height $height_param"); |
&Apache::lonxml::debug("Width $width_param"); |
&Apache::lonxml::debug("Width $width_param"); |
&Apache::lonxml::debug("Scale factors: $label_xscale $label_yscale"); |
&Apache::lonxml::debug("Scale factors: $label_xscale $label_yscale"); |
my $dirty_width = $width_param + 5; |
my $dirty_width = $width_param + $dirty_width_adjust; |
|
my $x_offset = -$dirty_width_adjust/2.0; |
|
# |
|
# Somewhere here it looks like height_param and |
|
# width_param got backwards... |
|
# |
$result .= '\parbox{'.$dirty_width.'mm}{'; |
$result .= '\parbox{'.$dirty_width.'mm}{'; |
$result .= " $src \n"; |
$result .= " $src \n"; |
$result .= '\setlength{\unitlength}{1mm}'."\n"; |
$result .= '\setlength{\unitlength}{1mm}'."\n"; |
$result .= '\begin{picture}('."$height_param,$width_param)"; |
$result .= '\begin{picture}('."$width_param,$height_param)"; |
$result .= "(0,-$height_param)"; |
$result .= "($x_offset,-$height_param)"; |
$result .= "\n"; |
$result .= "\n"; |
$Apache::lonxml::debug = 0; |
$Apache::lonxml::debug = 0; |
|
|
Line 349 sub start_labelgroup {
|
Line 353 sub start_labelgroup {
|
'TeXsize'); |
'TeXsize'); |
if ($constructtag) { |
if ($constructtag) { |
$result = &Apache::edit::rebuild_tag($token); |
$result = &Apache::edit::rebuild_tag($token); |
$result.=&Apache::edit::handle_insert(); |
|
} |
} |
} |
} |
return $result; |
return $result; |
Line 535 sub start_location {
|
Line 538 sub start_location {
|
$safeeval,'x','y','value'); |
$safeeval,'x','y','value'); |
if ($constructtag) { |
if ($constructtag) { |
$result = &Apache::edit::rebuild_tag($token); |
$result = &Apache::edit::rebuild_tag($token); |
$result.=&Apache::edit::handle_insert(); |
|
} |
} |
} |
} |
$Apache::lonxml::debug = 0; |
$Apache::lonxml::debug = 0; |
Line 550 sub end_location {
|
Line 552 sub end_location {
|
} |
} |
|
|
# <label>$var_abc</label> |
# <label>$var_abc</label> |
|
sub insert_label { |
|
my ($after) = @_; |
|
my $depth = scalar(@Apache::lonxml::depthcounter); |
|
$depth-- if ($after); |
|
my $inset = "\t"x$depth; |
|
return "\n$inset<label></label>"; |
|
} |
|
|
sub start_label { |
sub start_label { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my $result=''; |
my $result=''; |