From: <arj...@us...> - 2011-02-21 07:39:50
|
Revision: 11572 http://plplot.svn.sourceforge.net/plplot/?rev=11572&view=rev Author: arjenmarkus Date: 2011-02-21 07:39:43 +0000 (Mon, 21 Feb 2011) Log Message: ----------- First set of Tcl examples adjusted: add {} for expressions and remove local definitions of PLplot symbols. Note: in example 8 I ran into an oddity with the hexadecimal notation for MAG_COLOR. I had to use [expr] to get the picture right. I think it is due to the use of the C function atoi() to convert a string to a number. We should replace it with Tcl_GetInt() to take care of the alternative forms. Modified Paths: -------------- trunk/examples/tcl/x01.tcl trunk/examples/tcl/x03.tcl trunk/examples/tcl/x04.tcl trunk/examples/tcl/x05.tcl trunk/examples/tcl/x06.tcl trunk/examples/tcl/x07.tcl trunk/examples/tcl/x08.tcl trunk/examples/tcl/x09.tcl trunk/examples/tcl/x11.tcl trunk/examples/tcl/x12.tcl trunk/examples/tcl/x13.tcl trunk/examples/tcl/x14.tcl trunk/examples/tcl/x16.tcl trunk/examples/tcl/x17.tcl trunk/examples/tcl/x18.tcl trunk/examples/tcl/x19.tcl trunk/examples/tcl/x20.tcl trunk/examples/tcl/x21.tcl Modified: trunk/examples/tcl/x01.tcl =================================================================== --- trunk/examples/tcl/x01.tcl 2011-02-19 18:28:28 UTC (rev 11571) +++ trunk/examples/tcl/x01.tcl 2011-02-21 07:39:43 UTC (rev 11572) @@ -120,7 +120,6 @@ proc plot3 {w} { - set pi 3.14159265358979323846 $w cmd pladv 0 $w cmd plvsta $w cmd plwind 0.0 360.0 -1.2 1.2 @@ -155,7 +154,7 @@ for {set i 0} {$i < 101} {incr i} { x $i = [expr 3.6 * $i] - y $i = [expr sin([x $i] * $pi / 180.0)] + y $i = [expr sin([x $i] * $::PLPLOT::PL_PI / 180.0)] } $w cmd plcol0 4 Modified: trunk/examples/tcl/x03.tcl =================================================================== --- trunk/examples/tcl/x03.tcl 2011-02-19 18:28:28 UTC (rev 11571) +++ trunk/examples/tcl/x03.tcl 2011-02-21 07:39:43 UTC (rev 11572) @@ -3,7 +3,7 @@ #---------------------------------------------------------------------------- proc x03 {{w loopback}} { - set twopi [expr 2. * 3.14159265358979323846] + set twopi [expr {2. * $::PLPLOT::PL_PI}] # Set up viewport and window, but do not draw box $w cmd plenv -1.3 1.3 -1.3 1.3 1 -2 @@ -12,28 +12,28 @@ set ni 10 set nj 360 - set nj1 [expr $nj + 1] + set nj1 [expr {$nj + 1}] - set dr [expr 1. / $ni] - set dtheta [expr $twopi / $nj] + set dr [expr {1. / $ni}] + set dtheta [expr {$twopi / $nj}] matrix xj f $nj1 matrix yj f $nj1 for {set i 1} {$i <= $ni} {incr i} { - $w cmd plarc 0.0 0.0 [expr 0.1 * $i]] [expr 0.1 * $i] 0.0 360.0 0 + $w cmd plarc 0.0 0.0 [expr {0.1 * $i}]] [expr {0.1 * $i}] 0.0 360.0 0 } # Draw radial spokes for polar grid and write labels for angle $w cmd plcol0 2 for {set j 0} {$j <= 11} {incr j} { - set theta [expr $j * $twopi / 12.] - set xg [expr cos($theta)] - set yg [expr sin($theta)] + set theta [expr {$j * $twopi / 12.}] + set xg [expr {cos($theta)}] + set yg [expr {sin($theta)}] $w cmd pljoin 0.0 0.0 $xg $yg - set theta_deg [expr $theta*360./$twopi] + set theta_deg [expr {$theta*360./$twopi}] if {$theta_deg < 9.99} { set offset 0.45 } elseif {$theta_deg < 99.9} { @@ -44,15 +44,15 @@ # Slightly off zero to avoid floating point logic flips at 90 and 270 deg. if {$xg >= -0.00001} { - set dx [expr $xg] - set dy [expr $yg] - set just [expr -$offset] + set dx $xg + set dy $yg + set just [expr {-$offset}] } else { - set dx [expr -$xg] - set dy [expr -$yg] - set just [expr 1. + $offset] + set dx [expr {-$xg}] + set dy [expr {-$yg}] + set just [expr {1. + $offset}] } - set label [expr round($theta*360./$twopi)] + set label [expr {round($theta*360./$twopi)}] # N.B. cannot get this command to give same postscript output. Also visual # inspection shows 90 deg label jumping around slightly compared to python @@ -63,18 +63,18 @@ # Draw the graph set npts 360 - set npts1 [expr $npts+1] + set npts1 [expr {$npts+1}] - set dtheta [expr $twopi / $npts] + set dtheta [expr {$twopi / $npts}] matrix x f $npts1 matrix y f $npts1 for {set j 0} {$j <= $npts} {incr j} { - set theta [expr $j * $dtheta] - set r [expr sin(5 * $theta)] - x $j = [expr $r * cos($theta)] - y $j = [expr $r * sin($theta)] + set theta [expr {$j * $dtheta}] + set r [expr {sin(5 * $theta)}] + x $j = [expr {$r * cos($theta)}] + y $j = [expr {$r * sin($theta)}] } $w cmd plcol0 3 $w cmd plline $npts1 x y Modified: trunk/examples/tcl/x04.tcl =================================================================== --- trunk/examples/tcl/x04.tcl 2011-02-19 18:28:28 UTC (rev 11571) +++ trunk/examples/tcl/x04.tcl 2011-02-21 07:39:43 UTC (rev 11572) @@ -17,7 +17,6 @@ proc plot41 {w type} { - set pi 3.14159265358979323846 matrix freql f 101 matrix ampl f 101 matrix phase f 101 @@ -26,10 +25,10 @@ set f0 1.0 for {set i 0} {$i <= 100} {incr i} { - freql $i = [expr -2.0 + $i / 20.0] - set freq [expr pow(10.0, [freql $i])] - ampl $i = [expr 20.0 * log10(1.0 / sqrt(1.0 + pow(($freq/$f0), 2)))] - phase $i = [expr -(180.0 / $pi) * atan($freq/$f0)] + freql $i = [expr {-2.0 + $i / 20.0}] + set freq [expr {pow(10.0, [freql $i])}] + ampl $i = [expr {20.0 * log10(1.0 / sqrt(1.0 + pow(($freq/$f0), 2)))}] + phase $i = [expr {-(180.0 / $::PLPLOT::PL_PI) * atan($freq/$f0)}] } $w cmd plvpor 0.15 0.85 0.1 0.9 Modified: trunk/examples/tcl/x05.tcl =================================================================== --- trunk/examples/tcl/x05.tcl 2011-02-19 18:28:28 UTC (rev 11571) +++ trunk/examples/tcl/x05.tcl 2011-02-21 07:39:43 UTC (rev 11572) @@ -8,7 +8,7 @@ # Fill up data points - set delta [expr 2.0 * 3.14159265358979323846 / $npts] + set delta [expr 2.0 * $::PLPLOT::PL_PI / $npts] for {set i 0} {$i < $npts} {incr i} { data $i = [expr sin($i * $delta)] } Modified: trunk/examples/tcl/x06.tcl =================================================================== --- trunk/examples/tcl/x06.tcl 2011-02-19 18:28:28 UTC (rev 11571) +++ trunk/examples/tcl/x06.tcl 2011-02-21 07:39:43 UTC (rev 11572) @@ -36,7 +36,7 @@ $w cmd plcol0 15 for {set i 0} {$i <= 9} {incr i} { - $w cmd plmtex "b" 1.5 [expr 0.1 * $i + 0.05] 0.5 $i + $w cmd plmtex "b" 1.5 [expr {0.1 * $i + 0.05}] 0.5 $i } set k 0 @@ -44,10 +44,10 @@ # Write the digits to the left of the frame - $w cmd plmtex "lv" 1.0 [expr 1.0 - (2 * $i + 1)/26.0] 1.0 [expr 10*$i] + $w cmd plmtex "lv" 1.0 [expr {1.0 - (2 * $i + 1)/26.0}] 1.0 [expr {10*$i}] for {set j 0} {$j <= 9} {incr j} { - x 0 = [expr 0.1 * $j + 0.05] - y 0 = [expr 1.25 - 0.1 * $i] + x 0 = [expr {0.1 * $j + 0.05}] + y 0 = [expr {1.25 - 0.1 * $i}] # Display the symbols Modified: trunk/examples/tcl/x07.tcl =================================================================== --- trunk/examples/tcl/x07.tcl 2011-02-19 18:28:28 UTC (rev 11571) +++ trunk/examples/tcl/x07.tcl 2011-02-21 07:39:43 UTC (rev 11572) @@ -32,7 +32,7 @@ $w cmd plcol0 15 for {set i 0} {$i <= 9} {incr i} { - $w cmd plmtex "b" 1.5 [expr 0.1 * $i + 0.05] 0.5 $i + $w cmd plmtex "b" 1.5 [expr {0.1 * $i + 0.05}] 0.5 $i } set k 0 @@ -40,16 +40,16 @@ # Write the digits to the left of the frame - $w cmd plmtex "lv" 1.0 [expr (0.95 - 0.1 * $i)] 1.0 \ - [expr [base $l] + 10*$i] + $w cmd plmtex "lv" 1.0 [expr {0.95 - 0.1 * $i}] 1.0 \ + [expr {[base $l] + 10*$i}] for {set j 0} {$j <= 9} {incr j} { - x 0 = [expr 0.1 * $j + 0.05] - y 0 = [expr 0.95 - 0.1 * $i] + x 0 = [expr {0.1 * $j + 0.05}] + y 0 = [expr {0.95 - 0.1 * $i}] # Display the symbols - $w cmd plsym 1 x y [expr [base $l] + $k] + $w cmd plsym 1 x y [expr {[base $l] + $k}] incr k } } Modified: trunk/examples/tcl/x08.tcl =================================================================== --- trunk/examples/tcl/x08.tcl 2011-02-19 18:28:28 UTC (rev 11571) +++ trunk/examples/tcl/x08.tcl 2011-02-21 07:39:43 UTC (rev 11572) @@ -29,7 +29,7 @@ # For center control points, pick black or white, whichever is closer to bg # Be careful to pick just short of top or bottom else hue info is lost $w cmd plgcolbg rbg gbg bbg - set vertex [expr ($rbg + $gbg + $bbg)/(3.*255.)] + set vertex [expr {($rbg + $gbg + $bbg)/(3.*255.)}] if {$vertex < 0.5} { set vertex 0.01 set midpt 0.10 @@ -89,10 +89,6 @@ proc x08 {{w loopback}} { # these should be defined elsewhere. - set MAG_COLOR 0x04 - set BASE_CONT 0x08 - set SURF_CONT 0x20 - set FACETED 0x80 set rosen 1 matrix alt f 2 = {60.0, 20.0} @@ -101,23 +97,23 @@ set xpts 35 set ypts 46 set n_col 256 - set two_pi [expr 2.0 * 3.14159265358979323846 ] + set two_pi [expr {2.0 * $::PLPLOT::PL_PI} ] matrix x f $xpts matrix y f $ypts matrix z f $xpts $ypts for {set i 0} {$i < $xpts} {incr i} { - x $i = [expr ($i - ($xpts/2)) / double($xpts/2) ] + x $i = [expr {($i - ($xpts/2)) / double($xpts/2)} ] if {$rosen == 1} { - x $i = [expr 1.5* [x $i]] + x $i = [expr {1.5* [x $i]}] } } for {set i 0} {$i < $ypts} {incr i} { - y $i = [expr ($i - ($ypts/2)) / double($ypts/2) ] + y $i = [expr {($i - ($ypts/2)) / double($ypts/2)} ] if {$rosen == 1} { - y $i = [expr 0.5 + [y $i]] + y $i = [expr {0.5 + [y $i]}] } } @@ -126,18 +122,18 @@ for {set j 0} {$j < $ypts} {incr j} { set yy [y $j] if {$rosen == 1} { - z $i $j = [expr (pow(1. - $xx,2) + \ - 100 * pow($yy - pow($xx,2),2))] + z $i $j = [expr {(pow(1. - $xx,2) + \ + 100 * pow($yy - pow($xx,2),2))}] set zz [z $i $j] if {$zz > 0.} { - z $i $j = [expr (log($zz))] + z $i $j = [expr {log($zz)}] } else { - z $i $j = [expr -5] + z $i $j = [expr {-5.0}] } } else { - set r [expr sqrt( $xx * $xx + $yy * $yy ) ] + set r [expr {sqrt( $xx * $xx + $yy * $yy )} ] - z $i $j = [expr exp(-$r * $r) * cos( $two_pi * $r ) ] + z $i $j = [expr {exp(-$r * $r) * cos( $two_pi * $r )} ] } } } @@ -179,16 +175,19 @@ # magnitude colored plot } elseif {$ifshade == 1} { cmap1_init_8 $w 0 - $w cmd plsurf3d x y z [expr $MAG_COLOR] + + # Note: the [expr] command is essential here - plsurf3d doesn't accept + # the hexadecimal form apparently! + $w cmd plsurf3d x y z [expr {$::PLPLOT::MAG_COLOR}] # magnitude colored plot with faceted squares } elseif {$ifshade == 2} { cmap1_init_8 $w 0 - $w cmd plsurf3d x y z [expr $MAG_COLOR | $FACETED] + $w cmd plsurf3d x y z [expr {$::PLPLOT::MAG_COLOR | $::PLPLOT::FACETED}] # magnitude colored plot with contours. } else { cmap1_init_8 $w 0 $w cmd plsurf3d x y z $xpts $ypts \ - [expr $MAG_COLOR | $SURF_CONT | $BASE_CONT] clev $nlev + [expr {$::PLPLOT::MAG_COLOR | $::PLPLOT::SURF_CONT | $::PLPLOT::BASE_CONT}] clev $nlev } } } Modified: trunk/examples/tcl/x09.tcl =================================================================== --- trunk/examples/tcl/x09.tcl 2011-02-19 18:28:28 UTC (rev 11571) +++ trunk/examples/tcl/x09.tcl 2011-02-21 07:39:43 UTC (rev 11572) @@ -20,11 +20,11 @@ # Calculate the data matrices. for {set i 0} {$i < $xpts} {incr i} { - set xx [expr ($i - ($xpts / 2)) / double($xpts / 2) ] + set xx [expr {($i - ($xpts / 2)) / double($xpts / 2)} ] for {set j 0} {$j < $ypts} {incr j} { - set yy [expr ($j - ($ypts / 2)) / double($ypts / 2) - 1.0 ] - zz $i $j = [expr $xx * $xx - $yy * $yy ] - ww $i $j = [expr 2. * $xx * $yy ] + set yy [expr {($j - ($ypts / 2)) / double($ypts / 2) - 1.0} ] + zz $i $j = [expr {$xx * $xx - $yy * $yy} ] + ww $i $j = [expr {2. * $xx * $yy} ] } } @@ -37,35 +37,34 @@ matrix xg2 f $xpts $ypts matrix yg2 f $xpts $ypts - set pi 3.14159265358979323846 set distort .4 # Build the 1-d coord arrays. for {set i 0} {$i < $xpts} {incr i} { - set xx [expr -1. + $i * ( 2. / ($xpts-1.) )] - xg0 $i = [expr $xx] - xg1 $i = [expr $xx + $distort * cos( .5 * $pi * $xx ) ] + set xx [expr {-1. + $i * ( 2. / ($xpts-1.) )}] + xg0 $i = [expr {$xx}] + xg1 $i = [expr {$xx + $distort * cos( .5 * $::PLPLOT::PL_PI * $xx )} ] } for {set j 0} {$j < $ypts} {incr j} { - set yy [expr -1. + $j * ( 2. / ($ypts-1.) )] - yg0 $j = [expr $yy] - yg1 $j = [expr $yy - $distort * cos( .5 * $pi * $yy ) ] + set yy [expr {-1. + $j * ( 2. / ($ypts-1.) )}] + yg0 $j = [expr {$yy}] + yg1 $j = [expr {$yy - $distort * cos( .5 * $::PLPLOT::PL_PI * $yy )} ] } # Build the 2-d coord arrays. for {set i 0} {$i < $xpts} {incr i} { - set xx [expr -1. + $i * ( 2. / ($xpts-1.) )] + set xx [expr {-1. + $i * ( 2. / ($xpts-1.) )}] for {set j 0} {$j < $ypts} {incr j} { - set yy [expr -1. + $j * ( 2. / ($ypts-1.) )] + set yy [expr {-1. + $j * ( 2. / ($ypts-1.) )}] - set argx [expr .5 * $pi * $xx] - set argy [expr .5 * $pi * $yy] + set argx [expr .5 * $::PLPLOT::PL_PI * $xx] + set argy [expr .5 * $::PLPLOT::PL_PI * $yy] - xg2 $i $j = [expr $xx + $distort * cos($argx) * cos($argy) ] - yg2 $i $j = [expr $yy - $distort * cos($argx) * cos($argy) ] + xg2 $i $j = [expr {$xx + $distort * cos($argx) * cos($argy)} ] + yg2 $i $j = [expr {$yy - $distort * cos($argx) * cos($argy)} ] } } @@ -175,7 +174,6 @@ proc x09_polar {{w loopback}} { - set pi 3.14159265358979323846 $w cmd plenv -1 1 -1 1 0 -2 $w cmd plcol0 1 @@ -183,25 +181,25 @@ matrix px f 100; matrix py f 100 for {set i 0} {$i < 100} {incr i} { - set t [expr 2. * $pi * $i / 99.] - px $i = [expr cos($t)] - py $i = [expr sin($t)] + set t [expr {2. * $::PLPLOT::PL_PI * $i / 99.}] + px $i = [expr {cos($t)}] + py $i = [expr {sin($t)}] } $w cmd plline 100 px py - set xpts 40; set ypts 40; set ylim [expr $ypts - 1]; set wrap 2 + set xpts 40; set ypts 40; set ylim [expr {$ypts - 1}]; set wrap 2 matrix xg f $xpts $ylim matrix yg f $xpts $ylim matrix z f $xpts $ylim for {set i 0} {$i < $xpts} {incr i} { - set r [expr $i / ($xpts - 1.)] + set r [expr {$i / ($xpts - 1.)}] for {set j 0} {$j < $ylim} {incr j} { - set t [expr 2. * $pi * $j / ($ypts - 1.)] + set t [expr {2. * $::PLPLOT::PL_PI * $j / ($ypts - 1.)}] - xg $i $j = [expr $r * cos($t)] - yg $i $j = [expr $r * sin($t)] + xg $i $j = [expr {$r * cos($t)}] + yg $i $j = [expr {$r * sin($t)}] z $i $j = $r } @@ -219,8 +217,7 @@ proc x09_potential {{w loopback}} { # Shielded potential contour plot example - set pi 3.14159265358979323846 - set xpts 40; set ypts 64; set ylim [expr $ypts - 1]; set wrap 2; + set xpts 40; set ypts 64; set ylim [expr {$ypts - 1}]; set wrap 2; set perimeterpts 100; set nlevel 20 # Create data to be contoured. @@ -229,9 +226,9 @@ matrix z f $xpts $ylim for {set i 0} {$i < $xpts} {incr i} { - set r [expr 0.5 + $i] + set r [expr {0.5 + $i}] for {set j 0} {$j < $ylim} {incr j} { - set theta [expr {(2. * $pi / ($ypts - 1.))*(0.5 + $j)}] + set theta [expr {(2. * $::PLPLOT::PL_PI / ($ypts - 1.))*(0.5 + $j)}] xg $i $j = [expr {$r * cos($theta)}] yg $i $j = [expr {$r * sin($theta)}] @@ -251,35 +248,35 @@ if {[yg $i $j] > $ymax} { set ymax [yg $i $j] } } } - set x0 [expr ($xmin + $xmax)/2.] - set y0 [expr ($ymin + $ymax)/2.] + set x0 [expr {($xmin + $xmax)/2.}] + set y0 [expr {($ymin + $ymax)/2.}] # Expanded limits. - set peps [expr 0.05] - set xpmin [expr $xmin - abs($xmin)*$peps] - set xpmax [expr $xmax + abs($xmax)*$peps] - set ypmin [expr $ymin - abs($ymin)*$peps] - set ypmax [expr $ymax + abs($ymax)*$peps] + set peps 0.05 + set xpmin [expr {$xmin - abs($xmin)*$peps}] + set xpmax [expr {$xmax + abs($xmax)*$peps}] + set ypmin [expr {$ymin - abs($ymin)*$peps}] + set ypmax [expr {$ymax + abs($ymax)*$peps}] # Potential inside a conducting cylinder (or sphere) by method of images. # Charge 1 is placed at (d1, d1), with image charge at (d2, d2). # Charge 2 is placed at (d1, -d1), with image charge at (d2, -d2). # Also put in smoothing term at small distances. - set eps [expr 2.] + set eps 2. - set q1 [expr 1.] - set d1 [expr $rmax/4.] + set q1 1. + set d1 [expr {$rmax/4.}] - set q1i [expr - $q1*$rmax/$d1] - set d1i [expr pow($rmax,2)/$d1] + set q1i [expr {- $q1*$rmax/$d1}] + set d1i [expr {pow($rmax,2)/$d1}] - set q2 [expr -1.] - set d2 [expr $rmax/4.] + set q2 -1. + set d2 [expr {$rmax/4.}] - set q2i [expr - $q2*$rmax/$d2] - set d2i [expr pow($rmax,2)/$d2] + set q2i [expr {- $q2*$rmax/$d2}] + set d2i [expr {pow($rmax,2)/$d2}] for {set i 0} {$i < $xpts} {incr i} { for {set j 0} {$j < $ylim} {incr j} { @@ -301,9 +298,9 @@ } # Positive and negative contour levels. - set dz [expr ($zmax-$zmin)/$nlevel] - set nlevelneg [expr 0] - set nlevelpos [expr 0] + set dz [expr {($zmax-$zmin)/$nlevel}] + set nlevelneg 0 + set nlevelpos 0 matrix clevelneg f $nlevel matrix clevelpos f $nlevel for {set i 0} {$i < $nlevel} {incr i} { @@ -316,10 +313,10 @@ } # Colours! - set ncollin [expr 11] - set ncolbox [expr 1] - set ncollab [expr 2] - + set ncollin 11 + set ncolbox 1 + set ncollab 2 + # Finally start plotting this page! $w cmd pladv 0 $w cmd plcol0 $ncolbox @@ -339,7 +336,7 @@ $w cmd pllsty 2 $w cmd plcont z levneg pltr2 xg yg $wrap } - + if {$nlevelpos >0} { # Positive contours # copy partially full clevelpos to full levpos required by plcont @@ -350,12 +347,12 @@ $w cmd pllsty 1 $w cmd plcont z levpos pltr2 xg yg $wrap } - + #Draw outer boundary matrix px f $perimeterpts matrix py f $perimeterpts for {set i 0} {$i < $perimeterpts} {incr i} { - set t [expr {(2.*$pi/($perimeterpts-1))*$i}] + set t [expr {(2.*$::PLPLOT::PL_PI/($perimeterpts-1))*$i}] px $i = [expr {$x0 + $rmax*cos($t)}] py $i = [expr {$y0 + $rmax*sin($t)}] } Modified: trunk/examples/tcl/x11.tcl =================================================================== --- trunk/examples/tcl/x11.tcl 2011-02-19 18:28:28 UTC (rev 11571) +++ trunk/examples/tcl/x11.tcl 2011-02-21 07:39:43 UTC (rev 11572) @@ -73,11 +73,7 @@ # these should be defined elsewhere. # Must use numerical rather than hex value for this one since used # inside an array -# set DRAW_LINEXY 0x03 - set DRAW_LINEXY 3 - set MAG_COLOR 0x04 - set BASE_CONT 0x08 - matrix opt i 2 = "$DRAW_LINEXY, $DRAW_LINEXY" + matrix opt i 2 = "[expr {$::PLPLOT::DRAW_LINEXY}], [expr {$::PLPLOT::DRAW_LINEXY}]" matrix alt f 2 = {33.0, 17.0} matrix az f 2 = {24.0, 115.0} @@ -145,16 +141,16 @@ # magnitude colored wireframe plot } elseif {$i == 1} { - $w cmd plmesh x y z [expr {[opt $k] | $MAG_COLOR}] + $w cmd plmesh x y z [expr {[opt $k] | $::PLPLOT::MAG_COLOR}] # magnitude colored wireframe plot with sides } elseif {$i == 2} { - $w cmd plot3d x y z [expr {[opt $k] | $MAG_COLOR}] 1 + $w cmd plot3d x y z [expr {[opt $k] | $::PLPLOT::MAG_COLOR}] 1 # magnitude colored wireframe plot with base contour } elseif {$i == 3} { $w cmd plmeshc x y z $xpts $ypts \ - [expr {[opt $k] | $MAG_COLOR | $BASE_CONT}] clev $nlev + [expr {[opt $k] | $::PLPLOT::MAG_COLOR | $::PLPLOT::BASE_CONT}] clev $nlev } $w cmd plcol0 3 Modified: trunk/examples/tcl/x12.tcl =================================================================== --- trunk/examples/tcl/x12.tcl 2011-02-19 18:28:28 UTC (rev 11571) +++ trunk/examples/tcl/x12.tcl 2011-02-21 07:39:43 UTC (rev 11572) @@ -25,20 +25,20 @@ $w cmd plscmap1l 1 5 pos red green blue rev for {set i 0} {$i < 10} {incr i} { -# $w cmd plcol0 [expr $i+1] +# $w cmd plcol0 [expr {$i+1}] - $w cmd plcol1 [expr ($i / 9.0) ] + $w cmd plcol1 [expr {$i / 9.0} ] $w cmd plpsty 0 - plfbox $w [expr 1980. + $i] [y0 $i] + plfbox $w [expr {1980. + $i}] [y0 $i] set string [format "%.0f" [y0 $i] ] - $w cmd plptex [expr 1980. + $i + .5] [expr [y0 $i] + 1.] \ + $w cmd plptex [expr {1980. + $i + .5}] [expr {[y0 $i] + 1.}] \ 1.0 0.0 .5 $string - set string [format "%d" [expr 1980 + $i] ] - $w cmd plmtex "b" 1.0 [expr ($i + 1) * .1 - .05] 0.5 $string + set string [format "%d" [expr {1980 + $i}] ] + $w cmd plmtex "b" 1.0 [expr {($i + 1) * .1 - .05}] 0.5 $string } # Restore defaults # $w cmd plcol0 1 @@ -48,14 +48,14 @@ matrix x f 4; matrix y f 4 - x 0 = $x0; - y 0 = 0.; - x 1 = $x0; - y 1 = $y0; - x 2 = [expr $x0 + 1.]; - y 2 = $y0; - x 3 = [expr $x0 + 1.]; - y 3 = 0.; + x 0 = $x0 + y 0 = 0. + x 1 = $x0 + y 1 = $y0 + x 2 = [expr {$x0 + 1.}] + y 2 = $y0 + x 3 = [expr {$x0 + 1.}] + y 3 = 0. $w cmd plfill 4 x y $w cmd plcol0 1 $w cmd pllsty 1 Modified: trunk/examples/tcl/x13.tcl =================================================================== --- trunk/examples/tcl/x13.tcl 2011-02-19 18:28:28 UTC (rev 11571) +++ trunk/examples/tcl/x13.tcl 2011-02-21 07:39:43 UTC (rev 11572) @@ -27,9 +27,8 @@ $w cmd plcol0 2 set theta0 0. - set pi 3.14159265358979323846 - set factor [expr {2. * $pi / 500.}] + set factor [expr {2. * $::PLPLOT::PL_PI / 500.}] set dthet 1.0 for {set i 0} {$i <= 4} {incr i} { set j 0 @@ -50,7 +49,7 @@ } $w cmd plcol0 [expr {$i + 1}] - $w cmd plpsty [expr {(($i + 3) % 8 + 1)}] + $w cmd plpsty [expr {($i + 3) % 8 + 1}] $w cmd plfill $j x y $w cmd plcol0 1 $w cmd plline $j x y Modified: trunk/examples/tcl/x14.tcl =================================================================== --- trunk/examples/tcl/x14.tcl 2011-02-19 18:28:28 UTC (rev 11571) +++ trunk/examples/tcl/x14.tcl 2011-02-21 07:39:43 UTC (rev 11572) @@ -9,7 +9,7 @@ # Set up first stream $w cmd plsetopt "geometry" $geometry_master - + $w cmd plssub 2 2 $w cmd plinit @@ -18,13 +18,13 @@ puts "Demo of multiple output streams via the $driver driver." puts "Running with the second stream as slave to the first." puts "" - + # Start next stream $w cmd plsstrm 1 - + # Turn off pause to make this a slave (must follow master) - + $w cmd plsetopt "geometry" $geometry_slave $w cmd plspause 0 if {$driver != ""} { @@ -33,10 +33,10 @@ $w cmd plsfam $fam $num $bmax $w cmd plsetopt "fflen" "2" $w cmd plinit - + # Set up the data & plot # Original case - + $w cmd plsstrm 0 set xscale 6.0 @@ -51,51 +51,51 @@ set xscale 1. set yscale 1.e+6 plot141 $w - + # Set up the data & plot - + set xscale 1. set yscale 1.e-6 set digmax 2 $w cmd plsyax digmax 0 plot141 $w - + # Set up the data & plot - + set xscale 1. set yscale 0.0014 set yoff 0.0185 set digmax 5 $w cmd plsyax digmax 0 plot141 $w - + # To slave # The pleop() ensures the eop indicator gets lit. $w cmd plsstrm 1 plot144 $w - $w cmd pleop - + $w cmd pleop + # Back to master - + $w cmd plsstrm 0 plot142 $w plot143 $w - + # To slave */ $w cmd plsstrm 1 plot145 $w - - $w cmd pleop - + + $w cmd pleop + # Back to master to wait for user to advance - + $w cmd plsstrm 0 $w cmd pleop - + # Call plend to finish off. - + $w cmd plend } @@ -109,20 +109,20 @@ matrix y f $npts for {set i 0} {$i < $npts} {incr i} { - x $i = [expr $xoff + ($xscale * ($i + 1)) / $npts] - y $i = [expr $yoff + $yscale * pow([x $i],2)] + x $i = [expr {$xoff + ($xscale * ($i + 1)) / $npts}] + y $i = [expr {$yoff + $yscale * pow([x $i],2)}] } - set xmin [x [expr 0]] - set xmax [x [expr $npts-1]] - set ymin [y [expr 0]] - set ymax [y [expr $npts-1]] + set xmin [x 0] + set xmax [x [expr {$npts-1}]] + set ymin [y 0] + set ymax [y [expr {$npts-1}]] matrix x1 f 6 matrix y1 f 6 for {set i 0} {$i < 6} {incr i} { - set j [expr $i*10+3] + set j [expr {$i*10+3}] x1 $i = [x $j] y1 $i = [y $j] } @@ -158,10 +158,10 @@ matrix y1 f 101 for {set i 0} {$i < 100} {incr i} { - set x [expr ($i - 19.)/6.] + set x [expr {($i - 19.)/6.}] x1 $i = $x y1 $i = 1 - if {$x != 0} { y1 $i = [expr sin($x)/$x] } + if {$x != 0} { y1 $i = [expr {sin($x)/$x}] } } $w cmd plcol0 3 @@ -173,7 +173,6 @@ proc plot143 {w} { - set pi 3.14159265358979323846 $w cmd pladv 0 $w cmd plvsta $w cmd plwind 0.0 360.0 -1.2 1.2 @@ -183,7 +182,7 @@ $w cmd plcol0 1 $w cmd plbox "bcnst" 60.0 2 "bcnstv" 0.2 2 -# Superimpose a dashed line grid, with 1.5 mm marks and spaces. +# Superimpose a dashed line grid, with 1.5 mm marks and spaces. # plstyl expects two integer matrices for mark and space! matrix mark i 1 @@ -208,7 +207,7 @@ for {set i 0} {$i < 101} {incr i} { x $i = [expr 3.6 * $i] - y $i = [expr sin([x $i] * $pi / 180.0)] + y $i = [expr sin([x $i] * $::PLPLOT::PL_PI / 180.0)] } $w cmd plcol0 4 @@ -218,8 +217,8 @@ # This is supposed to work like example 3. proc plot144 {w} { - set twopi [expr 2. * 3.14159265358979323846] -# Set up viewport and window, but do not draw box + set twopi [expr {2. * $::PLPLOT::PL_PI}] +# Set up viewport and window, but do not draw box $w cmd plenv -1.3 1.3 -1.3 1.3 1 -2 @@ -227,20 +226,20 @@ set ni 10 set nj 360 - set nj1 [expr $nj + 1] + set nj1 [expr {$nj + 1}] - set dr [expr 1. / $ni] - set dtheta [expr $twopi / $nj] + set dr [expr {1. / $ni}] + set dtheta [expr {$twopi / $nj}] matrix xj f $nj1 matrix yj f $nj1 for {set i 1} {$i <= $ni} {incr i} { for {set j 0} {$j < $nj1} {incr j} { - set r [expr $i * $dr] - set theta [expr $j * $dtheta] - xj $j = [expr $r * cos($theta)] - yj $j = [expr $r * sin($theta)] + set r [expr {$i * $dr}] + set theta [expr {$j * $dtheta}] + xj $j = [expr {$r * cos($theta)}] + yj $j = [expr {$r * sin($theta)}] } $w cmd plline $nj1 xj yj } @@ -249,9 +248,9 @@ $w cmd plcol0 2 for {set j 0} {$j <= 11} {incr j} { - set theta [expr $j * $twopi / 12.] - set xg [expr cos($theta)] - set yg [expr sin($theta)] + set theta [expr {$j * $twopi / 12.}] + set xg [expr {cos($theta)}] + set yg [expr {sin($theta)}] $w cmd pljoin 0.0 0.0 $xg $yg # Slightly off zero to avoid floating point logic flips at 90 and 270 deg. @@ -260,33 +259,33 @@ set dy $yg set just -0.15 } else { - set dx [expr -$xg] - set dy [expr -$yg] + set dx [expr {-$xg}] + set dy [expr {-$yg}] set just 1.15 } - set label [expr round($theta*360./$twopi)] + set label [expr {round($theta*360./$twopi)}] -# N.B. cannot get this command to give same postscript output. Also visual +# N.B. cannot get this command to give same postscript output. Also visual # inspection shows 90 deg label jumping around slightly compared to python # and C front ends. No idea why (AWI comment). $w cmd plptex $xg $yg $dx $dy $just $label } -# Draw the graph +# Draw the graph set npts 360 - set npts1 [expr $npts+1] + set npts1 [expr {$npts+1}] - set dtheta [expr $twopi / $npts] + set dtheta [expr {$twopi / $npts}] matrix x f $npts1 matrix y f $npts1 for {set j 0} {$j <= $npts} {incr j} { - set theta [expr $j * $dtheta] - set r [expr sin(5 * $theta)] - x $j = [expr $r * cos($theta)] - y $j = [expr $r * sin($theta)] + set theta [expr {$j * $dtheta}] + set r [expr {sin(5 * $theta)}] + x $j = [expr {$r * cos($theta)}] + y $j = [expr {$r * sin($theta)}] } $w cmd plcol0 3 $w cmd plline $npts1 x y @@ -312,11 +311,11 @@ # Calculate the data matrices. for {set i 0} {$i < $xpts} {incr i} { - set xx [expr ($i - ($xpts / 2)) / double($xpts / 2) ] + set xx [expr {($i - ($xpts / 2)) / double($xpts / 2)} ] for {set j 0} {$j < $ypts} {incr j} { - set yy [expr ($j - ($ypts / 2)) / double($ypts / 2) - 1.0 ] - zz $i $j = [expr $xx * $xx - $yy * $yy ] - ww $i $j = [expr 2. * $xx * $yy ] + set yy [expr {($j - ($ypts / 2)) / double($ypts / 2) - 1.0} ] + zz $i $j = [expr {$xx * $xx - $yy * $yy} ] + ww $i $j = [expr {2. * $xx * $yy} ] } } @@ -326,13 +325,13 @@ # Build the 1-d coord arrays. for {set i 0} {$i < $xpts} {incr i} { - set xx [expr -1. + $i * ( 2. / ($xpts-1.) )] - xg0 $i = [expr $xx] + set xx [expr {-1. + $i * ( 2. / ($xpts-1.) )}] + xg0 $i = $xx } for {set j 0} {$j < $ypts} {incr j} { - set yy [expr -1. + $j * ( 2. / ($ypts-1.) )] - yg0 $j = [expr $yy] + set yy [expr {-1. + $j * ( 2. / ($ypts-1.) )}] + yg0 $j = $yy } # Plot using scaled identity transformation used to create Modified: trunk/examples/tcl/x16.tcl =================================================================== --- trunk/examples/tcl/x16.tcl 2011-02-19 18:28:28 UTC (rev 11571) +++ trunk/examples/tcl/x16.tcl 2011-02-21 07:39:43 UTC (rev 11572) @@ -10,7 +10,6 @@ set nx 35 set ny 46 - set pi 3.14159265358979323846 set fill_width 2; set cont_color 0; set cont_width 0 matrix clevel f $ns @@ -57,12 +56,12 @@ for {set i 0} {$i < $nx} {incr i} { set xx [expr {-1. + $i * ( 2. / ($nx-1.) )}] - xg1 $i = [expr {$xx + $distort * cos( .5 * $pi * $xx )} ] + xg1 $i = [expr {$xx + $distort * cos( .5 * $::PLPLOT::PL_PI * $xx )} ] } for {set j 0} {$j < $ny} {incr j} { set yy [expr {-1. + $j * ( 2. / ($ny-1.) )}] - yg1 $j = [expr {$yy - $distort * cos( .5 * $pi * $yy )} ] + yg1 $j = [expr {$yy - $distort * cos( .5 * $::PLPLOT::PL_PI * $yy )} ] } # Build the 2-d coord arrays. @@ -72,8 +71,8 @@ for {set j 0} {$j < $ny} {incr j} { set yy [expr {-1. + $j * ( 2. / ($ny-1.) )}] - set argx [expr {.5 * $pi * $xx}] - set argy [expr {.5 * $pi * $yy}] + set argx [expr {.5 * $::PLPLOT::PL_PI * $xx}] + set argy [expr {.5 * $::PLPLOT::PL_PI * $yy}] xg2 $i $j = [expr {$xx + $distort * cos($argx) * cos($argy)} ] yg2 $i $j = [expr {$yy - $distort * cos($argx) * cos($argy)} ] @@ -181,12 +180,12 @@ for {set i 0} {$i < $nx} {incr i} { set r [expr {$i / ($nx - 1.)}] for {set j 0} {$j < $nylim} {incr j} { - set t [expr {2. * $pi * $j / ($ny - 1.)}] + set t [expr {2. * $::PLPLOT::PL_PI * $j / ($ny - 1.)}] xg $i $j = [expr {$r * cos($t)}] yg $i $j = [expr {$r * sin($t)}] - z $i $j = [expr {exp(-$r*$r) * cos(5.*$t) * cos(5.*$pi*$r)} ] + z $i $j = [expr {exp(-$r*$r) * cos(5.*$t) * cos(5.*$::PLPLOT::PL_PI*$r)} ] } } @@ -219,7 +218,7 @@ matrix px f 100; matrix py f 100 for {set i 0} {$i < 100} {incr i} { - set t [expr {2. * $pi * $i / 99.}] + set t [expr {2. * $::PLPLOT::PL_PI * $i / 99.}] px $i = [expr {cos($t)}] py $i = [expr {sin($t)}] } Modified: trunk/examples/tcl/x17.tcl =================================================================== --- trunk/examples/tcl/x17.tcl 2011-02-19 18:28:28 UTC (rev 11571) +++ trunk/examples/tcl/x17.tcl 2011-02-21 07:39:43 UTC (rev 11572) @@ -40,7 +40,6 @@ # The plot will grow automatically if needed (but not shrink) set nsteps 1000 - set PI [expr {acos(-1.0)}] set ymin -0.1 set ymax 0.1 @@ -103,7 +102,7 @@ set t [expr {double($n) * $dt}] set noise [expr {[$w cmd plrandd] - 0.5}] set y1 [expr {$y1 + $noise}] - set y2 [expr {sin($t*$PI/18.)}] + set y2 [expr {sin($t*$::PLPLOT::PL_PI/18.)}] set y3 [expr {$y2 * $noise}] set y4 [expr {$y2 + $noise/3.}] Modified: trunk/examples/tcl/x18.tcl =================================================================== --- trunk/examples/tcl/x18.tcl 2011-02-19 18:28:28 UTC (rev 11571) +++ trunk/examples/tcl/x18.tcl 2011-02-21 07:39:43 UTC (rev 11572) @@ -9,7 +9,6 @@ matrix az f 4 = {30.0, 40.0, 50.0, 60.0} set npts 1000 - set pi 3.14159265358979323846 for {set k 0} {$k < 4} {incr k} { test_poly $w $k @@ -22,15 +21,15 @@ # From the mind of a sick and twisted physicist... for {set i 0} {$i < $npts} {incr i} { - z $i = [expr -1. + 2. * $i / $npts] + z $i = [expr {-1. + 2. * $i / $npts}] -# Pick one ... +# Pick one ... # r = 1. - ( (float) i / (float) NPTS ); set r [z $i] - x $i = [expr $r * cos( 2. * $pi * 6. * $i / $npts )] - y $i = [expr $r * sin( 2. * $pi * 6. * $i / $npts )] + x $i = [expr {$r * cos( 2. * $::PLPLOT::PL_PI * 6. * $i / $npts )}] + y $i = [expr {$r * sin( 2. * $::PLPLOT::PL_PI * 6. * $i / $npts )}] } for {set k 0} {$k < 4} {incr k} { @@ -67,7 +66,7 @@ matrix draw2 i 4 = { 0, 1, 0, 1 } matrix draw3 i 4 = { 1, 1, 0, 0 } - set pi 3.14159265358979323846; set two_pi [expr 2. * $pi] + set pi $::PLPLOT::PL_PI; set two_pi [expr {2. * $pi}] matrix x f 5 matrix y f 5 @@ -94,25 +93,25 @@ for {set i 0} {$i < 20} {incr i} { for {set j 0} {$j < 20} {incr j} { - x 0 = [expr sin( $pi * $j / 20.1 ) * cos( $two_pi * $i / 20 )] - y 0 = [expr sin( $pi * $j / 20.1 ) * sin( $two_pi * $i / 20 )] - z 0 = [expr cos( $pi * $j / 20.1 )] + x 0 = [expr {sin( $pi * $j / 20.1 ) * cos( $two_pi * $i / 20 )}] + y 0 = [expr {sin( $pi * $j / 20.1 ) * sin( $two_pi * $i / 20 )}] + z 0 = [expr {cos( $pi * $j / 20.1 )}] - x 1 = [expr sin( $pi * ($j+1) / 20.1 ) * cos( $two_pi * $i / 20 )] - y 1 = [expr sin( $pi * ($j+1) / 20.1 ) * sin( $two_pi * $i / 20 )] - z 1 = [expr cos( $pi * ($j+1) / 20.1 )] + x 1 = [expr {sin( $pi * ($j+1) / 20.1 ) * cos( $two_pi * $i / 20 )}] + y 1 = [expr {sin( $pi * ($j+1) / 20.1 ) * sin( $two_pi * $i / 20 )}] + z 1 = [expr {cos( $pi * ($j+1) / 20.1 )}] - x 2 = [expr sin($pi * ($j+1) / 20.1) * cos($two_pi * ($i+1) / 20)] - y 2 = [expr sin($pi * ($j+1) / 20.1) * sin($two_pi * ($i+1) / 20)] - z 2 = [expr cos($pi * ($j+1) / 20.1)] + x 2 = [expr {sin($pi * ($j+1) / 20.1) * cos($two_pi * ($i+1) / 20)}] + y 2 = [expr {sin($pi * ($j+1) / 20.1) * sin($two_pi * ($i+1) / 20)}] + z 2 = [expr {cos($pi * ($j+1) / 20.1)}] - x 3 = [expr sin( $pi * $j / 20.1 ) * cos( $two_pi * ($i+1) / 20 )] - y 3 = [expr sin( $pi * $j / 20.1 ) * sin( $two_pi * ($i+1) / 20 )] - z 3 = [expr cos( $pi * $j / 20.1 )] + x 3 = [expr {sin( $pi * $j / 20.1 ) * cos( $two_pi * ($i+1) / 20 )}] + y 3 = [expr {sin( $pi * $j / 20.1 ) * sin( $two_pi * ($i+1) / 20 )}] + z 3 = [expr {cos( $pi * $j / 20.1 )}] - x 4 = [expr sin( $pi * $j / 20.1 ) * cos( $two_pi * $i / 20 )] - y 4 = [expr sin( $pi * $j / 20.1 ) * sin( $two_pi * $i / 20 )] - z 4 = [expr cos( $pi * $j / 20.1 )] + x 4 = [expr {sin( $pi * $j / 20.1 ) * cos( $two_pi * $i / 20 )}] + y 4 = [expr {sin( $pi * $j / 20.1 ) * sin( $two_pi * $i / 20 )}] + z 4 = [expr {cos( $pi * $j / 20.1 )}] $w cmd plpoly3 5 x y z draw$k 1 } Modified: trunk/examples/tcl/x19.tcl =================================================================== --- trunk/examples/tcl/x19.tcl 2011-02-19 18:28:28 UTC (rev 11571) +++ trunk/examples/tcl/x19.tcl 2011-02-21 07:39:43 UTC (rev 11572) @@ -44,7 +44,7 @@ proc mapform19 {n matx maty} { - set deg_to_rad [expr {acos(-1.0)/180.0}] + set deg_to_rad [expr {$::PLPLOT::PL_PI/180.0}] for {set i 0} {$i < $n} {incr i} { set x [$matx $i] @@ -180,7 +180,7 @@ $w cmd plssym 0. 1. $w cmd plptex -76.6125 43. 0.0 0.0 0.0 "Baltimore, MD" - + $w cmd plstransform NULL $w cmd pllsty 1 Modified: trunk/examples/tcl/x20.tcl =================================================================== --- trunk/examples/tcl/x20.tcl 2011-02-19 18:28:28 UTC (rev 11571) +++ trunk/examples/tcl/x20.tcl 2011-02-21 07:39:43 UTC (rev 11572) @@ -70,7 +70,7 @@ proc x20 {{w loopback}} { - set PI [expr {4.0*atan(1.0)}] + set PI $::PLPLOT::PL_PI set XDIM 260 set YDIM 220 Modified: trunk/examples/tcl/x21.tcl =================================================================== --- trunk/examples/tcl/x21.tcl 2011-02-19 18:28:28 UTC (rev 11571) +++ trunk/examples/tcl/x21.tcl 2011-02-21 07:39:43 UTC (rev 11572) @@ -27,19 +27,8 @@ proc x21 {{w loopback}} { - set PI [expr {4.0*atan(1.0)}] + set PI $::PLPLOT::PL_PI - set GRID_CSA 1 - set GRID_DTLI 2 - set GRID_NNI 3 - set GRID_NNIDW 4 - set GRID_NNLI 5 - set GRID_NNAIDW 6 - - set DRAW_LINEXY 3 - set MAG_COLOR 4 - set BASE_CONT 8 - set pts 500 set xp 25 set yp 20 @@ -141,8 +130,8 @@ # the neighbors is done. # - if {($alg == $GRID_CSA) || ($alg == $GRID_DTLI) || - ($alg == $GRID_NNLI) || ($alg == $GRID_NNI)} { + if {($alg == $::PLPLOT::GRID_CSA) || ($alg == $::PLPLOT::GRID_DTLI) || + ($alg == $::PLPLOT::GRID_NNLI) || ($alg == $::PLPLOT::GRID_NNI)} { for {set i 0} {$i < $xp} {incr i} { for {set j 0} {$j < $yp} {incr j} { @@ -225,7 +214,7 @@ $w cmd plcol0 15 $w cmd pllab "" "" [lindex $title $alg] $w cmd plot3dc xg yg zg $xp $yp \ - [expr {$DRAW_LINEXY|$MAG_COLOR|$BASE_CONT}] clev $nl + [expr {$::PLPLOT::DRAW_LINEXY|$::PLPLOT::MAG_COLOR|$::PLPLOT::BASE_CONT}] clev $nl } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |