Skip to content

Commit

Permalink
PGPLOT use pgplot API to get devices, as the prophecy foretold
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Mar 28, 2024
1 parent d674bea commit 3d7f16f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- P{GPLOT,Lplot} to read devices using proper API not subprocesses

1.010 2024-03-24
- fix PGPLOT to read devices correctly

Expand Down
15 changes: 8 additions & 7 deletions lib/PDL/Graphics/Simple/PGPLOT.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use strict;
use warnings;
use File::Temp qw/tempfile/;
use PDL::Options q/iparse/;
use IPC::Open2;

use PDL;

Expand Down Expand Up @@ -47,18 +46,20 @@ sub check {
return 0;
}
# Module loaded OK, now try to extract valid devices from it
my @lines = eval {
open2(my $chld_out, my $chld_in, $^X, qw(-MPGPLOT -e pgopen(q[?])));
print $chld_in "?\n";
close $chld_in;
grep /^\s+\//, <$chld_out>;
eval {
my %devs;
PGPLOT::pgqndt(my $n);
for my $count (1..$n) {
PGPLOT::pgqdt($count,my ($type,$v1,$descr,$v2,$v3));
$devs{substr $type, 1} = 1; # chop off "/"
}
$mod->{devices} = \%devs;
};
if ($@) {
$mod->{ok} = 0;
$mod->{msg} = $@;
return 0;
}
$mod->{devices} = { map { chomp; s/^\s*\///; s/\s.*//; ($_,1) } @lines };
delete $mod->{disp_dev};
TRY:for my $try(qw/XWINDOW XSERVE CGW GW/){
if($mod->{devices}->{$try}) {
Expand Down

0 comments on commit 3d7f16f

Please sign in to comment.