NAME

PGPLOT::Device::PGWin - convenience class for PDL::Graphics::PGPLOT::Window

VERSION

version 0.12

SYNOPSIS

$pgwin = PGPLOT::Device::PGWin->new( { device => $user_device_spec,
                                       winopts => \%opts } );

$pgwin->override( $override );
$win = $pgwin->next;
$win->env( ... );

$pgwin->finish;

DESCRIPTION

PGPLOT::Device::PGWin is a convenience class which combines PGPLOT::Device and PDL::Graphics::PGPLOT::Window. It provides the logic to handle interactive devices (as illustrated in the Examples section of the PGPLOT::Device documentation).

Note that the "close" in PDL::Graphics::PGPLOT::Window method should never be called when using this module, as that will surely mess things up.

METHODS

new

$pgwin = PGPLOT::Device::PGWin->new( \%opts );

Create a new object. The possible options are:

device

The device specification. This is passed directly to "new" in PGPLOT::Device, so see its documentation.

devopts

A hashref containing options to pass to "new" in PGPLOT::Device.

winopts

A hashref containing options to pass to "new" in PDL::Graphics::PGPLOT::Windows. Do not include a Device option as that will break things.

winopts

# retrieve a copy of the current set of dinwo options.
$winopts = $pgwin->winopts;

device

$dev = $pgwin->device

This method returns the underlying PGPLOT::Device object.

next

$win = $pgwin->next( ?\%winopts, ?$spec  );

Return the window handle to use for constructing the next plot. If the device is not changing, simply returns the existing window handle.

%winopts

If %winopts is provided, it will be used to replace the previous set of window options. To merely amend that, set

%winopts = ( %{ $pgwin->winopts }, %newoptions );

If the device is not changing, some poking at PDL::Graphics::PGPLOT::Window innards must be performed so that the current window will pay attention to the new options. Only the following options are handled:

Justify NXPanel NYPanel
$spec

If the optional argument $spec is provided, it is equivalent to

$pgwin->override( $spec );
$pgwin->next;

override

$pgwin->override( ... );

This calls the override method of the associated PGPLOT::Device object.

finish

$pgwin->finish();

Close the associated device. This must be called to handle prompting for ephemeral interactive graphic devices before a program finishes execution.

This is not automatically called upon object destruction as there seems to be an ordering problem in destructors called during Perl's cleanup phase such that the underlying PDL::Graphics::PGPLOT::Window object is destroyed before this object.

EXAMPLES

my $pgwin = PGPLOT::Device::PGWin->new( { Device => $user_spec } );

eval {

  for my $plot in ( qw/ plot1 plot2 / )
  {
    $pgwin->override( $plot );
    my $win = $pgwin->next();
    $win->env( ... );
    ...
  }
};
my $error = $@;
$pgwin->finish;
die $error if $error;

SUPPORT

Bugs

Please report any bugs or feature requests to bug-pgplot-device@rt.cpan.org or through the web interface at: https://rt.cpan.org/Public/Dist/Display.html?Name=PGPLOT-Device

Source

Source is available at

https://gitlab.com/djerius/pgplot-device

and may be cloned from

https://gitlab.com/djerius/pgplot-device.git

SEE ALSO

Please see those modules/websites for more information related to this module.

AUTHOR

Diab Jerius <djerius@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2017 by Smithsonian Astrophysical Observatory.

This is free software, licensed under:

The GNU General Public License, Version 3, June 2007