| 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 multiple ways of passing things"; |
| 13 | |
| 14 | # Create 138x128 image - note must use transpose as |
| 15 | # perl is column major like C (see docs) |
| 16 | |
| 17 | my $k=0; |
| 18 | my (@img1D, @img2D); |
| 19 | for(my $i=0; $i<128; $i++) { for(my $j=0; $j<138; $j++) { |
| 20 | $img2D[$i][$j] = sqrtscip-perl cpan PGPLOT 2.36 main/sqrt().($i*$j) / 128; |
| 21 | $img1D[$k] = $img2D[$i][$j]; $k++; # For 1D test |
| 22 | }} |
| 23 | |
| 24 | my $imgchar = packscip-perl cpan PGPLOT 2.36 main/pack().("f*",@img1D); |
| 25 | |
| 26 | PGPLOT::pgbeginscip-perl cpan PGPLOT 2.36 PGPLOT/pgbegin().(0,$dev,2,2); # Open plot device |
| 27 | |
| 28 | notescip-perl cpan PGPLOT 2.36 main/note(). "Plotting..."; |
| 29 | |
| 30 | my @tr=(0,1,0,0,0,1); |
| 31 | |
| 32 | my @x=(10,20,30,40,50,60,70,80,90,100,110); |
| 33 | my @y=(30,35,40,45,50,55,60,65,70,75, 80); |
| 34 | |
| 35 | nextplotscip-perl cpan PGPLOT 2.36 main/nextplot().('Points: scalars passed one by one','Image: packed char string'); |
| 36 | |
| 37 | PGPLOT::pggrayscip-perl cpan PGPLOT 2.36 PGPLOT/pggray().($imgchar,138,128,1,138,1,128,1,0,\@tr); |
| 38 | for(my $i=0; $i<11; $i++){ PGPLOT::pgptscip-perl cpan PGPLOT 2.36 PGPLOT/pgpt().(1,$x[$i],$y[$i],17) } |
| 39 | |
| 40 | nextplotscip-perl cpan PGPLOT 2.36 main/nextplot().('Points: 1D array passed by glob','Image: 1D array passed by glob'); |
| 41 | |
| 42 | PGPLOT::pggrayscip-perl cpan PGPLOT 2.36 PGPLOT/pggray().(\@img1D,138,128,1,138,1,128,1,0,\@tr); |
| 43 | PGPLOT::pgptscip-perl cpan PGPLOT 2.36 PGPLOT/pgpt().(11,\@x,\@y,17); |
| 44 | |
| 45 | nextplotscip-perl cpan PGPLOT 2.36 main/nextplot().('Points: 1D array passed by reference','Image: 1D array passed by reference'); |
| 46 | |
| 47 | PGPLOT::pggrayscip-perl cpan PGPLOT 2.36 PGPLOT/pggray().(\@img1D,138,128,1,138,1,128,1,0,\@tr); |
| 48 | PGPLOT::pgptscip-perl cpan PGPLOT 2.36 PGPLOT/pgpt().(11,\@x,\@y,17); |
| 49 | |
| 50 | nextplotscip-perl cpan PGPLOT 2.36 main/nextplot().('Line: 1D cross-section of 2D array','Image: 2D array passed by reference'); |
| 51 | |
| 52 | PGPLOT::pggrayscip-perl cpan PGPLOT 2.36 PGPLOT/pggray().(\@img2D,138,128,1,138,1,128,1,0,\@tr); |
| 53 | PGPLOT::pgwindowscip-perl cpan PGPLOT 2.36 PGPLOT/pgwindow().(0,128,0,1); |
| 54 | PGPLOT::pglinescip-perl cpan PGPLOT 2.36 PGPLOT/pgline().(128, [0..127], $img2D[127]); |
| 55 | |
| 56 | PGPLOT::pgendscip-perl cpan PGPLOT 2.36 PGPLOT/pgend().(); |
| 57 | |
| 58 | pass; |
| 59 | done_testing; |
| 60 | |
| 61 | sub nextplotscip-perl cpan PGPLOT 2.36 main/nextplot(). { |
| 62 | note $_scip-perl cpan PGPLOT 2.36 main/$_.[0]; |
| 63 | note $_scip-perl cpan PGPLOT 2.36 main/$_.[1]; |
| 64 | notescip-perl cpan PGPLOT 2.36 main/note(). "--------------------------------------"; |
| 65 | PGPLOT::pgpagescip-perl cpan PGPLOT 2.36 PGPLOT/pgpage().(); PGPLOT::pgwnadscip-perl cpan PGPLOT 2.36 PGPLOT/pgwnad().(0,128,0,128); PGPLOT::pgsciscip-perl cpan PGPLOT 2.36 PGPLOT/pgsci().(3); PGPLOT::pgschscip-perl cpan PGPLOT 2.36 PGPLOT/pgsch().(1.3); |
| 66 | PGPLOT::pgboxscip-perl cpan PGPLOT 2.36 PGPLOT/pgbox().("BCST",0,0,"BCST",0,0); |
| 67 | if ($^Oscip-perl cpan PGPLOT 2.36 main/`$^O`. ne 'freebsd') { |
| 68 | # blows up for some reason |
| 69 | PGPLOT::pgmtextscip-perl cpan PGPLOT 2.36 PGPLOT/pgmtext().('T',1.0,0.2,0,$_scip-perl cpan PGPLOT 2.36 main/`@_`.[0]); |
| 70 | PGPLOT::pgmtextscip-perl cpan PGPLOT 2.36 PGPLOT/pgmtext().('T',2.4,0.2,0,$_scip-perl cpan PGPLOT 2.36 main/`@_`.[1]); |
| 71 | } |
| 72 | PGPLOT::pgsciscip-perl cpan PGPLOT 2.36 PGPLOT/pgsci().(4); |
| 73 | } |