From: <and...@us...> - 2008-08-21 11:18:00
|
Revision: 8695 http://plplot.svn.sourceforge.net/plplot/?rev=8695&view=rev Author: andrewross Date: 2008-08-21 11:18:09 +0000 (Thu, 21 Aug 2008) Log Message: ----------- Add tcl version of example 28. Modified Paths: -------------- trunk/examples/tcl/CMakeLists.txt trunk/examples/tcl/tcldemos.tcl trunk/plplot_test/test_tcl.sh.in Added Paths: ----------- trunk/examples/tcl/x28 trunk/examples/tcl/x28.tcl Modified: trunk/examples/tcl/CMakeLists.txt =================================================================== --- trunk/examples/tcl/CMakeLists.txt 2008-08-21 00:03:03 UTC (rev 8694) +++ trunk/examples/tcl/CMakeLists.txt 2008-08-21 11:18:09 UTC (rev 8695) @@ -54,6 +54,7 @@ "25" "26" "27" +"28" ) set(tcl_SCRIPTS) Modified: trunk/examples/tcl/tcldemos.tcl =================================================================== --- trunk/examples/tcl/tcldemos.tcl 2008-08-21 00:03:03 UTC (rev 8694) +++ trunk/examples/tcl/tcldemos.tcl 2008-08-21 11:18:09 UTC (rev 8695) @@ -33,7 +33,7 @@ # restore defaults plcol0 1 proc $i {} "$demo" -for {set i 24} {$i <= 27} {incr i} { +for {set i 24} {$i <= 28} {incr i} { set demo x[format "%02d" $i] source $demo.tcl # restore defaults Added: trunk/examples/tcl/x28 =================================================================== --- trunk/examples/tcl/x28 (rev 0) +++ trunk/examples/tcl/x28 2008-08-21 11:18:09 UTC (rev 8695) @@ -0,0 +1,19 @@ +#!/bin/sh +#--------------------------------*- Tcl -*------------------------------------# +# $Id:$ +# +# Maurice LeBrun +# 12/24/02 +# +# A front-end to x28.tcl for running directly from the command line, locating +# pltcl via PATH. +# Handles all usual plplot command arguments. See "pltcl -h" for info. +#-----------------------------------------------------------------------------# +#\ +exec pltcl -f "$0" ${1+"$@"} + +source x28.tcl + +plinit +x28 +plend Property changes on: trunk/examples/tcl/x28 ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/examples/tcl/x28.tcl =================================================================== --- trunk/examples/tcl/x28.tcl (rev 0) +++ trunk/examples/tcl/x28.tcl 2008-08-21 11:18:09 UTC (rev 8695) @@ -0,0 +1,368 @@ +# $Id$ +# +# plmtex3, plptex3 demo. +# +# Copyright (C) 2007 Alan W. Irwin +# +# This file is part of PLplot. +# +# PLplot is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Library Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# PLplot is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with PLplot; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# + +# +# Demonstrates plotting text in 3D. +# + +proc x28 {{w loopback}} { + + # Choose these values to correspond to tick marks. + set XPTS 2 + set YPTS 2 + set NREVOLUTION 16 + set NROTATION 8 + set NSHEAR 8 + + set pi 3.14159265358979323846 + + set DRAW_LINEXY 3 + + set xmin 0. + set xmax 1.0 + set xmid [expr {0.5*($xmax + $xmin)}] + set xrange [expr {$xmax - $xmin}] + set ymin 0. + set ymax 1.0 + set ymid [expr {0.5*($ymax + $ymin)}] + set yrange [expr {$ymax - $ymin}] + set zmin 0. + set zmax 1.0 + set zmid [expr {0.5*($zmax + $zmin)}] + set zrange [expr {$zmax - $zmin}] + + # p1string must be exactly one character + the null termination + # character. + set p1string "O" + set pstring "The future of our civilization depends on software freedom." + # Allocate and define the minimal x, y, and z to insure 3D box + matrix x f $XPTS + matrix y f $YPTS + matrix z f $XPTS $YPTS + + for {set i 0} {$i < $XPTS} {incr i} { + x $i = [expr {$xmin + double($i) * ($xmax-$xmin)/ double($XPTS-1)}] + } + + for {set j 0} {$j < $YPTS} {incr j} { + y $j = [expr {$ymin + double($j) * ($ymax-$ymin)/ double($YPTS-1)}] + } + + for {set i 0} {$i < $XPTS} {incr i} { + for {set j 0} {$j < $YPTS} {incr j} { + z $i $j = 0. + } + } + + # Page 1: Demonstrate inclination and shear capability pattern. + + $w cmd pladv 0 + $w cmd plvpor -0.15 1.15 -0.05 1.05 + $w cmd plwind -1.2 1.2 -0.8 1.5 + $w cmd plw3d 1.0 1.0 1.0 $xmin $xmax $ymin $ymax $zmin $zmax 20. 45. + + $w cmd plcol0 2 + $w cmd plbox3 "b" "" [expr {$xmax-$xmin}] 0 \ + "b" "" [expr {$ymax-$ymin}] 0 \ + "bcd" "" [expr {$zmax-$zmin}] 0 + + # z = zmin. + $w cmd plschr 0. 1.0 + for {set i 0} {$i < $NREVOLUTION} {incr i} { + set omega [expr {2.*$pi*double($i)/double($NREVOLUTION)}] + set sin_omega [expr {sin($omega)}] + set cos_omega [expr {cos($omega)}] + set x_inclination [expr {0.5*$xrange*$cos_omega}] + set y_inclination [expr {0.5*$yrange*$sin_omega}] + set z_inclination 0. + set x_shear [expr {-0.5*$xrange*$sin_omega}] + set y_shear [expr {0.5*$yrange*$cos_omega}] + set z_shear 0. + $w cmd plptex3 \ + $xmid $ymid $zmin \ + $x_inclination $y_inclination $z_inclination \ + $x_shear $y_shear $z_shear \ + 0.0 " revolution" + } + + # x = xmax. + $w cmd plschr 0. 1.0 + for {set i 0} {$i < $NREVOLUTION} {incr i} { + set omega [expr {2.*$pi*double($i)/double($NREVOLUTION)}] + set sin_omega [expr {sin($omega)}] + set cos_omega [expr {cos($omega)}] + set x_inclination 0. + set y_inclination [expr {-0.5*$yrange*$cos_omega}] + set z_inclination [expr {0.5*$zrange*$sin_omega}] + set x_shear 0. + set y_shear [expr {0.5*$yrange*$sin_omega}] + set z_shear [expr {0.5*$zrange*$cos_omega}] + $w cmd plptex3 \ + $xmax $ymid $zmid \ + $x_inclination $y_inclination $z_inclination \ + $x_shear $y_shear $z_shear \ + 0.0 " revolution" + } + + # y = ymax. + $w cmd plschr 0., 1.0 + for {set i 0} {$i < $NREVOLUTION} {incr i} { + set omega [expr {2.*$pi*double($i)/double($NREVOLUTION)}] + set sin_omega [expr {sin($omega)}] + set cos_omega [expr {cos($omega)}] + set x_inclination [expr {0.5*$xrange*$cos_omega}] + set y_inclination 0. + set z_inclination [expr {0.5*$zrange*$sin_omega}] + set x_shear [expr {-0.5*$xrange*$sin_omega}] + set y_shear 0. + set z_shear [expr {0.5*$zrange*$cos_omega}] + $w cmd plptex3 \ + $xmid $ymax $zmid \ + $x_inclination $y_inclination $z_inclination \ + $x_shear $y_shear $z_shear \ + 0.0 " revolution" + } + # Draw minimal 3D grid to finish defining the 3D box. + $w cmd plmesh x y z $XPTS $YPTS $DRAW_LINEXY + + # Page 2: Demonstrate rotation of string around its axis. + $w cmd pladv 0 + $w cmd plvpor -0.15 1.15 -0.05 1.05 + $w cmd plwind -1.2 1.2 -0.8 1.5 + $w cmd plw3d 1.0 1.0 1.0 $xmin $xmax $ymin $ymax $zmin $zmax 20. 45. + + $w cmd plcol0 2 + $w cmd plbox3 "b" "" [expr {$xmax-$xmin}] 0 \ + "b" "" [expr {$ymax-$ymin}] 0 \ + "bcd" "" [expr {$zmax-$zmin}] 0 + + # y = ymax. + $w cmd plschr 0. 1.0 + set x_inclination 1. + set y_inclination 0. + set z_inclination 0. + set x_shear 0. + for {set i 0} {$i < $NROTATION} {incr i} { + set omega [expr {2.*$pi*double($i)/double($NROTATION)}] + set sin_omega [expr {sin($omega)}] + set cos_omega [expr {cos($omega)}] + set y_shear [expr {0.5*$yrange*$sin_omega}] + set z_shear [expr {0.5*$zrange*$cos_omega}] + $w cmd plptex3 \ + $xmid $ymax [expr {$zmax -($zmax-0.2)*double($i)/double($NROTATION-1)}] \ + $x_inclination $y_inclination $z_inclination \ + $x_shear $y_shear $z_shear \ + 0.5 "rotation for y = y#dmax#u" + } + + # x = xmax. + $w cmd plschr 0. 1.0 + set x_inclination 0. + set y_inclination -1. + set z_inclination 0. + set y_shear 0. + for {set i 0} {$i < $NROTATION} {incr i} { + set omega [expr {2.*$pi*double($i)/double($NROTATION)}] + set sin_omega [expr {sin($omega)}] + set cos_omega [expr {cos($omega)}] + set x_shear [expr {0.5*$xrange*$sin_omega}] + set z_shear [expr {0.5*$zrange*$cos_omega}] + $w cmd plptex3 \ + $xmax $ymid [expr {$zmax -($zmax-0.2)*double($i)/double($NROTATION-1)}] \ + $x_inclination $y_inclination $z_inclination \ + $x_shear $y_shear $z_shear \ + 0.5 "rotation for x = x#dmax#u" + } + + # z = zmin. + $w cmd plschr 0. 1.0 + set x_inclination 1. + set y_inclination 0. + set z_inclination 0. + set x_shear 0. + for {set i 0} {$i < $NROTATION} {incr i} { + set omega [expr {2.*$pi*double($i)/double($NROTATION)}] + set sin_omega [expr {sin($omega)}] + set cos_omega [expr {cos($omega)}] + set y_shear [expr {0.5*$yrange*$cos_omega}] + set z_shear [expr {0.5*$zrange*$sin_omega}] + $w cmd plptex3 \ + $xmid [expr {$ymax -($ymax-0.2)*double($i)/double($NROTATION-1)}] $zmin \ + $x_inclination $y_inclination $z_inclination \ + $x_shear $y_shear $z_shear \ + 0.5 "rotation for z = z#dmin#u" + } + # Draw minimal 3D grid to finish defining the 3D box. + $w cmd plmesh x y z $XPTS $YPTS $DRAW_LINEXY + + # Page 3: Demonstrate shear of string along its axis. + # Work around xcairo and pngcairo (but not pscairo) problems for + # shear vector too close to axis of string. (N.B. no workaround + # would be domega = 0.) + set domega 0.05 + $w cmd pladv 0 + $w cmd plvpor -0.15 1.15 -0.05 1.05 + $w cmd plwind -1.2 1.2 -0.8 1.5 + $w cmd plw3d 1.0 1.0 1.0 $xmin $xmax $ymin $ymax $zmin $zmax 20. 45. + + $w cmd plcol0 2 + $w cmd plbox3 "b" "" [expr {$xmax-$xmin}] 0 \ + "b" "" [expr {$ymax-$ymin}] 0 \ + "bcd" "" [expr {$zmax-$zmin}] 0 + + # y = ymax. + $w cmd plschr 0. 1.0 + set x_inclination 1. + set y_inclination 0. + set z_inclination 0. + set y_shear 0. + for {set i 0} {$i < $NSHEAR} {incr i} { + set omega [expr {$domega + 2.*$pi*double($i)/double($NSHEAR)}] + set sin_omega [expr {sin($omega)}] + set cos_omega [expr {cos($omega)}] + set x_shear [expr {0.5*$xrange*$sin_omega}] + set z_shear [expr {0.5*$zrange*$cos_omega}] + $w cmd plptex3 \ + $xmid $ymax [expr {$zmax -($zmax-0.2)*double($i)/double($NSHEAR-1)}] \ + $x_inclination $y_inclination $z_inclination \ + $x_shear $y_shear $z_shear \ + 0.5 "shear for y = y#dmax#u" + } + + # x = xmax. + $w cmd plschr 0. 1.0 + set x_inclination 0. + set y_inclination -1. + set z_inclination 0. + set x_shear 0. + for {set i 0} {$i < $NSHEAR} {incr i} { + set omega [expr {$domega + 2.*$pi*double($i)/double($NSHEAR)}] + set sin_omega [expr {sin($omega)}] + set cos_omega [expr {cos($omega)}] + set y_shear [expr {-0.5*$yrange*$sin_omega}] + set z_shear [expr {0.5*$zrange*$cos_omega}] + $w cmd plptex3 \ + $xmax $ymid [expr {$zmax -($zmax-0.2)*double($i)/double($NSHEAR-1)}] \ + $x_inclination $y_inclination $z_inclination \ + $x_shear $y_shear $z_shear \ + 0.5 "shear for x = x#dmax#u" + } + + # z = zmin. + $w cmd plschr 0. 1.0 + set x_inclination 1. + set y_inclination 0. + set z_inclination 0. + set z_shear 0. + for {set i 0} {$i < $NSHEAR} {incr i} { + set omega [expr {$domega + 2.*$pi*double($i)/double($NSHEAR)}] + set sin_omega [expr {sin($omega)}] + set cos_omega [expr {cos($omega)}] + set y_shear [expr {0.5*$yrange*$cos_omega}] + set x_shear [expr {0.5*$xrange*$sin_omega}] + $w cmd plptex3 \ + $xmid [expr {$ymax -($ymax-0.2)*double($i)/double($NSHEAR-1)}] $zmin \ + $x_inclination $y_inclination $z_inclination \ + $x_shear $y_shear $z_shear \ + 0.5 "shear for z = z#dmin#u" + } + # Draw minimal 3D grid to finish defining the 3D box. + $w cmd plmesh x y z $XPTS $YPTS $DRAW_LINEXY + + # Page 4: Demonstrate drawing a string on a 3D path. + $w cmd pladv 0 + $w cmd plvpor -0.15 1.15 -0.05 1.05 + $w cmd plwind -1.2 1.2 -0.8 1.5 + $w cmd plw3d 1.0 1.0 1.0 $xmin $xmax $ymin $ymax $zmin $zmax 40. -30. + + $w cmd plcol0 2 + $w cmd plbox3 "b" "" [expr {$xmax-$xmin}] 0 \ + "b" "" [expr {$ymax-$ymin}] 0 \ + "bcd" "" [expr {$zmax-$zmin}] 0 + + $w cmd plschr 0. 1.2 + # domega controls the spacing between the various characters of the + # string and also the maximum value of omega for the given number + # of characters in *pstring. + set pslen [string length $pstring] + set domega [expr {2.*$pi/$pslen}] + set omega 0. + # 3D function is a helix of the given radius and pitch + set radius 0.5 + set pitch [expr {1./(2.*$pi)}] + for {set i 0} {$i < $pslen} {incr i} { + set sin_omega [expr {sin($omega)}] + set cos_omega [expr {cos($omega)}] + set xpos [expr {$xmid + $radius*$sin_omega}] + set ypos [expr {$ymid - $radius*$cos_omega}] + set zpos [expr {$zmin + $pitch*$omega}] + # In general, the inclination is proportional to the derivative of + # the position wrt theta. + set x_inclination [expr {$radius*$cos_omega}] + set y_inclination [expr {$radius*$sin_omega}] + set z_inclination [expr {$pitch}] + # The shear vector should be perpendicular to the 3D line with Z + # component maximized, but for low pitch a good approximation is + # a constant vector that is parallel to the Z axis. + set x_shear 0. + set y_shear 0. + set z_shear 1. + $w cmd plptex3 \ + $xpos $ypos $zpos \ + $x_inclination $y_inclination $z_inclination \ + $x_shear $y_shear $z_shear \ + 0.5 [string range $pstring $i $i] + set omega [expr {$omega + $domega}] + } + # Draw minimal 3D grid to finish defining the 3D box. + $w cmd plmesh x y z $XPTS $YPTS $DRAW_LINEXY + + # Page 5: Demonstrate plmtex3 axis labelling capability + $w cmd pladv 0 + $w cmd plvpor -0.15 1.15 -0.05 1.05 + $w cmd plwind -1.2 1.2 -0.8 1.5 + $w cmd plw3d 1.0 1.0 1.0 $xmin $xmax $ymin $ymax $zmin $zmax 20. 45. + + $w cmd plcol0 2 + $w cmd plbox3 "b" "" [expr {$xmax-$xmin}] 0 \ + "b" "" [expr {$ymax-$ymin}] 0 \ + "bcd" "" [expr {$zmax-$zmin}] 0 + + $w cmd plschr 0. 1.0 + $w cmd plmtex3 "xp" 3.0 0.5 0.5 "Arbitrarily displaced" + $w cmd plmtex3 "xp" 4.5 0.5 0.5 "primary X-axis label" + $w cmd plmtex3 "xs" -2.5 0.5 0.5 "Arbitrarily displaced" + $w cmd plmtex3 "xs" -1.0 0.5 0.5 "secondary X-axis label" + $w cmd plmtex3 "yp" 3.0 0.5 0.5 "Arbitrarily displaced" + $w cmd plmtex3 "yp" 4.5 0.5 0.5 "primary Y-axis label" + $w cmd plmtex3 "ys" -2.5 0.5 0.5 "Arbitrarily displaced" + $w cmd plmtex3 "ys" -1.0 0.5 0.5 "secondary Y-axis label" + $w cmd plmtex3 "zp" 4.5 0.5 0.5 "Arbitrarily displaced" + $w cmd plmtex3 "zp" 3.0 0.5 0.5 "primary Z-axis label" + $w cmd plmtex3 "zs" -2.5 0.5 0.5 "Arbitrarily displaced" + $w cmd plmtex3 "zs" -1.0 0.5 0.5 "secondary Z-axis label" + # Draw minimal 3D grid to finish defining the 3D box. + $w cmd plmesh x y z $XPTS $YPTS $DRAW_LINEXY + +} Property changes on: trunk/examples/tcl/x28.tcl ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/plplot_test/test_tcl.sh.in =================================================================== --- trunk/plplot_test/test_tcl.sh.in 2008-08-21 00:03:03 UTC (rev 8694) +++ trunk/plplot_test/test_tcl.sh.in 2008-08-21 11:18:09 UTC (rev 8695) @@ -75,7 +75,7 @@ # Skip 17th example because it is not implemented (and if it was, it # would be interactive only). # Other examples are not yet implemented. -for index in 01 02 03 04 05 06 07 08 09 10 11 12 13 15 16 18 22 23 24 25 26 27; do +for index in 01 02 03 04 05 06 07 08 09 10 11 12 13 15 16 18 22 23 24 25 26 27 28; do if [ "$verbose_test" ]; then echo "x${index}" fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |