Diff for /loncom/homework/randomlabel.pm between versions 1.86 and 1.92

version 1.86, 2007/05/10 10:27:22 version 1.92, 2008/11/18 19:14:28
Line 53 Line 53
 #             (32,65)  : $GroupTwo[1] = "TEXT-1"  #             (32,65)  : $GroupTwo[1] = "TEXT-1"
 #             (21,54)  : $GroupTwo[2] = "TEXT-2"  #             (21,54)  : $GroupTwo[2] = "TEXT-2"
 #  ===========================================  #  ===========================================
   
 package Apache::randomlabel;  package Apache::randomlabel;
 use Apache::lonnet;  use Apache::lonnet;
 use strict;  use strict;
Line 61  use Apache::File(); Line 62  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 70  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 147  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 165  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 179  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 268  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   #  Somewhere here it looks like height_param and
  #  width_param got backwards...   #  width_param got backwards...
Line 276  sub end_bgimg { Line 277  sub end_bgimg {
  $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,-$width_param)";   $result  .= "($x_offset,-$height_param)";
  $result  .= "\n";   $result  .= "\n";
  $Apache::lonxml::debug = 0;   $Apache::lonxml::debug = 0;
   
Line 353  sub start_labelgroup { Line 354  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 539  sub start_location { Line 539  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 554  sub end_location { Line 553  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='';

Removed from v.1.86  
changed lines
  Added in v.1.92


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>