| 1 | use strict; use warnings; |
| 2 | use Test::More; |
| 3 | use Config; |
| 4 | # Stop f77-linking causing spurious undefined symbols (alpha) |
| 5 | $ENV{'PERL_DL_NONLAZY'}=0 if $Config{'osname'} eq "dec_osf"; |
| 6 | require PGPLOT; |
| 7 | |
| 8 | my $dev = $ENV{PGPLOT_DEV} || '/NULL'; |
| 9 | |
| 10 | $ENV{PGPLOT_XW_WIDTH}=0.3; |
| 11 | |
| 12 | note "Testing perl function passing to pgconx"; |
| 13 | |
| 14 | # Read in image (int*2 raw byte array) |
| 15 | |
| 16 | my $img=""; |
| 17 | open(my $fh,"test.img") || die "Data file test.img not found"; |
| 18 | if($^O =~ /mswin32/i) {binmode($fh)} |
| 19 | read($fh, $img, 32768); |
| 20 | close($fh) or die "Can't close test.img: $!"; |
| 21 | |
| 22 | note length($img)," bytes read\n"; |
| 23 | |
| 24 | my @image = unpack("n*",$img); |
| 25 | |
| 26 | print $#image+1," element image stored\n"; |
| 27 | |
| 28 | PGPLOT::pgbegin(0,$dev,1,1); |
| 29 | |
| 30 | note "Plotting"; |
| 31 | |
| 32 | PGPLOT::pgsci(3); |
| 33 | PGPLOT::pgwnad(1,128,1,128); |
| 34 | PGPLOT::pgbox("BCNST",0,0,"BCNST",0,0); |
| 35 | |
| 36 | PGPLOT::pglabel("X","Y","Dropped Galaxy"); |
| 37 | |
| 38 | PGPLOT::pgsci(5); PGPLOT::pgsls(1); |
| 39 | my @cont = (-1,1000,2000,3000,4000,5000); |
| 40 | |
| 41 | PGPLOT::pgsci(5); |
| 42 | |
| 43 | PGPLOT::pgbbuf(); # buffer so giza does not flush to screen per primitive |
| 44 | PGPLOT::pgconx(\@image, 128, 128, 1,128,1,128, \@cont, 6, "squashplot"); |
| 45 | PGPLOT::pgebuf(); |
| 46 | PGPLOT::pgwnad(0,1000,0,1000); |
| 47 | |
| 48 | PGPLOT::pgend(); |
| 49 | |
| 50 | pass; |
| 51 | done_testing; |
| 52 | |
| 53 | sub squashplot { |
| 54 | my ($visible,$x,$y,$z) = @_; |
| 55 | |
| 56 | my $xworld = $x*$x/128; |
| 57 | my $yworld = $y*$y/128; |
| 58 | if ($visible) { |
| 59 | PGPLOT::pgdraw($xworld,$yworld); |
| 60 | }else{ |
| 61 | PGPLOT::pgmove($xworld,$yworld); |
| 62 | } |
| 63 | } |