"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Graphics/TriD/TriD/SimpleScaler.pm" between
PDL-2.076.tar.gz and PDL-2.077.tar.gz

About: PDL (Perl Data Language) aims to turn perl into an efficient numerical language for scientific computing (similar to IDL and MatLab).

SimpleScaler.pm  (PDL-2.076):SimpleScaler.pm  (PDL-2.077)
###################################################################### # a very simple unsophisticated scaler that
###################################################################### # takes advantage of the nice infrastructure provided by TJL
## ScaleController -- this is the module that controls 3-D window scaling # controls 3-D window scaling
## when you drag the mouse in the display window. # when you drag the mouse in the display window.
package PDL::Graphics::TriD::SimpleScaler;
package PDL::Graphics::TriD::ScaleController;
use strict; use strict;
use warnings; use warnings;
use base qw/PDL::Graphics::TriD::ButtonControl/; use base qw/PDL::Graphics::TriD::ButtonControl/;
use fields qw/Dist/; use fields qw/Dist/;
$PDL::Graphics::TriD::verbose //= 0; $PDL::Graphics::TriD::verbose //= 0;
sub new { sub new {
my($type,$win,$dist) = @_; my($type,$win,$dist) = @_;
my $this = $type->SUPER::new( $win); my $this = $type->SUPER::new( $win);
$this->{Dist} = $dist; $this->{Dist} = $dist;
$win->add_resizecommand(sub {print "Resized window: ",join(",",@_),"\n" if $PD L::debug_trid; $this->set_wh(@_); }); $win->add_resizecommand(sub {print "Resized window: ",join(",",@_),"\n" if $PD L::Graphics::TriD::verbose; $this->set_wh(@_); });
return $this; return $this;
} }
# coordinates normalised relative to center # coordinates normalised relative to center
sub xy2norm { sub xy2norm {
my($this,$x,$y) = @_; my($this,$x,$y) = @_;
print "xy2norm: this->{W}=$this->{W}; this->{H}=$this->{H}; this->{SC}=$t his->{SC}\n" if($PDL::Graphics::TriD::verbose); print "xy2norm: this->{W}=$this->{W}; this->{H}=$this->{H}; this->{SC}=$t his->{SC}\n" if($PDL::Graphics::TriD::verbose);
$x -= $this->{W}/2; $y -= $this->{H}/2; $x -= $this->{W}/2; $y -= $this->{H}/2;
$x /= $this->{SC}; $y /= $this->{SC}; $x /= $this->{SC}; $y /= $this->{SC};
return ($x,$y); return ($x,$y);
} }
sub mouse_moved { sub mouse_moved {
my($this,$x0,$y0,$x1,$y1) = @_; my($this,$x0,$y0,$x1,$y1) = @_;
# $this->{Dist} *=
${$this->{Dist}} *= ${$this->{Dist}} *=
$this->xy2fac($this->xy2norm($x0,$y0),$this->xy2norm($x1,$y1)); $this->xy2fac($this->xy2norm($x0,$y0),$this->xy2norm($x1,$y1));
} }
##############################################################
#
# a very simple unsophisticated scaler that
# takes advantage of the nice infrastructure provided by
# TJL
#
##############################################################
package PDL::Graphics::TriD::SimpleScaler;
use base qw/PDL::Graphics::TriD::ScaleController/;
# x,y to distance from center # x,y to distance from center
sub xy2fac { sub xy2fac {
my($this,$x0,$y0,$x1,$y1) = @_; my($this,$x0,$y0,$x1,$y1) = @_;
my $dy = $y0-$y1; my $dy = $y0-$y1;
return $dy>0 ? 1+2*$dy : 1/(1-2*$dy); return $dy>0 ? 1+2*$dy : 1/(1-2*$dy);
} }
1; 1;
 End of changes. 5 change blocks. 
18 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)