Annotation of loncom/homework/drawimage.pm, revision 1.14
1.1 albertel 1: # The LearningOnline Network with CAPA
2: # programatic image drawing
3: #
1.14 ! raeburn 4: # $Id: drawimage.pm,v 1.13 2024/04/05 22:44:19 raeburn Exp $
1.1 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29: package Apache::drawimage;
30: use strict;
31: use Apache::loncommon;
1.12 raeburn 32: use Apache::lonnet;
33: use Apache::lonxml;
1.14 ! raeburn 34: use Apache::edit;
1.9 www 35: use lib '/home/httpd/lib/perl/';
1.12 raeburn 36: use Time::HiRes qw(gettimeofday);
1.9 www 37: use LONCAPA;
38:
1.1 albertel 39:
40: my %args;
41: my $cgi_id;
1.7 albertel 42: my @cgi_ids;
1.1 albertel 43: BEGIN {
44: &Apache::lonxml::register('Apache::drawimage',('drawimage'));
45: }
46:
47: sub start_drawimage {
48: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.7 albertel 49: &Apache::lonxml::register('Apache::drawimage',('text','line','rectangle','arc','fill','polygon','image'));
1.14 ! raeburn 50: push(@Apache::lonxml::namespace,'drawimage');
! 51: my $result;
1.1 albertel 52: if ($target eq 'web' || $target eq 'tex') {
1.7 albertel 53: my $new_id=&Apache::loncommon::get_cgi_id();
54: if ($cgi_id) { push(@cgi_ids,$cgi_id); } else { undef(%args); }
55: $cgi_id=$new_id;
1.14 ! raeburn 56: } elsif ($target eq 'edit') {
! 57: $result .= &Apache::edit::tag_start($target,$token).
! 58: &Apache::edit::text_arg('Background color:','bgcolor' ,$token,8).
! 59: &Apache::edit::text_arg('Width(pixel):' ,'width' ,$token,6).
! 60: &Apache::edit::text_arg('Height(pixel):' ,'height' ,$token,6).
! 61: &Apache::edit::text_arg('TeXWidth(mm):' ,'texwidth',$token,6).
! 62: &Apache::edit::end_row().&Apache::edit::start_spanning_row();
! 63: } elsif ($target eq 'modified') {
! 64: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
! 65: $safeeval,'bgcolor','width',
! 66: 'height','texwidth');
! 67: if ($constructtag) {
! 68: $result = &Apache::edit::rebuild_tag($token);
! 69: }
1.1 albertel 70: }
1.14 ! raeburn 71: return $result;
1.1 albertel 72: }
73:
74: sub end_drawimage {
75: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
76: my $result;
1.12 raeburn 77: # need to call rand everytime start_script would evaluate, as the
78: # safe space rand number generator and the global rand generator
79: # are not separate
80: my $randnumber;
81: if ($target eq 'web' || $target eq 'tex' || $target eq 'grade' ||
82: $target eq 'answer') {
83: $randnumber=int(rand(1000));
84: }
1.1 albertel 85: if ($target eq 'web' || $target eq 'tex') {
1.7 albertel 86: my $width = &Apache::lonxml::get_param('width',$parstack,$safeeval);
87: my $height =&Apache::lonxml::get_param('height',$parstack,$safeeval);
88: my $bgcolor =&Apache::lonxml::get_param('bgcolor',$parstack,$safeeval);
89: if (!$width) { $width=300; }
90: if (!$height) { $height=300; }
1.12 raeburn 91: $args{"cgi.$cgi_id.BGCOLOR"}=join(':',($bgcolor));
92: if ($target eq 'tex') {
93: my $texwidth=&Apache::lonxml::get_param('texwidth',$parstack,$safeeval,undef,1);
94: if (!$texwidth) { $texwidth='90'; }
95: $args{"cgi.$cgi_id.SIZE"}=join(':',($width,$height,$texwidth));
96: my $tmpdir = LONCAPA::tempdir(); # Where temporary files live:
97: ## Determine filename
98: my ($seconds, $microseconds) = gettimeofday;
99: my $filename = $env{'user.name'}.'_'.$env{'user.domain'}.
100: '_'.$seconds.'_'.$microseconds.'_'.$$.$randnumber.'_drawimage.eps';
101: $args{"cgi.$cgi_id.EPSFILE"} = $env{'user.name'}.'_'.$env{'user.domain'}.
102: '_'.$seconds.'_'.$microseconds.'_'.$$.$randnumber.
103: '_drawimage.eps';
104: $result = "%DYNAMICIMAGE:$width:$height:$texwidth\n";
105: $result .= '\graphicspath{{'.$tmpdir.'}}'."\n";
106: $result .= '\includegraphics[width='.$texwidth.' mm]{'.$filename.'}';
107: &Apache::lonxml::register_ssi('/adm/randomlabel.png?token='.$cgi_id);
108: } else {
109: $args{"cgi.$cgi_id.SIZE"}=join(':',($width,$height));
110: $result.="<img width='$width' height='$height'
1.1 albertel 111: src='/adm/randomlabel.png?token=$cgi_id' />\n";
1.12 raeburn 112: }
1.10 raeburn 113: &Apache::lonnet::appenv(\%args);
1.7 albertel 114: if (@cgi_ids) {
115: $cgi_id=pop(@cgi_ids);
116: } else {
117: undef($cgi_id);
1.1 albertel 118: }
1.7 albertel 119: } elsif ($target eq 'edit') {
1.14 ! raeburn 120: $result.=&Apache::edit::end_table;
1.1 albertel 121: }
1.14 ! raeburn 122: pop(@Apache::lonxml::namespace);
! 123: &Apache::lonxml::deregister('Apache::drawimage',
! 124: ('text','line','rectangle','arc','fill',
! 125: 'polygon'));
1.4 matthew 126: return $result;
127: }
128:
1.5 albertel 129: sub start_text {
1.4 matthew 130: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
131: my $result;
132: if ($target eq 'web' || $target eq 'tex') {
1.6 albertel 133: &Apache::lonxml::startredirection();
1.14 ! raeburn 134: } elsif ($target eq 'edit') {
! 135: $result =
! 136: &Apache::edit::tag_start($target,$token).
! 137: &Apache::edit::text_arg('x:','x',$token,6).
! 138: &Apache::edit::text_arg('y:','y',$token,6).
! 139: &Apache::edit::text_arg('font:','font',$token,12).
! 140: &Apache::edit::text_arg('color:','color',$token,8).
! 141: &Apache::edit::select_arg('direction:','direction',
! 142: ['vertical','horizontal'],$token).
! 143: &Apache::edit::text_arg('rotation:','rotation',$token,6);
! 144: my $text=&Apache::lonxml::get_all_text('/text',$parser,$style);
! 145: $result .=
! 146: &Apache::edit::editfield($token->[1],$text,'Text',60,2).
! 147: &Apache::edit::end_row();
! 148: } elsif ($target eq 'modified') {
! 149: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
! 150: $safeeval,'x','y',
! 151: 'font','color',
! 152: 'direction','rotation');
! 153: if ($constructtag) {
! 154: $result = &Apache::edit::rebuild_tag($token);
! 155: } else {
! 156: $result = $token->[4];
! 157: }
! 158: $result .= &Apache::edit::modifiedfield('/text',$parser);
1.6 albertel 159: }
160: return $result;
161: }
162:
163: sub end_text {
164: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
165: my $result;
166: if ($target eq 'web' || $target eq 'tex') {
1.4 matthew 167: my $x = &Apache::lonxml::get_param('x',$parstack,$safeeval);
168: my $y = &Apache::lonxml::get_param('y',$parstack,$safeeval);
169: my $font = &Apache::lonxml::get_param('font',$parstack,$safeeval);
170: my $color = &Apache::lonxml::get_param('color',$parstack,$safeeval);
1.5 albertel 171: my $direction = &Apache::lonxml::get_param('direction',$parstack,$safeeval);
1.11 raeburn 172: my $rotation = &Apache::lonxml::get_param('rotation',$parstack,$safeeval);
1.6 albertel 173: my $text = &Apache::lonxml::endredirection();
1.9 www 174: $text = &escape($text);
1.4 matthew 175: $args{"cgi.$cgi_id.OBJTYPE"}.='LABEL:';
176: my $i=$args{"cgi.$cgi_id.OBJCOUNT"}++;
1.11 raeburn 177: $args{"cgi.$cgi_id.OBJ$i"}=join(':',($x,$y,$text,$font,$color,$direction,$rotation));
1.14 ! raeburn 178: } elsif ($target eq 'edit') {
! 179: $result=&Apache::edit::end_table();
1.4 matthew 180: }
1.1 albertel 181: return $result;
182: }
183:
184: sub start_line {
185: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
186: my $result;
187: if ($target eq 'web' || $target eq 'tex') {
188: my $x1 = &Apache::lonxml::get_param('x1',$parstack,$safeeval);
189: my $y1 = &Apache::lonxml::get_param('y1',$parstack,$safeeval);
190: my $x2 = &Apache::lonxml::get_param('x2',$parstack,$safeeval);
191: my $y2 = &Apache::lonxml::get_param('y2',$parstack,$safeeval);
192: my $color = &Apache::lonxml::get_param('color',$parstack,$safeeval);
193: my $thickness = &Apache::lonxml::get_param('thickness',$parstack,$safeeval);
1.3 albertel 194: my $i=$args{"cgi.$cgi_id.OBJCOUNT"}++;
1.1 albertel 195: $args{"cgi.$cgi_id.OBJ$i"}=join(':',($x1,$y1,$x2,$y2,$color,$thickness));
196: $args{"cgi.$cgi_id.OBJTYPE"}.='LINE:';
1.14 ! raeburn 197: } elsif ($target eq 'edit') {
! 198: $result .=
! 199: &Apache::edit::tag_start($target,$token).
! 200: &Apache::edit::text_arg('x1:','x1' ,$token,6).
! 201: &Apache::edit::text_arg('y1:','y1' ,$token,6).
! 202: &Apache::edit::text_arg('x2:','x2' ,$token,6).
! 203: &Apache::edit::text_arg('y2:','y2' ,$token,6).
! 204: &Apache::edit::text_arg('color:','color',$token,8).
! 205: &Apache::edit::text_arg('thickness:','thickness',$token,6).
! 206: &Apache::edit::end_row();
! 207: } elsif ($target eq 'modified') {
! 208: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
! 209: $safeeval,'x1','y1',
! 210: 'x2','y2','color','thickness');
! 211: if ($constructtag) {
! 212: $result = &Apache::edit::rebuild_tag($token);
! 213: }
1.1 albertel 214: }
215: return $result;
216: }
217:
218: sub end_line {
219: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
220: my $result;
1.14 ! raeburn 221: if ($target eq 'edit') {
! 222: $result=&Apache::edit::end_table();
! 223: }
1.1 albertel 224: return $result;
225: }
226:
227: sub start_rectangle {
228: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
229: my $result;
230: if ($target eq 'web' || $target eq 'tex') {
231: my $x1 = &Apache::lonxml::get_param('x1',$parstack,$safeeval);
232: my $y1 = &Apache::lonxml::get_param('y1',$parstack,$safeeval);
233: my $x2 = &Apache::lonxml::get_param('x2',$parstack,$safeeval);
234: my $y2 = &Apache::lonxml::get_param('y2',$parstack,$safeeval);
235: my $color = &Apache::lonxml::get_param('color',$parstack,$safeeval);
236: my $thickness = &Apache::lonxml::get_param('thickness',$parstack,
237: $safeeval);
238: my $filled = &Apache::lonxml::get_param('filled',$parstack,
239: $safeeval);
1.3 albertel 240: my $i=$args{"cgi.$cgi_id.OBJCOUNT"}++;
1.1 albertel 241: $args{"cgi.$cgi_id.OBJ$i"}=
242: join(':',($x1,$y1,$x2,$y2,$color,$thickness,$filled));
243: $args{"cgi.$cgi_id.OBJTYPE"}.='RECTANGLE:';
1.14 ! raeburn 244: } elsif ($target eq 'edit') {
! 245: $result .=
! 246: &Apache::edit::tag_start($target,$token).
! 247: &Apache::edit::text_arg('x1:','x1' ,$token,6).
! 248: &Apache::edit::text_arg('y1:','y1' ,$token,6).
! 249: &Apache::edit::text_arg('x2:','x2' ,$token,6).
! 250: &Apache::edit::text_arg('y2:','y2' ,$token,6).
! 251: &Apache::edit::text_arg('color:','color',$token,8).
! 252: &Apache::edit::text_arg('thickness:','thickness',$token,6).
! 253: &Apache::edit::select_arg('filled:','filled',
! 254: ['no','yes'],$token).
! 255: &Apache::edit::end_row();
! 256: } elsif ($target eq 'modified') {
! 257: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
! 258: $safeeval,'x1','y1',
! 259: 'x2','y2','color','thickness',
! 260: 'filled');
! 261: if ($constructtag) {
! 262: $result = &Apache::edit::rebuild_tag($token);
! 263: }
1.1 albertel 264: }
265: return $result;
266: }
267:
268: sub end_rectangle {
269: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
270: my $result;
1.14 ! raeburn 271: if ($target eq 'edit') {
! 272: $result=&Apache::edit::end_table();
! 273: }
1.1 albertel 274: return $result;
275: }
276:
277: sub start_arc {
278: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
279: my $result;
280: if ($target eq 'web' || $target eq 'tex') {
281: my $x = &Apache::lonxml::get_param('x',$parstack,$safeeval);
282: my $y = &Apache::lonxml::get_param('y',$parstack,$safeeval);
283: my $width = &Apache::lonxml::get_param('width',$parstack,$safeeval);
284: my $height = &Apache::lonxml::get_param('height',$parstack,$safeeval);
285: my $start = &Apache::lonxml::get_param('start',$parstack,$safeeval);
286: my $end = &Apache::lonxml::get_param('end',$parstack,$safeeval);
287: my $color = &Apache::lonxml::get_param('color',$parstack,$safeeval);
288: my $thickness = &Apache::lonxml::get_param('thickness',$parstack,$safeeval);
289: my $filled = &Apache::lonxml::get_param('filled',$parstack,$safeeval);
1.3 albertel 290: my $i=$args{"cgi.$cgi_id.OBJCOUNT"}++;
1.1 albertel 291: $args{"cgi.$cgi_id.OBJ$i"}=
292: join(':',($x,$y,$width,$height,$start,$end,$color,$thickness,
293: $filled));
294: $args{"cgi.$cgi_id.OBJTYPE"}.='ARC:';
1.14 ! raeburn 295: } elsif ($target eq 'edit') {
! 296: $result .=
! 297: &Apache::edit::tag_start($target,$token).
! 298: &Apache::edit::text_arg('x:','x',$token,6).
! 299: &Apache::edit::text_arg('y:','y',$token,6).
! 300: &Apache::edit::text_arg('width:','width',$token,6).
! 301: &Apache::edit::text_arg('height:','height',$token,6).
! 302: &Apache::edit::text_arg('start:','start',$token,6).
! 303: &Apache::edit::text_arg('end:','end',$token,6).
! 304: &Apache::edit::text_arg('color:','color',$token,8).
! 305: &Apache::edit::text_arg('thickness:','thickness',$token,6).
! 306: &Apache::edit::select_arg('filled:','filled',
! 307: ['no','yes'],$token).
! 308: &Apache::edit::end_row();
! 309: } elsif ($target eq 'modified') {
! 310: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
! 311: $safeeval,'x','y',
! 312: 'width','height',
! 313: 'start','end',
! 314: 'color','thickness',
! 315: 'filled');
! 316: if ($constructtag) {
! 317: $result = &Apache::edit::rebuild_tag($token);
! 318: }
1.1 albertel 319: }
320: return $result;
321: }
322:
323: sub end_arc {
324: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
325: my $result;
1.14 ! raeburn 326: if ($target eq 'edit') {
! 327: $result=&Apache::edit::end_table();
! 328: }
1.1 albertel 329: return $result;
330: }
331:
1.2 albertel 332: sub start_fill {
1.1 albertel 333: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
334: my $result;
335: if ($target eq 'web' || $target eq 'tex') {
336: my $x = &Apache::lonxml::get_param('x',$parstack,$safeeval);
337: my $y = &Apache::lonxml::get_param('y',$parstack,$safeeval);
338: my $color = &Apache::lonxml::get_param('color',$parstack,$safeeval);
1.3 albertel 339: my $i=$args{"cgi.$cgi_id.OBJCOUNT"}++;
1.1 albertel 340: $args{"cgi.$cgi_id.OBJ$i"}=join(':',($x,$y,$color));
341: $args{"cgi.$cgi_id.OBJTYPE"}.='FILL:';
1.14 ! raeburn 342: } elsif ($target eq 'edit') {
! 343: $result .=
! 344: &Apache::edit::tag_start($target,$token).
! 345: &Apache::edit::text_arg('x:','x' ,$token,6).
! 346: &Apache::edit::text_arg('y:','y' ,$token,6).
! 347: &Apache::edit::text_arg('color:','color',$token,8).
! 348: &Apache::edit::end_row();
! 349: } elsif ($target eq 'modified') {
! 350: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
! 351: $safeeval,'x','y',
! 352: 'color');
! 353: if ($constructtag) {
! 354: $result = &Apache::edit::rebuild_tag($token);
! 355: }
1.1 albertel 356: }
357: return $result;
358: }
359:
1.2 albertel 360: sub end_fill {
1.1 albertel 361: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
362: my $result;
1.14 ! raeburn 363: if ($target eq 'edit') {
! 364: $result=&Apache::edit::end_table();
! 365: }
1.1 albertel 366: return $result;
367: }
368:
1.7 albertel 369: my @polygon;
370: sub start_polygon {
371: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
372: my $result;
1.14 ! raeburn 373: push(@Apache::lonxml::namespace,'polygon');
1.7 albertel 374: &Apache::lonxml::register('Apache::drawimage',('point'));
1.13 raeburn 375: if ($target eq 'web' || $target eq 'tex') {
1.7 albertel 376: undef(@polygon);
1.14 ! raeburn 377: } elsif ($target eq 'edit') {
! 378: $result =
! 379: &Apache::edit::tag_start($target,$token).
! 380: &Apache::edit::text_arg('color:','color',$token,8).
! 381: &Apache::edit::select_arg('Open:','open',
! 382: ['no','yes'],$token).
! 383: &Apache::edit::select_arg('Filled:','filled',
! 384: ['no','yes'],$token).
! 385: &Apache::edit::text_arg('thickness:','thickness',$token,6).
! 386: &Apache::edit::end_row().
! 387: &Apache::edit::start_spanning_row();
! 388: } elsif ($target eq 'modified') {
! 389: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
! 390: $safeeval,'open','filled');
! 391: if ($constructtag) {
! 392: $result = &Apache::edit::rebuild_tag($token);
! 393: }
1.7 albertel 394: }
395: return $result;
396: }
397:
398: sub end_polygon {
399: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
400: my $result;
1.13 raeburn 401: if ($target eq 'web' || $target eq 'tex') {
1.7 albertel 402: my $color=&Apache::lonxml::get_param('color',$parstack,$safeeval);
403: my $filled=&Apache::lonxml::get_param('filled',$parstack,$safeeval);
404: my $open=&Apache::lonxml::get_param('open',$parstack,$safeeval);
405: my $thickness = &Apache::lonxml::get_param('thickness',$parstack,
406: $safeeval);
407: my $i=$args{"cgi.$cgi_id.OBJCOUNT"}++;
408: $args{"cgi.$cgi_id.OBJTYPE"}.='POLYGON:';
409: $args{"cgi.$cgi_id.OBJ$i"}=join(':',($color,$thickness,$open,$filled));
410: $args{"cgi.$cgi_id.OBJEXTRA$i"}=join('-',@polygon);
1.14 ! raeburn 411: } elsif ($target eq 'edit') {
! 412: $result=&Apache::edit::end_table();
1.7 albertel 413: }
1.14 ! raeburn 414: pop(@Apache::lonxml::namespace);
1.7 albertel 415: &Apache::lonxml::deregister('Apache::drawimage',('point'));
416: return $result;
417: }
418:
419: sub start_point {
420: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
421: my $result;
1.13 raeburn 422: if ($target eq 'web' || $target eq 'tex') {
1.7 albertel 423: my $x = &Apache::lonxml::get_param('x',$parstack,$safeeval);
424: my $y = &Apache::lonxml::get_param('y',$parstack,$safeeval);
425: push (@polygon,"($x,$y)");
1.14 ! raeburn 426: } elsif ($target eq 'edit') {
! 427: $result.=
! 428: &Apache::edit::tag_start($target,$token).
! 429: &Apache::edit::text_arg('x:','x' ,$token,6).
! 430: &Apache::edit::text_arg('y:','y' ,$token,6).
! 431: &Apache::edit::end_row();
! 432: } elsif ($target eq 'modified') {
! 433: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
! 434: $safeeval,'x','y');
! 435: if ($constructtag) {
! 436: $result = &Apache::edit::rebuild_tag($token);
! 437: }
1.7 albertel 438: }
439: return $result;
440: }
441:
442: sub end_point {
443: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
444: my $result;
1.14 ! raeburn 445: if ($target eq 'edit') {
! 446: $result=&Apache::edit::end_table();
! 447: }
1.7 albertel 448: return $result;
449: }
450:
451: sub start_image {
452: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
453: my $result;
454: if ($target eq 'web' || $target eq 'tex') {
455: &Apache::lonxml::startredirection();
1.14 ! raeburn 456: } elsif ($target eq 'edit') {
! 457: my $bgimg=&Apache::lonxml::get_all_text('/image',$parser,$style);
! 458: $Apache::edit::bgimgsrc=$bgimg;
! 459: $Apache::edit::bgimgsrcdepth=$Apache::lonxml::curdepth;
! 460: my $only = join(',',&Apache::loncommon::filecategorytypes('Pictures'));
! 461: $result=&Apache::edit::tag_start($target,$token,'Background Image').
! 462: &Apache::edit::editline($token->[1],$bgimg,'Image Source File',40).
! 463: &Apache::edit::browse_or_search(undef,'textnode',undef,$only,undef,1).
! 464: '<br />'.
! 465: &Apache::edit::text_arg('x:','x',$token,6).
! 466: &Apache::edit::text_arg('y:','y',$token,6).
! 467: &Apache::edit::text_arg('clipx:','clipx',$token,6).
! 468: &Apache::edit::text_arg('clipy:','clipy',$token,6).
! 469: &Apache::edit::text_arg('Clip width(pixel):','clipwidth',$token,6).
! 470: &Apache::edit::text_arg('Clip height(pixel):','clipheight',$token,6).
! 471: &Apache::edit::text_arg('Scaled width:','scaledwidth',$token,6).
! 472: &Apache::edit::text_arg('Scaled height:','scaledheight',$token,6).
! 473: &Apache::edit::text_arg('Transparent:','transparent',$token,6).
! 474: &Apache::edit::end_row();
! 475: } elsif ($target eq 'modified') {
! 476: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
! 477: $safeeval,'x','y',
! 478: 'clipx','clipy','clipwidth','clipheight',
! 479: 'scaledwidth','scaledheight','transparent');
! 480: if ($constructtag) {
! 481: $result = &Apache::edit::rebuild_tag($token);
! 482: } else {
! 483: $result = $token->[4];
! 484: }
! 485: $result .= &Apache::edit::modifiedfield('/image',$parser);
1.7 albertel 486: }
487: return $result;
488: }
1.1 albertel 489:
1.7 albertel 490: sub end_image {
491: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
492: my $result;
493: if ($target eq 'web' || $target eq 'tex') {
494: my $bgimg=&Apache::lonxml::endredirection();
495: my $x = &Apache::lonxml::get_param('x',$parstack,$safeeval);
496: my $y = &Apache::lonxml::get_param('y',$parstack,$safeeval);
497: my $clipx = &Apache::lonxml::get_param('clipx',$parstack,$safeeval);
498: my $clipy = &Apache::lonxml::get_param('clipy',$parstack,$safeeval);
499: my $clipwidth =
500: &Apache::lonxml::get_param('clipwidth',$parstack,$safeeval);
501: my $clipheight =
502: &Apache::lonxml::get_param('clipheight',$parstack,$safeeval);
503: my $scaledwidth =
504: &Apache::lonxml::get_param('scaledwidth',$parstack,$safeeval);
505: my $scaledheight =
506: &Apache::lonxml::get_param('scaledheight',$parstack,$safeeval);
507: my $transparent =
508: &Apache::lonxml::get_param('transparent',$parstack,$safeeval);
509: $bgimg=&Apache::imageresponse::clean_up_image($bgimg);
510: my $i=$args{"cgi.$cgi_id.OBJCOUNT"}++;
511: $args{"cgi.$cgi_id.OBJTYPE"}.='IMAGE:';
512: $args{"cgi.$cgi_id.OBJ$i"} =
1.9 www 513: join(':',($x,$y,&escape($bgimg),$transparent,
1.7 albertel 514: $clipx,$clipy,$scaledwidth,$scaledheight,$clipwidth,$clipheight));
1.14 ! raeburn 515: } elsif ($target eq 'edit') {
! 516: $result=&Apache::edit::end_table();
1.7 albertel 517: }
518: return $result;
519: }
1.1 albertel 520: 1;
521: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>