From: <arj...@us...> - 2008-08-18 20:05:34
|
Revision: 8669 http://plplot.svn.sourceforge.net/plplot/?rev=8669&view=rev Author: arjenmarkus Date: 2008-08-18 20:05:35 +0000 (Mon, 18 Aug 2008) Log Message: ----------- First implementation of example 26 in Tcl - not quite identical to the C version yet (flushing of the second page? Also: significant differences in PostScript, seems related to the "special" characters) Added Paths: ----------- trunk/examples/tcl/x26 trunk/examples/tcl/x26.tcl Added: trunk/examples/tcl/x26 =================================================================== --- trunk/examples/tcl/x26 (rev 0) +++ trunk/examples/tcl/x26 2008-08-18 20:05:35 UTC (rev 8669) @@ -0,0 +1,19 @@ +#!/bin/sh +#--------------------------------*- Tcl -*------------------------------------# +# $Id$ +# +# Arjen Markus +# 08/18/08 +# +# A front-end to x26.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 x26.tcl + +plinit +x10 +plend Property changes on: trunk/examples/tcl/x26 ___________________________________________________________________ Added: svn:executable + * Added: trunk/examples/tcl/x26.tcl =================================================================== --- trunk/examples/tcl/x26.tcl (rev 0) +++ trunk/examples/tcl/x26.tcl 2008-08-18 20:05:35 UTC (rev 8669) @@ -0,0 +1,182 @@ +# -*- coding: utf-8; -*- +# +# $Id$ +# +# Multi-lingual version of the first page of example 4. +# +# Copyright (C) 2006 Alan Irwin +# Copyright (C) 2006,2008 Andrew Ross +# Copyright (C) 2008 Arjen Markus +# +# Thanks to the following for providing translated strings for this example: +# Valery Pipin (Russian) +# +# 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 +# +# + +# +# This example designed just for devices (e.g., psttfc and the +# cairo-related devices) that utilise the pango and fontconfig libraries. The +# best choice of glyph is selected by fontconfig and automatically rendered +# by pango in way that is sensitive to complex text layout (CTL) language +# issues for each unicode character in this example. Of course, you must +# have the appropriate TrueType fonts installed to have access to all the +# required glyphs. +# +# Translation instructions: The strings to be translated are given by +# x_label, y_label, alty_label, title_label, and line_label below. The +# encoding used must be UTF-8. +# +# The following strings to be translated involve some scientific/mathematical +# jargon which is now discussed further to help translators. +# +# (1) dB is a decibel unit, see http://en.wikipedia.org/wiki/Decibel . +# (2) degrees is an angular measure, see +# http://en.wikipedia.org/wiki/Degree_(angle) . +# (3) low-pass filter is one that transmits (passes) low frequencies. +# (4) pole is in the mathematical sense, see +# http://en.wikipedia.org/wiki/Pole_(complex_analysis) . "Single Pole" +# means a particular mathematical transformation of the filter function has +# a single pole, see +# http://ccrma.stanford.edu/~jos/filters/Pole_Zero_Analysis_I.html . +# Furthermore, a single-pole filter must have an inverse square decline +# (or -20 db/decade). Since the filter plotted here does have that +# characteristic, it must by definition be a single-pole filter, see also +# http://www-k.ext.ti.com/SRVS/Data/ti/KnowledgeBases/analog/document/faqs/1p.htm +# (5) decade represents a factor of 10, see +# http://en.wikipedia.org/wiki/Decade_(log_scale) . +# +# +# + +# -------------------------------------------------------------------------- +# main +# +# Illustration of logarithmic axes, and redefinition of window. +# -------------------------------------------------------------------------- + +proc x26 {{w loopback}} { + + set x_label { + "Frequency" + "Частота" + } + + set y_label { + "Amplitude (dB)" + "Амплитуда (dB)" + } + + set alty_label { + "Phase shift (degrees)" + "Фазовый сдвиг (градусы)" + } + + set title_label { + "Single Pole Low-Pass Filter" + "Однополюсный Низко-Частотный Фильт\xD1" + } + + set line_label { + "-20 dB/decade" + "-20 dB/десяток" + } + + # Parse and process command line arguments + + # AM: TODO + # plparseopts? + + # Initialize plplot + + $w cmd plfont 2 + + # Make log plots using two different styles. + + foreach xl $x_label yl $y_label altyl $alty_label title $title_label linel $line_label { + plot1 $w 0 $xl $yl $altyl $title $linel + } + $w cmd plend + +} + +# -------------------------------------------------------------------------- +# plot1 +# +# Log-linear plot. +# -------------------------------------------------------------------------- + +proc plot1 { w type x_label y_label alty_label title_label line_label } { + + set PI [expr {4.0*atan(1.0)}] + + matrix freql f 101 + matrix ampl f 101 + matrix phase f 101 + + $w cmd pladv 0 + + # Set up data for log plot + + set f0 1.0 + for {set i 0} {$i < 101} {incr i} { + freql $i = [expr {-2.0 + ($i-1) / 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)}] + } + $w cmd plvpor 0.15 0.85 0.1 0.9 + $w cmd plwind -2.0 3.0 -80.0 0.0 + + # Try different axis and labelling styles. + + $w cmd plcol0 1 + if { $type == 0 } { + $w cmd plbox "bclnst" 0.0 0 "bnstv" 0.0 0 + } + if { $type == 1 } { + $w cmd plbox "bcfghlnst" 0.0 0 "bcghnstv" 0.0 0 + } + + # Plot ampl vs freq + + $w cmd plcol0 2 + $w cmd plline 101 freql ampl + $w cmd plcol0 1 + $w cmd plptex 1.6 -30.0 1.0 -20.0 0.5 $line_label + + # Put labels on + + $w cmd plcol0 1 + $w cmd plmtex "b" 3.2 0.5 0.5 $x_label + $w cmd plmtex "t" 2.0 0.5 0.5 $title_label + $w cmd plcol0 2 + $w cmd plmtex "l" 5.0 0.5 0.5 $y_label + + # For the gridless case, put phase vs freq on same plot + + if {$type == 0} { + $w cmd plcol0 1 + $w cmd plwind -2.0 3.0 -100.0 0.0 + $w cmd plbox "" 0.0 0 "cmstv" 30.0 3 + $w cmd plcol0 3 + $w cmd plline 101 freql phase + $w cmd plcol0 3 + $w cmd plmtex "r" 5.0 0.5 0.5 $alty_label + } +} Property changes on: trunk/examples/tcl/x26.tcl ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arj...@us...> - 2008-08-18 20:12:21
|
Revision: 8670 http://plplot.svn.sourceforge.net/plplot/?rev=8670&view=rev Author: arjenmarkus Date: 2008-08-18 20:12:24 +0000 (Mon, 18 Aug 2008) Log Message: ----------- Setting the proper SVN properties for x26 and x26.tcl (does not seem to occur automatically yet) Property Changed: ---------------- trunk/examples/tcl/x26 trunk/examples/tcl/x26.tcl Property changes on: trunk/examples/tcl/x26 ___________________________________________________________________ Deleted: svn:executable - * Added: svn:keywords + Id Added: svn:eol-style + native Property changes on: trunk/examples/tcl/x26.tcl ___________________________________________________________________ Deleted: svn:executable - * Added: svn:keywords + Id Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arj...@us...> - 2008-08-19 04:19:54
|
Revision: 8671 http://plplot.svn.sourceforge.net/plplot/?rev=8671&view=rev Author: arjenmarkus Date: 2008-08-19 04:20:03 +0000 (Tue, 19 Aug 2008) Log Message: ----------- Corrected svn:keywords to include Author, Date and Revision Property Changed: ---------------- trunk/examples/tcl/x26 trunk/examples/tcl/x26.tcl Property changes on: trunk/examples/tcl/x26 ___________________________________________________________________ Modified: svn:keywords - Id + Author Date Id Revision Property changes on: trunk/examples/tcl/x26.tcl ___________________________________________________________________ Modified: svn:keywords - Id + Author Date Id Revision This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2008-08-19 08:33:30
|
Revision: 8673 http://plplot.svn.sourceforge.net/plplot/?rev=8673&view=rev Author: andrewross Date: 2008-08-19 08:33:39 +0000 (Tue, 19 Aug 2008) Log Message: ----------- Correct exectuable status for tcl example 26. Correct a couple of bugs so it builds and runs as part of ctest. Results still differ from C version. Modified Paths: -------------- trunk/examples/tcl/CMakeLists.txt trunk/examples/tcl/x26 Property Changed: ---------------- trunk/examples/tcl/x26 Modified: trunk/examples/tcl/CMakeLists.txt =================================================================== --- trunk/examples/tcl/CMakeLists.txt 2008-08-19 07:12:58 UTC (rev 8672) +++ trunk/examples/tcl/CMakeLists.txt 2008-08-19 08:33:39 UTC (rev 8673) @@ -49,6 +49,7 @@ "18" "19" "22" +"26" ) set(tcl_SCRIPTS) Modified: trunk/examples/tcl/x26 =================================================================== --- trunk/examples/tcl/x26 2008-08-19 07:12:58 UTC (rev 8672) +++ trunk/examples/tcl/x26 2008-08-19 08:33:39 UTC (rev 8673) @@ -15,5 +15,5 @@ source x26.tcl plinit -x10 +x26 plend Property changes on: trunk/examples/tcl/x26 ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2008-08-19 10:54:07
|
Revision: 8674 http://plplot.svn.sourceforge.net/plplot/?rev=8674&view=rev Author: andrewross Date: 2008-08-19 10:54:16 +0000 (Tue, 19 Aug 2008) Log Message: ----------- Shift the restoring of the colour to tcldemos.tcl rather than in the x??.tcl files. This means that the interactive examples still all work correctly with tcldemos.tcl, but the ctest results are not confused by the additional call to plcol in the individual examples. With this change most of the tcl examples now pass the ctest compare test. Currently examples 11 and 26 produce different results. Modified Paths: -------------- trunk/examples/tcl/tcldemos.tcl trunk/examples/tcl/x01.tcl trunk/examples/tcl/x02.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/x10.tcl trunk/examples/tcl/x11.tcl trunk/examples/tcl/x12.tcl trunk/examples/tcl/x13.tcl trunk/examples/tcl/x15.tcl trunk/examples/tcl/x16.tcl trunk/examples/tcl/x18.tcl Modified: trunk/examples/tcl/tcldemos.tcl =================================================================== --- trunk/examples/tcl/tcldemos.tcl 2008-08-19 08:33:39 UTC (rev 8673) +++ trunk/examples/tcl/tcldemos.tcl 2008-08-19 10:54:16 UTC (rev 8674) @@ -23,9 +23,13 @@ for {set i 1} {$i <= 19} {incr i} { set demo x[format "%02d" $i] source $demo.tcl + # restore defaults + plcol0 1 proc $i {} "$demo" } set i 22 set demo x[format "%02d" $i] source $demo.tcl +# restore defaults +plcol0 1 proc $i {} "$demo" Modified: trunk/examples/tcl/x01.tcl =================================================================== --- trunk/examples/tcl/x01.tcl 2008-08-19 08:33:39 UTC (rev 8673) +++ trunk/examples/tcl/x01.tcl 2008-08-19 10:54:16 UTC (rev 8674) @@ -39,8 +39,8 @@ plot3 $w # Restore defaults - $w cmd plcol0 1 - $w cmd plssub 1 1 +# $w cmd plcol0 1 +# $w cmd plssub 1 1 $w cmd pleop } Modified: trunk/examples/tcl/x02.tcl =================================================================== --- trunk/examples/tcl/x02.tcl 2008-08-19 08:33:39 UTC (rev 8673) +++ trunk/examples/tcl/x02.tcl 2008-08-19 10:54:16 UTC (rev 8674) @@ -10,7 +10,7 @@ # Restore defaults $w cmd plssub 1 1 $w cmd plfont 1 - $w cmd plcol0 1 + # $w cmd plcol0 1 } # Demonstrates multiple windows and default color map 0 palette. Modified: trunk/examples/tcl/x03.tcl =================================================================== --- trunk/examples/tcl/x03.tcl 2008-08-19 08:33:39 UTC (rev 8673) +++ trunk/examples/tcl/x03.tcl 2008-08-19 10:54:16 UTC (rev 8674) @@ -80,5 +80,5 @@ $w cmd plmtex "t" 2.0 0.5 0.5 "#frPLplot Example 3 - r(#gh)=sin 5#gh" # Restore defaults - $w cmd plcol0 1 +# $w cmd plcol0 1 } Modified: trunk/examples/tcl/x04.tcl =================================================================== --- trunk/examples/tcl/x04.tcl 2008-08-19 08:33:39 UTC (rev 8673) +++ trunk/examples/tcl/x04.tcl 2008-08-19 10:54:16 UTC (rev 8674) @@ -10,7 +10,7 @@ # Restore defaults $w cmd plfont 1 - $w cmd plcol0 1 + # $w cmd plcol0 1 } Modified: trunk/examples/tcl/x05.tcl =================================================================== --- trunk/examples/tcl/x05.tcl 2008-08-19 08:33:39 UTC (rev 8673) +++ trunk/examples/tcl/x05.tcl 2008-08-19 10:54:16 UTC (rev 8674) @@ -20,5 +20,5 @@ $w cmd pllab "#frValue" "#frFrequency" \ "#frPLplot Example 5 - Probability function of Oscillator" # Restore defaults - $w cmd plcol0 1 + # $w cmd plcol0 1 } Modified: trunk/examples/tcl/x06.tcl =================================================================== --- trunk/examples/tcl/x06.tcl 2008-08-19 08:33:39 UTC (rev 8673) +++ trunk/examples/tcl/x06.tcl 2008-08-19 10:54:16 UTC (rev 8674) @@ -49,5 +49,5 @@ $w cmd plmtex "t" 1.5 0.5 0.5 "PLplot Example 6 - plpoin symbols" # Restore defaults - $w cmd plcol0 1 + # $w cmd plcol0 1 } Modified: trunk/examples/tcl/x07.tcl =================================================================== --- trunk/examples/tcl/x07.tcl 2008-08-19 08:33:39 UTC (rev 8673) +++ trunk/examples/tcl/x07.tcl 2008-08-19 10:54:16 UTC (rev 8674) @@ -53,5 +53,5 @@ $w cmd plmtex "t" 1.5 0.5 0.5 "PLplot Example 7 - PLSYM symbols" } # Restore defaults - $w cmd plcol0 1 + # $w cmd plcol0 1 } Modified: trunk/examples/tcl/x08.tcl =================================================================== --- trunk/examples/tcl/x08.tcl 2008-08-19 08:33:39 UTC (rev 8673) +++ trunk/examples/tcl/x08.tcl 2008-08-19 10:54:16 UTC (rev 8674) @@ -194,6 +194,6 @@ } # Restore defaults - $w cmd plcol0 1 + # $w cmd plcol0 1 restore_cmap1_8 $w } Modified: trunk/examples/tcl/x09.tcl =================================================================== --- trunk/examples/tcl/x09.tcl 2008-08-19 08:33:39 UTC (rev 8673) +++ trunk/examples/tcl/x09.tcl 2008-08-19 10:54:16 UTC (rev 8674) @@ -159,7 +159,7 @@ # x09_potential $w # Restore defaults - $w cmd plcol0 1 + # $w cmd plcol0 1 # $w cmd pl_setcontlabelparam 0.006 0.3 0.1 0 } Modified: trunk/examples/tcl/x10.tcl =================================================================== --- trunk/examples/tcl/x10.tcl 2008-08-19 08:33:39 UTC (rev 8673) +++ trunk/examples/tcl/x10.tcl 2008-08-19 10:54:16 UTC (rev 8674) @@ -12,5 +12,5 @@ $w cmd plbox bc 0.0 0 bc 0.0 0 $w cmd plptex 0.5 0.5 1.0 0.0 0.5 "BOX at (50,150,50,100)" # Restore defaults - $w cmd plcol0 1 + # $w cmd plcol0 1 } Modified: trunk/examples/tcl/x11.tcl =================================================================== --- trunk/examples/tcl/x11.tcl 2008-08-19 08:33:39 UTC (rev 8673) +++ trunk/examples/tcl/x11.tcl 2008-08-19 10:54:16 UTC (rev 8674) @@ -165,6 +165,6 @@ } } # Restore defaults - $w cmd plcol0 1 + # $w cmd plcol0 1 restore_cmap1_11 $w } Modified: trunk/examples/tcl/x12.tcl =================================================================== --- trunk/examples/tcl/x12.tcl 2008-08-19 08:33:39 UTC (rev 8673) +++ trunk/examples/tcl/x12.tcl 2008-08-19 10:54:16 UTC (rev 8674) @@ -33,7 +33,7 @@ $w cmd plmtex "b" 1.0 [expr ($i + 1) * .1 - .05] 0.5 $string } # Restore defaults - $w cmd plcol0 1 + # $w cmd plcol0 1 } proc plfbox {w x0 y0} { Modified: trunk/examples/tcl/x13.tcl =================================================================== --- trunk/examples/tcl/x13.tcl 2008-08-19 08:33:39 UTC (rev 8673) +++ trunk/examples/tcl/x13.tcl 2008-08-19 10:54:16 UTC (rev 8674) @@ -67,5 +67,5 @@ $w cmd plschr 0. 1.3 $w cmd plptex 5.0 9.0 1.0 0.0 0.5 "Percentage of Sales" # Restore defaults - $w cmd plcol0 1 + # $w cmd plcol0 1 } Modified: trunk/examples/tcl/x15.tcl =================================================================== --- trunk/examples/tcl/x15.tcl 2008-08-19 08:33:39 UTC (rev 8673) +++ trunk/examples/tcl/x15.tcl 2008-08-19 10:54:16 UTC (rev 8674) @@ -122,5 +122,5 @@ $w cmd plcol0 2 $w cmd pllab "distance" "altitude" "Bogon flux" # Restore defaults - $w cmd plcol0 1 + # $w cmd plcol0 1 } Modified: trunk/examples/tcl/x16.tcl =================================================================== --- trunk/examples/tcl/x16.tcl 2008-08-19 08:33:39 UTC (rev 8673) +++ trunk/examples/tcl/x16.tcl 2008-08-19 10:54:16 UTC (rev 8674) @@ -219,5 +219,5 @@ $w cmd plcol0 2 $w cmd pllab "" "" "Tokamak Bogon Instability" # Restore defaults - $w cmd plcol0 1 + # $w cmd plcol0 1 } Modified: trunk/examples/tcl/x18.tcl =================================================================== --- trunk/examples/tcl/x18.tcl 2008-08-19 08:33:39 UTC (rev 8673) +++ trunk/examples/tcl/x18.tcl 2008-08-19 10:54:16 UTC (rev 8674) @@ -57,7 +57,7 @@ $w cmd plmtex t 1.0 0.5 0.5 "$title" } # Restore defaults - $w cmd plcol0 1 + # $w cmd plcol0 1 } proc test_poly {{w loopback} k} { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arj...@us...> - 2008-08-19 16:13:26
|
Revision: 8680 http://plplot.svn.sourceforge.net/plplot/?rev=8680&view=rev Author: arjenmarkus Date: 2008-08-19 16:13:34 +0000 (Tue, 19 Aug 2008) Log Message: ----------- Added example 27 for Tcl Modified Paths: -------------- trunk/examples/tcl/CMakeLists.txt Added Paths: ----------- trunk/examples/tcl/x27 trunk/examples/tcl/x27.tcl Modified: trunk/examples/tcl/CMakeLists.txt =================================================================== --- trunk/examples/tcl/CMakeLists.txt 2008-08-19 15:26:30 UTC (rev 8679) +++ trunk/examples/tcl/CMakeLists.txt 2008-08-19 16:13:34 UTC (rev 8680) @@ -52,6 +52,7 @@ "24" "25" "26" +"27" ) set(tcl_SCRIPTS) @@ -63,7 +64,7 @@ install(FILES ${tcl_FILES} DESTINATION ${DATA_DIR}/examples/tcl) install(PROGRAMS ${tcl_SCRIPTS} DESTINATION ${DATA_DIR}/examples/tcl) -# Copy file and scripts to the binary directory if different to the +# Copy file and scripts to the binary directory if different to the # source directory. Needed for ctest, but also so the tclIndex file # is generated in the binary tree not the source tree. if(NOT CMAKE_CURRENT_BINARY_DIR STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") Added: trunk/examples/tcl/x27 =================================================================== --- trunk/examples/tcl/x27 (rev 0) +++ trunk/examples/tcl/x27 2008-08-19 16:13:34 UTC (rev 8680) @@ -0,0 +1,19 @@ +#!/bin/sh +#--------------------------------*- Tcl -*------------------------------------# +# $Id$ +# +# Arjen Markus +# 08/18/08 +# +# A front-end to x26.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 x27.tcl + +plinit +x27 +plend Property changes on: trunk/examples/tcl/x27 ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/examples/tcl/x27.tcl =================================================================== --- trunk/examples/tcl/x27.tcl (rev 0) +++ trunk/examples/tcl/x27.tcl 2008-08-19 16:13:34 UTC (rev 8680) @@ -0,0 +1,136 @@ +# $Id$ +# +# Drawing "spirograph" curves - epitrochoids, cycolids, roulettes +# +# Copyright (C) 2007 Arjen Markus +# Copyright (C) 2008 Andrew Ross +# +# 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 +# +# + +# -------------------------------------------------------------------------- +# main +# +# Generates two kinds of plots: +# - construction of a cycloid (animated) +# - series of epitrochoids and hypotrochoids +# -------------------------------------------------------------------------- + +proc x27 {{w loopback}} { + + # R, r, p, N + set params { + { 21.0 7.0 7.0 3.0 } + { 21.0 7.0 10.0 3.0 } + { 21.0 -7.0 10.0 3.0 } + { 20.0 3.0 7.0 20.0 } + { 20.0 3.0 10.0 20.0 } + { 20.0 -3.0 10.0 20.0 } + { 20.0 13.0 7.0 20.0 } + { 20.0 13.0 20.0 20.0 } + { 20.0 -13.0 20.0 20.0 }} + + # Illustrate the construction of a cycloid + + cycloid $w + + # Loop over the various curves + # First an overview, then all curves one by one + + $w cmd plssub 3 3 + + for { set i 0 } { $i < 9 } { incr i } { + $w cmd pladv 0 + $w cmd plvpor 0.0 1.0 0.0 1.0 + spiro $w [lindex $params $i] + } + $w cmd pladv 0 + $w cmd plssub 1 1 + + for { set i 0 } { $i < 9 } { incr i } { + $w cmd pladv 0 + $w cmd plvpor 0.0 1.0 0.0 1.0 + spiro $w [lindex $params $i] + } + # Don't forget to $w cmd plend() to finish off! + + $w cmd plend + +} + +# =============================================================== + +proc cycloid {w} { + + # TODO + +} + +# =============================================================== + +proc spiro {w params} { + + foreach {param1 param2 param3 param4} $params {break} + + set NPNT 20000 + + matrix xcoord f [expr {$NPNT+1}] + matrix ycoord f [expr {$NPNT+1}] + + # Fill the coordinates + + set windings [expr {int($param4)}] + set steps [expr {$NPNT/$windings}] + set dphi [expr {8.0*acos(-1.0)/double($steps)}] + + # This initialisation is safe! + set xmin 0.0 + set xmax 0.0 + set ymin 0.0 + set ymax 0.0 + + set n [expr {$windings*$steps+1}] + + for { set i 0 } { $i < $n } { incr i } { + set phi [expr {double($i) * $dphi}] + set phiw [expr {($param1-$param2)/$param2*$phi}] + xcoord $i = [expr {($param1-$param2)*cos($phi)+$param3*cos($phiw)}] + ycoord $i = [expr {($param1-$param2)*sin($phi)-$param3*sin($phiw)}] + + if { $xmin > [xcoord $i] } { set xmin [xcoord $i] } + if { $xmax < [xcoord $i] } { set xmax [xcoord $i] } + if { $ymin > [ycoord $i] } { set ymin [ycoord $i] } + if { $ymax < [ycoord $i] } { set ymax [ycoord $i] } + } + + if { $xmax-$xmin > $ymax-$ymin } { + set scale [expr {$xmax - $xmin}] + } else { + set scale [expr {$ymax - $ymin}] + } + set xmin [expr {- 0.65 * $scale}] + set xmax [expr { 0.65 * $scale}] + set ymin [expr {- 0.65 * $scale}] + set ymax [expr { 0.65 * $scale}] + + $w cmd plwind $xmin $xmax $ymin $ymax + + $w cmd plcol0 1 + $w cmd plline [expr {$n-1}] xcoord ycoord + +} Property changes on: trunk/examples/tcl/x27.tcl ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2008-08-19 19:58:06
|
Revision: 8682 http://plplot.svn.sourceforge.net/plplot/?rev=8682&view=rev Author: andrewross Date: 2008-08-19 19:58:15 +0000 (Tue, 19 Aug 2008) Log Message: ----------- Update some tcl examples to ensure they work correctly with tcldemos.tcl. Modified Paths: -------------- trunk/examples/tcl/tcldemos.tcl trunk/examples/tcl/x01.tcl trunk/examples/tcl/x03.tcl trunk/examples/tcl/x25.tcl trunk/examples/tcl/x26.tcl trunk/examples/tcl/x27.tcl Modified: trunk/examples/tcl/tcldemos.tcl =================================================================== --- trunk/examples/tcl/tcldemos.tcl 2008-08-19 19:26:48 UTC (rev 8681) +++ trunk/examples/tcl/tcldemos.tcl 2008-08-19 19:58:15 UTC (rev 8682) @@ -33,3 +33,10 @@ # restore defaults plcol0 1 proc $i {} "$demo" +for {set i 24} {$i <= 27} {incr i} { + set demo x[format "%02d" $i] + source $demo.tcl + # restore defaults + plcol0 1 + proc $i {} "$demo" +} Modified: trunk/examples/tcl/x01.tcl =================================================================== --- trunk/examples/tcl/x01.tcl 2008-08-19 19:26:48 UTC (rev 8681) +++ trunk/examples/tcl/x01.tcl 2008-08-19 19:58:15 UTC (rev 8682) @@ -40,7 +40,7 @@ plot3 $w # Restore defaults # $w cmd plcol0 1 -# $w cmd plssub 1 1 + $w cmd plssub 1 1 $w cmd pleop } Modified: trunk/examples/tcl/x03.tcl =================================================================== --- trunk/examples/tcl/x03.tcl 2008-08-19 19:26:48 UTC (rev 8681) +++ trunk/examples/tcl/x03.tcl 2008-08-19 19:58:15 UTC (rev 8682) @@ -6,6 +6,7 @@ set twopi [expr 2. * 3.14159265358979323846] # Set up viewport and window, but do not draw box + $w cmd pladv 0 $w cmd plenv -1.3 1.3 -1.3 1.3 1 -2 # Draw circles for polar grid Modified: trunk/examples/tcl/x25.tcl =================================================================== --- trunk/examples/tcl/x25.tcl 2008-08-19 19:26:48 UTC (rev 8681) +++ trunk/examples/tcl/x25.tcl 2008-08-19 19:58:15 UTC (rev 8682) @@ -167,4 +167,8 @@ } } + # Restore defaults + $w cmd plssub 1 1 + $w cmd pleop + } Modified: trunk/examples/tcl/x26.tcl =================================================================== --- trunk/examples/tcl/x26.tcl 2008-08-19 19:26:48 UTC (rev 8681) +++ trunk/examples/tcl/x26.tcl 2008-08-19 19:58:15 UTC (rev 8682) @@ -109,9 +109,8 @@ # Make log plots using two different styles. foreach xl $x_label yl $y_label altyl $alty_label title $title_label linel $line_label { - plot1 $w 0 $xl $yl $altyl $title $linel + plot261 $w 0 $xl $yl $altyl $title $linel } - $w cmd plend } @@ -121,7 +120,7 @@ # Log-linear plot. # -------------------------------------------------------------------------- -proc plot1 { w type x_label y_label alty_label title_label line_label } { +proc plot261 { w type x_label y_label alty_label title_label line_label } { set PI [expr {4.0*atan(1.0)}] Modified: trunk/examples/tcl/x27.tcl =================================================================== --- trunk/examples/tcl/x27.tcl 2008-08-19 19:26:48 UTC (rev 8681) +++ trunk/examples/tcl/x27.tcl 2008-08-19 19:58:15 UTC (rev 8682) @@ -51,7 +51,7 @@ # Loop over the various curves # First an overview, then all curves one by one - + $w cmd pladv 0 $w cmd plssub 3 3 for { set i 0 } { $i < 9 } { incr i } { @@ -67,10 +67,7 @@ $w cmd plvpor 0.0 1.0 0.0 1.0 spiro $w [lindex $params $i] } - # Don't forget to $w cmd plend() to finish off! - $w cmd plend - } # =============================================================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2008-08-20 07:21:21
|
Revision: 8684 http://plplot.svn.sourceforge.net/plplot/?rev=8684&view=rev Author: andrewross Date: 2008-08-20 07:21:31 +0000 (Wed, 20 Aug 2008) Log Message: ----------- Add intial tcl version of example 23. Still needs debugging. Modified Paths: -------------- trunk/examples/tcl/CMakeLists.txt Added Paths: ----------- trunk/examples/tcl/x23 trunk/examples/tcl/x23.tcl Modified: trunk/examples/tcl/CMakeLists.txt =================================================================== --- trunk/examples/tcl/CMakeLists.txt 2008-08-20 00:29:40 UTC (rev 8683) +++ trunk/examples/tcl/CMakeLists.txt 2008-08-20 07:21:31 UTC (rev 8684) @@ -49,6 +49,7 @@ "18" "19" "22" +"23" "24" "25" "26" Added: trunk/examples/tcl/x23 =================================================================== --- trunk/examples/tcl/x23 (rev 0) +++ trunk/examples/tcl/x23 2008-08-20 07:21:31 UTC (rev 8684) @@ -0,0 +1,19 @@ +#!/bin/sh +#--------------------------------*- Tcl -*------------------------------------# +# $Id:$ +# +# Maurice LeBrun +# 12/24/02 +# +# A front-end to x23.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 x23.tcl + +plinit +x23 +plend Property changes on: trunk/examples/tcl/x23 ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/examples/tcl/x23.tcl =================================================================== --- trunk/examples/tcl/x23.tcl (rev 0) +++ trunk/examples/tcl/x23.tcl 2008-08-20 07:21:31 UTC (rev 8684) @@ -0,0 +1,379 @@ +# $Id:$ +# +# Displays Greek letters and mathematically interesting Unicode ranges +# Copyright (C) 2005,2008 Alan Irwin +# Copyright (C) 2005,2008 Andrew Ross +# +# +# 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 +# + +# +# Displays Greek letters and mathematically interesting Unicode ranges +# + +proc x23 {{w loopback}} { + + set Greek0 "#gA" + set Greek1 "#gB" + set Greek2 "#gG" + set Greek3 "#gD" + set Greek4 "#gE" + set Greek5 "#gZ" + set Greek6 "#gY" + set Greek7 "#gH" + set Greek8 "#gI" + set Greek9 "#gK" + set Greek10 "#gL" + set Greek11 "#gM" + set Greek12 "#gN" + set Greek13 "#gC" + set Greek14 "#gO" + set Greek15 "#gP" + set Greek16 "#gR" + set Greek17 "#gS" + set Greek18 "#gT" + set Greek19 "#gU" + set Greek20 "#gF" + set Greek21 "#gX" + set Greek22 "#gQ" + set Greek23 "#gW" + set Greek24 "#ga" + set Greek25 "#gb" + set Greek26 "#gg" + set Greek27 "#gd" + set Greek28 "#ge" + set Greek29 "#gz" + set Greek30 "#gy" + set Greek31 "#gh" + set Greek32 "#gi" + set Greek33 "#gk" + set Greek34 "#gl" + set Greek35 "#gm" + set Greek36 "#gn" + set Greek37 "#gc" + set Greek38 "#go" + set Greek39 "#gp" + set Greek40 "#gr" + set Greek41 "#gs" + set Greek42 "#gt" + set Greek43 "#gu" + set Greek44 "#gf" + set Greek45 "#gx" + set Greek46 "#gq" + set Greek47 "#gw" + + + matrix Type1 i 166 = { + 0x0020, 0x0021, 0x0023, 0x0025, 0x0026, + 0x0028, 0x0029, 0x002b, 0x002c, 0x002e, + 0x002f, 0x0030, 0x0031, 0x0032, 0x0033, + 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, + 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, + 0x003e, 0x003f, 0x005b, 0x005d, 0x005f, + 0x007b, 0x007c, 0x007d, 0x00a9, 0x00ac, + 0x00ae, 0x00b0, 0x00b1, 0x00d7, 0x00f7, + 0x0192, 0x0391, 0x0392, 0x0393, 0x0394, + 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, + 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, + 0x039f, 0x03a0, 0x03a1, 0x03a3, 0x03a4, + 0x03a5, 0x03a6, 0x03a7, 0x03a8, 0x03a9, + 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, + 0x03b6, 0x03b7, 0x03b8, 0x03b9, 0x03ba, + 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, + 0x03c0, 0x03c1, 0x03c2, 0x03c3, 0x03c4, + 0x03c5, 0x03c6, 0x03c7, 0x03c8, 0x03c9, + 0x03d1, 0x03d2, 0x03d5, 0x03d6, 0x2022, + 0x2026, 0x2032, 0x2033, 0x203e, 0x2044, + 0x2111, 0x2118, 0x211c, 0x2122, 0x2126, + 0x2135, 0x2190, 0x2191, 0x2192, 0x2193, + 0x2194, 0x21b5, 0x21d0, 0x21d1, 0x21d2, + 0x21d3, 0x21d4, 0x2200, 0x2202, 0x2203, + 0x2205, 0x2206, 0x2207, 0x2208, 0x2209, + 0x220b, 0x220f, 0x2211, 0x2212, 0x2215, + 0x2217, 0x221a, 0x221d, 0x221e, 0x2220, + 0x2227, 0x2228, 0x2229, 0x222a, 0x222b, + 0x2234, 0x223c, 0x2245, 0x2248, 0x2260, + 0x2261, 0x2264, 0x2265, 0x2282, 0x2283, + 0x2284, 0x2286, 0x2287, 0x2295, 0x2297, + 0x22a5, 0x22c5, 0x2320, 0x2321, 0x2329, + 0x232a, 0x25ca, 0x2660, 0x2663, 0x2665, + 0x2666 + } + + set title0 "#<0x10>PLplot Example 23 - Greek Letters" + set title1 "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (a)" + set title2 "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (b)" + set title3 "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (c)" + set title4 "#<0x10>PLplot Example 23 - Number Forms Unicode Block" + set title5 "#<0x10>PLplot Example 23 - Arrows Unicode Block (a)" + set title6 "#<0x10>PLplot Example 23 - Arrows Unicode Block (b)" + set title7 "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (a)" + set title8 "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (b)" + set title9 "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (c)" + set title10 "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (d)" + + + matrix lo i 11 = { + 0x0, + 0x0, + 0x40, + 0x80, + 0x2153, + 0x2190, + 0x21d0, + 0x2200, + 0x2240, + 0x2280, + 0x22c0 + } + + matrix hi i 11 = { + 0x30, + 0x40, + 0x80, + 0xA6, + 0x2184, + 0x21d0, + 0x2200, + 0x2240, + 0x2280, + 0x22c0, + 0x2300 + } + + matrix nxcells i 11 = { + 12, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8 + } + + matrix nycells i 11 = { + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8 + } + + # non-zero values Must be consistent with nxcells and nycells. + matrix offset i 11 = { + 0, + 0, + 64, + 128, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + } + +# 30 possible FCI values. + matrix fci i 30 = { + 0x80000000, + 0x80000001, + 0x80000002, + 0x80000003, + 0x80000004, + 0x80000010, + 0x80000011, + 0x80000012, + 0x80000013, + 0x80000014, + 0x80000020, + 0x80000021, + 0x80000022, + 0x80000023, + 0x80000024, + 0x80000100, + 0x80000101, + 0x80000102, + 0x80000103, + 0x80000104, + 0x80000110, + 0x80000111, + 0x80000112, + 0x80000113, + 0x80000114, + 0x80000120, + 0x80000121, + 0x80000122, + 0x80000123, + 0x80000124, + } + + set family(0) "sans-serif" + set family(1) "serif" + set family(2) "monospace" + set family(3) "script" + set family(4) "symbol" + + set style(0) "upright" + set style(1) "italic" + set style(2) "oblique" + + set weight(0) "medium" + set weight(1) "bold" + + for {set page 0} {$page<11} {incr page} { + + $w cmd pladv 0 + + # Set up viewport and window + + $w cmd plvpor 0.02 0.98 0.02 0.90 + $w cmd plwind 0.0 1.0 0.0 1.0 + $w cmd plgspa xmin xmax ymin ymax + $w cmd plschr 0.0 0.8 + set ycharacter_scale [ expr {1.0/($ymax-$ymin)}] + + # Factor should be 0.5, but heuristically it turns out to be larger. + $w cmd plgchr chardef charht + set yoffset [ expr {1.0*$charht*$ycharacter_scale} ] + + # Draw the grid using plbox + + $w cmd plcol0 2 + set deltax [ expr {1.0/[nxcells $page]} ] + set deltay [ expr {1.0/[nycells $page]} ] + $w cmd plbox "bcg" $deltax 0 "bcg" $deltay 0 + $w cmd plcol0 15 + set length [ expr {[hi $page]-[lo $page]} ] + set slice 0 + for {set j [ expr {[nycells $page]-1} ]} {$j>=-1} {incr j -1} { + set y [ expr {(0.5+$j)*$deltay} ] + for {set i 0} {$i<[nxcells $page]} {incr i} { + set x [ expr {(0.5+$i)*$deltax} ] + if {$slice < $length} { + if {$page == 0} { + set cmdString [set Greek$slice] + } elseif (($page >= 1) && ($page <= 3)) { + set cmdString [format "##[0x%.4x]" [ Type1 [expr [offset $page]+$slice] ] ] + } elseif ($page >= 4) { + set cmdString [format "##[0x%.4x]" [eval {[lo $page]+$slice}]] + } + $w cmd plptex $x [ expr {$y+$yoffset}] 1. 0. 0.5 $cmdString + $w cmd plptex $x [ expr {$y-$yoffset}] 1. 0. 0.5 $cmdString + } + incr slice + } + } + + $w cmd plschr 0. 1.0 + # Page title + $w cmd plmtex "t" 1.5 0.5 0.5 [set title$page] + } + + # Demonstrate methods of getting the current fonts + $w cmd plgfci fci_old + $w cmd plgfont ifamily istyle iweight + format "For example 23 prior to page 12 the FCI is 0x%x\n" $fci_old + format "For example 23 prior to page 12 the font family, style and weight are %s %s %s\n" $family($ifamily) $style($istyle) $weight($iweight) + + for {set page 11} {$page<16} {incr page} { + set dy 0.030 + + $w cmd pladv 0 + $w cmd plvpor 0.02 0.98 0.02 0.90 + $w cmd plwind 0.0 1.0 0.0 1.0 + $w cmd plsfci 0 + if {$page == 11} { + $w cmd plmtex "t" 1.5 0.5 0.5 "#<0x10>PLplot Example 23 - Set Font with plsfci" + } elseif {$page == 12} { + $w cmd plmtex "t" 1.5 0.5 0.5 "#<0x10>PLplot Example 23 - Set Font with plsfont" + } elseif {$page == 13} { + $w cmd plmtex "t" 1.5 0.5 0.5 "#<0x10>PLplot Example 23 - Set Font with ##<0x8nnnnnnn> construct" + } elseif {$page == 14} { + $w cmd plmtex "t" 1.5 0.5 0.5 "#<0x10>PLplot Example 23 - Set Font with ##<0xmn> constructs" + } elseif {$page == 15} { + $w cmd plmtex "t" 1.5 0.5 0.5 "#<0x10>PLplot Example 23 - Set Font with ##<FCI COMMAND STRING/> constructs" + } + $w cmd plschr 0. 0.75 + for {set i 0} {$i< 30} {incr i} { + set family_index [ expr {$i % 5}] + set style_index [ expr {($i/5) % 3}] + set weight_index [ expr {(($i/5)/3) % 2}] + if {$page == 11} { + $w cmd plsfci [fci $i] + set string [format "Page 12, %s, %s, %s: The quick brown fox jumps over the lazy dog" \ + $family($family_index) \ + $style($style_index) \ + $weight($weight_index) \ + ] + } elseif {$page == 12} { + $w cmd plsfont $family_index $style_index $weight_index + set string [format \ + "Page 13, %s, %s, %s: The quick brown fox jumps over the lazy dog" \ + $family($family_index) \ + $style($style_index) \ + $weight($weight_index) \ + ] + } elseif {$page == 13} { + set string [format \ + "Page 14, %s, %s, %s: #<0x%x>The quick brown fox jumps over the lazy dog" \ + $family($family_index) \ + $style($style_index) \ + $weight($weight_index) \ + [fci $i] \ + ] + } elseif {$page == 14} { + set string [format \ + "Page 15, %s, %s, %s: #<0x%1x0>#<0x%1x1>#<0x%1x2>The quick brown fox jumps over the lazy dog" \ + $family($family_index) \ + $style($style_index) \ + $weight($weight_index) \ + $family_index \ + $style_index \ + $weight_index \ + ] + } elseif {$page == 15} { + set string [format \ + "Page 16, %s, %s, %s: #<%s/>#<%s/>#<%s/>The quick brown fox jumps over the lazy dog" \ + $family($family_index) \ + $style($style_index) \ + $weight($weight_index) \ + $family($family_index) \ + $style($style_index) \ + $weight($weight_index) \ + ] + } + $w cmd plptex 0. [ expr {1. - ($i+0.5)*$dy}] 1. 0. 0. $string + } + + $w cmd plschr 0. 1.0 + } + + # Restore defaults + $w cmd plcol0 1 +} Property changes on: trunk/examples/tcl/x23.tcl ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arj...@us...> - 2008-08-24 10:05:29
|
Revision: 8708 http://plplot.svn.sourceforge.net/plplot/?rev=8708&view=rev Author: arjenmarkus Date: 2008-08-24 10:05:39 +0000 (Sun, 24 Aug 2008) Log Message: ----------- Added first implementation of example x21 - API not complete yet, so stops at the call to plgriddata Added Paths: ----------- trunk/examples/tcl/x21 trunk/examples/tcl/x21.tcl Added: trunk/examples/tcl/x21 =================================================================== --- trunk/examples/tcl/x21 (rev 0) +++ trunk/examples/tcl/x21 2008-08-24 10:05:39 UTC (rev 8708) @@ -0,0 +1,19 @@ +#!/bin/sh +#--------------------------------*- Tcl -*------------------------------------# +# $Id$ +# +# Maurice LeBrun +# 12/24/02 +# +# A front-end to x06.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 x21.tcl + +plinit +x21 +plend Property changes on: trunk/examples/tcl/x21 ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/examples/tcl/x21.tcl =================================================================== --- trunk/examples/tcl/x21.tcl (rev 0) +++ trunk/examples/tcl/x21.tcl 2008-08-24 10:05:39 UTC (rev 8708) @@ -0,0 +1,290 @@ +# $Id$ +# Grid data demo. +# +# Copyright (C) 2004 Joao Cardoso +# Copyright (C) 2008 Andrew Ross +# +# 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 +# +# Note: +# This example uses NaNs (not-a-number) and these special "numbers" +# are only properly supported by Tcl 8.5 and later (in the sense +# that a NaN does not stop the program with an error message). + +proc x21 {{w loopback}} { + + if { [catch {package require Tcl 8.5}] } { + puts "This example require Tcl 8.5 or later: use of NaNs" + return + } + + set PI [expr {4.0*atan(1.0)}] + + 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 + set nl 16 + set knn_order 20 + set threshold 1.001 + set wmin -1e3 + set randn 0 + set rosen 0 + + matrix x f $pts + matrix y f $pts + matrix z f $pts + matrix clev f $pts + matrix xg f $xp + matrix yg f $yp + matrix zg f $xp $yp + + set title {"Cubic Spline Approximation" + "Delaunay Linear Interpolation" + "Natural Neighbors Interpolation" + "KNN Inv. Distance Weighted" + "3NN Linear Interpolation" + "4NN Around Inv. Dist. Weighted"} + + matrix opt f 6 = { 0.0 0.0 0.0 0.0 0.0 0.0 } + + set xmin -0.2 + set ymin -0.2 + set xmax 0.6 + set ymax 0.6 + + opt 3 = $wmin + opt 4 = [expr {double($knn_order)}] + opt 5 = $threshold + + for {set i 0} {$i < $pts} {incr i} { + set xt [expr {($xmax-$xmin)*[plrandd]}] + set yt [expr {($ymax-$ymin)*[plrandd]}] + if {$randn == 0} { + x $i = [expr {$xt + $xmin}] + y $i = [expr {$yt + $ymin}] + } else { + x $i = [expr {sqrt(-2.*log($xt)) * cos(2.*$PI*$yt) + $xmin}] + y $i = [expr {sqrt(-2.*log($xt)) * sin(2.*$PI*$yt) + $ymin}] + } + if {$rosen == 0} { + set xx [x $i] + set yy [x $i] + set r [expr {sqrt($xx*$xx + $yy*$yy)}] + z $i = [expr {exp(-$r*$r)*cos(2.*$PI*$r)}] + } else { + set xx [x $i] + set yy [x $i] + z $i = [expr {log((1.-$xx)**2 + 100.*($yy-$xx**2)**2)}] + } + } + + set zmin [z 0] + set zmax [z 0] + for {set i 1} {$i < $pts} {incr i} { + set zmax [max $zmax [z $i]] + set zmin [min $zmin [z $i]] + } + + for {set i 0} {$i < $xp} {incr i} { + xg $i = [expr {$xmin + ($xmax-$xmin)*($i-1.)/($xp-1.)}] + } + for {set i 0} {$i < $yp} {incr i} { + yg $i = [expr {$ymin + ($ymax-$ymin)*($i-1.)/($yp-1.)}] + } + + $w cmd plcol0 1 + $w cmd plenv $xmin $xmax $ymin $ymax 2 0 + $w cmd plcol0 15 + $w cmd pllab "X" "Y" "The original data sampling" + $w cmd plcol0 2 + $w cmd plpoin $pts x y 5 + $w cmd pladv 0 + + $w cmd plssub 3 2 + + for {set k 0} {$k < 2} {incr k} { + $w cmd pladv 0 + for {set alg 1} {$alg <= 6} {incr alg} { + + $w cmd plgriddata x y z xg yg zg $alg [opt $alg] + +# - CSA can generate NaNs (only interpolates? #). +# - DTLI and NNI can generate NaNs for points outside the convex hull +# of the data points. +# - NNLI can generate NaNs if a sufficiently thick triangle is not found +# +# PLplot should be NaN/Inf aware, but changing it now is quite a job... +# so, instead of not plotting the NaN regions, a weighted average over +# the neighbors is done. +# + + if {($alg == $GRID_CSA) || ($alg == $GRID_DTLI) || + ($alg == $GRID_NNLI) || ($alg == $GRID_NNI} { + + for {set i 0} {$i < $xp} {incr i} { + for {set j 0} {$j < $yp} {incr j} { + if { [zg $i $j] == NaN } { +# average (IDW) over the 8 neighbors + + zg $i $j = 0. + set dist 0. + + set ii [expr {$i-1}] + while {($ii < $i+1) && ($ii < $xp)} { + set jj [expr {$j-1}] + while {($jj == $j+1) && ($jj < $yp)} { + if {($ii >= 0) && (jj >= 1) && + ![isnan [zg $ii $jj]] } { + if {abs($ii-$i) + abs($jj-$j) == 1)} { + set d 1. + } else { + set d 1.4142 + } + zg $i $j = [expr {[zg $i $j] + [zg $ii $jj]/($d*$d)}] + set dist [expr {$dist + $d}] + } + incr jj + } + incr ii + } + if {$dist != 0.} { + zg $i $j = [expr {[zg $i $j] / $dist}] + } else { + zg $i $j = $zmin + } + } + } + } + } + + a2mnmx zg xp yp lzmin lzmax xp + + set lzmin = [min $lzmin $zmin] + set lzmax = [max $lzmax $zmax] + + set lzmin = [expr {lzmin - 0.01}] + set lzmax = [expr {lzmax + 0.01}] + + $w cmd plcol0 1 + $w cmd pladv $alg + + if {$k == 0} { + + for {set i 0} {$i < $nl} {incr i} { + clev $i = [expr {$lzmin + ($lzmax-$lzmin)/($nl-1.)*($i-1.)}] + } + $w cmd plenv0 xmin xmax ymin ymax 2 0 + $w cmd plcol0 15 + $w cmd pllab "X" "Y" [lindex $title $alg] + $w cmd plshades zg $defined $xmin $xmax $ymin \ + $ymax clev 1 0 1 + $w cmd plcol0 2 + } else { + + for {set i 0} {$i < $nl} {incr i} { + clev $i = [expr {$lzmin + ($lzmax-$lzmin)/($nl-1.)*($i-1.)}] + } + cmap1_init + $w cmd plvpor 0. 1. 0. 0.9 + $w cmd plwind -1.1 0.75 -0.65 1.20 +# +# For the comparison to be fair, all plots should have the +# same z values, but to get the max/min of the data generated +# by all algorithms would imply two passes. Keep it simple. +# +# plw3d(1., 1., 1., xmin, xmax, ymin, ymax, zmin, zmax, 30, -60); +# + + $w cmd plw3d 1. 1. 1. $xmin $xmax $ymin $ymax \ + $lzmin $lzmax 30. -40. + $w cmd plbox3 "bntu" "X" 0. 0 \ + "bntu" "Y" 0. 0 \ + "bcdfntu" "Z" 0.5 0 + $w cmd plcol0 15 + $w cmd pllab "" "" [lindex $title $alg] + $w cmd plot3dc xg yg zg ior ior $DRAW_LINEXY + $MAG_COLOR $BASE_CONT clev + } + } + } + + $w cmd plend +} + + +#---------------------------------------------------------------------------- +# proc max and min +proc max {x y} { + expr {$x > $y? $x : $y} +} +proc min {x y} { + expr {$x > $y? $y : $x} +} + + +#---------------------------------------------------------------------------- +# proc cmap1_init +# Set up the colour map +proc cmap1_init {} { + + matrix i i 2 + matrix h i 2 + matrix l i 2 + matrix s i 2 + + i 1 = 0. + i 2 = 1. + + h 1 = 240. + h 2 = 0. + + l 1 = 0.6 + l 2 = 0.6 + + s 1 = 0.8 + s 2 = 0.8 + + $w cmd plscmap1n 256 + $w cmd plscmap1l .false. i h l s +} + +#---------------------------------------------------------------------------- +# proc a2mnmx +# Minimum and the maximum elements of a 2-d array. + +proc a2mnmx {f nx ny fmin fmax xdim} { + + set fmax [f 0 0] + set fmin $fmax + for {set j 0} {$j < $ny} {incr j} { + for {set i 0} {$i < $nx} {incr i} { + set fmax [max $fmax [f $i $j]] + set fmin [min $fmin [f $i $j]] + } + } +} Property changes on: trunk/examples/tcl/x21.tcl ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2010-05-31 19:46:57
|
Revision: 11045 http://plplot.svn.sourceforge.net/plplot/?rev=11045&view=rev Author: airwin Date: 2010-05-31 19:46:51 +0000 (Mon, 31 May 2010) Log Message: ----------- Put call to plinit in x01 while replacing plstar (which internally calls the equivalent of plinit) with plssub in x01.tcl. This fix allows test_tk_standard_examples (a dependency of the test_interactive target) to work again since tkdemos.tcl (run indirectly by test_tk_standard_examples) assumes no plinit-like commands are in x??.tcl. This fix has also been tested with test_diff_psc and the standalone run of x01 is still consistent with its C counterpart. Modified Paths: -------------- trunk/examples/tcl/x01 trunk/examples/tcl/x01.tcl Modified: trunk/examples/tcl/x01 =================================================================== --- trunk/examples/tcl/x01 2010-05-31 17:31:25 UTC (rev 11044) +++ trunk/examples/tcl/x01 2010-05-31 19:46:51 UTC (rev 11045) @@ -17,5 +17,6 @@ plgver ver puts [format "PLplot library version: %s" $ver ] +plinit x01 plend Modified: trunk/examples/tcl/x01.tcl =================================================================== --- trunk/examples/tcl/x01.tcl 2010-05-31 17:31:25 UTC (rev 11044) +++ trunk/examples/tcl/x01.tcl 2010-05-31 19:46:51 UTC (rev 11045) @@ -11,7 +11,7 @@ # first, this call to pladv is absolutely essential to finish the # preceding page. - $w cmd plstar 2 2 + $w cmd plssub 2 2 #$w cmd pladv 0 #$w cmd plssub 2 2 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arj...@us...> - 2011-02-22 07:31:40
|
Revision: 11574 http://plplot.svn.sourceforge.net/plplot/?rev=11574&view=rev Author: arjenmarkus Date: 2011-02-22 07:31:33 +0000 (Tue, 22 Feb 2011) Log Message: ----------- Adjusted the second set of Tcl examples to use the new PLPLOT namespace for predefined constants Modified Paths: -------------- trunk/examples/tcl/x22.tcl trunk/examples/tcl/x23.tcl trunk/examples/tcl/x26.tcl trunk/examples/tcl/x27.tcl trunk/examples/tcl/x28.tcl trunk/examples/tcl/x29.tcl trunk/examples/tcl/x31.tcl Modified: trunk/examples/tcl/x22.tcl =================================================================== --- trunk/examples/tcl/x22.tcl 2011-02-21 17:20:25 UTC (rev 11573) +++ trunk/examples/tcl/x22.tcl 2011-02-22 07:31:33 UTC (rev 11574) @@ -33,10 +33,10 @@ set dx 1.0 set dy 1.0 - set xmin [expr (-$nx/2*$dx)] - set xmax [expr ($nx/2*$dx)] - set ymin [expr (-$ny/2*$dy)] - set ymax [expr ($ny/2*$dy)] + set xmin [expr {-$nx/2*$dx}] + set xmax [expr {$nx/2*$dx}] + set ymin [expr {-$ny/2*$dy}] + set ymax [expr {$ny/2*$dy}] matrix xg f $nx $ny matrix yg f $nx $ny @@ -45,13 +45,13 @@ # Create data - circulation around the origin. for {set i 0} {$i < $nx} {incr i} { - set x [expr (($i-$nx/2+0.5)*$dx) ] + set x [expr {($i-$nx/2+0.5)*$dx} ] for {set j 0} {$j < $ny} {incr j} { - set y [expr (($j-$ny/2+0.5)*$dy)] + set y [expr {($j-$ny/2+0.5)*$dy}] xg $i $j = $x yg $i $j = $y u $i $j = $y - v $i $j = [expr (-1.0*$x)] + v $i $j = [expr {-1.0*$x}] } } @@ -67,18 +67,16 @@ # Vector plot of flow through a constricted pipe proc constriction {w} { - set pi 3.14159265358979323846 - set nx 20 set ny 20 set dx 1.0 set dy 1.0 - set xmin [expr (-$nx/2*$dx)] - set xmax [expr ($nx/2*$dx)] - set ymin [expr (-$ny/2*$dy)] - set ymax [expr ($ny/2*$dy)] + set xmin [expr {-$nx/2*$dx}] + set xmax [expr {$nx/2*$dx}] + set ymin [expr {-$ny/2*$dy}] + set ymax [expr {$ny/2*$dy}] matrix xg f $nx $ny matrix yg f $nx $ny @@ -88,16 +86,16 @@ set Q 2.0 # Create data - circulation around the origin. for {set i 0} {$i < $nx} {incr i} { - set x [expr (($i-$nx/2+0.5)*$dx) ] + set x [expr {($i-$nx/2+0.5)*$dx} ] for {set j 0} {$j < $ny} {incr j} { - set y [expr (($j-$ny/2+0.5)*$dy)] + set y [expr {($j-$ny/2+0.5)*$dy}] xg $i $j = $x yg $i $j = $y - set b [expr ($ymax/4.0*(3.0-cos($pi*$x/$xmax)))] + set b [expr {$ymax/4.0*(3.0-cos($::PLPLOT::PL_PI*$x/$xmax))}] if {abs($y) < $b} { - set dbdx [expr ($ymax/4.0*sin($pi*$x/$xmax)*$y/$b)] - u $i $j = [expr ($Q*$ymax/$b)] - v $i $j = [expr ($Q*$ymax/$b*$dbdx)] + set dbdx [expr {$ymax/4.0*sin($::PLPLOT::PL_PI*$x/$xmax)*$y/$b}] + u $i $j = [expr {$Q*$ymax/$b}] + v $i $j = [expr {$Q*$ymax/$b*$dbdx}] } else { u $i $j = 0.0 v $i $j = 0.0 @@ -117,8 +115,6 @@ # Vector plot of the gradient of a shielded potential (see example 9) proc potential {w} { - set pi 3.14159265358979323846 - set nr 20 set ntheta 20 set nper 100 @@ -137,24 +133,24 @@ set rmax $nr - 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 < $nr} {incr i} { - set r [expr 0.5 + $i] + set r [expr {0.5 + $i}] for {set j 0} {$j < $ntheta} {incr j} { - set theta [expr {(2. * $pi / ($ntheta - 1.))*(0.5 + $j)}] + set theta [expr {(2. * $::PLPLOT::PL_PI / ($ntheta - 1.))*(0.5 + $j)}] set x [expr {$r * cos($theta)}] set y [expr {$r * sin($theta)}] xg $i $j = $x @@ -166,9 +162,9 @@ pow($eps,2))}] set div2i [expr {sqrt(pow($x-$d2i,2) + pow($y+$d2i,2) + pow($eps,2))}] z $i $j = [expr {$q1/$div1 + $q1i/$div1i + $q2/$div2 + $q2i/$div2i}] - u $i $j = [expr {-$q1*($x-$d1)/pow($div1,3) - $q1i*($x-$d1i)/pow($div1i,3) - + u $i $j = [expr {-$q1*($x-$d1)/pow($div1,3) - $q1i*($x-$d1i)/pow($div1i,3) - $q2*($x-$d2)/pow($div2,3) - $q2i*($x-$d2i)/pow($div2i,3)}] - v $i $j = [expr {-$q1*($y-$d1)/pow($div1,3) - $q1i*($y-$d1i)/pow($div1i,3) - + v $i $j = [expr {-$q1*($y-$d1)/pow($div1,3) - $q1i*($y-$d1i)/pow($div1i,3) - $q2*($y+$d2)/pow($div2,3) - $q2i*($y+$d2i)/pow($div2i,3)}] } } @@ -194,7 +190,7 @@ $w cmd plenv $xmin $xmax $ymin $ymax 0 0 $w cmd pllab "(x)" "(y)" "#frPLplot Example 22 - potential gradient vector plot" # Plot contours of the potential - set dz [expr (($zmax-$zmin)/$nlevel)] + set dz [expr {($zmax-$zmin)/$nlevel}] matrix clevel f $nlevel for {set i 0} {$i < $nlevel} {incr i} { clevel $i = [expr {$zmin + ($i + 0.5)*$dz}] @@ -213,11 +209,11 @@ # Plot the perimeter of the cylinder matrix px f $nper matrix py f $nper - set dtheta [expr (2.0*$pi/($nper-1.0))] + set dtheta [expr {2.0*$::PLPLOT::PL_PI/($nper-1.0)}] for {set i 0} {$i < $nper} {incr i} { - set theta [expr $dtheta*$i] - px $i = [expr ($rmax*cos($theta))] - py $i = [expr ($rmax*sin($theta))] + set theta [expr {$dtheta*$i}] + px $i = [expr {$rmax*cos($theta)}] + py $i = [expr {$rmax*sin($theta)}] } $w cmd plline $nper px py Modified: trunk/examples/tcl/x23.tcl =================================================================== --- trunk/examples/tcl/x23.tcl 2011-02-21 17:20:25 UTC (rev 11573) +++ trunk/examples/tcl/x23.tcl 2011-02-22 07:31:33 UTC (rev 11574) @@ -28,175 +28,175 @@ proc x23 {{w loopback}} { - set Greek0 "#gA" + set Greek0 "#gA" set Greek1 "#gB" set Greek2 "#gG" set Greek3 "#gD" set Greek4 "#gE" set Greek5 "#gZ" - set Greek6 "#gY" - set Greek7 "#gH" + set Greek6 "#gY" + set Greek7 "#gH" set Greek8 "#gI" - set Greek9 "#gK" - set Greek10 "#gL" - set Greek11 "#gM" - set Greek12 "#gN" - set Greek13 "#gC" - set Greek14 "#gO" - set Greek15 "#gP" - set Greek16 "#gR" - set Greek17 "#gS" - set Greek18 "#gT" - set Greek19 "#gU" - set Greek20 "#gF" - set Greek21 "#gX" - set Greek22 "#gQ" - set Greek23 "#gW" - set Greek24 "#ga" - set Greek25 "#gb" - set Greek26 "#gg" - set Greek27 "#gd" - set Greek28 "#ge" - set Greek29 "#gz" - set Greek30 "#gy" - set Greek31 "#gh" - set Greek32 "#gi" - set Greek33 "#gk" - set Greek34 "#gl" - set Greek35 "#gm" - set Greek36 "#gn" - set Greek37 "#gc" - set Greek38 "#go" - set Greek39 "#gp" - set Greek40 "#gr" - set Greek41 "#gs" - set Greek42 "#gt" - set Greek43 "#gu" - set Greek44 "#gf" - set Greek45 "#gx" - set Greek46 "#gq" - set Greek47 "#gw" - + set Greek9 "#gK" + set Greek10 "#gL" + set Greek11 "#gM" + set Greek12 "#gN" + set Greek13 "#gC" + set Greek14 "#gO" + set Greek15 "#gP" + set Greek16 "#gR" + set Greek17 "#gS" + set Greek18 "#gT" + set Greek19 "#gU" + set Greek20 "#gF" + set Greek21 "#gX" + set Greek22 "#gQ" + set Greek23 "#gW" + set Greek24 "#ga" + set Greek25 "#gb" + set Greek26 "#gg" + set Greek27 "#gd" + set Greek28 "#ge" + set Greek29 "#gz" + set Greek30 "#gy" + set Greek31 "#gh" + set Greek32 "#gi" + set Greek33 "#gk" + set Greek34 "#gl" + set Greek35 "#gm" + set Greek36 "#gn" + set Greek37 "#gc" + set Greek38 "#go" + set Greek39 "#gp" + set Greek40 "#gr" + set Greek41 "#gs" + set Greek42 "#gt" + set Greek43 "#gu" + set Greek44 "#gf" + set Greek45 "#gx" + set Greek46 "#gq" + set Greek47 "#gw" + matrix Type1 i 166 = { - 0x0020, 0x0021, 0x0023, 0x0025, 0x0026, - 0x0028, 0x0029, 0x002b, 0x002c, 0x002e, - 0x002f, 0x0030, 0x0031, 0x0032, 0x0033, - 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, - 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, - 0x003e, 0x003f, 0x005b, 0x005d, 0x005f, - 0x007b, 0x007c, 0x007d, 0x00a9, 0x00ac, - 0x00ae, 0x00b0, 0x00b1, 0x00d7, 0x00f7, - 0x0192, 0x0391, 0x0392, 0x0393, 0x0394, - 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, - 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, - 0x039f, 0x03a0, 0x03a1, 0x03a3, 0x03a4, - 0x03a5, 0x03a6, 0x03a7, 0x03a8, 0x03a9, - 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, - 0x03b6, 0x03b7, 0x03b8, 0x03b9, 0x03ba, - 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, - 0x03c0, 0x03c1, 0x03c2, 0x03c3, 0x03c4, - 0x03c5, 0x03c6, 0x03c7, 0x03c8, 0x03c9, - 0x03d1, 0x03d2, 0x03d5, 0x03d6, 0x2022, - 0x2026, 0x2032, 0x2033, 0x203e, 0x2044, - 0x2111, 0x2118, 0x211c, 0x2122, 0x2126, - 0x2135, 0x2190, 0x2191, 0x2192, 0x2193, - 0x2194, 0x21b5, 0x21d0, 0x21d1, 0x21d2, - 0x21d3, 0x21d4, 0x2200, 0x2202, 0x2203, - 0x2205, 0x2206, 0x2207, 0x2208, 0x2209, - 0x220b, 0x220f, 0x2211, 0x2212, 0x2215, - 0x2217, 0x221a, 0x221d, 0x221e, 0x2220, - 0x2227, 0x2228, 0x2229, 0x222a, 0x222b, - 0x2234, 0x223c, 0x2245, 0x2248, 0x2260, - 0x2261, 0x2264, 0x2265, 0x2282, 0x2283, - 0x2284, 0x2286, 0x2287, 0x2295, 0x2297, - 0x22a5, 0x22c5, 0x2320, 0x2321, 0x2329, - 0x232a, 0x25ca, 0x2660, 0x2663, 0x2665, + 0x0020, 0x0021, 0x0023, 0x0025, 0x0026, + 0x0028, 0x0029, 0x002b, 0x002c, 0x002e, + 0x002f, 0x0030, 0x0031, 0x0032, 0x0033, + 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, + 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, + 0x003e, 0x003f, 0x005b, 0x005d, 0x005f, + 0x007b, 0x007c, 0x007d, 0x00a9, 0x00ac, + 0x00ae, 0x00b0, 0x00b1, 0x00d7, 0x00f7, + 0x0192, 0x0391, 0x0392, 0x0393, 0x0394, + 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, + 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, + 0x039f, 0x03a0, 0x03a1, 0x03a3, 0x03a4, + 0x03a5, 0x03a6, 0x03a7, 0x03a8, 0x03a9, + 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, + 0x03b6, 0x03b7, 0x03b8, 0x03b9, 0x03ba, + 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, + 0x03c0, 0x03c1, 0x03c2, 0x03c3, 0x03c4, + 0x03c5, 0x03c6, 0x03c7, 0x03c8, 0x03c9, + 0x03d1, 0x03d2, 0x03d5, 0x03d6, 0x2022, + 0x2026, 0x2032, 0x2033, 0x203e, 0x2044, + 0x2111, 0x2118, 0x211c, 0x2122, 0x2126, + 0x2135, 0x2190, 0x2191, 0x2192, 0x2193, + 0x2194, 0x21b5, 0x21d0, 0x21d1, 0x21d2, + 0x21d3, 0x21d4, 0x2200, 0x2202, 0x2203, + 0x2205, 0x2206, 0x2207, 0x2208, 0x2209, + 0x220b, 0x220f, 0x2211, 0x2212, 0x2215, + 0x2217, 0x221a, 0x221d, 0x221e, 0x2220, + 0x2227, 0x2228, 0x2229, 0x222a, 0x222b, + 0x2234, 0x223c, 0x2245, 0x2248, 0x2260, + 0x2261, 0x2264, 0x2265, 0x2282, 0x2283, + 0x2284, 0x2286, 0x2287, 0x2295, 0x2297, + 0x22a5, 0x22c5, 0x2320, 0x2321, 0x2329, + 0x232a, 0x25ca, 0x2660, 0x2663, 0x2665, 0x2666 } - set title0 "#<0x10>PLplot Example 23 - Greek Letters" - set title1 "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (a)" - set title2 "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (b)" - set title3 "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (c)" - set title4 "#<0x10>PLplot Example 23 - Number Forms Unicode Block" - set title5 "#<0x10>PLplot Example 23 - Arrows Unicode Block (a)" - set title6 "#<0x10>PLplot Example 23 - Arrows Unicode Block (b)" - set title7 "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (a)" - set title8 "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (b)" - set title9 "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (c)" - set title10 "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (d)" - + set title0 "#<0x10>PLplot Example 23 - Greek Letters" + set title1 "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (a)" + set title2 "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (b)" + set title3 "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (c)" + set title4 "#<0x10>PLplot Example 23 - Number Forms Unicode Block" + set title5 "#<0x10>PLplot Example 23 - Arrows Unicode Block (a)" + set title6 "#<0x10>PLplot Example 23 - Arrows Unicode Block (b)" + set title7 "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (a)" + set title8 "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (b)" + set title9 "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (c)" + set title10 "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (d)" + matrix lo i 11 = { - 0x0, - 0x0, - 0x40, - 0x80, - 0x2153, - 0x2190, - 0x21d0, - 0x2200, - 0x2240, - 0x2280, - 0x22c0 + 0x0, + 0x0, + 0x40, + 0x80, + 0x2153, + 0x2190, + 0x21d0, + 0x2200, + 0x2240, + 0x2280, + 0x22c0 } matrix hi i 11 = { - 0x30, - 0x40, - 0x80, - 0xA6, - 0x2184, - 0x21d0, - 0x2200, - 0x2240, - 0x2280, - 0x22c0, - 0x2300 + 0x30, + 0x40, + 0x80, + 0xA6, + 0x2184, + 0x21d0, + 0x2200, + 0x2240, + 0x2280, + 0x22c0, + 0x2300 } matrix nxcells i 11 = { - 12, - 8, - 8, - 8, + 12, 8, - 8, - 8, - 8, - 8, - 8, - 8 + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8 } - + matrix nycells i 11 = { - 8, - 8, - 8, - 8, - 8, - 8, - 8, - 8, - 8, - 8, - 8 + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8 } # non-zero values Must be consistent with nxcells and nycells. matrix offset i 11 = { - 0, - 0, - 64, - 128, - 0, - 0, - 0, - 0, - 0, - 0, - 0 + 0, + 0, + 64, + 128, + 0, + 0, + 0, + 0, + 0, + 0, + 0 } # 30 possible FCI values. @@ -232,20 +232,20 @@ 0x80000123, 0x80000124, } - - set family(0) "sans-serif" - set family(1) "serif" - set family(2) "monospace" - set family(3) "script" - set family(4) "symbol" - - set style(0) "upright" - set style(1) "italic" - set style(2) "oblique" - - set weight(0) "medium" - set weight(1) "bold" - + + set family(0) "sans-serif" + set family(1) "serif" + set family(2) "monospace" + set family(3) "script" + set family(4) "symbol" + + set style(0) "upright" + set style(1) "italic" + set style(2) "oblique" + + set weight(0) "medium" + set weight(1) "bold" + for {set page 0} {$page<11} {incr page} { $w cmd pladv 0 @@ -279,7 +279,7 @@ if {$page == 0} { set cmdString [format "#%s" [set Greek$slice]] } elseif {$page <= 3} { - set cmdString [format "##\[0x%.4x\]" [ Type1 [expr [offset $page]+$slice] ] ] + set cmdString [format "##\[0x%.4x\]" [ Type1 [expr {[offset $page]+$slice}] ] ] } else { set cmdString [format "##\[0x%.4x\]" [expr {[lo $page]+$slice}]] } @@ -338,7 +338,7 @@ "Page 13, %s, %s, %s: The quick brown fox jumps over the lazy dog" \ $family($family_index) \ $style($style_index) \ - $weight($weight_index) \ + $weight($weight_index) \ ] } elseif {$page == 13} { set string [format \ Modified: trunk/examples/tcl/x26.tcl =================================================================== --- trunk/examples/tcl/x26.tcl 2011-02-21 17:20:25 UTC (rev 11573) +++ trunk/examples/tcl/x26.tcl 2011-02-22 07:31:33 UTC (rev 11574) @@ -130,8 +130,6 @@ proc plot261 { w type x_label y_label alty_label legend_text title_label line_label } { - set PI [expr {4.0*atan(1.0)}] - matrix freql f 101 matrix ampl f 101 matrix phase f 101 @@ -145,7 +143,7 @@ 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)}] + phase $i = [expr {-(180.0 / $::PLPLOT::PL_PI) * atan($freq / $f0)}] } $w cmd plvpor 0.15 0.85 0.1 0.9 $w cmd plwind -2.0 3.0 -80.0 0.0 Modified: trunk/examples/tcl/x27.tcl =================================================================== --- trunk/examples/tcl/x27.tcl 2011-02-21 17:20:25 UTC (rev 11573) +++ trunk/examples/tcl/x27.tcl 2011-02-22 07:31:33 UTC (rev 11574) @@ -93,7 +93,7 @@ set windings [expr {int($param4)}] set steps [expr {$NPNT/$windings}] - set dphi [expr {8.0*acos(-1.0)/double($steps)}] + set dphi [expr {8.0*$::PLPLOT::PL_PI/double($steps)}] # This initialisation is safe! set xmin 0.0 Modified: trunk/examples/tcl/x28.tcl =================================================================== --- trunk/examples/tcl/x28.tcl 2011-02-21 17:20:25 UTC (rev 11573) +++ trunk/examples/tcl/x28.tcl 2011-02-22 07:31:33 UTC (rev 11574) @@ -35,9 +35,7 @@ set NROTATION 8 set NSHEAR 8 - set pi 3.14159265358979323846 - - set DRAW_LINEXY 3 + set pi $::PLPLOT::PL_PI set xmin 0. set xmax 1.0 @@ -63,7 +61,7 @@ set dzsrot [expr {$zsrange / ( $NROTATION - 1 )}] set dzsshear [expr {$zsrange / ( $NSHEAR - 1 )}] - # p1string must be exactly one character + the null termination + # p1string must be exactly one character + the null termination # character. set p1string "O" set pstring "The future of our civilization depends on software freedom." @@ -87,12 +85,12 @@ } # 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 \ @@ -117,7 +115,7 @@ 0.0 " revolution" } - # x = xmax. + # 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)}] @@ -136,7 +134,7 @@ 0.0 " revolution" } - # y = ymax. + # 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)}] @@ -154,21 +152,21 @@ $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. + # Draw minimal 3D grid to finish defining the 3D box. + $w cmd plmesh x y z $XPTS $YPTS [expr {$::PLPLOT::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. + # y = ymax. $w cmd plschr 0. 1.0 set x_inclination 1. set y_inclination 0. @@ -188,7 +186,7 @@ 0.5 "rotation for y = y#dmax#u" } - # x = xmax. + # x = xmax. $w cmd plschr 0. 1.0 set x_inclination 0. set y_inclination -1. @@ -208,7 +206,7 @@ 0.5 "rotation for x = x#dmax#u" } - # z = zmin. + # z = zmin. $w cmd plschr 0. 1.0 set x_inclination 1. set y_inclination 0. @@ -227,25 +225,25 @@ $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 + # Draw minimal 3D grid to finish defining the 3D box. + $w cmd plmesh x y z $XPTS $YPTS [expr {$::PLPLOT::DRAW_LINEXY}] - # Page 3: Demonstrate shear of string along its axis. - # Work around xcairo and pngcairo (but not pscairo) problems for + # 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.) + # 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. + # y = ymax. $w cmd plschr 0. 1.0 set x_inclination 1. set y_inclination 0. @@ -265,7 +263,7 @@ 0.5 "shear for y = y#dmax#u" } - # x = xmax. + # x = xmax. $w cmd plschr 0. 1.0 set x_inclination 0. set y_inclination -1. @@ -285,7 +283,7 @@ 0.5 "shear for x = x#dmax#u" } - # z = zmin. + # z = zmin. $w cmd plschr 0. 1.0 set x_inclination 1. set y_inclination 0. @@ -304,28 +302,28 @@ $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. + # Draw minimal 3D grid to finish defining the 3D box. + $w cmd plmesh x y z $XPTS $YPTS [expr {$::PLPLOT::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. + # 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 + # 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} { @@ -334,14 +332,14 @@ 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. + # 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. + # a constant vector that is parallel to the Z axis. set x_shear 0. set y_shear 0. set z_shear 1. @@ -352,15 +350,15 @@ 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 + # Draw minimal 3D grid to finish defining the 3D box. + $w cmd plmesh x y z $XPTS $YPTS [expr {$::PLPLOT::DRAW_LINEXY}] - # Page 5: Demonstrate plmtex3 axis labelling capability + # 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 \ @@ -379,7 +377,7 @@ $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 - + # Draw minimal 3D grid to finish defining the 3D box. + $w cmd plmesh x y z $XPTS $YPTS [expr {$::PLPLOT::DRAW_LINEXY}] + } Modified: trunk/examples/tcl/x29.tcl =================================================================== --- trunk/examples/tcl/x29.tcl 2011-02-21 17:20:25 UTC (rev 11573) +++ trunk/examples/tcl/x29.tcl 2011-02-22 07:31:33 UTC (rev 11574) @@ -24,14 +24,14 @@ # Draws several plots which demonstrate the use of date / time formats for # the axis labels. -# Time formatting is done using the system strftime routine. See the +# Time formatting is done using the system strftime routine. See the # documentation of this for full details of the available formats. # # 1) Plotting temperature over a day (using hours / minutes) -# 2) Plotting +# 2) Plotting # -# Note: Times are stored as seconds since the epoch (usually 1st Jan 1970). -# +# Note: Times are stored as seconds since the epoch (usually 1st Jan 1970). +# proc x29 {{w loopback}} { @@ -50,27 +50,25 @@ # Plot a model diurnal cycle of temperature proc x29_plot1 {{w loopback}} { - set pi 3.14159265358979323846 - # Data points every 10 minutes for 1 day set npts 73 - + matrix x f $npts matrix y f $npts matrix xerr1 f $npts matrix xerr2 f $npts matrix yerr1 f $npts matrix yerr2 f $npts - + set xmin 0 # Number of seconds in a day - set xmax [expr {60.0*60.0*24.0}] + set xmax [expr {60.0*60.0*24.0}] set ymin 10.0 set ymax 20.0 - + for {set i 0} {$i<$npts} {incr i} { set xx [expr {$xmax*double($i)/double($npts)}] - set yy [expr {15.0 - 5.0*cos( 2*$pi*double($i)/double($npts))}] + set yy [expr {15.0 - 5.0*cos( 2*$::PLPLOT::PL_PI*double($i)/double($npts))}] x $i = $xx y $i = $yy xerr1 $i = [expr {$xx - 60.0*5.0}] @@ -78,7 +76,7 @@ yerr1 $i = [expr {$yy - 0.1}] yerr2 $i = [expr {$yy + 0.1}] } - + $w cmd pladv 0 $w cmd plsmaj 0.0 0.5 @@ -96,7 +94,7 @@ $w cmd plcol0 3 $w cmd pllab "Time (hours:mins)" "Temperature (degC)" \ "@frPLplot Example 29 - Daily temperature" - + $w cmd plcol0 4 $w cmd plline $npts x y @@ -110,25 +108,25 @@ } # Plot the number of hours of daylight as a function of day for a year -proc x29_plot2 {{w loopback}} { - - set pi 3.14159265358979323846 +proc x29_plot2 {{w loopback}} { + set pi $::PLPLOT::PL_PI + # Latitude for London set lat 51.5 - + set npts 365 - + matrix x f $npts matrix y f $npts - + set xmin 0 set xmax [expr {$npts*60.0*60.0*24.0}] set ymin 0 set ymax 24 - - # Formula for hours of daylight from - # "A Model Comparison for Daylength as a Function of Latitude and + + # Formula for hours of daylight from + # "A Model Comparison for Daylength as a Function of Latitude and # Day of the Year", 1995, Ecological Modelling, 80, pp 87-95. for {set j 0} {$j < $npts} {incr j} { x $j = [expr {$j*60.0*60.0*24.0}] @@ -139,7 +137,7 @@ (cos($lat*$pi/180.0)*cos($p)) )}] y $j = $d } - + $w cmd plcol0 1 # Set time format to be abbreviated month name followed by day of month $w cmd pltimefmt "%b %d" @@ -150,7 +148,7 @@ $w cmd plcol0 3 $w cmd pllab "Date" "Hours of daylight" \ "@frPLplot Example 29 - Hours of daylight at 51.5N" - + $w cmd plcol0 4 $w cmd plline $npts x y @@ -160,16 +158,14 @@ proc x29_plot3 {{w loopback}} { - set pi 3.14159265358979323846 - # Calculate seconds since the Unix epoch for 2005-12-01 UTC. - # On newer versions of tcl should use the -format "%Y-%m-%d" - # option rather than free-form scanning, but this doesn't + # On newer versions of tcl should use the -format "%Y-%m-%d" + # option rather than free-form scanning, but this doesn't # seem to work on tcl8.4 # Also -timezone :UTC should be used instead of -gmt set tstart [clock scan "2005-12-01" \ -gmt true ] - + set npts 62 matrix x f $npts @@ -179,11 +175,11 @@ set xmax [expr {$xmin + $npts*60.0*60.0*24.0}] set ymin 0.0 set ymax 5.0 - + for {set i 0} {$i<$npts} {incr i} { x $i = [expr {$xmin + $i*60.0*60.0*24.0}] set imin [expr {$i < $npts-$i ? $i : $npts-$i}] - y $i = [expr {1.0 + sin( 2*$pi*double($i)/7.0 ) + \ + y $i = [expr {1.0 + sin( 2*$::PLPLOT::PL_PI*double($i)/7.0 ) + \ exp( double($imin) / 31.0) }] } $w cmd pladv 0 @@ -197,25 +193,25 @@ $w cmd pltimefmt "%Y-%m-%d" # Draw a box with ticks spaced every 14 days in X and 1 hour in Y. $w cmd plbox "bcnstd" [expr {14*24.0*60.0*60.0}] 14 "bcnstv" 1 4 - + $w cmd plcol0 3 $w cmd pllab "Date" "Hours of television watched" \ "@frPLplot Example 29 - Hours of television watched in Dec 2005 / Jan 2006" - + $w cmd plcol0 4 $w cmd plssym 0.0 0.5 $w cmd plpoin $npts x y 2 - $w cmd plline $npts x y + $w cmd plline $npts x y } proc x29_plot4 {{w loopback}} { # TAI-UTC (seconds) as a function of time. # Use Besselian epochs as the continuous time interval just to prove # this does not introduce any issues. - + # Use the definition given in http://en.wikipedia.org/wiki/Besselian_epoch - # B = 1900. + (JD -2415020.31352)/365.242198781 + # B = 1900. + (JD -2415020.31352)/365.242198781 # ==> (as calculated with aid of "bc -l" command) # B = (MJD + 678940.364163900)/365.242198781 # ==> @@ -327,6 +323,6 @@ $w cmd plline $npts x y } - + } Modified: trunk/examples/tcl/x31.tcl =================================================================== --- trunk/examples/tcl/x31.tcl 2011-02-21 17:20:25 UTC (rev 11573) +++ trunk/examples/tcl/x31.tcl 2011-02-22 07:31:33 UTC (rev 11574) @@ -4,9 +4,6 @@ proc x31 {{w loopback}} { - # this constant should be defined centrally. - set PL_NOTSET -42 - # Test setting / getting familying parameters before plinit. # Save values set by plparseopts to be restored later. @@ -25,7 +22,7 @@ } # Restore values set initially by plparseopts. $w cmd plsfam $fam0 $num0 $bmax0 - + # Test setting / getting page parameters before plinit. # Save values set by plparseopts to be restored later. $w cmd plgpage xp0 yp0 xleng0 yleng0 xoff0 yoff0 @@ -57,7 +54,7 @@ # Test if device initialization screwed around with the preset # compression parameter. - $w cmd plgcompression compression2 + $w cmd plgcompression compression2 puts [ format "Output various PLplot parameters" ] puts [ format "compression parameter = %d" $compression2 ] if {$compression2 != $compression1} { @@ -75,7 +72,7 @@ $w cmd plscmap1 r1 g1 b1 2 $w cmd plscmap1a r1 g1 b1 a1 2 - $w cmd plglevel level2 + $w cmd plglevel level2 puts [ format "level parameter = %d" $level2 ] if {$level2 != 1} { puts stderr "plglevel test failed." @@ -90,8 +87,8 @@ puts stderr "plgvpd test failed" set status 1 } - set xmid [ expr 0.5*($xmin+$xmax) ] - set ymid [ expr 0.5*($ymin+$ymax) ] + set xmid [ expr {0.5*($xmin+$xmax)} ] + set ymid [ expr {0.5*($ymin+$ymax)} ] $w cmd plwind 0.2 0.3 0.4 0.5 $w cmd plgvpw xmin xmax ymin ymax @@ -110,7 +107,7 @@ } # Retrieve and print the name of the output file (if any) - $w cmd plgfnam fnam + $w cmd plgfnam fnam if {$fnam == ""} { puts [ format "No output file name is set" ] } {else} { @@ -119,7 +116,7 @@ puts stderr [ format "Output file name is %s" $fnam ] # Set and get the number of digits used to display axis labels - # Note digits is currently ignored in pls[xyz]ax and + # Note digits is currently ignored in pls[xyz]ax and # therefore it does not make sense to test the returned value. $w cmd plsxax 3 0 $w cmd plgxax digmax digits @@ -137,14 +134,14 @@ set status 1 } $w cmd plszax 5 0 - $w cmd plgzax digmax digits + $w cmd plgzax digmax digits puts [ format "z axis parameters: digmax, digits = %d %d" $digmax $digits ] if {$digmax != 5} { puts stderr "plgzax test failed" set status 1 } - $w cmd plsdidev 0.05 $PL_NOTSET 0.1 0.2 + $w cmd plsdidev 0.05 [expr {$::PLPLOT::PL_NOTSET}] 0.1 0.2 $w cmd plgdidev mar aspect jx jy puts [ format "device-space window parameters: mar, aspect, jx, jy = %f %f %f %f" $mar $aspect $jx $jy ] if {$mar != 0.05 || $jx != 0.1 || $jy != 0.2} { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2013-11-12 10:16:42
|
Revision: 12683 http://sourceforge.net/p/plplot/code/12683 Author: airwin Date: 2013-11-12 10:16:40 +0000 (Tue, 12 Nov 2013) Log Message: ----------- Change the two-argument min and max functions used in various examples to the exact variable number of argument min and max used in bindings/tk/pltools.tcl. This prevents a clash (found under plserver when editing the cmap1 colour palette for example 8) in min and max function definitions when these examples are running in examples/tk under plserver. Modified Paths: -------------- trunk/examples/tcl/x20.tcl trunk/examples/tcl/x21.tcl trunk/examples/tcl/x33.tcl Modified: trunk/examples/tcl/x20.tcl =================================================================== --- trunk/examples/tcl/x20.tcl 2013-11-12 08:15:37 UTC (rev 12682) +++ trunk/examples/tcl/x20.tcl 2013-11-12 10:16:40 UTC (rev 12683) @@ -514,11 +514,20 @@ #---------------------------------------------------------------------------- # proc max and min -proc max {x y} { - expr {$x > $y? $x : $y} +proc min {args} { + set x [lindex $args 0] + foreach i $args { + if {$i<$x} {set x $i} + } + return $x } -proc min {x y} { - expr {$x > $y? $y : $x} + +proc max {args} { + set x [lindex $args 0] + foreach i $args { + if {$i>$x} {set x $i} + } + return $x } Modified: trunk/examples/tcl/x21.tcl =================================================================== --- trunk/examples/tcl/x21.tcl 2013-11-12 08:15:37 UTC (rev 12682) +++ trunk/examples/tcl/x21.tcl 2013-11-12 10:16:40 UTC (rev 12683) @@ -269,14 +269,22 @@ #---------------------------------------------------------------------------- # proc max and min -proc max {x y} { - expr {$x > $y? $x : $y} +proc min {args} { + set x [lindex $args 0] + foreach i $args { + if {$i<$x} {set x $i} + } + return $x } -proc min {x y} { - expr {$x > $y? $y : $x} + +proc max {args} { + set x [lindex $args 0] + foreach i $args { + if {$i>$x} {set x $i} + } + return $x } - #---------------------------------------------------------------------------- # proc cmap1_init # Set up the colour map Modified: trunk/examples/tcl/x33.tcl =================================================================== --- trunk/examples/tcl/x33.tcl 2013-11-12 08:15:37 UTC (rev 12682) +++ trunk/examples/tcl/x33.tcl 2013-11-12 10:16:40 UTC (rev 12683) @@ -975,10 +975,18 @@ } # Auxiliary routines -proc max {a b} { - expr {$a > $b? $a : $b} +proc min {args} { + set x [lindex $args 0] + foreach i $args { + if {$i<$x} {set x $i} + } + return $x } -proc min {a b} { - expr {$a < $b? $a : $b} +proc max {args} { + set x [lindex $args 0] + foreach i $args { + if {$i>$x} {set x $i} + } + return $x } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arj...@us...> - 2008-08-30 07:00:23
|
Revision: 8722 http://plplot.svn.sourceforge.net/plplot/?rev=8722&view=rev Author: arjenmarkus Date: 2008-08-30 07:00:32 +0000 (Sat, 30 Aug 2008) Log Message: ----------- Initial commit for example x20 (almost working - calls to plimagefr need correction). Various corrections in example x21, still needs work Modified Paths: -------------- trunk/examples/tcl/x21.tcl Added Paths: ----------- trunk/examples/tcl/x20 trunk/examples/tcl/x20.tcl Added: trunk/examples/tcl/x20 =================================================================== --- trunk/examples/tcl/x20 (rev 0) +++ trunk/examples/tcl/x20 2008-08-30 07:00:32 UTC (rev 8722) @@ -0,0 +1,19 @@ +#!/bin/sh +#--------------------------------*- Tcl -*------------------------------------# +# $Id$ +# +# Maurice LeBrun +# 12/24/02 +# +# A front-end to x06.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 x20.tcl + +plinit +x20 +plend Property changes on: trunk/examples/tcl/x20 ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/examples/tcl/x20.tcl =================================================================== --- trunk/examples/tcl/x20.tcl (rev 0) +++ trunk/examples/tcl/x20.tcl 2008-08-30 07:00:32 UTC (rev 8722) @@ -0,0 +1,548 @@ +# $Id$ +# +# Copyright (C) 2004 Alan W. Irwin +# Copyright (C) 2008 Arjen Markus +# +# +# 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 +# +# +# plimage demo +# +# + +#static PLOptionTable options[] = { +#{ +# "dbg", /* extra debugging plot */ +# NULL, +# NULL, +# &dbg, +# PL_OPT_BOOL, +# "-dbg", +# "Extra debugging plot" }, +#{ +# "nosombrero", /* Turns on test of xor function */ +# NULL, +# NULL, +# &nosombrero, +# PL_OPT_BOOL, +# "-nosombrero", +# "No sombrero plot" }, +#{ +# "nointeractive", /* Turns on test of xor function */ +# NULL, +# NULL, +# &nointeractive, +# PL_OPT_BOOL, +# "-nointeractive", +# "No interactive selection" }, +#{ +# "save", /* For saving in postscript */ +# NULL, +# NULL, +# &f_name, +# PL_OPT_STRING, +# "-save filename", +# "Save sombrero plot in color postscript `filename'" }, +#{ +# NULL, /* option */ +# NULL, /* handler */ +# NULL, /* client data */ +# NULL, /* address of variable to set */ +# 0, /* mode flag */ +# NULL, /* short syntax */ +# NULL } /* long syntax */ +#}; + +proc x20 {{w loopback}} { + + set PI [expr {4.0*atan(1.0)}] + + set XDIM 260 + set YDIM 220 + + matrix x f $XDIM + matrix y f $YDIM + matrix z f $XDIM $YDIM + matrix r f $XDIM $YDIM + +# +# Bugs in plimage(): +# -at high magnifications, the left and right edge are ragged, try +# ./x20c -dev xwin -wplt 0.3,0.3,0.6,0.6 -ori 0.5 +# +# Bugs in x20c.c: +# -if the window is resized after a selection is made on 'lena', when +# making a new selection the old one will re-appear. +# +# +# Parse and process command line arguments +# +# $w cmd plMergeOpts options "x20c options" NULL + + set dbg 0 + set nosombrero 0 + set nointeractive 0 + set f_name "" + + set XDIMM1 [expr {$XDIM-1}] + set YDIMM1 [expr {$YDIM-1}] + +# View image border pixels + if { $dbg} { + $w cmd plenv 1. $XDIM 1. $YDIM 1 1 + + for { set i 0 } { $i < $YDIM } { incr i } { + for { set j 0 } { $j < $YDIM } { incr j } { + z $i $j = 0.0 + } + } + +# Build a one pixel square border, for diagnostics + + for { set i 0 } { $i <$XDIM } { incr i } { +# Right + z $i $YDIMM1 = 1.0 +# Left + z $i 0 = 1.0 + } + + for { set i 0 } { $i <$YDIM } { incr i } { +# Top + z 0 $i = 1.0 +# Bottom + z $XDIMM1 $i = 1.0 + } + + $w cmd pllab "...around a blue square."" " \ + "A red border should appear...") + + $w cmd plimage z 1. $XDIM 1. $YDIM 0. 0. 1. $XDIM 1.$YDIM + + $w cmd pladv 0 + } + +# Sombrero-like demo + if { ! $nosombrero } { +# draw a yellow plot box, useful for diagnostics# :( + $w cmd plcol0 2 + $w cmd plenv 0. [expr {2.*$PI}] 0.0 [expr {3.*$PI}] 1 -1 + + for { set i 0 } { $i < $XDIM } { incr i } { + x $i = [expr {double($i)*2.*$PI/double($XDIMM1)}] + } + for { set i 0 } { $i < $YDIM } { incr i } { + y $i = [expr {double($i)*3.*$PI/double($YDIMM1)}] + } + + for { set i 0 } { $i < $XDIM } { incr i } { + for { set j 0 } { $j < $YDIM } { incr j } { + set xx [x $i] + set yy [y $j] + r $i $j = [expr {sqrt($xx*$xx+$yy*$yy)+0.001}] + set rr [r $i $j] + z $i $j = [expr {sin($rr) / $rr}] + } + } + + $w cmd pllab "No an amplitude clipped \"sombrero\"" "" "Saturn?" + $w cmd plptex 2. 2. 3. 4. 0. "Transparent image" + $w cmd plimage z 0. [expr {2.*$PI}] 0.0 [expr {3.*$PI}] \ + 0.05 1. 0. [expr {2.*$PI}] 0. [expr {3.*$PI}] + +# Save the plot + if { $f_name != "" } { + save_plot $w $f_name + } + + $w cmd pladv 0 + } + +# +# Read Lena image +# Note we try two different locations to cover the case where this +# examples is being run from the test_c.sh script +# + if { ![read_img "lena.pgm" img_f width height num_col] } { + if { ![read_img "../lena.pgm" img_f width height num_col] } { +#C $w cmd plabort "No such file" + puts "Image could not be read" + $w cmd plend + exit + } + } + +# Set gray colormap + gray_cmap $w $num_col + +# Display Lena + $w cmd plenv 1. $width 1. $height 1 -1 + + if { !$nointeractive } { + $w cmd pllab "Set and drag Button 1 to re set selection Button 2 to finish." \ + "" "Lena..." + } else { + $w cmd pllab """ ""Lena..." + } + + $w cmd plimage img_f 1. $width 1. $height 0. 0. 1. $width 1. $height + +# Selection/expansion demo + if { !$nointeractive } { + set xi 200.0 + set xe 330.0 + set yi 280.0 + set ye 220.0 + + if { [get_clip $w $xi $xe $yi $ye] } { + $w cmd plend + $w cmd exit 0 + } + +# +# I'm unable to continue, clearing the plot and advancing to the next +# one, without hiting the enter key, or pressing the button... help# +# Forcing the xwin driver to leave locate mode and destroying the +# xhairs in GetCursorCmd solves some problems but I still have +# to press the enter key or press Button-2 to go to next plot, even +# if a pladv() is not present# Using plbop() solves the problem, but +# it shouldn't be needed# +# +# plspause(0), pladv(0), plspause(1), also works, +# but the above question remains. +# With this approach, the previous pause state is lost, +# as there is no API $w cmd to get its current state. +# + + $w cmd plspause 0 + $w cmd pladv 0 + +# Display selection only + $w cmd plimage img_f 1. $width 1. $height 0. 0. $xi $xe $ye $yi + + $w cmd plspause 1 + $w cmd pladv 0 + +# Zoom in selection + $w cmd plenv $xi $xe $ye $yi 1 -1 + $w cmd plimage img_f 1. $width 1. $height 0. 0. $xi $xe $ye $yi + $w cmd pladv 0 + } + +# Base the dynamic range on the image contents. + + a2mnmx img_f $width $height img_min img_max + + $w cmd plcol 2 + $w cmd plenv 0. $width 0. $height 1 -1 + $w cmd pllab "" "" "Reduced dynamic range image example" + $w cmd plimagefr img_f 0. $width 0. $height 0. 0. \ + [expr {$img_min + $img_max * 0.25}] \ + [expr {$img_max - $img_max * 0.25}] + +# Draw a distorted version of the original image, showing its +# full dynamic range. + $w cmd plenv 0. $width 0. $height 1 -1 + $w cmd pllab "" "" "Distorted image example" + +# Populate the 2-d grids used for the distortion +# NB grids must be 1 larger in each dimension than the image +# since the coordinates are for the corner of each pixel. + + set widthp1 [expr {$width+1}] + set heightp1 [expr {$height+1}] + matrix xg f $withp1 $heightp1 + matrix yg f $withp1 $heightp1 + + set x0 [expr {0.5*$width}] + set y0 [expr {0.5*$height}] + set dy [expr {0.5*$height}] + set stretch 0.5 + for { set i 0 } { $i < $widthp1 } { incr i } { + for { set j 0 } { $j < $widthp1 } { incr j } { + xg $i $j = [expr {$x0 + ($x0-double($i))*(1.0 - $stretch * + cos((double($j)-$y0)/$dy*$PI*0.5))}] + yg $i $j = $j + } + } + $w cmd plimagefr img_f 0. $width_r 0. $height_r 0. 0. $img_min \ + $img_max xg yg + $w cmd pladv 0 + + $w cmd plend + $w cmd exit 0 +} + +# ------------------------------------------- +# Read image from file in binary ppm format +proc read_img {fname img_f_name width_name height_name num_col_name} { + upvar 1 $img_f_name img_f + upvar 1 $width_name width + upvar 1 $height_name height + upvar 1 $num_col_name num_col + +# Naive grayscale binary ppm reading. If you know how to, improve it + + if { [catch { + set infile [open $fname r] + }] } { + return 0 ;# File does not exist + } + + if { [catch { +# I only understand "P5"# + set ver [gets $infile] + if { $ver != "P5" } { + return 0 + } + + while {1} { + set ver [gets $infile] + + if { [string index $ver 0] != "#" } { + break + } + } + +# Found the line with the sizes + + scan $ver "%d %d" w h + + set ver [gets $infile] + scan $ver "%d" num_col + + matrix img_f f $w $h + +# +# Read the second part - it becomes binary +# + fconfigure $infile -translation binary + + set picture [read $infile] + close $infile + +# +# The picture needs to be flipped vertically. +# So do that rightaway +# +# + set count 0 + for { set j 0 } { $j < $h } { incr j } { + for { set i 0 } { $i < $w } { incr i } { + + binary scan [string index $picture $count] c value + if { $value < 0 } { + set value [expr {256+$value}] + } + img_f $i [expr {$h-$j-1}] = $value + incr count + } + } + + set width $w + set height $h + } msg] } { + # Some error occurred + puts "Error reading picture file: $msg" + return 0 + } else { + return 1 + } +} + +# Save plot +proc save_plot {w fname} { + +# Get current stream + $w cmd plgstrm cur_strm + +# Create a new one + $w cmd plmkstrm new_strm + +# New device type. _Use_ a known existing driver + $w cmd plsdev "psc" + $w cmd plsfnam $fname + +# Copy old stream parameters to new stream + $w cmd plcpstrm $cur_strm 0 + $w cmd plreplot + $w cmd plend1 + +# Return to previous one + $w cmd plsstrm $cur_strm +} + +# Get selection square interactively +proc get_clip {w xi xe yi ye} { + +# How do we translate that? +# type(PLGraphicsIn) :: gin + + return 0 ;# getcursor not supported! + + matrix sx f 5 + matrix sy f 5 + + set PLK_Return "\r" + + scan "Q" %c Q + + set xxi $xi + set yyi $yi + set xxe $xe + set yye $ye + set start 0 + +# Enter xor mode to draw a selection rectangle + $w cmd plxormod 1 st + + +# Driver has xormod capability, continue + if { $st } { + while {1} { + + $w cmd plxormod 0 st + $w cmd plgetcursor gin + $w cmd plxormod 1 st + + if { $gin_button == 1 } { + set xxi $gin_wX + set yyi $gin_wY + if { start } { +#C clear previous rectangle + $w cmd plline 5 sx sy + } + + set start 0 + + sx 0 = $xxi + sy 0 = $yyi + sx 4 = $xxi + sy 4 = $yyi + } + + if { gin%state & 0x100 != 0 } { + set xxe $gin_wX + set yye $gin_wY + if { $start } { +# Clear previous rectangle + $w cmd plline 5 sx sy + } + set start 1 + + sx 2 = $xxe + sy 2 = $yye + sx 1 = $xxe + sy 1 = $yyi + sx 3 = $xxi + sy 3 = $yye +# Draw new rectangle + $w cmd plline 5 sx sy + } + + if {($gin_button == 3) || ($gin_keysym == $PLK_Return) || + ($gin_keysym == $Q } { + if { $start } { +# Clear previous rectangle + $w cmd plline 5 sx sy + break + } + } + } + +# Leave xor mode + $w cmd plxormod 0 st + + if { $xxe < $xxi } { + set t $xxi + set xxi $xxe + set xxe $t + } + + if { $yyi < $yye } { + set t $yyi + set yyi $yye + set yye $t + } + + set xe $xxe + set xi $xxi + set ye $yye + set yi $yyi + + set get_clip [expr { $gin_keysym == $Q}] + } else { +# driver has no xormod capability, just do nothing + get_clip = 0 + return + } +} + +# Set gray colormap +proc gray_cmap {w num_col} { + + matrix R f 2 + matrix G f 2 + matrix B f 2 + matrix pos f 2 + matrix rev i 2 + + R 0 = 0.0 + G 0 = 0.0 + B 0 = 0.0 + R 1 = 1.0 + G 1 = 1.0 + B 1 = 1.0 + + pos 0 = 0.0 + pos 1 = 1.0 + rev 0 = 0 + rev 1 = 0 + + $w cmd plscmap1n num_col + $w cmd plscmap1l 1 2 pos R G B rev + +} + + +#---------------------------------------------------------------------------- +# proc max and min +proc max {x y} { + expr {$x > $y? $x : $y} +} +proc min {x y} { + expr {$x > $y? $y : $x} +} + + +#---------------------------------------------------------------------------- +# proc a2mnmx +# Minimum and the maximum elements of a 2-d array. + +proc a2mnmx {f nx ny fmin fmax} { + upvar 1 $fmin vmin + upvar 1 $fmax vmax + + set vmax [$f 0 0] + set vmin $vmax + for {set j 0} {$j < $ny} {incr j} { + for {set i 0} {$i < $nx} {incr i} { + set vmax [max $vmax [$f $i $j]] + set vmin [min $vmin [$f $i $j]] + } + } +} Property changes on: trunk/examples/tcl/x20.tcl ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/examples/tcl/x21.tcl =================================================================== --- trunk/examples/tcl/x21.tcl 2008-08-30 06:56:00 UTC (rev 8721) +++ trunk/examples/tcl/x21.tcl 2008-08-30 07:00:32 UTC (rev 8722) @@ -58,12 +58,13 @@ matrix x f $pts matrix y f $pts matrix z f $pts - matrix clev f $pts + matrix clev f $nl matrix xg f $xp matrix yg f $yp matrix zg f $xp $yp - set title {"Cubic Spline Approximation" + set title {"-dummy-" + "Cubic Spline Approximation" "Delaunay Linear Interpolation" "Natural Neighbors Interpolation" "KNN Inv. Distance Weighted" @@ -77,9 +78,9 @@ set xmax 0.6 set ymax 0.6 - opt 3 = $wmin - opt 4 = [expr {double($knn_order)}] - opt 5 = $threshold + opt 2 = $wmin + opt 3 = [expr {double($knn_order)}] + opt 4 = $threshold for {set i 0} {$i < $pts} {incr i} { set xt [expr {($xmax-$xmin)*[plrandd]}] @@ -111,10 +112,12 @@ } for {set i 0} {$i < $xp} {incr i} { - xg $i = [expr {$xmin + ($xmax-$xmin)*($i-1.)/($xp-1.)}] + xg $i = [expr {$xmin + ($xmax-$xmin)*$i/double($xp-1.)}] + puts "xg: $i [xg $i]" } for {set i 0} {$i < $yp} {incr i} { - yg $i = [expr {$ymin + ($ymax-$ymin)*($i-1.)/($yp-1.)}] + yg $i = [expr {$ymin + ($ymax-$ymin)*$i/double($yp-1.)}] + puts "yg: $i [yg $i]" } $w cmd plcol0 1 @@ -131,7 +134,7 @@ $w cmd pladv 0 for {set alg 1} {$alg <= 6} {incr alg} { - $w cmd plgriddata x y z xg yg zg $alg [opt $alg] + $w cmd plgriddata x y z xg yg zg $alg [opt [expr {$alg-1}]] # - CSA can generate NaNs (only interpolates? #). # - DTLI and NNI can generate NaNs for points outside the convex hull @@ -144,7 +147,7 @@ # if {($alg == $GRID_CSA) || ($alg == $GRID_DTLI) || - ($alg == $GRID_NNLI) || ($alg == $GRID_NNI} { + ($alg == $GRID_NNLI) || ($alg == $GRID_NNI)} { for {set i 0} {$i < $xp} {incr i} { for {set j 0} {$j < $yp} {incr j} { @@ -155,10 +158,10 @@ set dist 0. set ii [expr {$i-1}] - while {($ii < $i+1) && ($ii < $xp)} { + while {($ii <= $i+1) && ($ii < $xp)} { set jj [expr {$j-1}] - while {($jj == $j+1) && ($jj < $yp)} { - if {($ii >= 0) && (jj >= 1) && + while {($jj <= $j+1) && ($jj < $yp)} { + if {($ii >= 0) && ($jj >= 0) && ![isnan [zg $ii $jj]] } { if {abs($ii-$i) + abs($jj-$j) == 1)} { set d 1. @@ -182,13 +185,13 @@ } } - a2mnmx zg xp yp lzmin lzmax xp + a2mnmx zg $xp $yp lzmin lzmax - set lzmin = [min $lzmin $zmin] - set lzmax = [max $lzmax $zmax] + set lzmin [min $lzmin $zmin] + set lzmax [max $lzmax $zmax] - set lzmin = [expr {lzmin - 0.01}] - set lzmax = [expr {lzmax + 0.01}] + set lzmin [expr {$lzmin - 0.01}] + set lzmax [expr {$lzmax + 0.01}] $w cmd plcol0 1 $w cmd pladv $alg @@ -196,20 +199,19 @@ if {$k == 0} { for {set i 0} {$i < $nl} {incr i} { - clev $i = [expr {$lzmin + ($lzmax-$lzmin)/($nl-1.)*($i-1.)}] + clev $i = [expr {$lzmin + ($lzmax-$lzmin)/double($nl-1.)*$i}] } - $w cmd plenv0 xmin xmax ymin ymax 2 0 + $w cmd plenv0 $xmin $xmax $ymin $ymax 2 0 $w cmd plcol0 15 $w cmd pllab "X" "Y" [lindex $title $alg] - $w cmd plshades zg $defined $xmin $xmax $ymin \ - $ymax clev 1 0 1 + $w cmd plshades zg $xmin $xmax $ymin $ymax clev 1 0 1 2 $w cmd plcol0 2 } else { for {set i 0} {$i < $nl} {incr i} { - clev $i = [expr {$lzmin + ($lzmax-$lzmin)/($nl-1.)*($i-1.)}] + clev $i = [expr {$lzmin + ($lzmax-$lzmin)/double($nl-1.)*$i}] } - cmap1_init + cmap1_init $w $w cmd plvpor 0. 1. 0. 0.9 $w cmd plwind -1.1 0.75 -0.65 1.20 # @@ -227,12 +229,13 @@ "bcdfntu" "Z" 0.5 0 $w cmd plcol0 15 $w cmd pllab "" "" [lindex $title $alg] - $w cmd plot3dc xg yg zg ior ior $DRAW_LINEXY - $MAG_COLOR $BASE_CONT clev + $w cmd plot3dc xg yg zg $xp $yp \ + [expr {$DRAW_LINEXY|$MAG_COLOR|$BASE_CONT}] clev $nl } } } + $w cmd plflush $w cmd plend } @@ -250,41 +253,47 @@ #---------------------------------------------------------------------------- # proc cmap1_init # Set up the colour map -proc cmap1_init {} { +proc cmap1_init {w} { - matrix i i 2 - matrix h i 2 - matrix l i 2 - matrix s i 2 + matrix i f 2 + matrix h f 2 + matrix l f 2 + matrix s f 2 + matrix r i 2 - i 1 = 0. - i 2 = 1. + i 0 = 0. + i 1 = 1. - h 1 = 240. - h 2 = 0. + h 0 = 240. + h 1 = 0. + l 0 = 0.6 l 1 = 0.6 - l 2 = 0.6 + s 0 = 0.8 s 1 = 0.8 - s 2 = 0.8 + r 0 = 0 + r 1 = 0 + $w cmd plscmap1n 256 - $w cmd plscmap1l .false. i h l s + $w cmd plscmap1l 0 2 i h l s r } #---------------------------------------------------------------------------- # proc a2mnmx # Minimum and the maximum elements of a 2-d array. -proc a2mnmx {f nx ny fmin fmax xdim} { +proc a2mnmx {f nx ny fmin fmax} { + upvar 1 $fmin vmin + upvar 1 $fmax vmax - set fmax [f 0 0] - set fmin $fmax + set vmax [$f 0 0] + set vmin $vmax for {set j 0} {$j < $ny} {incr j} { for {set i 0} {$i < $nx} {incr i} { - set fmax [max $fmax [f $i $j]] - set fmin [min $fmin [f $i $j]] + set vmax [max $vmax [$f $i $j]] + set vmin [min $vmin [$f $i $j]] } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arj...@us...> - 2008-08-30 07:32:41
|
Revision: 8724 http://plplot.svn.sourceforge.net/plplot/?rev=8724&view=rev Author: arjenmarkus Date: 2008-08-30 07:32:51 +0000 (Sat, 30 Aug 2008) Log Message: ----------- Added examples 20 and 21 to the list of examples. Note: the code is not quite finished yet, but they are getting into shape. Modified Paths: -------------- trunk/examples/tcl/CMakeLists.txt trunk/examples/tcl/tcldemos.tcl Modified: trunk/examples/tcl/CMakeLists.txt =================================================================== --- trunk/examples/tcl/CMakeLists.txt 2008-08-30 07:30:19 UTC (rev 8723) +++ trunk/examples/tcl/CMakeLists.txt 2008-08-30 07:32:51 UTC (rev 8724) @@ -48,6 +48,8 @@ "17" "18" "19" +"20" +"21" "22" "23" "24" Modified: trunk/examples/tcl/tcldemos.tcl =================================================================== --- trunk/examples/tcl/tcldemos.tcl 2008-08-30 07:30:19 UTC (rev 8723) +++ trunk/examples/tcl/tcldemos.tcl 2008-08-30 07:32:51 UTC (rev 8724) @@ -20,23 +20,10 @@ # Tcl scripts compatible. #---------------------------------------------------------------------------- -for {set i 1} {$i <= 19} {incr i} { +for {set i 1} {$i <= 30} {incr i} { set demo x[format "%02d" $i] source $demo.tcl # restore defaults plcol0 1 proc $i {} "$demo" } -set i 22 -set demo x[format "%02d" $i] -source $demo.tcl -# restore defaults -plcol0 1 -proc $i {} "$demo" -for {set i 24} {$i <= 30} {incr i} { - set demo x[format "%02d" $i] - source $demo.tcl - # restore defaults - plcol0 1 - proc $i {} "$demo" -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2008-12-16 15:53:40
|
Revision: 9137 http://plplot.svn.sourceforge.net/plplot/?rev=9137&view=rev Author: andrewross Date: 2008-12-16 15:53:35 +0000 (Tue, 16 Dec 2008) Log Message: ----------- Update tcl examples to reflect recent changes in the C examples. Note example 31 is not yet implemented. Also tcldemos.tcl will not produce identical results for example 1 and 3 as example 1 uses plstar and example 3 has a call to plsori before plinit is called. Modified Paths: -------------- trunk/examples/tcl/x01 trunk/examples/tcl/x01.tcl trunk/examples/tcl/x03 trunk/examples/tcl/x13.tcl trunk/examples/tcl/x29.tcl Modified: trunk/examples/tcl/x01 =================================================================== --- trunk/examples/tcl/x01 2008-12-16 15:11:32 UTC (rev 9136) +++ trunk/examples/tcl/x01 2008-12-16 15:53:35 UTC (rev 9137) @@ -14,6 +14,6 @@ source x01.tcl -plinit +plstar 2 2 x01 plend Modified: trunk/examples/tcl/x01.tcl =================================================================== --- trunk/examples/tcl/x01.tcl 2008-12-16 15:11:32 UTC (rev 9136) +++ trunk/examples/tcl/x01.tcl 2008-12-16 15:53:35 UTC (rev 9137) @@ -10,8 +10,8 @@ # essentially a nop. However, for the case when other examples are run # first, this call to pladv is absolutely essential to finish the # preceding page. - $w cmd pladv 0 - $w cmd plssub 2 2 + #$w cmd pladv 0 + #$w cmd plssub 2 2 # First plot Modified: trunk/examples/tcl/x03 =================================================================== --- trunk/examples/tcl/x03 2008-12-16 15:11:32 UTC (rev 9136) +++ trunk/examples/tcl/x03 2008-12-16 15:53:35 UTC (rev 9137) @@ -14,6 +14,7 @@ source x03.tcl +plsori 1 plinit x03 plend Modified: trunk/examples/tcl/x13.tcl =================================================================== --- trunk/examples/tcl/x13.tcl 2008-12-16 15:11:32 UTC (rev 9136) +++ trunk/examples/tcl/x13.tcl 2008-12-16 15:53:35 UTC (rev 9137) @@ -20,7 +20,10 @@ matrix y f 500 matrix per f 5 = {10., 32., 12., 30., 16.} - $w cmd plenv 0. 10. 0. 10. 1 -2 + $w cmd pladv 0 + $w cmd plvasp 1. + $w cmd plwind 0. 10. 0. 10. + # $w cmd plenv 0. 10. 0. 10. 1 -2 $w cmd plcol0 2 set theta0 0.; Modified: trunk/examples/tcl/x29.tcl =================================================================== --- trunk/examples/tcl/x29.tcl 2008-12-16 15:11:32 UTC (rev 9136) +++ trunk/examples/tcl/x29.tcl 2008-12-16 15:53:35 UTC (rev 9137) @@ -1,4 +1,4 @@ -# $Id:$ +# $Id$ # # Sample plots using date / time formatting for axes # @@ -35,6 +35,8 @@ proc x29 {{w loopback}} { + $w cmd plsesc "@" + x29_plot1 $w x29_plot2 $w @@ -49,10 +51,14 @@ set pi 3.14159265358979323846 # Data points every 10 minutes for 1 day - set npts 145 + set npts 73 matrix x f $npts matrix y f $npts + matrix xerr1 f $npts + matrix xerr2 f $npts + matrix yerr1 f $npts + matrix yerr2 f $npts set xmin 0 # Number of seconds in a day @@ -61,12 +67,21 @@ set ymax 20.0 for {set i 0} {$i<$npts} {incr i} { - x $i = [expr {$xmax*double($i)/double($npts)}] - y $i = [expr {15.0 - 5.0*cos( 2*$pi*double($i)/double($npts))}] + set xx [expr {$xmax*double($i)/double($npts)}] + set yy [expr {15.0 - 5.0*cos( 2*$pi*double($i)/double($npts))}] + x $i = $xx + y $i = $yy + xerr1 $i = [expr {$xx - 60.0*5.0}] + xerr2 $i = [expr {$xx + 60.0*5.0}] + yerr1 $i = [expr {$yy - 0.1}] + yerr2 $i = [expr {$yy + 0.1}] } $w cmd pladv 0 + $w cmd plsmaj 0.0 0.5 + $w cmd plsmin 0.0 0.5 + $w cmd plvsta $w cmd plwind $xmin $xmax $ymin $ymax @@ -78,11 +93,18 @@ $w cmd plcol0 3 $w cmd pllab "Time (hours:mins)" "Temperature (degC)" \ - "#frPLplot Example 29 - Daily temperature" + "@frPLplot Example 29 - Daily temperature" $w cmd plcol0 4 $w cmd plline $npts x y + $w cmd plcol0 2 + $w cmd plerrx $npts xerr1 xerr2 y + $w cmd plcol0 3 + $w cmd plerry $npts x yerr1 yerr2 + + $w cmd plsmaj 0.0 1.0 + $w cmd plsmin 0.0 1.0 } # Plot the number of hours of daylight as a function of day for a year @@ -119,17 +141,19 @@ $w cmd plcol0 1 # Set time format to be abbreviated month name followed by day of month $w cmd pltimefmt "%b %d" + $w cmd plprec 1 1 $w cmd plenv $xmin $xmax $ymin $ymax 0 40 $w cmd plcol0 3 $w cmd pllab "Date" "Hours of daylight" \ - "#frPLplot Example 29 - Hours of daylight at 51.5N" + "@frPLplot Example 29 - Hours of daylight at 51.5N" $w cmd plcol0 4 $w cmd plline $npts x y - + + $w cmd plprec 0 0 } proc x29_plot3 {{w loopback}} { @@ -174,10 +198,11 @@ $w cmd plcol0 3 $w cmd pllab "Date" "Hours of television watched" \ - "#frPLplot Example 29 - Hours of television watched in Dec 2005 / Jan 2006" + "@frPLplot Example 29 - Hours of television watched in Dec 2005 / Jan 2006" $w cmd plcol0 4 + $w cmd plssym 0.0 0.5 $w cmd plpoin $npts x y 2 $w cmd plline $npts x y This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arj...@us...> - 2009-01-02 12:22:25
|
Revision: 9246 http://plplot.svn.sourceforge.net/plplot/?rev=9246&view=rev Author: arjenmarkus Date: 2009-01-02 11:43:47 +0000 (Fri, 02 Jan 2009) Log Message: ----------- Corrected examples x11 and x13: x11 now gives a few rounding differences only, x13 gives a perfect match (at least on Windows) Modified Paths: -------------- trunk/examples/tcl/x11.tcl trunk/examples/tcl/x13.tcl Modified: trunk/examples/tcl/x11.tcl =================================================================== --- trunk/examples/tcl/x11.tcl 2009-01-02 11:42:13 UTC (rev 9245) +++ trunk/examples/tcl/x11.tcl 2009-01-02 11:43:47 UTC (rev 9246) @@ -8,10 +8,10 @@ # Routine for restoring colour map1 to default. # See static void plcmap1_def(void) in plctrl.c for reference. proc restore_cmap1_11 {w} { - # For center control points, pick black or white, whichever is closer to bg + # 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 @@ -62,7 +62,7 @@ # Integer flag array is zero (no interpolation along far-side of colour # figure matrix rev i 2 = {0, 0} - # Number of cmap1 colours is 256 in this case. + # Number of cmap1 colours is 256 in this case. $w cmd plscmap1n 256 # Interpolate between control points to set up default cmap1. $w cmd plscmap1l 0 2 i h l s rev @@ -77,9 +77,9 @@ set DRAW_LINEXY 3 set MAG_COLOR 0x04 set BASE_CONT 0x08 - matrix opt i 4 = "$DRAW_LINEXY, $DRAW_LINEXY" - matrix alt f 4 = {33.0, 17.0} - matrix az f 4 = {24.0, 115.0} + matrix opt i 2 = "$DRAW_LINEXY, $DRAW_LINEXY" + matrix alt f 2 = {33.0, 17.0} + matrix az f 2 = {24.0, 115.0} set xpts 35 set ypts 46 @@ -89,33 +89,33 @@ matrix z f $xpts $ypts for {set i 0} {$i < $xpts} {incr i} { - x $i = [expr 3.* ($i - ($xpts/2)) / double($xpts/2) ] + x $i = [expr {3.* ($i - ($xpts/2)) / double($xpts/2)} ] } for {set i 0} {$i < $ypts} {incr i} { - y $i = [expr 3.* ($i - ($ypts/2)) / double($ypts/2) ] + y $i = [expr {3.* ($i - ($ypts/2)) / double($ypts/2)} ] } for {set i 0} {$i < $xpts} {incr i} { set xx [x $i] for {set j 0} {$j < $ypts} {incr j} { set yy [y $j] - z $i $j = [expr 3. * (1.-$xx)*(1.-$xx) * exp(-($xx*$xx) - \ + z $i $j = [expr {3. * (1.-$xx)*(1.-$xx) * exp(-($xx*$xx) - \ ($yy+1.)*($yy+1.)) - 10. * ($xx/5. - pow($xx,3.) - \ pow($yy,5.)) * exp(-$xx*$xx-$yy*$yy) - \ - 1./3. * exp(-($xx+1)*($xx+1) - ($yy*$yy))] - # Jungfraujoch/Interlaken + 1./3. * exp(-($xx+1)*($xx+1) - ($yy*$yy))}] + # Jungfraujoch/Interlaken if {1==2} { set zz [z $i $j] if {$zz <= -1.} { - z $i $j = [expr -1] + z $i $j = -1.0 } } } } - set zmin [z min [ expr $xpts * $ypts]] - set zmax [z max [ expr $xpts * $ypts]] + set zmin [z min [ expr {$xpts * $ypts}]] + set zmax [z max [ expr {$xpts * $ypts}]] set nlev 10 matrix clev f $nlev @@ -141,20 +141,20 @@ # wireframe plot if {$i == 0} { - $w cmd plmesh x y z [expr [opt $k]] + $w cmd plmesh x y z [expr {[opt $k]}] # 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] | $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] | $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] | $MAG_COLOR | $BASE_CONT}] clev $nlev } $w cmd plcol0 3 Modified: trunk/examples/tcl/x13.tcl =================================================================== --- trunk/examples/tcl/x13.tcl 2009-01-02 11:42:13 UTC (rev 9245) +++ trunk/examples/tcl/x13.tcl 2009-01-02 11:43:47 UTC (rev 9246) @@ -22,49 +22,51 @@ $w cmd pladv 0 $w cmd plvasp 1. - $w cmd plwind 0. 10. 0. 10. + $w cmd plwind 0. 10. 0. 10. # $w cmd plenv 0. 10. 0. 10. 1 -2 $w cmd plcol0 2 - set theta0 0.; + set theta0 0. set pi 3.14159265358979323846 - set dthet [expr 2. * $pi / 500.] + set factor [expr {2. * $pi / 500.}] + set dthet 1.0 for {set i 0} {$i <= 4} {incr i} { - set j 0; - x $j = 5.; - y $j = 5.; + set j 0 + x $j = 5. + y $j = 5. incr j - set theta1 [expr $theta0 + 2. * $pi * [per $i] / 100.] + set theta1 [expr {$theta0 + 5.0 * [per $i]}] if {$i == 4} { - set theta1 [expr 2. * $pi] + set theta1 500.0 } for {set theta $theta0} {$theta <= $theta1} { - set theta [expr $theta + $dthet]} { - x $j = [expr 5. + 3. * cos($theta) ] - y $j = [expr 5. + 3. * sin($theta) ] + set theta [expr {$theta + $dthet}]} { + x $j = [expr {5. + 3. * cos($factor*$theta)} ] + y $j = [expr {5. + 3. * sin($factor*$theta)} ] incr j } - $w cmd plcol0 [expr $i + 1] - $w cmd plpsty [expr (($i + 3) % 8 + 1)] + $w cmd plcol0 [expr {$i + 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 - set just [expr ($theta0 + $theta1) / 2.] - set dx [expr .25 * cos($just)] - set dy [expr .25 * sin($just)] - if {$just < $pi / 2. || $just > 3. * $pi / 2.} { + set just [expr {$factor * ($theta0 + $theta1) / 2.}] + set dx [expr {.25 * cos($just)}] + set dy [expr {.25 * sin($just)}] + if { ($theta0 + $theta1) < 250.0 || ($theta0 + $theta1) > 750.0 } { set just 0. } else { set just 1. } - $w cmd plptex [expr [x [expr $j / 2]] + $dx] \ - [expr [y [expr $j / 2]] + $dy] 1.0 0.0 $just [set text$i] - set theta0 [expr $theta - $dthet] + set halfj [expr {$j/2}] + $w cmd plptex [expr {[x $halfj] + $dx}] \ + [expr {[y $halfj] + $dy}] 1.0 0.0 $just [set text$i] + set theta0 [expr {$theta - $dthet}] } $w cmd plfont 2 $w cmd plschr 0. 1.3 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arj...@us...> - 2009-01-03 11:05:04
|
Revision: 9249 http://plplot.svn.sourceforge.net/plplot/?rev=9249&view=rev Author: arjenmarkus Date: 2009-01-03 11:05:01 +0000 (Sat, 03 Jan 2009) Log Message: ----------- Added braces for all expressions and some rearrangements Modified Paths: -------------- trunk/examples/tcl/x15.tcl trunk/examples/tcl/x16.tcl Modified: trunk/examples/tcl/x15.tcl =================================================================== --- trunk/examples/tcl/x15.tcl 2009-01-03 11:02:30 UTC (rev 9248) +++ trunk/examples/tcl/x15.tcl 2009-01-03 11:05:01 UTC (rev 9249) @@ -13,11 +13,11 @@ # cmap1_init152 $w for {set i 0} {$i < $xpts} {incr i} { - set x [expr ($i - ($xpts/2)) / double($xpts/2)] + set x [expr {double($i - ($xpts/2)) / double($xpts/2)}] for {set j 0} {$j < $ypts} {incr j} { - set y [expr ($j - double($ypts/2)) / double($ypts/2) - 1.] + set y [expr {double($j - ($ypts/2)) / double($ypts/2) - 1.}] - z $i $j = [expr $x*$x - $y*$y + ($x - $y)/($x * $x + $y * $y + .1) ] + z $i $j = [expr {$x*$x - $y*$y + ($x - $y)/($x * $x + $y * $y + .1)} ] } } set zmin [z 0 0] @@ -31,7 +31,7 @@ plot151 $w $z $zmin $zmax plot152 $w $z $zmin $zmax plot153 $w - + } proc cmap1_init152 { w } { @@ -60,7 +60,7 @@ s 1 = 0.5 s 2 = 0.5 s 3 = 1.0 - + rev 0 = 0 rev 1 = 0 rev 2 = 0 @@ -78,8 +78,8 @@ # N.B. this flag set to use cmap0 set sh_cmap 0 - set shade_min [expr $zmin + ($zmax - $zmin)*.4 ] - set shade_max [expr $zmin + ($zmax - $zmin)*.6 ] + set shade_min [expr {$zmin + ($zmax - $zmin)*.4} ] + set shade_max [expr {$zmin + ($zmax - $zmin)*.6} ] set sh_color 7 $w cmd pladv 0 @@ -132,9 +132,9 @@ $w cmd plvpor .1 .9 .1 .9 $w cmd plwind -1.0 1.0 -1.0 1.0 for {set i 0} {$i < 10} {incr i} { - set shade_min [expr $zmin + ($zmax - $zmin)*$i/10.0 ] - set shade_max [expr $zmin + ($zmax - $zmin)*($i + 1)/10.0 ] - set sh_color [expr $i + 6] + set shade_min [expr {$zmin + ($zmax - $zmin)*$i/10.0} ] + set shade_max [expr {$zmin + ($zmax - $zmin)*($i + 1)/10.0} ] + set sh_color [expr {$i + 6}] $w cmd plpat [nlin $i] inc$i del$i $w cmd plshade z -1. 1. -1. 1. $shade_min $shade_max \ $sh_cmap $sh_color $sh_width \ @@ -150,9 +150,9 @@ proc plot153 { w } { - matrix xx0 f 5 = {-1.0, 1.0, 1.0, -1.0, -1.0} + matrix xx0 f 5 = {-1.0, 1.0, 1.0, -1.0, -1.0} matrix xx1 f 5 = {-1.0, 1.0, 1.0, -1.0, -1.0} - matrix yy0 f 5 = {1.0, 1.0, 0.0, 0.0, 1.0} + matrix yy0 f 5 = {1.0, 1.0, 0.0, 0.0, 1.0} matrix yy1 f 5 = {-1.0, -1.0, 0.0, 0.0, -1.0} matrix zz0 f 5 = {0.0, 0.0, 1.0, 1.0, 0.0} matrix zz1 f 5 = {0.0, 0.0, 1.0, 1.0, 0.0} @@ -163,7 +163,7 @@ $w cmd plw3d 1. 1. 1. -1.0 1.0 -1.0 1.0 0.0 1.5 30 -40 # Plot using identity transform - + $w cmd plcol0 1 $w cmd plbox3 "bntu" "X" 0.0 0 "bntu" "Y" 0.0 0 "bcdfntu" "Z" 0.5 0 $w cmd plcol0 2 Modified: trunk/examples/tcl/x16.tcl =================================================================== --- trunk/examples/tcl/x16.tcl 2009-01-03 11:02:30 UTC (rev 9248) +++ trunk/examples/tcl/x16.tcl 2009-01-03 11:05:01 UTC (rev 9249) @@ -25,12 +25,12 @@ # Set up data array for {set i 0} {$i < $nx} {incr i} { - set x [expr double($i - ($nx/2)) / double($nx/2)] + set x [expr {double($i - ($nx/2)) / double($nx/2)}] for {set j 0} {$j < $ny} {incr j} { - set y [expr double($j - $ny/2) / double($ny/2) - 1.] + set y [expr {double($j - $ny/2) / double($ny/2) - 1.}] - zz $i $j = [expr -sin(7.*$x) * cos(7.*$y) + $x*$x - $y*$y ] - ww $i $j = [expr -cos(7.*$x) * sin(7.*$y) + 2 * $x * $y ] + zz $i $j = [expr {-sin(7.*$x) * cos(7.*$y) + $x*$x - $y*$y} ] + ww $i $j = [expr {-cos(7.*$x) * sin(7.*$y) + 2 * $x * $y} ] } } @@ -44,11 +44,11 @@ } for {set i 0} {$i < $ns} {incr i} { - clevel $i = [expr $zmin + ($zmax - $zmin) * ($i + .5) / $ns.] + clevel $i = [expr {$zmin + ($zmax - $zmin) * ($i + .5) / double($ns)}] } - for {set i 0} {$i < [expr $ns+1]} {incr i} { - shedge $i = [expr $zmin + ($zmax - $zmin) * double($i) / double($ns)] + for {set i 0} {$i < $ns+1} {incr i} { + shedge $i = [expr {$zmin + ($zmax - $zmin) * double($i) / double($ns)}] } # Build the 1-d coord arrays. @@ -56,27 +56,27 @@ set distort .4 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 ) ] + set xx [expr {-1. + $i * ( 2. / ($nx-1.) )}] + xg1 $i = [expr {$xx + $distort * cos( .5 * $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 ) ] + set yy [expr {-1. + $j * ( 2. / ($ny-1.) )}] + yg1 $j = [expr {$yy - $distort * cos( .5 * $pi * $yy )} ] } # Build the 2-d coord arrays. for {set i 0} {$i < $nx} {incr i} { - set xx [expr -1. + $i * ( 2. / ($nx-1.) )] + set xx [expr {-1. + $i * ( 2. / ($nx-1.) )}] for {set j 0} {$j < $ny} {incr j} { - set yy [expr -1. + $j * ( 2. / ($ny-1.) )] + set yy [expr {-1. + $j * ( 2. / ($ny-1.) )}] - set argx [expr .5 * $pi * $xx] - set argy [expr .5 * $pi * $yy] + set argx [expr {.5 * $pi * $xx}] + set argy [expr {.5 * $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)} ] } } @@ -101,7 +101,7 @@ $w cmd pllab "distance" "altitude" "Bogon density" # Plot using 1d coordinate transform - + $w cmd pladv 0 $w cmd plvpor 0.1 0.9 0.1 0.9 $w cmd plwind -1.0 1.0 -1.0 1.0 @@ -167,14 +167,14 @@ matrix z f $nx $nylim for {set i 0} {$i < $nx} {incr i} { - set r [expr $i / ($nx - 1.)] + 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. * $pi * $j / ($ny - 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 = [expr exp(-$r*$r) * cos(5.*$t) * cos(5.*$pi*$r) ] + z $i $j = [expr {exp(-$r*$r) * cos(5.*$t) * cos(5.*$pi*$r)} ] } } @@ -190,7 +190,7 @@ } for {set i 0} {$i < [expr $ns+1]} {incr i} { - shedge $i = [expr $zmin + ($zmax - $zmin)/double($ns) * double($i)] + shedge $i = [expr {$zmin + ($zmax - $zmin)/double($ns) * double($i)}] } $w cmd pladv 0 @@ -207,9 +207,9 @@ 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. * $pi * $i / 99.}] + px $i = [expr {cos($t)}] + py $i = [expr {sin($t)}] } # draw the perimeter. $w cmd plcol0 1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2010-05-03 05:02:30
|
Revision: 10964 http://plplot.svn.sourceforge.net/plplot/?rev=10964&view=rev Author: airwin Date: 2010-05-03 05:02:24 +0000 (Mon, 03 May 2010) Log Message: ----------- Explicitly specify pltr as "NULL" for plshade and plshades which translates to NULL at the C level and which is interpreted there as defining the x and y arrays from xmin, xmax, nx and ymin, ymax, and ny. This is very different from using pltr0 (the default user-friendly Tcl result if nothing is specified for pltr). This solves the Tcl issue of dropping the pltr_data tests for NULL at the C level. We were relying on those tests before to obtain the xmin, xmax,... result but when those tests were dropped we were getting the Tcl user-friendly pltr0 default instead which had such an incorrect scale and offset for these examples that the pages were blank or might have a single polygon. Modified Paths: -------------- trunk/examples/tcl/x15.tcl trunk/examples/tcl/x16.tcl trunk/examples/tcl/x21.tcl Modified: trunk/examples/tcl/x15.tcl =================================================================== --- trunk/examples/tcl/x15.tcl 2010-05-03 04:51:51 UTC (rev 10963) +++ trunk/examples/tcl/x15.tcl 2010-05-03 05:02:24 UTC (rev 10964) @@ -89,7 +89,7 @@ $w cmd plpsty 8 $w cmd plshade z -1. 1. -1. 1. $shade_min $shade_max \ $sh_cmap $sh_color $sh_width \ - $min_color $min_width $max_color $max_width 1 + $min_color $min_width $max_color $max_width 1 "NULL" $w cmd plcol0 1 $w cmd plbox bcnst 0.0 0 bcnstv 0.0 0 $w cmd plcol0 2 @@ -138,7 +138,7 @@ $w cmd plpat [nlin $i] inc$i del$i $w cmd plshade z -1. 1. -1. 1. $shade_min $shade_max \ $sh_cmap $sh_color $sh_width \ - $min_color $min_width $max_color $max_width 1 + $min_color $min_width $max_color $max_width 1 "NULL" } $w cmd plcol0 1 $w cmd plbox bcnst 0.0 0 bcnstv 0.0 0 Modified: trunk/examples/tcl/x16.tcl =================================================================== --- trunk/examples/tcl/x16.tcl 2010-05-03 04:51:51 UTC (rev 10963) +++ trunk/examples/tcl/x16.tcl 2010-05-03 05:02:24 UTC (rev 10964) @@ -93,7 +93,7 @@ $w cmd plshades zz -1. 1. -1. 1. \ shedge $fill_width $cont_color $cont_width \ - 1 + 1 "NULL" $w cmd plcol0 1 $w cmd plbox "bcnst" 0.0 0 "bcnstv" 0.0 0 Modified: trunk/examples/tcl/x21.tcl =================================================================== --- trunk/examples/tcl/x21.tcl 2010-05-03 04:51:51 UTC (rev 10963) +++ trunk/examples/tcl/x21.tcl 2010-05-03 05:02:24 UTC (rev 10964) @@ -204,7 +204,7 @@ $w cmd plenv0 $xmin $xmax $ymin $ymax 2 0 $w cmd plcol0 15 $w cmd pllab "X" "Y" [lindex $title $alg] - $w cmd plshades zg $xmin $xmax $ymin $ymax clev 1 0 1 2 + $w cmd plshades zg $xmin $xmax $ymin $ymax clev 1 0 1 1 "NULL" $w cmd plcol0 2 } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arj...@us...> - 2010-05-07 06:55:28
|
Revision: 10977 http://plplot.svn.sourceforge.net/plplot/?rev=10977&view=rev Author: arjenmarkus Date: 2010-05-07 06:55:22 +0000 (Fri, 07 May 2010) Log Message: ----------- Propagating the recent changes to examples 6 and 7 to Tcl. Modified Paths: -------------- trunk/examples/tcl/x06.tcl trunk/examples/tcl/x07.tcl Modified: trunk/examples/tcl/x06.tcl =================================================================== --- trunk/examples/tcl/x06.tcl 2010-05-07 04:56:04 UTC (rev 10976) +++ trunk/examples/tcl/x06.tcl 2010-05-07 06:55:22 UTC (rev 10977) @@ -7,47 +7,64 @@ matrix x f 1 matrix y f 1 - $w cmd pladv 0 - $w cmd plfont 1 + for {set kind_font 0} {$kind_font < 2} {incr kind_font} { + $w cmd plfontld $kind_font + if {$kind_font == 0} { + set maxfont 1 + } else { + set maxfont 4 + } + + for {set font 0} {$font < $maxfont} {incr font} { + + $w cmd plfont [expr {$font+1}] + + $w cmd pladv 0 + # Set up viewport and window - $w cmd plcol0 2 - $w cmd plvpor 0.1 1.0 0.1 0.9 - $w cmd plwind 0.0 1.0 0.0 1.3 + $w cmd plcol0 2 + $w cmd plvpor 0.1 1.0 0.1 0.9 + $w cmd plwind 0.0 1.0 0.0 1.3 # Draw the grid using plbox - $w cmd plbox "bcg" 0.1 0 "bcg" 0.1 0 + $w cmd plbox "bcg" 0.1 0 "bcg" 0.1 0 # Write the digits below the frame - $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 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 + } - set k 0 - for {set i 0} {$i <= 12} {incr i} { + set k 0 + for {set i 0} {$i <= 12} {incr i} { # 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] - for {set j 0} {$j <= 9} {incr j} { - x 0 = [expr 0.1 * $j + 0.05] - y 0 = [expr 1.25 - 0.1 * $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] # Display the symbols - if {$k < 128} { - $w cmd plpoin 1 x y $k - } - incr k - } + if {$k < 128} { + $w cmd plpoin 1 x y $k + } + incr k + } + } + + if {$kind_font==0} { + $w cmd plmtex "t" 1.5 0.5 0.5 "PLplot Example 6 - plpoin symbols (compact)" + } else { + $w cmd plmtex "t" 1.5 0.5 0.5 "PLplot Example 6 - plpoin symbols (extended)" + } + } } - - $w cmd plmtex "t" 1.5 0.5 0.5 "PLplot Example 6 - plpoin symbols" - # Restore defaults # $w cmd plcol0 1 } Modified: trunk/examples/tcl/x07.tcl =================================================================== --- trunk/examples/tcl/x07.tcl 2010-05-07 04:56:04 UTC (rev 10976) +++ trunk/examples/tcl/x07.tcl 2010-05-07 06:55:22 UTC (rev 10977) @@ -4,15 +4,18 @@ proc x07 {{w loopback}} { - matrix base i 17 = \ - {0, 200, 500, 600, 700, 800, 900, \ + matrix base i 20 = \ + {0, 100, 0, 100, 200, 500, 600, 700, 800, 900, \ 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900} matrix x f 1 matrix y f 1 - $w cmd plfontld 1 - for {set l 0} {$l < 17} {incr l} { + $w cmd plfontld 0 + for {set l 0} {$l < 20} {incr l} { + if {$l == 2} { + $w cmd plfontld 1 + } $w cmd pladv 0 # Set up viewport and window @@ -50,7 +53,11 @@ incr k } } - $w cmd plmtex "t" 1.5 0.5 0.5 "PLplot Example 7 - PLSYM symbols" + if {$l < 2} { + $w cmd plmtex "t" 1.5 0.5 0.5 "PLplot Example 7 - PLSYM symbols (compact)" + } else { + $w cmd plmtex "t" 1.5 0.5 0.5 "PLplot Example 7 - PLSYM symbols (extended)" + } } # Restore defaults # $w cmd plcol0 1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2010-05-27 09:56:43
|
Revision: 11026 http://plplot.svn.sourceforge.net/plplot/?rev=11026&view=rev Author: andrewross Date: 2010-05-27 09:56:37 +0000 (Thu, 27 May 2010) Log Message: ----------- A load of little changes to tcl scripts to restore defaults at the end of the example. This ensures the correct results when multiple examples are run within the same plserver session (e.g. by make test_interactive). Modified Paths: -------------- trunk/examples/tcl/x07.tcl trunk/examples/tcl/x09.tcl trunk/examples/tcl/x13.tcl trunk/examples/tcl/x17.tcl trunk/examples/tcl/x19.tcl trunk/examples/tcl/x21.tcl trunk/examples/tcl/x26.tcl Modified: trunk/examples/tcl/x07.tcl =================================================================== --- trunk/examples/tcl/x07.tcl 2010-05-27 09:51:11 UTC (rev 11025) +++ trunk/examples/tcl/x07.tcl 2010-05-27 09:56:37 UTC (rev 11026) @@ -61,4 +61,5 @@ } # Restore defaults # $w cmd plcol0 1 + $w cmd plfontld 0 } Modified: trunk/examples/tcl/x09.tcl =================================================================== --- trunk/examples/tcl/x09.tcl 2010-05-27 09:51:11 UTC (rev 11025) +++ trunk/examples/tcl/x09.tcl 2010-05-27 09:56:37 UTC (rev 11026) @@ -162,6 +162,7 @@ # Restore defaults # $w cmd plcol0 1 # $w cmd pl_setcontlabelparam 0.006 0.3 0.1 0 + $w cmd pllsty 1 } # Demonstrate plotting of wrapped data. What is significant to Modified: trunk/examples/tcl/x13.tcl =================================================================== --- trunk/examples/tcl/x13.tcl 2010-05-27 09:51:11 UTC (rev 11025) +++ trunk/examples/tcl/x13.tcl 2010-05-27 09:56:37 UTC (rev 11026) @@ -73,4 +73,5 @@ $w cmd plptex 5.0 9.0 1.0 0.0 0.5 "Percentage of Sales" # Restore defaults # $w cmd plcol0 1 + $w cmd plfont 1 } Modified: trunk/examples/tcl/x17.tcl =================================================================== --- trunk/examples/tcl/x17.tcl 2010-05-27 09:51:11 UTC (rev 11025) +++ trunk/examples/tcl/x17.tcl 2010-05-27 09:56:37 UTC (rev 11026) @@ -128,4 +128,7 @@ # Destroy strip chart and it's memory $w cmd plstripd $id1 + +# Restore defaults + $w cmd pllsty 1 } Modified: trunk/examples/tcl/x19.tcl =================================================================== --- trunk/examples/tcl/x19.tcl 2010-05-27 09:51:11 UTC (rev 11025) +++ trunk/examples/tcl/x19.tcl 2010-05-27 09:56:37 UTC (rev 11026) @@ -180,6 +180,8 @@ $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 # No defaults to restore Modified: trunk/examples/tcl/x21.tcl =================================================================== --- trunk/examples/tcl/x21.tcl 2010-05-27 09:51:11 UTC (rev 11025) +++ trunk/examples/tcl/x21.tcl 2010-05-27 09:56:37 UTC (rev 11026) @@ -231,7 +231,8 @@ } $w cmd plflush - $w cmd plend + #$w cmd plend + $w cmd plssub 1 1 } #---------------------------------------------------------------------------- Modified: trunk/examples/tcl/x26.tcl =================================================================== --- trunk/examples/tcl/x26.tcl 2010-05-27 09:51:11 UTC (rev 11025) +++ trunk/examples/tcl/x26.tcl 2010-05-27 09:56:37 UTC (rev 11026) @@ -112,6 +112,9 @@ plot261 $w 0 $xl $yl $altyl $title $linel } + # Restore defauls + $w cmd plfont 1 + } # -------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arj...@us...> - 2010-05-31 08:55:58
|
Revision: 11042 http://plplot.svn.sourceforge.net/plplot/?rev=11042&view=rev Author: arjenmarkus Date: 2010-05-31 08:55:52 +0000 (Mon, 31 May 2010) Log Message: ----------- Moving commands into the procedure that implement the example, so that chaining them in the standard_examples script becomes simpler. This can not be done for example x16, as then we get differences in the PostScript output wrt the C version. Modified Paths: -------------- trunk/examples/tcl/x01 trunk/examples/tcl/x01.tcl trunk/examples/tcl/x03 trunk/examples/tcl/x03.tcl trunk/examples/tcl/x16 trunk/examples/tcl/x16.tcl Modified: trunk/examples/tcl/x01 =================================================================== --- trunk/examples/tcl/x01 2010-05-31 00:46:56 UTC (rev 11041) +++ trunk/examples/tcl/x01 2010-05-31 08:55:52 UTC (rev 11042) @@ -17,6 +17,5 @@ plgver ver puts [format "PLplot library version: %s" $ver ] -plstar 2 2 x01 plend Modified: trunk/examples/tcl/x01.tcl =================================================================== --- trunk/examples/tcl/x01.tcl 2010-05-31 00:46:56 UTC (rev 11041) +++ trunk/examples/tcl/x01.tcl 2010-05-31 08:55:52 UTC (rev 11042) @@ -5,11 +5,14 @@ proc x01 {{w loopback}} { global xscale yscale xoff yoff - # For starting from scratch this call to pladv increments cursub, but - # then the following plssub sets it to zero so the whole thing is - # essentially a nop. However, for the case when other examples are run - # first, this call to pladv is absolutely essential to finish the + # For starting from scratch this call to pladv increments cursub, but + # then the following plssub sets it to zero so the whole thing is + # essentially a nop. However, for the case when other examples are run + # first, this call to pladv is absolutely essential to finish the # preceding page. + + $w cmd plstar 2 2 + #$w cmd pladv 0 #$w cmd plssub 2 2 @@ -129,7 +132,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 Modified: trunk/examples/tcl/x03 =================================================================== --- trunk/examples/tcl/x03 2010-05-31 00:46:56 UTC (rev 11041) +++ trunk/examples/tcl/x03 2010-05-31 08:55:52 UTC (rev 11042) @@ -14,7 +14,6 @@ source x03.tcl -plsori 1 plinit x03 plend Modified: trunk/examples/tcl/x03.tcl =================================================================== --- trunk/examples/tcl/x03.tcl 2010-05-31 00:46:56 UTC (rev 11041) +++ trunk/examples/tcl/x03.tcl 2010-05-31 08:55:52 UTC (rev 11042) @@ -4,8 +4,9 @@ proc x03 {{w loopback}} { set twopi [expr 2. * 3.14159265358979323846] -# Set up viewport and window, but do not draw box +# Set up viewport and window, but do not draw box + $w cmd plsori 1 $w cmd plenv -1.3 1.3 -1.3 1.3 1 -2 # Draw circles for polar grid @@ -41,7 +42,7 @@ } else { set offset 0.15 } - + # Slightly off zero to avoid floating point logic flips at 90 and 270 deg. if {$xg >= -0.00001} { set dx [expr $xg] @@ -54,13 +55,13 @@ } 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] Modified: trunk/examples/tcl/x16 =================================================================== --- trunk/examples/tcl/x16 2010-05-31 00:46:56 UTC (rev 11041) +++ trunk/examples/tcl/x16 2010-05-31 08:55:52 UTC (rev 11042) @@ -14,8 +14,7 @@ source x16.tcl -# For consistency with C version these need to be set before plinit is -# called. +# Reducing the size of the colour map needs to be done before plinit plspal0 "cmap0_black_on_white.pal" plspal1 "cmap1_gray.pal" 1 plscmap0n 3 Modified: trunk/examples/tcl/x16.tcl =================================================================== --- trunk/examples/tcl/x16.tcl 2010-05-31 00:46:56 UTC (rev 11041) +++ trunk/examples/tcl/x16.tcl 2010-05-31 08:55:52 UTC (rev 11042) @@ -22,9 +22,6 @@ matrix zz f $nx $ny matrix ww f $nx $ny - $w cmd plspal0 "cmap0_black_on_white.pal" - $w cmd plspal1 "cmap1_gray.pal" 1 - # Set up data array for {set i 0} {$i < $nx} {incr i} { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2010-05-31 15:01:20
|
Revision: 11043 http://plplot.svn.sourceforge.net/plplot/?rev=11043&view=rev Author: airwin Date: 2010-05-31 15:01:09 +0000 (Mon, 31 May 2010) Log Message: ----------- Revert recent example 3 change for Tcl because it lead to inconsistency with corresponding C example. Modified Paths: -------------- trunk/examples/tcl/x03 trunk/examples/tcl/x03.tcl Modified: trunk/examples/tcl/x03 =================================================================== --- trunk/examples/tcl/x03 2010-05-31 08:55:52 UTC (rev 11042) +++ trunk/examples/tcl/x03 2010-05-31 15:01:09 UTC (rev 11043) @@ -14,6 +14,7 @@ source x03.tcl +plsori 1 plinit x03 plend Modified: trunk/examples/tcl/x03.tcl =================================================================== --- trunk/examples/tcl/x03.tcl 2010-05-31 08:55:52 UTC (rev 11042) +++ trunk/examples/tcl/x03.tcl 2010-05-31 15:01:09 UTC (rev 11043) @@ -6,7 +6,6 @@ set twopi [expr 2. * 3.14159265358979323846] # Set up viewport and window, but do not draw box - $w cmd plsori 1 $w cmd plenv -1.3 1.3 -1.3 1.3 1 -2 # Draw circles for polar grid This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arj...@us...> - 2011-01-07 07:46:51
|
Revision: 11447 http://plplot.svn.sourceforge.net/plplot/?rev=11447&view=rev Author: arjenmarkus Date: 2011-01-07 07:46:45 +0000 (Fri, 07 Jan 2011) Log Message: ----------- Solve the encoding issue for examples 18, 24 and 26 (example 33 is still to be implemented). The solution was suggested by several people on the comp.lang.tcl newsgroup. From Tcl 8.5 onwards we can use the -encoding option to the source command, for earlier versions we explicitly convert the contents of the file to UTF-8 before eval'ing it. Modified Paths: -------------- trunk/examples/tcl/x18 trunk/examples/tcl/x24 trunk/examples/tcl/x26 Modified: trunk/examples/tcl/x18 =================================================================== --- trunk/examples/tcl/x18 2011-01-06 13:39:37 UTC (rev 11446) +++ trunk/examples/tcl/x18 2011-01-07 07:46:45 UTC (rev 11447) @@ -12,8 +12,33 @@ #\ exec pltcl -f "$0" ${1+"$@"} -source x18.tcl +# +# This example uses UTF-8 characters, placed directly in the source code +# +if { [encoding system] != "utf-8" } { + if { [package vsatisfies [info patch] 8.5] } { + source -encoding utf-8 x18.tcl + + } else { + + # + # Pre-Tcl 8.5 + # + set infile [open "x18.tcl"] + set contents [read $infile] + close $infile + eval [encoding convertfrom utf-8 \ + [encoding convertto [encoding system] $contents]] + } +} else { + + # + # Plain source will do + # + source x18.tcl +} + plinit x18 plend Modified: trunk/examples/tcl/x24 =================================================================== --- trunk/examples/tcl/x24 2011-01-06 13:39:37 UTC (rev 11446) +++ trunk/examples/tcl/x24 2011-01-07 07:46:45 UTC (rev 11447) @@ -1,6 +1,6 @@ #!/bin/sh #--------------------------------*- Tcl -*------------------------------------# -# $Id:$ +# $Id$ # # Maurice LeBrun # 12/24/02 @@ -12,8 +12,33 @@ #\ exec pltcl -f "$0" ${1+"$@"} -source x24.tcl +# +# This example uses UTF-8 characters, placed directly in the source code +# +if { [encoding system] != "utf-8" } { + if { [package vsatisfies [info patch] 8.5] } { + source -encoding utf-8 x24.tcl + + } else { + + # + # Pre-Tcl 8.5 + # + set infile [open "x24.tcl"] + set contents [read $infile] + close $infile + eval [encoding convertfrom utf-8 \ + [encoding convertto [encoding system] $contents]] + } +} else { + + # + # Plain source will do + # + source x24.tcl +} + plinit x24 plend Modified: trunk/examples/tcl/x26 =================================================================== --- trunk/examples/tcl/x26 2011-01-06 13:39:37 UTC (rev 11446) +++ trunk/examples/tcl/x26 2011-01-07 07:46:45 UTC (rev 11447) @@ -12,8 +12,33 @@ #\ exec pltcl -f "$0" ${1+"$@"} -source x26.tcl +# +# This example uses UTF-8 characters, placed directly in the source code +# +if { [encoding system] != "utf-8" } { + if { [package vsatisfies [info patch] 8.5] } { + source -encoding utf-8 x26.tcl + + } else { + + # + # Pre-Tcl 8.5 + # + set infile [open "x26.tcl"] + set contents [read $infile] + close $infile + eval [encoding convertfrom utf-8 \ + [encoding convertto [encoding system] $contents]] + } +} else { + + # + # Plain source will do + # + source x26.tcl +} + plinit x26 plend This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <arj...@us...> - 2011-02-22 07:32:50
|
Revision: 11575 http://plplot.svn.sourceforge.net/plplot/?rev=11575&view=rev Author: arjenmarkus Date: 2011-02-22 07:32:44 +0000 (Tue, 22 Feb 2011) Log Message: ----------- Start of the implementation of example 33 in Tcl - conversion is far from complete, only committing it as a backup Added Paths: ----------- trunk/examples/tcl/x33 trunk/examples/tcl/x33.tcl Added: trunk/examples/tcl/x33 =================================================================== --- trunk/examples/tcl/x33 (rev 0) +++ trunk/examples/tcl/x33 2011-02-22 07:32:44 UTC (rev 11575) @@ -0,0 +1,44 @@ +#!/bin/sh +#--------------------------------*- Tcl -*------------------------------------# +# $Id: x26 11447 2011-01-07 07:46:45Z arjenmarkus $ +# +# Arjen Markus +# 08/18/08 +# +# A front-end to x26.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+"$@"} + +# +# This example uses UTF-8 characters, placed directly in the source code +# +if { [encoding system] != "utf-8" } { + if { [package vsatisfies [info patch] 8.5] } { + + source -encoding utf-8 x33.tcl + + } else { + + # + # Pre-Tcl 8.5 + # + set infile [open "x33.tcl"] + set contents [read $infile] + close $infile + eval [encoding convertfrom utf-8 \ + [encoding convertto [encoding system] $contents]] + } +} else { + + # + # Plain source will do + # + source x33.tcl +} + +plinit +x33 +plend Added: trunk/examples/tcl/x33.tcl =================================================================== --- trunk/examples/tcl/x33.tcl (rev 0) +++ trunk/examples/tcl/x33.tcl 2011-02-22 07:32:44 UTC (rev 11575) @@ -0,0 +1,614 @@ +# $Id: x33c.c 11565 2011-02-13 21:06:58Z airwin $ +# +# Demonstrate most pllegend capability including unicode symbols. +# +# Copyright (C) 2010 Alan 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 +# +# +# This example designed just for devices (e.g., the cairo-related and +# qt-related devices) where the best choice of glyph is automatically +# selected by the related libraries (pango/cairo or Qt4) for each +# unicode character depending on what system fonts are installed. Of +# course, you must have the appropriate TrueType fonts installed to +# have access to all the required glyphs. + +set position_options [list + [expr {$::PLPLOT::PL_POSITION_LEFT | $::PLPLOT::PL_POSITION_TOP | $::PLPLOT::PL_POSITION_OUTSIDE}] \ + [expr {$::PLPLOT::PL_POSITION_TOP | $::PLPLOT::PL_POSITION_OUTSIDE}] \ + [expr {$::PLPLOT::PL_POSITION_RIGHT | $::PLPLOT::PL_POSITION_TOP | $::PLPLOT::PL_POSITION_OUTSIDE}] \ + [expr {$::PLPLOT::PL_POSITION_RIGHT | $::PLPLOT::PL_POSITION_OUTSIDE}] \ + [expr {$::PLPLOT::PL_POSITION_RIGHT | $::PLPLOT::PL_POSITION_BOTTOM | $::PLPLOT::PL_POSITION_OUTSIDE}] \ + [expr {$::PLPLOT::PL_POSITION_BOTTOM | $::PLPLOT::PL_POSITION_OUTSIDE}] \ + [expr {$::PLPLOT::PL_POSITION_LEFT | $::PLPLOT::PL_POSITION_BOTTOM | $::PLPLOT::PL_POSITION_OUTSIDE}] \ + [expr {$::PLPLOT::PL_POSITION_LEFT | $::PLPLOT::PL_POSITION_OUTSIDE}] \ + [expr {$::PLPLOT::PL_POSITION_LEFT | $::PLPLOT::PL_POSITION_TOP | $::PLPLOT::PL_POSITION_INSIDE}] \ + [expr {$::PLPLOT::PL_POSITION_TOP | $::PLPLOT::PL_POSITION_INSIDE]] \ + [expr {$::PLPLOT::PL_POSITION_RIGHT | $::PLPLOT::PL_POSITION_TOP | $::PLPLOT::PL_POSITION_INSIDE}] \ + [expr {$::PLPLOT::PL_POSITION_RIGHT | $::PLPLOT::PL_POSITION_INSIDE}] \ + [expr {$::PLPLOT::PL_POSITION_RIGHT | $::PLPLOT::PL_POSITION_BOTTOM | $::PLPLOT::PL_POSITION_INSIDE}] \ + [expr {$::PLPLOT::PL_POSITION_BOTTOM | $::PLPLOT::PL_POSITION_INSIDE}] \ + [expr {$::PLPLOT::PL_POSITION_LEFT | $::PLPLOT::PL_POSITION_BOTTOM | $::PLPLOT::PL_POSITION_INSIDE}] \ + [expr {$::PLPLOT::PL_POSITION_LEFT | $::PLPLOT::PL_POSITION_INSIDE}] ] + +// Pick 5 arbitrary UTF-8 symbols useful for plotting points (✠✚✱✪✽✺✰✴✦). +set special_symbols [list + "✰" \ + "✴" \ + "✱" \ + "✽" \ + "✦" ] + +set colorbar 0 ;# By default do not plot plcolorbar pages + # for now while we are working out the API. + +# TODO +#set options [list { +# { +# "colorbar", // Turns on pages showing colorbars +# NULL, +# NULL, +# &colorbar, +# PL_OPT_BOOL, +# "-colorbar", +# "Plot the \"color bar\" pages." +# }, +# { +# NULL, // option +# NULL, // handler +# NULL, // client data +# NULL, // address of variable to set +# 0, // mode flag +# NULL, // short syntax +# NULL +# } // long syntax +#}; + +set notes { "Make sure you get it right!" NULL } + +# -------------------------------------------------------------------------- +# main +# +# Demonstrate most pllegend capability including unicode symbols. +# -------------------------------------------------------------------------- + +set MAX_NLEGEND 7 + +proc x33 {{w loopback}} { + + # Parse and process command line arguments + # TODO + # plMergeOpts options "x33c options" notes + # void plparseopts &argc argv PL_PARSE_FULL + + # Initialize plplot + $w cmd plinit + + # First page illustrating the 16 standard positions. + $w cmd pladv 0 + $w cmd plvpor 0.25 0.75 0.25 0.75 + $w cmd plwind 0.0 1.0 0.0 1.0 + $w cmd plbox "bc" 0.0 0 "bc" 0.0 0 + $w cmd plsfont $::PLPLOT::PL_FCI_SANS}] -1 -1 + $w cmd plmtex "t" 8.0 0.5 0.5 "The 16 standard legend positions with" + $w cmd plmtex "t" 6.0 0.5 0.5 "the same 0.05 offset in x and y" + + nlegend = 1 + // Only specify legend data that are required according to the + // value of opt_array for that entry. + opt_base = [expr {$::PLPLOT::PL_LEGEND_BACKGROUND | $::PLPLOT::PL_LEGEND_BOUNDING_BOX}] + opt_array[0] = [expr {$::PLPLOT::PL_LEGEND_LINE | $::PLPLOT::PL_LEGEND_SYMBOL}] + line_styles[0] = 1 + line_widths[0] = 1 + symbol_scales[0] = 1. + symbol_numbers[0] = 4 + symbols[0] = "*" + + // Use monotype fonts so that all legends are the same size. + $w cmd plsfont [expr {$::PLPLOT::PL_FCI_MONO}] -1 -1 + $w cmd plscol0a 15 32 32 32 0.70 + + for {set k 0} {$k < 16} {incr k} { + set position [lindex $position_options $k] + set opt $opt_base + sprintf text[0] "%2.2d" k + text_colors[0] = 1 + k % 8 + line_colors[0] = 1 + k % 8 + symbol_colors[0] = 1 + k % 8 + + $w cmd pllegend( &legend_width, &legend_height, position, opt, 0.05, 0.05, + 0.1, 15, 1, 1, 0, 0, + nlegend, opt_array, 1.0, 1.0, 2.0, + 1., text_colors, (const char **) text, + NULL, NULL, NULL, NULL, + line_colors, line_styles, line_widths, + symbol_colors symbol_scales symbol_numbers const char ** symbols + } + + // Second page illustrating effect of nrow, ncolumn for the same legend + // data. + $w cmd pladv 0 + $w cmd plvpor 0.25 0.75 0.25 0.75 + $w cmd plwind 0.0 1.0 0.0 1.0 + $w cmd plbox "bc" 0.0 0 "bc" 0.0 0 + $w cmd plsfont [expr {$::PLPLOT::PL_FCI_SANS}] -1 -1 + $w cmd plmtex "t" 8.0 0.5 0.5 "The effect of nrow ncolumn PL_LEGEND_ROW_MAJOR" + $w cmd plmtex "t" 6.0 0.5 0.5 "and position for the same legend data" + + nlegend = 7 + + // Only specify legend data that are required according to the + // value of opt_array for that entry. + opt_base = [expr {$::PLPLOT::PL_LEGEND_BACKGROUND | $::PLPLOT::PL_LEGEND_BOUNDING_BOX}] + for k = 0 k < nlegend; k++ + { + opt_array[k] = [expr {$::PLPLOT::PL_LEGEND_LINE | $::PLPLOT::PL_LEGEND_SYMBOL}] + line_styles[k] = 1 + line_widths[k] = 1 + symbol_scales[k] = 1. + symbol_numbers[k] = 2 + symbols[k] = "*" + sprintf text[k] "%2.2d" k + text_colors[k] = 1 + k % 8 + line_colors[k] = 1 + k % 8 + symbol_colors[k] = 1 + k % 8 + } + + // Use monotype fonts so that all legends are the same size. + $w cmd plsfont [expr {$::PLPLOT::PL_FCI_MONO}] -1 -1 + $w cmd plscol0a 15 32 32 32 0.70 + + position = [expr {$::PLPLOT::PL_POSITION_TOP | $::PLPLOT::PL_POSITION_OUTSIDE}] + opt = opt_base + x = 0. + y = 0.1 + nrow = 1 + ncolumn = nlegend + $w cmd pllegend( &legend_width, &legend_height, position, opt, x, y, + 0.05, 15, 1, 1, nrow, ncolumn, + nlegend, opt_array, 1.0, 1.0, 2.0, + 1., text_colors, (const char **) text, + NULL, NULL, NULL, NULL, + line_colors, line_styles, line_widths, + symbol_colors symbol_scales symbol_numbers const char ** symbols + + position = [expr {$::PLPLOT::PL_POSITION_BOTTOM | $::PLPLOT::PL_POSITION_OUTSIDE}] + opt = opt_base + x = 0. + y = 0.1 + nrow = 1 + ncolumn = nlegend + $w cmd pllegend( &legend_width, &legend_height, position, opt, x, y, + 0.05, 15, 1, 1, nrow, ncolumn, + nlegend, opt_array, 1.0, 1.0, 2.0, + 1., text_colors, (const char **) text, + NULL, NULL, NULL, NULL, + line_colors, line_styles, line_widths, + symbol_colors symbol_scales symbol_numbers const char ** symbols + + position = [expr {$::PLPLOT::PL_POSITION_LEFT | $::PLPLOT::PL_POSITION_OUTSIDE}] + opt = opt_base + x = 0.1 + y = 0. + nrow = nlegend + ncolumn = 1 + $w cmd pllegend( &legend_width, &legend_height, position, opt, x, y, + 0.05, 15, 1, 1, nrow, ncolumn, + nlegend, opt_array, 1.0, 1.0, 2.0, + 1., text_colors, (const char **) text, + NULL, NULL, NULL, NULL, + line_colors, line_styles, line_widths, + symbol_colors symbol_scales symbol_numbers const char ** symbols + + position = [expr {$::PLPLOT::PL_POSITION_RIGHT | $::PLPLOT::PL_POSITION_OUTSIDE}] + opt = opt_base + x = 0.1 + y = 0. + nrow = nlegend + ncolumn = 1 + $w cmd pllegend( &legend_width, &legend_height, position, opt, x, y, + 0.05, 15, 1, 1, nrow, ncolumn, + nlegend, opt_array, 1.0, 1.0, 2.0, + 1., text_colors, (const char **) text, + NULL, NULL, NULL, NULL, + line_colors, line_styles, line_widths, + symbol_colors symbol_scales symbol_numbers const char ** symbols + + position = [expr {$::PLPLOT::PL_POSITION_LEFT | $::PLPLOT::PL_POSITION_TOP | $::PLPLOT::PL_POSITION_INSIDE}] + opt = opt_base + x = 0. + y = 0. + nrow = 6 + ncolumn = 2 + $w cmd pllegend( &legend_width, &legend_height, position, opt, x, y, + 0.05, 15, 1, 1, nrow, ncolumn, + nlegend, opt_array, 1.0, 1.0, 2.0, + 1., text_colors, (const char **) text, + NULL, NULL, NULL, NULL, + line_colors, line_styles, line_widths, + symbol_colors symbol_scales symbol_numbers const char ** symbols + + position = [expr {$::PLPLOT::PL_POSITION_RIGHT | $::PLPLOT::PL_POSITION_TOP | $::PLPLOT::PL_POSITION_INSIDE}] + opt = [expr {$opt_base | $::PLPLOT::PL_LEGEND_ROW_MAJOR}] + x = 0. + y = 0. + nrow = 6 + ncolumn = 2 + $w cmd pllegend( &legend_width, &legend_height, position, opt, x, y, + 0.05, 15, 1, 1, nrow, ncolumn, + nlegend, opt_array, 1.0, 1.0, 2.0, + 1., text_colors, (const char **) text, + NULL, NULL, NULL, NULL, + line_colors, line_styles, line_widths, + symbol_colors symbol_scales symbol_numbers const char ** symbols + + position = [expr {$::PLPLOT::PL_POSITION_BOTTOM | $::PLPLOT::PL_POSITION_INSIDE}] + opt = opt_base | $::PLPLOT::PL_LEGEND_ROW_MAJOR}] + x = 0. + y = 0. + nrow = 3 + ncolumn = 3 + $w cmd pllegend( &legend_width, &legend_height, position, opt, x, y, + 0.05, 15, 1, 1, nrow, ncolumn, + nlegend, opt_array, 1.0, 1.0, 2.0, + 1., text_colors, (const char **) text, + NULL, NULL, NULL, NULL, + line_colors, line_styles, line_widths, + symbol_colors symbol_scales symbol_numbers const char ** symbols + + // Third page demonstrating legend alignment + $w cmd pladv 0 + $w cmd plvpor 0.0 1.0 0.0 0.9 + $w cmd plwind 0.0 1.0 0.0 1.0 + $w cmd plsfont [expr {$::PLPLOT::PL_FCI_SANS}] -1 -1 + $w cmd plmtex "t" 2.0 0.5 0.5 "Demonstrate legend alignment" + + x = 0.1 + y = 0.1 + nturn = 4 + nlegend = 0 + position = [expr {$::PLPLOT::PL_POSITION_TOP | $::PLPLOT::PL_POSITION_LEFT | $::PLPLOT::PL_POSITION_SUBPAGE}] + opt_base = [expr {$::PLPLOT::PL_LEGEND_BACKGROUND | $::PLPLOT::PL_LEGEND_BOUNDING_BOX}] + opt = opt_base + for i = 0 i < 9; i++ + { + // Set up legend arrays with the correct size, type. + if ( i <= nturn ) + nlegend += 1 + else + nlegend -= 1 + nlegend = MAX 1 nlegend + // nly specify legend data that are required according to the + // value of opt_array for that entry. + for k = 0 k < nlegend; k++ + { + opt_array[k] = [expr {$::PLPLOT::PL_LEGEND_LINE | $::PLPLOT::PL_LEGEND_SYMBOL}] + line_styles[k] = 1 + line_widths[k] = 1 + symbol_scales[k] = 1. + symbol_numbers[k] = 2 + symbols[k] = "*" + sprintf text[k] "%2.2d" k + text_colors[k] = 1 + k % 8 + line_colors[k] = 1 + k % 8 + symbol_colors[k] = 1 + k % 8 + } + // Use monotype fonts so that all legends are the same size. + $w cmd plsfont [expr {$::PLPLOT::PL_FCI_MONO}] -1 -1 + $w cmd plscol0a 15 32 32 32 0.70 + + nrow = MIN 3 nlegend + ncolumn = 0 + + $w cmd pllegend( &legend_width, &legend_height, position, opt, x, y, + 0.025, 15, 1, 1, nrow, ncolumn, + nlegend, opt_array, 1.0, 1.0, 1.5, + 1., text_colors, (const char **) text, + NULL, NULL, NULL, NULL, + line_colors, line_styles, line_widths, + symbol_colors symbol_scales symbol_numbers const char ** symbols + + if ( i == nturn ) + { + position = [expr {$::PLPLOT::PL_POSITION_TOP | $::PLPLOT::PL_POSITION_RIGHT | $::PLPLOT::PL_POSITION_SUBPAGE}] + opt = opt_base + x = 1. - x + y += legend_height + } + else + { + x += legend_width + y += legend_height + } + } + + // Fourth page illustrating various kinds of legends + max_height = 0. + xstart = 0.0 + ystart = 0.1 + x = xstart + y = ystart + text_scale = 0.90 + $w cmd pladv 0 + $w cmd plvpor 0.0 1. 0.0 0.90 + $w cmd plwind 0.0 1.0 0.0 1.0 + //$w cmd plbox"bc" 0.0 0 "bc" 0.0 0 + $w cmd plsfont [expr {$::PLPLOT::PL_FCI_SANS}] -1 -1 + $w cmd plmtex "t" 2.0 0.5 0.5 "Demonstrate Various Kinds of Legends" + + nlegend = 5 + // Only specify legend data that are required according to the + // value of opt_array for that entry. + position = [expr {$::PLPLOT::PL_POSITION_LEFT | $::PLPLOT::PL_POSITION_TOP}] + opt_base = [expr {$::PLPLOT::PL_LEGEND_BACKGROUND | $::PLPLOT::PL_LEGEND_BOUNDING_BOX | $::PLPLOT::PL_LEGEND_TEXT_LEFT}] + + // Set up None, Box, Line, Symbol, and Line & Symbol legend entries. + opt_array[0] = [expr {$::PLPLOT::PL_LEGEND_NONE}] + sprintf text[0] "%s" "None" + text_colors[0] = 1 + + opt_array[1] = [expr {$::PLPLOT::PL_LEGEND_COLOR_BOX}] + sprintf text[1] "%s" "Box" + text_colors[1] = 2 + box_colors[1] = 2 + box_patterns[1] = 0 + box_scales[1] = 0.8 + box_line_widths[1] = 1 + + opt_array[2] = [expr {$::PLPLOT::PL_LEGEND_LINE}] + sprintf text[2] "%s" "Line" + text_colors[2] = 3 + line_colors[2] = 3 + line_styles[2] = 1 + line_widths[2] = 1 + + opt_array[3] = [expr {$::PLPLOT::PL_LEGEND_SYMBOL}] + sprintf text[3] "%s" "Symbol" + text_colors[3] = 4 + symbol_colors[3] = 4 + symbol_scales[3] = text_scale + symbol_numbers[3] = 4 + symbols[3] = special_symbols[2] + + opt_array[4] = [expr {$::PLPLOT::PL_LEGEND_SYMBOL | $::PLPLOT::PL_LEGEND_LINE}] + sprintf text[4] "%s" "L & S" + text_colors[4] = 5 + line_colors[4] = 5 + line_styles[4] = 1 + line_widths[4] = 1 + symbol_colors[4] = 5 + symbol_scales[4] = text_scale + symbol_numbers[4] = 4 + symbols[4] = special_symbols[2] + + opt = opt_base + $w cmd plscol0a 15 32 32 32 0.70 + + $w cmd pllegend( &legend_width, &legend_height, position, opt, x, y, + 0.1, 15, 1, 1, 0, 0, + nlegend, opt_array, 1.0, text_scale, 2.0, + 0., text_colors, (const char **) text, + box_colors, box_patterns, box_scales, box_line_widths, + line_colors, line_styles, line_widths, + symbol_colors symbol_scales symbol_numbers const char ** symbols + max_height = MAX max_height legend_height + + // Set up symbol legend entries with various symbols. + for i = 0 i < nlegend; i++ + { + opt_array[i] = [expr {$::PLPLOT::PL_LEGEND_SYMBOL}] + sprintf text[i] "%s%s" "Symbol " special_symbols[i] + text_colors[i] = i + 1 + symbol_colors[i] = i + 1 + symbol_scales[i] = text_scale + symbol_numbers[i] = 4 + symbols[i] = special_symbols[i] + } + + opt = opt_base + x += legend_width + $w cmd plscol0a 15 32 32 32 0.70 + + $w cmd pllegend( &legend_width, &legend_height, position, opt, x, y, + 0.1, 15, 1, 1, 0, 0, + nlegend, opt_array, 1.0, text_scale, 2.0, + 0., text_colors, (const char **) text, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, + symbol_colors symbol_scales symbol_numbers const char ** symbols + max_height = MAX max_height legend_height + + // Set up symbol legend entries with various numbers of symbols. + for i = 0 i < nlegend; i++ + { + opt_array[i] = [expr {$::PLPLOT::PL_LEGEND_SYMBOL}] + sprintf text[i] "%s %d" "Symbol Number" i + 2 + text_colors[i] = i + 1 + symbol_colors[i] = i + 1 + symbol_scales[i] = text_scale + symbol_numbers[i] = i + 2 + symbols[i] = special_symbols[2] + } + + opt = opt_base + x += legend_width + $w cmd plscol0a 15 32 32 32 0.70 + + $w cmd pllegend( &legend_width, &legend_height, position, opt, x, y, + 0.1, 15, 1, 1, 0, 0, + nlegend, opt_array, 1.0, text_scale, 2.0, + 0., text_colors, (const char **) text, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, + symbol_colors symbol_scales symbol_numbers const char ** symbols + max_height = MAX max_height legend_height + + // Set up box legend entries with various colours. + for i = 0 i < nlegend; i++ + { + opt_array[i] = [expr {$::PLPLOT::PL_LEGEND_COLOR_BOX}] + sprintf text[i] "%s %d" "Box Color" i + 1 + text_colors[i] = i + 1 + box_colors[i] = i + 1 + box_patterns[i] = 0 + box_scales[i] = 0.8 + box_line_widths[i] = 1 + } + + opt = opt_base + // Use new origin + x = xstart + y += max_height + max_height = 0. + $w cmd plscol0a 15 32 32 32 0.70 + + $w cmd pllegend( &legend_width, &legend_height, position, opt, x, y, + 0.1, 15, 1, 1, 0, 0, + nlegend, opt_array, 1.0, text_scale, 2.0, + 0., text_colors, (const char **) text, + box_colors, box_patterns, box_scales, box_line_widths, + NULL, NULL, NULL, + NULL NULL NULL NULL + max_height = MAX max_height legend_height + + // Set up box legend entries with various patterns. + for i = 0 i < nlegend; i++ + { + opt_array[i] = [expr {$::PLPLOT::PL_LEGEND_COLOR_BOX}] + sprintf text[i] "%s %d" "Box Pattern" i + text_colors[i] = 2 + box_colors[i] = 2 + box_patterns[i] = i + box_scales[i] = 0.8 + box_line_widths[i] = 1 + } + + opt = opt_base + x += legend_width + $w cmd plscol0a 15 32 32 32 0.70 + + $w cmd pllegend( &legend_width, &legend_height, position, opt, x, y, + 0.1, 15, 1, 1, 0, 0, + nlegend, opt_array, 1.0, text_scale, 2.0, + 0., text_colors, (const char **) text, + box_colors, box_patterns, box_scales, box_line_widths, + NULL, NULL, NULL, + NULL NULL NULL NULL + max_height = MAX max_height legend_height + + // Set up box legend entries with various box pattern line widths. + for i = 0 i < nlegend; i++ + { + opt_array[i] = [expr {$::PLPLOT::PL_LEGEND_COLOR_BOX}] + sprintf text[i] "%s %d" "Box Line Width" i + 1 + text_colors[i] = 2 + box_colors[i] = 2 + box_patterns[i] = 3 + box_scales[i] = 0.8 + box_line_widths[i] = i + 1 + } + + opt = opt_base + x += legend_width + $w cmd plscol0a 15 32 32 32 0.70 + + $w cmd pllegend( &legend_width, &legend_height, position, opt, x, y, + 0.1, 15, 1, 1, 0, 0, + nlegend, opt_array, 1.0, text_scale, 2.0, + 0., text_colors, (const char **) text, + box_colors, box_patterns, box_scales, box_line_widths, + NULL, NULL, NULL, + NULL NULL NULL NULL + max_height = MAX max_height legend_height + + // Set up line legend entries with various colours. + for i = 0 i < nlegend; i++ + { + opt_array[i] = [expr {$::PLPLOT::PL_LEGEND_LINE}] + sprintf text[i] "%s %d" "Line Color" i + 1 + text_colors[i] = i + 1 + line_colors[i] = i + 1 + line_styles[i] = 1 + line_widths[i] = 1 + } + + opt = opt_base + // Use new origin + x = xstart + y += max_height + max_height = 0. + $w cmd plscol0a 15 32 32 32 0.70 + + $w cmd pllegend( &legend_width, &legend_height, position, opt, x, y, + 0.1, 15, 1, 1, 0, 0, + nlegend, opt_array, 1.0, text_scale, 2.0, + 0., text_colors, (const char **) text, + NULL, NULL, NULL, NULL, + line_colors, line_styles, line_widths, + NULL NULL NULL NULL + max_height = MAX max_height legend_height + + // Set up line legend entries with various styles. + for i = 0 i < nlegend; i++ + { + opt_array[i] = [expr {$::PLPLOT::PL_LEGEND_LINE}] + sprintf text[i] "%s %d" "Line Style" i + 1 + text_colors[i] = 2 + line_colors[i] = 2 + line_styles[i] = i + 1 + line_widths[i] = 1 + } + + opt = opt_base + x += legend_width + $w cmd plscol0a 15 32 32 32 0.70 + + $w cmd pllegend( &legend_width, &legend_height, position, opt, x, y, + 0.1, 15, 1, 1, 0, 0, + nlegend, opt_array, 1.0, text_scale, 2.0, + 0., text_colors, (const char **) text, + NULL, NULL, NULL, NULL, + line_colors, line_styles, line_widths, + NULL NULL NULL NULL + max_height = MAX max_height legend_height + + // Set up line legend entries with various widths. + for i = 0 i < nlegend; i++ + { + opt_array[i] = [expr {$::PLPLOT::PL_LEGEND_LINE}] + sprintf text[i] "%s %d" "Line Width" i + 1 + text_colors[i] = 2 + line_colors[i] = 2 + line_styles[i] = 1 + line_widths[i] = i + 1 + } + + opt = opt_base + x += legend_width + $w cmd plscol0a 15 32 32 32 0.70 + + $w cmd pllegend( &legend_width, &legend_height, position, opt, x, y, + 0.1, 15, 1, 1, 0, 0, + nlegend, opt_array, 1.0, text_scale, 2.0, + 0., text_colors, (const char **) text, + NULL, NULL, NULL, NULL, + line_colors, line_styles, line_widths, + NULL NULL NULL NULL + max_height = MAX max_height legend_height +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |