From: Mike G. v. a. <we...@ma...> - 2009-06-25 21:04:41
|
Log Message: ----------- merging changes from HEAD Tags: ---- rel-2-4-patches Modified Files: -------------- pg/lib: Parser.pm WWPlot.pm pg/lib/Parser: Value.pm pg/lib/Value: Matrix.pm Revision Data ------------- Index: WWPlot.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/WWPlot.pm,v retrieving revision 1.3 retrieving revision 1.3.8.1 diff -Llib/WWPlot.pm -Llib/WWPlot.pm -u -r1.3 -r1.3.8.1 --- lib/WWPlot.pm +++ lib/WWPlot.pm @@ -142,16 +142,22 @@ to access methods defined in GD but not supported directly by WWPlot. (See the documentation for GD.) -=item moveTo, lineTo +=item moveTo, lineTo, arrowTo $graph->moveTo($x,$y); $graph->lineTo($x,$y,$color); - -Moves to the point ($x, $y) (defined in real world coordinates) or draws a line from the -current position to the specified point ($x, $y) using the color $color. $color is the -name, e.g. 'white', of the color, not an index value or RGB specification. These are -low level call back routines used by the function, label and stamp objects to draw themselves. - + $graph->lineTo($x,$y,$color,$thickness); + $graph->lineTo($x,$y,$color,$thickness,'dashed'); + $graph->arrowTo($x,$y,$color); + $graph->arrowTo($x,$y,$color,$thickness); + $graph->arrowTo($x,$y,$color,$thickness,'dashed'); + +Moves to the point ($x, $y) (defined in real world coordinates) or draws a line or arrow +from the current position to the specified point ($x, $y) using the color $color. $color +is the name, e.g. 'white', of the color, not an index value or RGB specification. +$thickness gives the thickness of the line or arrow to draw. If 'dashed' is specified, +the line or arrow is rendered with a dashed line. These are low level call +back routines used by the function, label and stamp objects to draw themselves. =item ii, jj @@ -363,12 +369,25 @@ sub lineTo { my $self = shift; - my ($x,$y,$color) = @_; + my ($x,$y,$color, $w, $d) = @_; + $w = 1 if ! defined( $w ); + $d = 0 if ! defined( $d ); ## draw a dashed line? + $x=$self->ii($x); $y=$self->jj($y); $color = $self->{'colors'}{$color} if $color=~/[A-Za-z]+/ && defined($self->{'colors'}{$color}) ; # colors referenced by name works here. $color = $self->{'colors'}{'default_color'} unless defined($color); - $self->im->line(@{$self->position},$x,$y,$color); + + $self->im->setThickness( $w ); + if ( $d ) { + my @dashing = ( $color )x(4*$w*$w); + my @spacing = ( GD::gdTransparent )x(3*$w*$w); + $self->im->setStyle( @dashing, @spacing ); + $self->im->line(@{$self->position},$x,$y,GD::gdStyled); + } else { + $self->im->line(@{$self->position},$x,$y,$color); + } + $self->im->setThickness( 1 ); #warn "color is $color"; @{$self->position} = ($x,$y); } @@ -383,6 +402,52 @@ @{$self->position} = ( $x,$y ); } +sub arrowTo { + my $self = shift; + my ( $x1, $y1, $color, $w, $d ) = @_; + $w = 1 if ! defined( $w ); + $d = 0 if ! defined( $d ); + my $width = ( $w == 1 ) ? 2 : $w; + + $x1 = $self->ii($x1); + $y1 = $self->jj($y1); + $color = $self->{'colors'}{$color} if $color=~/[A-Za-z]+/ && defined($self->{'colors'}{$color}) ; + $color = $self->{'colors'}{'default_color'} unless defined($color); + + ## set thickness + $self->im->setThickness($w); + + my ($x0, $y0) = @{$self->position}; + my $dx = $x1 - $x0; + my $dy = $y1 - $y0; + my $len = sqrt($dx*$dx + $dy*$dy); + my $ux = $dx/$len; ## a unit vector in the direction of the arrow + my $uy = $dy/$len; + my $px = -1*$uy; ## a unit vector perpendicular + my $py = $ux; + my $hbx = $x1 - 5*$width*$ux; ## the base of the arrowhead + my $hby = $y1 - 5*$width*$uy; + my $head = new GD::Polygon; + $head->addPt($x1,$y1); + $head->addPt($hbx + 2*$width*$px, $hby + 2*$width*$py); + $head->addPt($hbx - 2*$width*$px, $hby - 2*$width*$py); + $self->im->filledPolygon( $head, $color ); + if ( $d ) { + my @dashing = ( $color )x(4*$w*$w); + my @spacing = ( GD::gdTransparent )x(3*$w*$w); + $self->im->setStyle( @dashing, @spacing ); + $self->im->line( $x0,$y0,$x1,$y1,GD::gdStyled); + } else { + $self->im->line( $x0,$y0,$x1,$y1,$color ); + } + + @{$self->position} = ( $x1, $y1 ); + + ## reset thickness + $self->im->setThickness(1); +} + + sub v_axis { my $self = shift; @{$self->{vaxis}}=@_; # y_value, color Index: Parser.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser.pm,v retrieving revision 1.32.2.2.2.2 retrieving revision 1.32.2.2.2.3 diff -Llib/Parser.pm -Llib/Parser.pm -u -r1.32.2.2.2.2 -r1.32.2.2.2.3 --- lib/Parser.pm +++ lib/Parser.pm @@ -389,7 +389,9 @@ $self->Item("List")->new($self,[$top->makeList],$top->{isConstant},$paren, ($top->type eq 'Comma') ? $top->entryType : $top->typeRef, ($type ne 'start') ? ($self->top->{value},$type) : () )}; - } + } else { + $top->{value}{hadParens} = 1; + } $self->pop; $self->push($top); $self->CloseFn() if ($paren->{function} && $self->prev->{type} eq 'fn'); } elsif ($paren->{formInterval} eq $type && $self->top->{value}->length == 2) { Index: Value.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Value.pm,v retrieving revision 1.17.6.2.2.1 retrieving revision 1.17.6.2.2.2 diff -Llib/Parser/Value.pm -Llib/Parser/Value.pm -u -r1.17.6.2.2.1 -r1.17.6.2.2.2 --- lib/Parser/Value.pm +++ lib/Parser/Value.pm @@ -46,8 +46,7 @@ # Set flags for the object # sub check { - my $self = shift; - my $type = $self->{type}; my $value = $self->{value}; + my $self = shift; my $value = $self->{value}; $self->{isZero} = $value->isZero; $self->{isOne} = $value->isOne; } Index: Matrix.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Matrix.pm,v retrieving revision 1.22.4.2.2.2 retrieving revision 1.22.4.2.2.3 diff -Llib/Value/Matrix.pm -Llib/Value/Matrix.pm -u -r1.22.4.2.2.2 -r1.22.4.2.2.3 --- lib/Value/Matrix.pm +++ lib/Value/Matrix.pm @@ -396,6 +396,7 @@ $d = scalar(@entries); @entries = (); } } + $TeX =~ s/\\cr\n$/\n/; return '\left'.$open.'\begin{array}{'.('c'x$d).'}'."\n".$TeX.'\end{array}\right'.$close; } |