Window.pm (PDL-2.076) | : | Window.pm (PDL-2.077) | ||
---|---|---|---|---|
skipping to change at line 571 | skipping to change at line 571 | |||
lot cleaner. | lot cleaner. | |||
The pgwin exported constructor, arguably, breaks this philosophy; hopefully | The pgwin exported constructor, arguably, breaks this philosophy; hopefully | |||
it will ``wither away'' when other compatible modules are available. | it will ``wither away'' when other compatible modules are available. | |||
=back | =back | |||
Anyway, enough philosophizing, let us get down to Earth and give some | Anyway, enough philosophizing, let us get down to Earth and give some | |||
examples of the use of OO PGPLOT. As an example we will take Odd (which | examples of the use of OO PGPLOT. As an example we will take Odd (which | |||
happens to be a common Norwegian name) who is monitoring the birth of | happens to be a common Norwegian name) who is monitoring the birth of | |||
rabbits in O'Fib-o-nachy's farm (alternatively he can of course be | rabbits in O'Fib-o-nachy's farm (alternatively they can of course be | |||
monitoring processes or do something entirely different). Odd wants the | monitoring processes or do something entirely different). Odd wants the | |||
user to be able to monitor both the birth rates and accumulated number | user to be able to monitor both the birth rates and accumulated number | |||
of rabbits and the spatial distribution of the births. Since these are | of rabbits and the spatial distribution of the births. Since these are | |||
logically different he chooses to have two windows open: | logically different they chooses to have two windows open: | |||
$rate_win = PDL::Graphics::PGPLOT::Window->new(Device => '/xw', | $rate_win = PDL::Graphics::PGPLOT::Window->new(Device => '/xw', | |||
Aspect => 1, WindowWidth => 5, NXPanel => 2); | Aspect => 1, WindowWidth => 5, NXPanel => 2); | |||
$area_win = PDL::Graphics::PGPLOT::Window->new(Device => '/xw', | $area_win = PDL::Graphics::PGPLOT::Window->new(Device => '/xw', | |||
Aspect => 1, WindowWidth => 5); | Aspect => 1, WindowWidth => 5); | |||
See the documentation for L</new> below for a full overview of the | See the documentation for L</new> below for a full overview of the | |||
options you can pass to the constructor. | options you can pass to the constructor. | |||
skipping to change at line 2871 | skipping to change at line 2871 | |||
sub replay { | sub replay { | |||
my $self = shift; | my $self = shift; | |||
my $state = shift || $self->{State}; | my $state = shift || $self->{State}; | |||
die "A state object must be defined to play back commands!\n" | die "A state object must be defined to play back commands!\n" | |||
if !defined $state; | if !defined $state; | |||
my @list = $state->get(); | my @list = $state->get(); | |||
if ($#list < 0) { | if ($#list < 0) { | |||
# If there are no commands, then the user might have forgotten to | # If there are no commands, then the user might have forgotten to | |||
# turn on recording, let us remind him/her | # turn on recording, let us remind them | |||
warn "Replaying an empty state - did you turn on recording?\n"; | warn "Replaying an empty state - did you turn on recording?\n"; | |||
print "Hint: Put PDL::Graphics::PGPLOT::RECORDING=1 in your .perldlrc file\n " | print "Hint: Put PDL::Graphics::PGPLOT::RECORDING=1 in your .perldlrc file\n " | |||
} | } | |||
catch_signals { | catch_signals { | |||
foreach my $arg (@list) { | foreach my $arg (@list) { | |||
my ($command, $commandname, $arg, $opt)=@$arg; | my ($command, $commandname, $arg, $opt)=@$arg; | |||
&$command($self, @$arg, $opt); | &$command($self, @$arg, $opt); | |||
} | } | |||
skipping to change at line 4135 | skipping to change at line 4135 | |||
$opt = {} if !defined($opt); # For safety. | $opt = {} if !defined($opt); # For safety. | |||
# Now the titles are set per plot so we use the general options to | # Now the titles are set per plot so we use the general options to | |||
# parse the options (if they were set per window we would use | # parse the options (if they were set per window we would use | |||
# $self->{Options} | # $self->{Options} | |||
my ($o, $u_opt) = $self->_parse_options($self->{PlotOptions}, $opt); | my ($o, $u_opt) = $self->_parse_options($self->{PlotOptions}, $opt); | |||
# Added 25/8/01 JB to check whether label_axes is called before env.. | # Added 25/8/01 JB to check whether label_axes is called before env.. | |||
# This is not fool-proof though... And it will give a warning if the | # This is not fool-proof though... And it will give a warning if the | |||
# user creates her/his env box outside of this package. | # user creates their env box outside of this package. | |||
warn "label_axes called before env - weird results might occur!\n" unless | warn "label_axes called before env - weird results might occur!\n" unless | |||
defined($self->{_env_options}); | defined($self->{_env_options}); | |||
$self->_save_status(); | $self->_save_status(); | |||
$self->_standard_options_parser($u_opt); | $self->_standard_options_parser($u_opt); | |||
$o->{Title}=$title if defined($title); | $o->{Title}=$title if defined($title); | |||
$o->{XTitle}=$xtitle if defined($xtitle); | $o->{XTitle}=$xtitle if defined($xtitle); | |||
$o->{YTitle}=$ytitle if defined($ytitle); | $o->{YTitle}=$ytitle if defined($ytitle); | |||
# what width do we use? | # what width do we use? | |||
skipping to change at line 4384 | skipping to change at line 4384 | |||
if ( defined $o->{ImageDims} ) { | if ( defined $o->{ImageDims} ) { | |||
if ( ref($o->{ImageDims}) eq 'ARRAY' ) { | if ( ref($o->{ImageDims}) eq 'ARRAY' ) { | |||
($x_pix, $y_pix) = @{$o->{ImageDims}}; | ($x_pix, $y_pix) = @{$o->{ImageDims}}; | |||
} | } | |||
else { | else { | |||
barf "Image dimensions must be given as an array reference!"; | barf "Image dimensions must be given as an array reference!"; | |||
} | } | |||
} | } | |||
# The user has to pass the dimensions of the image somehow, so this | # The user has to pass the dimensions of the image somehow, so this | |||
# is a good point to check whether he/she/it has done so. | # is a good point to check whether they have done so. | |||
unless (defined($x_pix) && defined($y_pix)) { | unless (defined($x_pix) && defined($y_pix)) { | |||
barf "You must pass the image dimensions to the transform routine\n"; | barf "You must pass the image dimensions to the transform routine\n"; | |||
} | } | |||
# The RefPos option gives more flexibility than | # The RefPos option gives more flexibility than | |||
# ImageCentre, since ImageCentre => [ a, b ] is the same | # ImageCentre, since ImageCentre => [ a, b ] is the same | |||
# as PosReference => [ [(nx-1)/2,(ny-1/2)], [a,b] ]. | # as PosReference => [ [(nx-1)/2,(ny-1/2)], [a,b] ]. | |||
# We use ImageCentre in preference to PosReference | # We use ImageCentre in preference to PosReference | |||
# | # | |||
if (defined $o->{ImageCenter}) { | if (defined $o->{ImageCenter}) { | |||
End of changes. 5 change blocks. | ||||
5 lines changed or deleted | 5 lines changed or added |