Skip to content

Commit 7a16fb2

Browse files
committed
allow add_dataseries to have more than one contained object
1 parent a128add commit 7a16fb2

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

lib/PDL/Graphics/TriD/GL.pm

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,16 @@ sub PDL::Graphics::TriD::Object::delete_displist {
4949
delete @$this{qw(List ValidList)};
5050
}
5151

52-
sub PDL::Graphics::TriD::Object::togl { $_->togl for @{$_[0]->{Objects}} }
52+
sub PDL::Graphics::TriD::Object::togl { $_->togl for $_[0]->contained_objects }
5353

5454
sub PDL::Graphics::TriD::Graph::togl {
55-
my($this) = @_;
56-
$this->{Axis}{$_}->togl for grep $_ ne "Default", keys %{$this->{Axis}};
57-
$this->{Data}{$_}->togl($this->get_points($_)) for keys %{$this->{Data}};
55+
my ($this) = @_;
56+
$this->{Axis}{$_}->togl for grep $_ ne "Default", keys %{$this->{Axis}};
57+
while (my ($series,$h) = each %{ $this->{Data} }) {
58+
for my $data (values %$h) {
59+
$data->togl($this->get_points($series, $data));
60+
}
61+
}
5862
}
5963

6064
use PDL;

lib/PDL/Graphics/TriD/Graph.pm

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ sub add_dataseries {
4141
$this->add_dataseries($_, $name, 1) for $data->contained_objects;
4242
}
4343
if ($data->can('get_points')) {
44-
$this->{Data}{$name} = $data;
44+
$this->{Data}{$name}{$data} = $data;
4545
$this->add_object($data);
4646
}
4747
$this->changed if !$no_changed;
@@ -71,31 +71,32 @@ sub set_axis {
7171

7272
# Bind all unbound things here...
7373
sub scalethings {
74-
my($this) = @_;
74+
my ($this) = @_;
7575
$this->bind_default($_) for keys %{$this->{UnBound}};
7676
$_->init_scale() for values %{$this->{Axis}};
77-
while(my ($series_name,$v) = each %{$this->{DataBind}}) {
77+
while (my ($series_name,$v) = each %{$this->{DataBind}}) {
7878
for my $bound (@$v) {
7979
my ($axis, $axes) = @$bound;
80-
$this->{Axis}{$axis}->add_scale($this->{Data}{$series_name}->get_points(), $axes);
80+
for my $data (values %{ $this->{Data}{$series_name} }) {
81+
$this->{Axis}{$axis}->add_scale($data->get_points, $axes);
82+
}
8183
}
8284
}
8385
$_->finish_scale() for values %{$this->{Axis}};
8486
}
8587

8688
sub get_points {
87-
my($this,$name) = @_;
88-
# print Dumper($this->{Axis});
89-
my $d = $this->{Data}{$name}->get_points();
90-
my @ddims = $d->dims; shift @ddims;
91-
my $p = PDL->zeroes(PDL::float(),3,@ddims);
92-
my $pnew;
93-
for(@{$this->{DataBind}{$name}}) {
94-
defined($this->{Axis}{$_->[0]}) or die("Axis not defined: $_->[0]");
89+
my ($this,$name,$data) = @_;
90+
my $d = $data->get_points;
91+
my @ddims = $d->dims; shift @ddims;
92+
my $p = PDL->zeroes(PDL::float(),3,@ddims);
93+
my $pnew;
94+
for (@{$this->{DataBind}{$name}}) {
95+
defined($this->{Axis}{$_->[0]}) or die("Axis not defined: $_->[0]");
9596
# Transform can return the same or a different ndarray.
96-
$p = $pnew = $this->{Axis}{$_->[0]}->transform($p,$d,$_->[1]);
97-
}
98-
return $pnew;
97+
$p = $pnew = $this->{Axis}{$_->[0]}->transform($p,$d,$_->[1]);
98+
}
99+
$pnew;
99100
}
100101

101102
sub clear_data {

0 commit comments

Comments
 (0)