version 1.47, 2010/11/24 02:53:13
|
version 1.48, 2010/11/24 15:30:45
|
Line 161 sub update_register {
|
Line 161 sub update_register {
|
# Set a point coordinate variable |
# Set a point coordinate variable |
# |
# |
sub set_point_coordinate { |
sub set_point_coordinate { |
my ($id,$variable,$x,$y)=@_; |
my ($id,$variable,$x,$y,$fixed)=@_; |
|
my $mult=($fixed?'a*':''); |
return (<<ENDSETVARIABLE); |
return (<<ENDSETVARIABLE); |
document.ggbApplet_$id.evalCommand("$variable=($x,$y)"); |
document.ggbApplet_$id.evalCommand("a=1"); |
|
document.ggbApplet_$id.evalCommand("$variable=$mult($x,$y)"); |
document.ggbApplet_$id.setLabelVisible("$variable",false); |
document.ggbApplet_$id.setLabelVisible("$variable",false); |
ENDSETVARIABLE |
ENDSETVARIABLE |
} |
} |
Line 172 ENDSETVARIABLE
|
Line 174 ENDSETVARIABLE
|
# Set a slope coordinate variable |
# Set a slope coordinate variable |
# |
# |
sub set_slope_coordinate { |
sub set_slope_coordinate { |
my ($id,$variable,$xrel,$yrel,$xmin,$xmax,$ymin,$ymax,$pointname)=@_; |
my ($id,$variable,$xrel,$yrel,$xmin,$xmax,$ymin,$ymax,$pointname,$fixed)=@_; |
my $xvariable=$variable.'x'; |
my $xvariable=$variable.'x'; |
my $yvariable=$variable.'y'; |
my $yvariable=$variable.'y'; |
my $domain=$xmax-$xmin; |
my $domain=$xmax-$xmin; |
my $range=$ymax-$ymin; |
my $range=$ymax-$ymin; |
my $xinterval=$domain/100.; |
my $xinterval=$domain/100.; |
my $yinterval=$range/200.; |
my $yinterval=$range/200.; |
|
my $mult=($fixed?'a*':''); |
return (<<ENDSETSVARIABLE); |
return (<<ENDSETSVARIABLE); |
|
document.ggbApplet_$id.evalCommand("a=1"); |
document.ggbApplet_$id.evalCommand("$xvariable=Slider[0,$domain,$xinterval]"); |
document.ggbApplet_$id.evalCommand("$xvariable=Slider[0,$domain,$xinterval]"); |
document.ggbApplet_$id.setVisible("$xvariable", false); |
document.ggbApplet_$id.setVisible("$xvariable", false); |
document.ggbApplet_$id.evalCommand("$xvariable=$xrel"); |
document.ggbApplet_$id.evalCommand("$xvariable=$xrel"); |
document.ggbApplet_$id.evalCommand("$yvariable=Slider[-$range,$range,$yinterval]"); |
document.ggbApplet_$id.evalCommand("$yvariable=Slider[-$range,$range,$yinterval]"); |
document.ggbApplet_$id.setVisible("$yvariable", false); |
document.ggbApplet_$id.setVisible("$yvariable", false); |
document.ggbApplet_$id.evalCommand("$yvariable=$yrel"); |
document.ggbApplet_$id.evalCommand("$yvariable=$yrel"); |
document.ggbApplet_$id.evalCommand("$variable=($xvariable+x($pointname),$yvariable+y($pointname))"); |
document.ggbApplet_$id.evalCommand("$variable=$mult($xvariable+x($pointname),$yvariable+y($pointname))"); |
document.ggbApplet_$id.setLabelVisible("$variable", false); |
document.ggbApplet_$id.setLabelVisible("$variable", false); |
ENDSETSVARIABLE |
ENDSETSVARIABLE |
} |
} |
Line 215 sub generate_input_field {
|
Line 219 sub generate_input_field {
|
# Initialize a new point coordinate variable at set a listener on it |
# Initialize a new point coordinate variable at set a listener on it |
# |
# |
sub new_point_coordinate { |
sub new_point_coordinate { |
my ($id,$variable,$x,$y)=@_; |
my ($id,$variable,$x,$y,$fixed)=@_; |
if (defined($Apache::functionplotresponse::previous{&field_name($id,$variable,'x')})) { |
if (defined($Apache::functionplotresponse::previous{&field_name($id,$variable,'x')})) { |
$x=$Apache::functionplotresponse::previous{&field_name($id,$variable,'x')}; |
$x=$Apache::functionplotresponse::previous{&field_name($id,$variable,'x')}; |
} |
} |
Line 223 sub new_point_coordinate {
|
Line 227 sub new_point_coordinate {
|
$y=$Apache::functionplotresponse::previous{&field_name($id,$variable,'y')}; |
$y=$Apache::functionplotresponse::previous{&field_name($id,$variable,'y')}; |
} |
} |
&generate_input_field($id,$variable,$x,$y); |
&generate_input_field($id,$variable,$x,$y); |
return &set_point_coordinate($id,$variable,$x,$y).&update_register($id,$variable); |
return &set_point_coordinate($id,$variable,$x,$y,$fixed).&update_register($id,$variable); |
} |
} |
|
|
# |
# |
# Initialize a new slope coordinate variable at set a listener on it |
# Initialize a new slope coordinate variable at set a listener on it |
# |
# |
sub new_slope_coordinate { |
sub new_slope_coordinate { |
my ($id,$variable,$x,$y,$pointname,$xp,$yp,$xmin,$xmax,$ymin,$ymax)=@_; |
my ($id,$variable,$x,$y,$pointname,$xp,$yp,$xmin,$xmax,$ymin,$ymax,$fixed)=@_; |
# |
# |
# $variable: name of the slope point |
# $variable: name of the slope point |
# $x, $y: coordinates of the slope point |
# $x, $y: coordinates of the slope point |
Line 253 sub new_slope_coordinate {
|
Line 257 sub new_slope_coordinate {
|
&generate_input_field($id,$variable,$x,$y); |
&generate_input_field($id,$variable,$x,$y); |
my $xrel=$x-$xp; |
my $xrel=$x-$xp; |
my $yrel=$y-$yp; |
my $yrel=$y-$yp; |
return &set_slope_coordinate($id,$variable,$xrel,$yrel,$xmin,$xmax,$ymin,$ymax,$pointname).&update_register($id,$variable); |
return &set_slope_coordinate($id,$variable,$xrel,$yrel,$xmin,$xmax,$ymin,$ymax,$pointname,$fixed).&update_register($id,$variable); |
} |
} |
|
|
# |
# |
Line 366 sub plot_script {
|
Line 370 sub plot_script {
|
# |
# |
|
|
sub generate_spline { |
sub generate_spline { |
my ($id,$label,$xmin,$xmax,$ymin,$ymax)=@_; |
my ($id,$label,$xmin,$xmax,$ymin,$ymax,$fixed)=@_; |
my $result=''; |
my $result=''; |
my $order=$Apache::functionplotresponse::splineorder{$label}; |
my $order=$Apache::functionplotresponse::splineorder{$label}; |
my $x=$Apache::functionplotresponse::splineinitx{$label}; |
my $x=$Apache::functionplotresponse::splineinitx{$label}; |
Line 375 sub generate_spline {
|
Line 379 sub generate_spline {
|
my $sy=$Apache::functionplotresponse::splinescaley{$label}; |
my $sy=$Apache::functionplotresponse::splinescaley{$label}; |
my @coords=(); |
my @coords=(); |
foreach my $i (1..$order) { |
foreach my $i (1..$order) { |
$result.=&new_point_coordinate($id,$label.'P'.$i,$x,$y); |
$result.=&new_point_coordinate($id,$label.'P'.$i,$x,$y,$fixed); |
my $xp=$x; |
my $xp=$x; |
$x+=$sx/(2.*($order-1)); |
$x+=$sx/(2.*($order-1)); |
push(@coords,$label.'P'.$i); |
push(@coords,$label.'P'.$i); |
$result.=&new_slope_coordinate($id,$label.'S'.$i,$x,$y+$sy,$label.'P'.$i,$xp,$y,$xmin,$xmax,$ymin,$ymax); |
$result.=&new_slope_coordinate($id,$label.'S'.$i,$x,$y+$sy,$label.'P'.$i,$xp,$y,$xmin,$xmax,$ymin,$ymax,$fixed); |
$x+=$sx/(2.*($order-1)); |
$x+=$sx/(2.*($order-1)); |
push(@coords,$label.'S'.$i); |
push(@coords,$label.'S'.$i); |
} |
} |
Line 1190 sub end_functionplotelements {
|
Line 1194 sub end_functionplotelements {
|
} |
} |
} |
} |
} |
} |
|
my $fixed=0; |
|
if (($showanswer) || (&Apache::response::check_status()>=2)) { $fixed=1; } |
# Now is the time to render all of the stored splines |
# Now is the time to render all of the stored splines |
foreach my $label (keys(%Apache::functionplotresponse::splineorder)) { |
foreach my $label (keys(%Apache::functionplotresponse::splineorder)) { |
$result.=&generate_spline($internalid,$label,$xmin,$xmax,$ymin,$ymax); |
$result.=&generate_spline($internalid,$label,$xmin,$xmax,$ymin,$ymax,$fixed); |
} |
} |
# close the init script |
# close the init script |
$result.=&end_init_script(); |
$result.=&end_init_script(); |