"Fossies" - the Fresh Open Source Software Archive  

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

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

Graph.pm  (PDL-2.077):Graph.pm  (PDL-2.078)
package PDL::Graphics::TriD::Graph; package PDL::Graphics::TriD::Graph;
=head1 NAME
PDL::Graphics::TriD::Graph - PDL 3D graph object with axes
=head1 SYNOPSIS
use PDL::Graphics::TriD;
use PDL::Graphics::TriD::Graph;
$g = PDL::Graphics::TriD::Graph->new;
$g->default_axes;
$g->add_dataseries(PDL::Graphics::TriD::Lattice->new($y,$c), "lat0");
$g->bind_default("lat0");
$g->add_dataseries(PDL::Graphics::TriD::LineStrip->new($y+pdl(0,0,1),$c), "lat
1");
$g->bind_default("lat1");
$g->scalethings;
$win = PDL::Graphics::TriD::get_current_window();
$win->clear_objects;
$win->add_object($g);
$win->twiddle;
=cut
use strict; use strict;
use warnings; use warnings;
use base qw/PDL::Graphics::TriD::Object/; use base qw/PDL::Graphics::TriD::Object/;
use PDL::LiteF; # XXX F needed? use PDL::LiteF; # XXX F needed?
use fields qw(Data DataBind UnBound DefaultAxes Axis ); use fields qw(Data DataBind UnBound DefaultAxes Axis );
sub add_dataseries { sub add_dataseries {
my($this,$data,$name) = @_; my($this,$data,$name) = @_;
if(!defined $name) { if(!defined $name) {
skipping to change at line 32 skipping to change at line 55
sub bind_data { sub bind_data {
my($this,$dser,$axes,$axis) = @_; my($this,$dser,$axes,$axis) = @_;
push @{$this->{DataBind}{$dser}},[$axis,$axes]; push @{$this->{DataBind}{$dser}},[$axis,$axes];
delete $this->{UnBound}{$dser}; delete $this->{UnBound}{$dser};
$this->changed(); $this->changed();
} }
sub bind_default { sub bind_default {
my($this,$dser,$axes) = @_; my($this,$dser,$axes) = @_;
if(!defined $axes) {$axes = $this->{DefaultAxes}}; $axes //= $this->{DefaultAxes};
$this->{DataBind}{$dser} = [['Default',$axes]]; $this->{DataBind}{$dser} = [['Default',$axes]];
delete $this->{UnBound}{$dser}; delete $this->{UnBound}{$dser};
} }
sub set_axis { sub set_axis {
my($this,$axis,$name) = @_; my($this,$axis,$name) = @_;
$this->{Axis}{$name} = $axis; $this->{Axis}{$name} = $axis;
$this->changed(); $this->changed();
} }
# Bind all unbound things here... # Bind all unbound things here...
sub scalethings { sub scalethings {
my($this) = @_; my($this) = @_;
for(sort keys %{$this->{UnBound}}) { $this->bind_default($_) for keys %{$this->{UnBound}};
$this->bind_default($_); $_->init_scale() for values %{$this->{Axis}};
}
for(values %{$this->{Axis}}) {
$_->init_scale() ;
}
my ($k,$v); my ($k,$v);
while(($k,$v) = each %{$this->{DataBind}}) { while(($k,$v) = each %{$this->{DataBind}}) {
for(@$v) { $this->{Axis}{$_->[0]}->add_scale($this->{Data}{$k}->get_points()
$this->{Axis}{$_->[0]}->add_scale( , $_->[1]) for @$v;
$this->{Data}{$k}->get_points(), $_->[1]);
}
}
for(values %{$this->{Axis}}) {
$_->finish_scale();
} }
$_->finish_scale() for values %{$this->{Axis}};
} }
# use Data::Dumper;
sub get_points { sub get_points {
my($this,$name) = @_; my($this,$name) = @_;
# print Dumper($this->{Axis}); # print Dumper($this->{Axis});
my $d = $this->{Data}{$name}->get_points(); my $d = $this->{Data}{$name}->get_points();
my @ddims = $d->dims; shift @ddims; my @ddims = $d->dims; shift @ddims;
my $p = PDL->zeroes(&PDL::float(),3,@ddims); my $p = PDL->zeroes(PDL::float(),3,@ddims);
my $pnew; my $pnew;
for(@{$this->{DataBind}{$name}}) { for(@{$this->{DataBind}{$name}}) {
defined($this->{Axis}{$_->[0]}) or die("Axis not defined: $_->[0] "); defined($this->{Axis}{$_->[0]}) or die("Axis not defined: $_->[0] ");
# Transform can return the same or a different ndarray. # Transform can return the same or a different ndarray.
$pnew = $this->{Axis}{$_->[0]}->transform($p,$d,$_->[1]); $p = $pnew = $this->{Axis}{$_->[0]}->transform($p,$d,$_->[1]);
$p = $pnew;
} }
return $pnew; return $pnew;
} }
sub clear_data { sub clear_data {
my($this) = @_; my($this) = @_;
$this->{Data} = {}; $this->{$_} = {} for qw(Data DataBind UnBound);
$this->{DataBind} = {}; $this->changed;
$this->{UnBound} = {};
$this->changed();
} }
sub delete_data { sub delete_data {
my($this,$name) = @_; my($this,$name) = @_;
delete $this->{Data}{$name}; delete $this->{$_}{$name} for qw(Data DataBind UnBound);
delete $this->{DataBind}{$name}; $this->changed;
delete $this->{UnBound}{$name};
$this->changed();
} }
sub default_axes { sub default_axes {
my($this) = @_; my($this) = @_;
$this->set_axis(PDL::Graphics::TriD::EuclidAxes->new(),"Euclid3"); $this->set_axis(PDL::Graphics::TriD::EuclidAxes->new(),"Euclid3");
$this->set_default_axis("Euclid3",[0,1,2]); $this->set_default_axis("Euclid3",[0,1,2]);
} }
sub set_default_axis { sub set_default_axis {
my($this,$name,$axes) = @_; my($this,$name,$axes) = @_;
 End of changes. 10 change blocks. 
26 lines changed or deleted 36 lines changed or added

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