version 1.78, 2005/06/28 14:58:23
|
version 1.81, 2005/12/01 18:46:31
|
Line 369 sub get_label_width {
|
Line 369 sub get_label_width {
|
|
|
|
|
} |
} |
|
|
|
sub get_label_height { |
|
my $label = shift; |
|
&Apache::lonxml::debug("image label = $label"); |
|
if (-e $label) { |
|
&Apache::lonxml::debug("$label exists"); |
|
} else { |
|
&Apache::lonxml::debug("$label does not exist"); |
|
} |
|
my $magick = Image::Magick->new; |
|
$magick->Read($label); |
|
my $pixel_height = $magick->Get('height'); |
|
return $pixel_height * $scale_factor; |
|
} |
|
|
sub add_vars { |
sub add_vars { |
my ($name,$order,$label,$labelorder,$value,$image,$safeeval) = @_; |
my ($name,$order,$label,$labelorder,$value,$image,$safeeval) = @_; |
if (!defined($name) || $name eq '') { return; } |
if (!defined($name) || $name eq '') { return; } |
Line 436 sub end_labelgroup {
|
Line 451 sub end_labelgroup {
|
for(my $i=0;$i <= $#Apache::randomlabel::label_arr; $i++) { |
for(my $i=0;$i <= $#Apache::randomlabel::label_arr; $i++) { |
my $label = "$Apache::randomlabel::label_arr[ $idx_arr[$i] ]"; |
my $label = "$Apache::randomlabel::label_arr[ $idx_arr[$i] ]"; |
my $x = $Apache::randomlabel::xcoord[$i]; |
my $x = $Apache::randomlabel::xcoord[$i]; |
# FIXME the 3.5 here is the 'height' of the letter in TeX |
my $y = $Apache::randomlabel::ycoord[$i]; |
my $y = $Apache::randomlabel::ycoord[$i]-3.5; |
if ( $type eq 'text' ) { |
|
# FIXME the 3.5 here is the 'height' of the letter in TeX |
|
$y=$y-3.5; |
|
} |
&Apache::lonxml::debug("initially: x= $x y= $y"); |
&Apache::lonxml::debug("initially: x= $x y= $y"); |
my $value = $Apache::randomlabel::value[$i]; |
my $value = $Apache::randomlabel::value[$i]; |
#x latex coordinate |
#x latex coordinate |
Line 446 sub end_labelgroup {
|
Line 464 sub end_labelgroup {
|
#y latex coordinate |
#y latex coordinate |
# my $ratio=($wwidth > 0 ? $wheight/$wwidth : 1 ); |
# my $ratio=($wwidth > 0 ? $wheight/$wwidth : 1 ); |
my $tcY=$height_param-$y*($height_param/$wheight); |
my $tcY=$height_param-$y*($height_param/$wheight); |
|
if ( $type eq 'image') { |
|
my $label_height = &get_label_height($label); |
|
$tcY=$tcY-$label_height; |
|
} |
|
|
&Apache::lonxml::debug("hparam = $height_param wheight = $wheight texy = $tcY"); |
&Apache::lonxml::debug("hparam = $height_param wheight = $wheight texy = $tcY"); |
$tcX=sprintf('%.2f',$tcX); |
$tcX=sprintf('%.2f',$tcX); |
$tcY=sprintf('%.2f',$tcY); |
$tcY=sprintf('%.2f',$tcY); |
Line 456 sub end_labelgroup {
|
Line 479 sub end_labelgroup {
|
} elsif ( $type eq 'image') { |
} elsif ( $type eq 'image') { |
my ($path,$file) = &Apache::londefdef::get_eps_image($label); |
my ($path,$file) = &Apache::londefdef::get_eps_image($label); |
my $image_name = $path.$file; |
my $image_name = $path.$file; |
my $label_width = get_label_width($label); |
my $label_width = &get_label_width($label); |
|
|
$result .= '\includegraphics[width='.$label_width.'mm]{' |
$result .= '\includegraphics[width='.$label_width.'mm]{' |
.$image_name."}}\n"; |
.$image_name."}}\n"; |
Line 528 sub start_label {
|
Line 551 sub start_label {
|
&Apache::lonxml::startredirection; |
&Apache::lonxml::startredirection; |
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
$result.=&Apache::edit::tag_start($target,$token,"$type Label"); |
$result.=&Apache::edit::tag_start($target,$token,"$type Label"); |
my $text=&Apache::lonxml::get_all_text("/label",$parser); |
my $text=&Apache::lonxml::get_all_text("/label",$parser,$style); |
if ($type eq 'image') { |
if ($type eq 'image') { |
$result.=&Apache::edit::end_row(). |
$result.=&Apache::edit::end_row(). |
&Apache::edit::start_spanning_row(); |
&Apache::edit::start_spanning_row(); |