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