Skip to content

Commit 5ab3bce

Browse files
committed
zap indirect-object notation
1 parent 059b8a5 commit 5ab3bce

File tree

6 files changed

+29
-33
lines changed

6 files changed

+29
-33
lines changed

demos/tvrml2.p

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ PDL::Graphics::VRML::Protos->import();
6060
# vrn(Transform,
6161
# translation => '0 0 -1',
6262
# children =>
63-
# [new PDL::Graphics::VRMLNode('PDLBlockText10')
63+
# [PDL::Graphics::VRMLNode->new('PDLBlockText10')
6464
# ]
6565
# )
6666
# ));

lib/PDL/Graphics/TriD/ArcBall.pm

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ sub new {
2222
my $this = $type->SUPER::new($win);
2323
$this->{Inv} = $inv;
2424
$this->{Quat} = (defined($quat) ? $quat :
25-
new PDL::Graphics::TriD::Quaternion(1,0,0,0));
25+
PDL::Graphics::TriD::Quaternion->new(1,0,0,0));
2626
$win->add_resizecommand(sub {$this->set_wh(@_)});
2727
return $this;
2828
}
@@ -38,11 +38,10 @@ sub xy2qua {
3838
sub mouse_moved {
3939
my($this,$x0,$y0,$x1,$y1) = @_;
4040
# Copy the size of the owning viewport to our size, in case it changed
41-
$this->{H} = $this->{Win}->{H};
42-
$this->{W} = $this->{Win}->{W};
43-
if($PDL::Graphics::TriD::verbose) {
44-
print "QuaterController: mouse-moved: $this: $x0,$y0,$x1,$y1,$this->{W},$this->{H},$this->{SC}\n" if($PDL::Graphics::TriD::verbose);
45-
if($PDL::Graphics::TriD::verbose > 1) {
41+
@$this{qw(H W)} = @{$this->{Win}}{qw(H W)};
42+
if ($PDL::Graphics::TriD::verbose) {
43+
print "QuaterController: mouse-moved: $this: $x0,$y0,$x1,$y1,$this->{W},$this->{H},$this->{SC}\n";
44+
if ($PDL::Graphics::TriD::verbose > 1) {
4645
print "\tthis is:\n";
4746
foreach my $k(sort keys %$this) {
4847
print "\t$k\t=>\t$this->{$k}\n";
@@ -52,14 +51,13 @@ sub mouse_moved {
5251
# Convert both to quaternions.
5352
my ($qua0,$qua1) = ($this->xy2qua($x0,$y0),$this->xy2qua($x1,$y1));
5453
my $arc = $qua1->multiply($qua0->invert());
55-
if($this->{Inv}) {
54+
if ($this->{Inv}) {
5655
$arc->invert_rotation_this();
5756
}
5857
$this->{Quat}->set($arc->multiply($this->{Quat}));
5958
1; # signals a refresh
6059
}
6160

62-
#
6361
# Original ArcBall
6462
#
6563
package PDL::Graphics::TriD::ArcBall;

lib/PDL/Graphics/TriD/OOGL.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use strict;
33
use warnings;
44

55
$PDL::Graphics::TriD::create_window_sub = $PDL::Graphics::TriD::create_window_sub = sub {
6-
return new PDL::Graphics::TriD::OOGL::Window;
6+
return PDL::Graphics::TriD::OOGL::Window->new;
77
};
88

99
package PDL::Graphics::TriD::Object;

lib/PDL/Graphics/TriD/Quaternion.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ sub new {
2929
}
3030

3131
sub copy {
32-
return new PDL::Graphics::TriD::Quaternion(@{$_[0]});
32+
return PDL::Graphics::TriD::Quaternion->new(@{$_[0]});
3333
}
3434

3535
sub new_vrmlrot {
@@ -77,11 +77,11 @@ sub multiply_scalar {
7777
my $ang = POSIX::acos($this->[0]);
7878
my $d = sin($ang);
7979
if(abs($d) < 0.0000001) {
80-
return new PDL::Graphics::TriD::Quaternion(1,0,0,0);
80+
return PDL::Graphics::TriD::Quaternion->new(1,0,0,0);
8181
}
8282
$ang *= $scalar;
8383
my $d2 = sin($ang);
84-
return new PDL::Graphics::TriD::Quaternion(
84+
return PDL::Graphics::TriD::Quaternion->new(
8585
cos($ang), map {$_*$d2/$d} @{$this}[1..3]
8686
);
8787
}

lib/PDL/Graphics/TriD/VRML.pm

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ sub PDL::Graphics::TriD::Material::tovrml {
120120
my $ambi = (pdl(@{$this->{Ambient}})**2)->sum /
121121
(pdl(@{$this->{Diffuse}})**2)->sum;
122122
$ambi = sqrt($ambi);
123-
new PDL::Graphics::VRMLNode('Material',
123+
PDL::Graphics::VRMLNode->new('Material',
124124
'diffuseColor' => vrml3v($this->{Diffuse}),
125125
'emissiveColor' => vrml3v($this->{Emissive}),
126126
'shininess' => $this->{Shine},
@@ -131,14 +131,14 @@ sub PDL::Graphics::TriD::Material::tovrml {
131131

132132
sub PDL::Graphics::TriD::Scale::tovrml {my ($this) = @_;
133133
print "Scale ",(join ',',@{$this->{Args}}),"\n";
134-
new PDL::Graphics::VRMLNode('Transform',
134+
PDL::Graphics::VRMLNode->new('Transform',
135135
'scale',vrml3v(@{$this->{Args}}));
136136
}
137137

138138

139139
sub PDL::Graphics::TriD::Translation::tovrml {
140140
my ($this) = @_;
141-
new PDL::Graphics::VRMLNode('Transform',
141+
PDL::Graphics::VRMLNode->new('Transform',
142142
'translation',vrml3v(@{$this->{Args}}));
143143
}
144144

@@ -156,7 +156,7 @@ sub PDL::Graphics::TriD::Quaternion::tovrml {my($this) = @_;
156156
# die "Unnormalized Quaternion!\n";
157157
$this->normalize_this();
158158
}
159-
new PDL::Graphics::VRMLNode('Transform',
159+
PDL::Graphics::VRMLNode->new('Transform',
160160
'rotation',vrml3v(@{$this}[1..3])." $this->[0]");
161161
}
162162

@@ -185,27 +185,27 @@ sub PDL::Graphics::TriD::GObject::tovrml_graph {
185185

186186
sub PDL::Graphics::TriD::Points::vdraw {
187187
my($this,$points) = @_;
188-
new PDL::Graphics::VRMLNode('Shape',
188+
PDL::Graphics::VRMLNode->new('Shape',
189189
'geometry' =>
190-
new PDL::Graphics::VRMLPdlNode($points,$this->{Colors},
190+
PDL::Graphics::VRMLPdlNode->new($points,$this->{Colors},
191191
{Title => 'PointSet',
192192
DefColors => $this->defcols}));
193193
}
194194

195195
sub PDL::Graphics::TriD::LineStrip::vdraw {
196196
my($this,$points) = @_;
197-
new PDL::Graphics::VRMLNode('Shape',
197+
PDL::Graphics::VRMLNode->new('Shape',
198198
'geometry' =>
199-
new PDL::Graphics::VRMLPdlNode($points,$this->{Colors},
199+
PDL::Graphics::VRMLPdlNode->new($points,$this->{Colors},
200200
{Title => 'IndexedLineSet',
201201
DefColors => $this->defcols}));
202202
}
203203

204204
sub PDL::Graphics::TriD::Lattice::vdraw {
205205
my($this,$points) = @_;
206-
new PDL::Graphics::VRMLNode('Shape',
206+
PDL::Graphics::VRMLNode->new('Shape',
207207
'geometry' =>
208-
new PDL::Graphics::VRMLPdlNode($points,$this->{Colors},
208+
PDL::Graphics::VRMLPdlNode->new($points,$this->{Colors},
209209
{Title => 'IndexedLineSet',
210210
DefColors => $this->defcols,
211211
IsLattice => 1}));
@@ -215,14 +215,14 @@ sub PDL::Graphics::TriD::SLattice::vdraw {
215215
my($this,$points) = @_;
216216
my $children = [vrn('Shape',
217217
'geometry' =>
218-
new PDL::Graphics::VRMLPdlNode($points,$this->{Colors},
218+
PDL::Graphics::VRMLPdlNode->new($points,$this->{Colors},
219219
{Title => 'IndexedFaceSet',
220220
DefColors => $this->defcols,
221221
IsLattice => 1,
222222
}))];
223223
push @$children, vrn('Shape',
224224
'geometry' =>
225-
new PDL::Graphics::VRMLPdlNode($points,$this->{Colors},
225+
PDL::Graphics::VRMLPdlNode->new($points,$this->{Colors},
226226
{Title => 'IndexedLineSet',
227227
DefColors => 0,
228228
Surface => 1,
@@ -242,15 +242,15 @@ sub PDL::Graphics::TriD::SLattice_S::vdraw {
242242
'appearance' => vrn('Appearance',
243243
'material' => $mat),
244244
'geometry' =>
245-
new PDL::Graphics::VRMLPdlNode($points,$this->{Colors},
245+
PDL::Graphics::VRMLPdlNode->new($points,$this->{Colors},
246246
{Title => 'IndexedFaceSet',
247247
DefColors => 1,
248248
IsLattice => 1,
249249
Smooth => $this->{Options}->{Smooth},
250250
}))];
251251
push @$children, vrn('Shape',
252252
'geometry' =>
253-
new PDL::Graphics::VRMLPdlNode($points,$this->{Colors},
253+
PDL::Graphics::VRMLPdlNode->new($points,$this->{Colors},
254254
{Title => 'IndexedLineSet',
255255
DefColors => 0,
256256
Surface => 1,
@@ -561,7 +561,7 @@ package PDL::Graphics::TriD::VRML;
561561
$PDL::Graphics::VRML::current_window = undef;
562562
$PDL::Graphics::TriD::create_window_sub =
563563
$PDL::Graphics::TriD::create_window_sub = sub {
564-
return new PDL::Graphics::TriD::Window;
564+
return PDL::Graphics::TriD::Window->new;
565565
};
566566

567567
# set up the default parameters for VRML

lib/PDL/Graphics/TriD/Window.pm

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,10 @@ sub new_viewport {
6363
} else {
6464
eval "use PDL::Graphics::TriD::GL";
6565
}
66-
my $ev = $options->{EHandler};
67-
$ev = PDL::Graphics::TriD::EventHandler->new($vp) unless defined($ev);
68-
my $cont = $options->{Transformer};
69-
$cont = PDL::Graphics::TriD::SimpleController->new unless defined($cont);
66+
my $ev = $options->{EHandler} // PDL::Graphics::TriD::EventHandler->new($vp);
67+
my $cont = $options->{Transformer} // PDL::Graphics::TriD::SimpleController->new;
7068
$vp->transformer($cont);
71-
if(ref($ev)){
69+
if (ref($ev)){
7270
$ev->set_button(0,PDL::Graphics::TriD::ArcCone->new( $vp, 0, $cont->{WRotation}));
7371
$ev->set_button(2,PDL::Graphics::TriD::SimpleScaler->new( $vp, \$cont->{CDistance}));
7472
$ev->set_button(3,PDL::Graphics::TriD::ScrollButtonScaler->new( $vp, \$cont->{CDistance}, 0.9));

0 commit comments

Comments
 (0)