From: <ai...@us...> - 2010-03-03 02:13:41
|
Revision: 10838 http://plplot.svn.sourceforge.net/plplot/?rev=10838&view=rev Author: airwin Date: 2010-03-03 02:13:34 +0000 (Wed, 03 Mar 2010) Log Message: ----------- Change over to configured form of the tk01, tk02, tk03, and tk04 scripts. This allows clean separation of build-tree and install-tree location of xtk01 (invoked by tk01), xtk02 (invoked by tk02), plserver (invoked by tk03), and xtk04 (invoked by tk04). Modified Paths: -------------- trunk/examples/tk/CMakeLists.txt Added Paths: ----------- trunk/examples/tk/tk01.in trunk/examples/tk/tk02.in trunk/examples/tk/tk03.in trunk/examples/tk/tk04.in Removed Paths: ------------- trunk/examples/tk/tk01 trunk/examples/tk/tk02 trunk/examples/tk/tk03 trunk/examples/tk/tk04 Modified: trunk/examples/tk/CMakeLists.txt =================================================================== --- trunk/examples/tk/CMakeLists.txt 2010-03-01 20:52:41 UTC (rev 10837) +++ trunk/examples/tk/CMakeLists.txt 2010-03-03 02:13:34 UTC (rev 10838) @@ -62,10 +62,6 @@ runAllDemos.tcl runExtendedDemos.tcl tkdemos.tcl - tk01 - tk02 - tk03 - tk04 ) # Copy files to the binary directory (if different) for generating tclIndex @@ -123,40 +119,14 @@ DEPENDS ${tk_FILES} ${CMAKE_CURRENT_BINARY_DIR}/tclIndex ) +# The third example is run using a configured shell script which invokes +# plserver so there is no source code to be compiled. +set(tk_SRC xtk01.c) # The second and fourth Tk examples depend on Itk to work. -set(tk_SCRIPTS tk01 tk03) -set(tk_SRC xtk01.c) - if(ENABLE_itk) - list(APPEND tk_SCRIPTS tk02 tk04) list(APPEND tk_SRC xtk02.c xtk04.c) endif(ENABLE_itk) -if(CORE_BUILD) - install(FILES ${tk_FILES} DESTINATION ${DATA_DIR}/examples/tk) - - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tclIndex DESTINATION ${DATA_DIR}/examples/tk) - - install(PROGRAMS ${tk_SCRIPTS} DESTINATION ${DATA_DIR}/examples/tk) - install(FILES ${tk_SRC} DESTINATION ${DATA_DIR}/examples/tk) - - set(CC ${CMAKE_C_COMPILER}) - - configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/Makefile.examples.in - ${CMAKE_CURRENT_BINARY_DIR}/Makefile.examples - ) - - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Makefile.examples - DESTINATION ${DATA_DIR}/examples/tk - RENAME Makefile - ) - - install(FILES CMakeLists.txt - DESTINATION ${DATA_DIR}/examples/tk - ) -endif(CORE_BUILD) - if(BUILD_TEST) if(CORE_BUILD) include_directories( @@ -188,3 +158,64 @@ endforeach(TK_SRC_FILE ${tk_SRC}) set_property(GLOBAL APPEND PROPERTY TARGETS_examples_tk tclIndex_examples_tk) endif(BUILD_TEST) + +# The first, second, and fourth tk examples depend on configured bang +# scripts to work which depends directly on the executables, xtk01, +# xtk02, and xtk04. +# The third example is run with the configured shell script, tk03, which +# invokes plserver. +set(tk_SCRIPTS tk01.in tk03.in) +get_target_property(xtk01_LOCATION xtk01 LOCATION) +get_target_property(plserver_LOCATION plserver LOCATION) + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/tk01.in + ${CMAKE_CURRENT_BINARY_DIR}/tk01 + @ONLY +) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/tk03.in + ${CMAKE_CURRENT_BINARY_DIR}/tk03 + @ONLY +) +# The second and fourth Tk examples depend on Itk to work. +if(ENABLE_itk) + list(APPEND tk_SCRIPTS tk02.in tk04.in) + get_target_property(xtk02_LOCATION xtk02 LOCATION) + get_target_property(xtk04_LOCATION xtk04 LOCATION) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/tk02.in + ${CMAKE_CURRENT_BINARY_DIR}/tk02 + @ONLY + ) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/tk04.in + ${CMAKE_CURRENT_BINARY_DIR}/tk04 + @ONLY + ) +endif(ENABLE_itk) + +if(CORE_BUILD) + install(PROGRAMS ${tk_SCRIPTS} DESTINATION ${DATA_DIR}/examples/tk) + install(FILES ${tk_FILES} DESTINATION ${DATA_DIR}/examples/tk) + + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tclIndex DESTINATION ${DATA_DIR}/examples/tk) + + install(FILES ${tk_SRC} DESTINATION ${DATA_DIR}/examples/tk) + + set(CC ${CMAKE_C_COMPILER}) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/Makefile.examples.in + ${CMAKE_CURRENT_BINARY_DIR}/Makefile.examples + ) + + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Makefile.examples + DESTINATION ${DATA_DIR}/examples/tk + RENAME Makefile + ) + + install(FILES CMakeLists.txt + DESTINATION ${DATA_DIR}/examples/tk + ) +endif(CORE_BUILD) Deleted: trunk/examples/tk/tk01 =================================================================== --- trunk/examples/tk/tk01 2010-03-01 20:52:41 UTC (rev 10837) +++ trunk/examples/tk/tk01 2010-03-03 02:13:34 UTC (rev 10838) @@ -1,130 +0,0 @@ -#!xtk01 -f -# -*-tcl-*- -# $Id$ -# -# Geoffrey Furnish -# 11 April 1994 -# -# @> A script for using Tk to control xtk01 -############################################################################### - -wm title . "x01c -- TK version" -plstdwin . - -# If you just want a bare plframe, set this to 0. - -set use_plxframe 1 - -if { $use_plxframe == 1 } then { - set plwin .plw.plwin -} else { - set plwin .plwin -} - -############################################################################### -# Set up the menubar and message widgets. - -frame .menu -relief raised -borderwidth 3 - -button .menu.one -text "One" -command "myplot 1" -pack append .menu .menu.one {left expand fill} - -button .menu.two -text "Two" -command "myplot 2" -pack append .menu .menu.two {left expand fill} - -button .menu.three -text "Three" -command "myplot 3" -pack append .menu .menu.three {left expand fill} - -button .menu.four -text "Four" -command "myplot 4" -pack append .menu .menu.four {left expand fill} - -button .menu.exit -text "Exit" -command "quit 0" -pack append .menu .menu.exit {right expand fill} - -message .msg \ - -font -Adobe-helvetica-medium-r-normal--*-240* -aspect 200 \ - -width 500 -borderwidth 1 \ - -text "TK01: Control x01c from TK" - -pack append . \ - .menu {top fillx} \ - .msg {top padx 5 pady 5 fill} - -tk_menuBar .menu .menu.one .menu.two .menu.three .menu.four .menu.exit - -############################################################################### - -if { $use_plxframe == 1 } then { - plxframe .plw - pack append . .plw {left expand fill} - -} else { - plframe .plwin - pack append . .plwin {left expand fill} -} - -bind $plwin L locate_on -bind $plwin <Escape> locate_off - -bind $plwin <Control-Button-1> rband_on -bind $plwin <Control-ButtonRelease-1> rband_off - -proc rband_on {} { - global plwin - $plwin configure -rubberband 1 -} - -proc rband_off {} { - global plwin - $plwin configure -rubberband 0 -} - -############################################################################### -# Definitions of procedures used in this script. - -# Punch eject and hold onto your seat !!! - -proc quit a { - exit -} - -# Utility routine. - -proc dpos w { - wm geometry $w +300+300 -} - -############################################################################### -# Here is a binding which allows you to obtain the world coordinates of a -# point or points through invoking a "Locate" mode. You could instead just -# turn it on somewhere in the script and leave it on if you prefer modeless -# behavior, although you can sometimes get into trouble if you move the -# crosshairs while a graphic draw is being performed (X is not forced to -# handle these events serially -- the crosshairs may be updated before the -# graphic draw is complete, and if the graphic draw then obscures the -# crosshairs it will leave traces of the crosshairs on the plot when you -# next move them). Note especially that in the body of this example -# "get_coords" proc, you can do anything you can do from Tcl. In -# particular, you need not put the data out to stdout (which is pretty -# boring). Instead, you can use this to feed the world coords to some more -# complicated Tcl proc of your choosing. Use the regexp parser to pull out -# the world x and y coordinates, etc. Have fun! - -proc locate_on {} { - global plwin - $plwin configure -xhairs 1 - bind $plwin <Shift-1> { get_coords %x %y } -} - -proc locate_off {} { - global plwin - $plwin configure -xhairs 0 - bind $plwin <Shift-1> {} -} - -proc get_coords {x y} { - global plwin - puts "world coordinates: [$plwin report wc $x $y]" -} - -############################################################################### Copied: trunk/examples/tk/tk01.in (from rev 10837, trunk/examples/tk/tk01) =================================================================== --- trunk/examples/tk/tk01.in (rev 0) +++ trunk/examples/tk/tk01.in 2010-03-03 02:13:34 UTC (rev 10838) @@ -0,0 +1,130 @@ +#!@xtk01_LOCATION@ -f +# -*-tcl-*- +# $Id$ +# +# Geoffrey Furnish +# 11 April 1994 +# +# @> A script for using Tk to control xtk01 +############################################################################### + +wm title . "x01c -- TK version" +plstdwin . + +# If you just want a bare plframe, set this to 0. + +set use_plxframe 1 + +if { $use_plxframe == 1 } then { + set plwin .plw.plwin +} else { + set plwin .plwin +} + +############################################################################### +# Set up the menubar and message widgets. + +frame .menu -relief raised -borderwidth 3 + +button .menu.one -text "One" -command "myplot 1" +pack append .menu .menu.one {left expand fill} + +button .menu.two -text "Two" -command "myplot 2" +pack append .menu .menu.two {left expand fill} + +button .menu.three -text "Three" -command "myplot 3" +pack append .menu .menu.three {left expand fill} + +button .menu.four -text "Four" -command "myplot 4" +pack append .menu .menu.four {left expand fill} + +button .menu.exit -text "Exit" -command "quit 0" +pack append .menu .menu.exit {right expand fill} + +message .msg \ + -font -Adobe-helvetica-medium-r-normal--*-240* -aspect 200 \ + -width 500 -borderwidth 1 \ + -text "TK01: Control x01c from TK" + +pack append . \ + .menu {top fillx} \ + .msg {top padx 5 pady 5 fill} + +tk_menuBar .menu .menu.one .menu.two .menu.three .menu.four .menu.exit + +############################################################################### + +if { $use_plxframe == 1 } then { + plxframe .plw + pack append . .plw {left expand fill} + +} else { + plframe .plwin + pack append . .plwin {left expand fill} +} + +bind $plwin L locate_on +bind $plwin <Escape> locate_off + +bind $plwin <Control-Button-1> rband_on +bind $plwin <Control-ButtonRelease-1> rband_off + +proc rband_on {} { + global plwin + $plwin configure -rubberband 1 +} + +proc rband_off {} { + global plwin + $plwin configure -rubberband 0 +} + +############################################################################### +# Definitions of procedures used in this script. + +# Punch eject and hold onto your seat !!! + +proc quit a { + exit +} + +# Utility routine. + +proc dpos w { + wm geometry $w +300+300 +} + +############################################################################### +# Here is a binding which allows you to obtain the world coordinates of a +# point or points through invoking a "Locate" mode. You could instead just +# turn it on somewhere in the script and leave it on if you prefer modeless +# behavior, although you can sometimes get into trouble if you move the +# crosshairs while a graphic draw is being performed (X is not forced to +# handle these events serially -- the crosshairs may be updated before the +# graphic draw is complete, and if the graphic draw then obscures the +# crosshairs it will leave traces of the crosshairs on the plot when you +# next move them). Note especially that in the body of this example +# "get_coords" proc, you can do anything you can do from Tcl. In +# particular, you need not put the data out to stdout (which is pretty +# boring). Instead, you can use this to feed the world coords to some more +# complicated Tcl proc of your choosing. Use the regexp parser to pull out +# the world x and y coordinates, etc. Have fun! + +proc locate_on {} { + global plwin + $plwin configure -xhairs 1 + bind $plwin <Shift-1> { get_coords %x %y } +} + +proc locate_off {} { + global plwin + $plwin configure -xhairs 0 + bind $plwin <Shift-1> {} +} + +proc get_coords {x y} { + global plwin + puts "world coordinates: [$plwin report wc $x $y]" +} + +############################################################################### Property changes on: trunk/examples/tk/tk01.in ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Deleted: trunk/examples/tk/tk02 =================================================================== --- trunk/examples/tk/tk02 2010-03-01 20:52:41 UTC (rev 10837) +++ trunk/examples/tk/tk02 2010-03-03 02:13:34 UTC (rev 10838) @@ -1,190 +0,0 @@ -#!xtk02 -f -# -*-tcl-*- -# $Id$ -# -# Geoffrey Furnish -# 11 April 1994 -# -# @> A script for using Tk to control xtk01, using the PLplot itcl interface. -############################################################################### - -package require Itk - -wm title . "x01c -- TK version" -plstdwin . - -############################################################################### -# Set up the menubar and message widgets. - -frame .menu -relief raised -borderwidth 3 - -button .menu.one -text "One" -command "myplot1" -pack append .menu .menu.one {left expand fill} - -button .menu.two -text "Two" -command "myplot 2" -pack append .menu .menu.two {left expand fill} - -button .menu.three -text "Three" -command "plot2" -pack append .menu .menu.three {left expand fill} - -button .menu.four -text "Four" -command "myplot 4" -pack append .menu .menu.four {left expand fill} - -button .menu.five -text "Five" -command "gumbyplot" -pack append .menu .menu.five {left expand fill} - -button .menu.six -text "Six" -command "snoopy" -pack .menu.six -side left -expand 1 -fill x - -button .menu.exit -text "Exit" -command "quit 0" -pack append .menu .menu.exit {right expand fill} - -message .msg \ - -font -Adobe-helvetica-medium-r-normal--*-240* -aspect 200 \ - -width 500 -borderwidth 1 \ - -text "TK02: Demo \[incr Tcl\] interface to PLplot" - -#PLXWin .plw -Pltkwin .plw - -pack append . .menu {top fillx} \ - .msg {top padx 5 pady 5 fill} \ - .plw {bottom expand fill} - -update - -tk_menuBar .menu .menu.one .menu.two .menu.three .menu.four .menu.exit - -############################################################################### -# Definitions of procedures used in this script. - -proc myplot1 {} { - global xscale yscale xoff yoff - - set xscale 6 - set yscale 1 - set xoff 0 - set yoff 0 - - plot1 -} - -# This is supposed to work just like the plot1() in x01c.c/xtk02.c - -proc plot1 {} { - global xscale yscale xoff yoff - - matrix x1 float 10 - matrix y1 float 10 - - for {set i 2; set n1 0} {$i < 60} {incr i 10; incr n1} { - set x [expr $xoff + $xscale * ($i + 1) / 60] - x1 $n1 = $x - y1 $n1 = [expr $yoff + $yscale * pow($x,2)] - } - - set n2 60 - matrix x2 float $n2 - matrix y2 float $n2 - - for {set i 0} {$i < $n2} {incr i} { - set x [expr $xoff + $xscale * ($i + 1) / $n2] - x2 $i = $x - y2 $i = [expr $yoff + $yscale * pow($x,2)] - } - - set xmax [x2 [expr $n2-1]] - set ymax [y2 [expr $n2-1]] - - .plw plcol 1 - .plw plenv $xoff $xmax $yoff $ymax 0 0 - .plw plcol 6 - .plw pllab "(x)" "(y)" "#frPLPLOT Example 1 - y=x#u2" - - # plot the data points - - .plw plcol 9 - .plw plpoin $n1 x1 y1 9 - - # plot the data points - - .plw plcol 4 - .plw plline $n2 x2 y2 -} - -# This is supposed to work just like the plot2() in x01c.c/xtk02.c - -proc plot2 {} { - .plw plcol 1 - .plw plenv -2 10 -.4 1.2 0 1 - .plw plcol 2 - .plw pllab "(x)" "sin(x)/x" "#frPLPLOT Example 1 - Sinc Function" - - # Fill up the array - - matrix x1 float 101 - matrix y1 float 101 - - for {set i 0} {$i < 101} {incr i} { - set x [expr ($i - 19.)/6.] - x1 $i = $x - y1 $i = 1 - if {$x != 0} { y1 $i = [expr sin($x)/$x] } - } - - .plw plcol 3 - .plw plline 101 x1 y1 -} - -proc gumbyplot {} { - .plw plcol 1 - .plw plenv 0 1 0 1 0 0 - .plw plcol 6 - .plw pllab "(x)" "(y)" "#frPLplot Example 1 - y=1-2x+2x#u2" - - matrix x1 float 101 - matrix y1 float 101 - - for {set i 0} {$i < 101} {incr i} { - set x [expr $i * .01] - x1 $i = $x - y1 $i = [expr 1 - 2 * $x + 2 * $x * $x] - } - - .plw plline 101 x1 y1 -} - -# This proc shows off the use of a matrix extension subcommand. - -proc snoopy {} { - - matrix x float 101 - matrix y float 101 - - for {set i 0} {$i < 101} {incr i} { - set xx [expr $i * .01] - x $i = $xx - } - - y stuff - - .plw plcol 1 - .plw plenv 0 1 0 1 0 0 - .plw plcol 6 - .plw pllab "(x)" "(y)" "#frDemo of Matrix extension subcommand" - .plw plline 101 x y -} - -# Punch eject and hold onto your seat !!! - -proc quit a { - exit -} - -# Utility routine. - -proc dpos w { - wm geometry $w +300+300 -} - -############################################################################### Copied: trunk/examples/tk/tk02.in (from rev 10837, trunk/examples/tk/tk02) =================================================================== --- trunk/examples/tk/tk02.in (rev 0) +++ trunk/examples/tk/tk02.in 2010-03-03 02:13:34 UTC (rev 10838) @@ -0,0 +1,190 @@ +#!@xtk02_LOCATION@ -f +# -*-tcl-*- +# $Id$ +# +# Geoffrey Furnish +# 11 April 1994 +# +# @> A script for using Tk to control xtk01, using the PLplot itcl interface. +############################################################################### + +package require Itk + +wm title . "x01c -- TK version" +plstdwin . + +############################################################################### +# Set up the menubar and message widgets. + +frame .menu -relief raised -borderwidth 3 + +button .menu.one -text "One" -command "myplot1" +pack append .menu .menu.one {left expand fill} + +button .menu.two -text "Two" -command "myplot 2" +pack append .menu .menu.two {left expand fill} + +button .menu.three -text "Three" -command "plot2" +pack append .menu .menu.three {left expand fill} + +button .menu.four -text "Four" -command "myplot 4" +pack append .menu .menu.four {left expand fill} + +button .menu.five -text "Five" -command "gumbyplot" +pack append .menu .menu.five {left expand fill} + +button .menu.six -text "Six" -command "snoopy" +pack .menu.six -side left -expand 1 -fill x + +button .menu.exit -text "Exit" -command "quit 0" +pack append .menu .menu.exit {right expand fill} + +message .msg \ + -font -Adobe-helvetica-medium-r-normal--*-240* -aspect 200 \ + -width 500 -borderwidth 1 \ + -text "TK02: Demo \[incr Tcl\] interface to PLplot" + +#PLXWin .plw +Pltkwin .plw + +pack append . .menu {top fillx} \ + .msg {top padx 5 pady 5 fill} \ + .plw {bottom expand fill} + +update + +tk_menuBar .menu .menu.one .menu.two .menu.three .menu.four .menu.exit + +############################################################################### +# Definitions of procedures used in this script. + +proc myplot1 {} { + global xscale yscale xoff yoff + + set xscale 6 + set yscale 1 + set xoff 0 + set yoff 0 + + plot1 +} + +# This is supposed to work just like the plot1() in x01c.c/xtk02.c + +proc plot1 {} { + global xscale yscale xoff yoff + + matrix x1 float 10 + matrix y1 float 10 + + for {set i 2; set n1 0} {$i < 60} {incr i 10; incr n1} { + set x [expr $xoff + $xscale * ($i + 1) / 60] + x1 $n1 = $x + y1 $n1 = [expr $yoff + $yscale * pow($x,2)] + } + + set n2 60 + matrix x2 float $n2 + matrix y2 float $n2 + + for {set i 0} {$i < $n2} {incr i} { + set x [expr $xoff + $xscale * ($i + 1) / $n2] + x2 $i = $x + y2 $i = [expr $yoff + $yscale * pow($x,2)] + } + + set xmax [x2 [expr $n2-1]] + set ymax [y2 [expr $n2-1]] + + .plw plcol 1 + .plw plenv $xoff $xmax $yoff $ymax 0 0 + .plw plcol 6 + .plw pllab "(x)" "(y)" "#frPLPLOT Example 1 - y=x#u2" + + # plot the data points + + .plw plcol 9 + .plw plpoin $n1 x1 y1 9 + + # plot the data points + + .plw plcol 4 + .plw plline $n2 x2 y2 +} + +# This is supposed to work just like the plot2() in x01c.c/xtk02.c + +proc plot2 {} { + .plw plcol 1 + .plw plenv -2 10 -.4 1.2 0 1 + .plw plcol 2 + .plw pllab "(x)" "sin(x)/x" "#frPLPLOT Example 1 - Sinc Function" + + # Fill up the array + + matrix x1 float 101 + matrix y1 float 101 + + for {set i 0} {$i < 101} {incr i} { + set x [expr ($i - 19.)/6.] + x1 $i = $x + y1 $i = 1 + if {$x != 0} { y1 $i = [expr sin($x)/$x] } + } + + .plw plcol 3 + .plw plline 101 x1 y1 +} + +proc gumbyplot {} { + .plw plcol 1 + .plw plenv 0 1 0 1 0 0 + .plw plcol 6 + .plw pllab "(x)" "(y)" "#frPLplot Example 1 - y=1-2x+2x#u2" + + matrix x1 float 101 + matrix y1 float 101 + + for {set i 0} {$i < 101} {incr i} { + set x [expr $i * .01] + x1 $i = $x + y1 $i = [expr 1 - 2 * $x + 2 * $x * $x] + } + + .plw plline 101 x1 y1 +} + +# This proc shows off the use of a matrix extension subcommand. + +proc snoopy {} { + + matrix x float 101 + matrix y float 101 + + for {set i 0} {$i < 101} {incr i} { + set xx [expr $i * .01] + x $i = $xx + } + + y stuff + + .plw plcol 1 + .plw plenv 0 1 0 1 0 0 + .plw plcol 6 + .plw pllab "(x)" "(y)" "#frDemo of Matrix extension subcommand" + .plw plline 101 x y +} + +# Punch eject and hold onto your seat !!! + +proc quit a { + exit +} + +# Utility routine. + +proc dpos w { + wm geometry $w +300+300 +} + +############################################################################### Property changes on: trunk/examples/tk/tk02.in ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Deleted: trunk/examples/tk/tk03 =================================================================== --- trunk/examples/tk/tk03 2010-03-01 20:52:41 UTC (rev 10837) +++ trunk/examples/tk/tk03 2010-03-03 02:13:34 UTC (rev 10838) @@ -1,288 +0,0 @@ -#!/bin/sh -#--------------------------------*- Tcl -*------------------------------------# -# $Id$ -# -# Maurice LeBrun -# 30 Jun 1994 -# -# @> A script illustrating multiple toplevel plframes. -#-----------------------------------------------------------------------------# -#\ -exec plserver -f "$0" ${1+"$@"} - -# Note: I defer running "open_main" until later to make sure everything -# has been sourced. - -wm title . "tk03" -plstdwin . - -set child_count 1 - -# If you just want a bare plframe, set this to 0. - -set use_plxframe 1 - -############################################################################### -# Set up the menubar and message widgets for main window. - -proc open_main {} { - - global use_plxframe - - if { $use_plxframe == 1 } then { - set plwin .plw.plwin - } else { - set plwin .plwin - } - - frame .menu -relief raised -borderwidth 3 - - button .menu.one -text "One" -command "1 $plwin" - pack append .menu .menu.one {left expand fill} - - button .menu.two -text "Two" -command "2 $plwin" - pack append .menu .menu.two {left expand fill} - - button .menu.open -text "Open new" -command "open_child" - pack append .menu .menu.open {left expand fill} - - button .menu.exit -text "Exit" -command "destroy ." - -#"quit 0" - - pack append .menu .menu.exit {right expand fill} - - message .msg \ - -font -Adobe-helvetica-medium-r-normal--*-240* -aspect 200 \ - -width 500 -borderwidth 1 \ - -text "TK03: Multiple toplevels with plframes" - - pack append . \ - .menu {top fillx} \ - .msg {top padx 5 pady 5 fill} - - tk_menuBar .menu .menu.one .menu.two .menu.exit - - if { $use_plxframe == 1 } then { - plxframe .plw - pack append . .plw {left expand fill} - } else { - plframe .plwin - pack append . .plwin {left expand fill} - } -} - -############################################################################### -# Set up the second toplevel - -proc open_child {} { - - global child_count use_plxframe - - set w .$child_count - - toplevel $w - plstdwin $w - - if { $use_plxframe == 1 } then { - set plwin $w.plw.plwin - } else { - set plwin $w.plwin - } - -# Set up the second menubar and message widgets. - - frame $w.menu -relief raised -borderwidth 3 - - button $w.menu.three -text "Three" -command "plot2 $plwin" - pack append $w.menu $w.menu.three {left expand fill} - - button $w.menu.four -text "Four" -command "plot3 $plwin" - pack append $w.menu $w.menu.four {left expand fill} - - button $w.menu.exit -text "Dismiss" -command "destroy $w" - pack append $w.menu $w.menu.exit {right expand fill} - - message $w.msg \ - -font -Adobe-helvetica-medium-r-normal--*-240* -aspect 200 \ - -width 500 -borderwidth 1 \ - -text "TK03: toplevel $child_count" - - pack append $w \ - $w.menu {top fillx} \ - $w.msg {top padx 5 pady 5 fill} - - tk_menuBar $w.menu $w.menu.three $w.menu.four - -# This creates the plframe "megawidget". If you just want a bare plframe, -# change use_plxframe to 0. - - if { $use_plxframe == 1 } then { - plxframe $w.plw - pack append $w $w.plw {left expand fill} - } else { - plframe $w.plwin - pack append $w $w.plwin {left expand fill} - } - - incr child_count -} - -############################################################################### -# Utility routines - -# Punch eject and hold onto your seat !!! - -proc quit a { - exit -} - -# Utility routine. - -proc dpos w { - wm geometry $w +300+300 -} - -############################################################################### -# Plotting routines -############################################################################### - -proc 1 {w} { - global xscale yscale xoff yoff - - set xscale 6.0 - set yscale 1.0 - set xoff 0.0 - set yoff 0.0 - - plot1 $w -} - -proc 2 {w} { - global xscale yscale xoff yoff - - set xscale 1.0 - set yscale 0.0014 - set xoff 0.0 - set yoff 0.0185 - - $w cmd plsyax 5 - - plot1 $w -} - -# This is supposed to work just like the plot1() in x01c.c - -proc plot1 {w} { - global xscale yscale xoff yoff - - set npts 60 - matrix x f $npts - 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)] - } - - set xmax [x [expr $npts-1]] - 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] - x1 $i = [x $j] - y1 $i = [y $j] - } - - $w cmd plcol 1 - $w cmd plenv $xoff $xmax $yoff $ymax 0 0 - $w cmd plcol 6 - $w cmd pllab "(x)" "(y)" "#frPLplot Example 1 - y=x#u2" - - # plot the data points - - $w cmd plcol 9 - $w cmd plpoin 6 x1 y1 9 - - # draw the line through the data - - $w cmd plcol 4 - $w cmd plline $npts x y -} - -# This is supposed to work just like the plot2() in x01c.c - -proc plot2 {w} { - $w cmd plcol 1 - $w cmd plenv -2 10 -.4 1.2 0 1 - $w cmd plcol 2 - $w cmd pllab "(x)" "sin(x)/x" "#frPLplot Example 1 - Sinc Function" - - # Fill up the array - - matrix x1 f 101 - matrix y1 f 101 - - for {set i 0} {$i < 101} {incr i} { - set x [expr ($i - 19.)/6.] - x1 $i = $x - y1 $i = 1 - if {$x != 0} { y1 $i = [expr sin($x)/$x] } - } - - $w cmd plcol 3 - $w cmd plline 101 x1 y1 -} - -# This is supposed to work just like the plot3() in x01c.c - -proc plot3 {w} { - - $w cmd pladv - $w cmd plvsta - $w cmd plwind 0.0 360.0 -1.2 1.2 - -# Draw a box with ticks spaced 60 degrees apart in X, and 0.2 in Y. - - $w cmd plcol 1 - $w cmd plbox "bcnst" 60.0 2 "bcnstv" 0.2 2 - -# 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 - matrix space i 1 - - mark 0 = 1500 - space 0 = 1500 - $w cmd plstyl 1 mark space - - $w cmd plcol 2 - $w cmd plbox "g" 30.0 0 "g" 0.2 0 - - mark 0 = 0 - space 0 = 0 - $w cmd plstyl 0 mark space - - $w cmd plcol 3 - $w cmd pllab "Angle (degrees)" "sine" "#frPLplot Example 1 - Sine function" - - matrix x f 101 - matrix y f 101 - - for {set i 0} {$i < 101} {incr i} { - x $i = [expr 3.6 * $i] - y $i = [expr sin([x $i] * 3.141592654 / 180.0)] - } - - $w cmd plcol 4 - $w cmd plline 101 x y -} - -############################################################################### - -open_main - Copied: trunk/examples/tk/tk03.in (from rev 10837, trunk/examples/tk/tk03) =================================================================== --- trunk/examples/tk/tk03.in (rev 0) +++ trunk/examples/tk/tk03.in 2010-03-03 02:13:34 UTC (rev 10838) @@ -0,0 +1,288 @@ +#!/bin/sh +#--------------------------------*- Tcl -*------------------------------------# +# $Id$ +# +# Maurice LeBrun +# 30 Jun 1994 +# +# @> A script illustrating multiple toplevel plframes. +#-----------------------------------------------------------------------------# +#\ +exec @plserver_LOCATION@ -f "$0" ${1+"$@"} + +# Note: I defer running "open_main" until later to make sure everything +# has been sourced. + +wm title . "tk03" +plstdwin . + +set child_count 1 + +# If you just want a bare plframe, set this to 0. + +set use_plxframe 1 + +############################################################################### +# Set up the menubar and message widgets for main window. + +proc open_main {} { + + global use_plxframe + + if { $use_plxframe == 1 } then { + set plwin .plw.plwin + } else { + set plwin .plwin + } + + frame .menu -relief raised -borderwidth 3 + + button .menu.one -text "One" -command "1 $plwin" + pack append .menu .menu.one {left expand fill} + + button .menu.two -text "Two" -command "2 $plwin" + pack append .menu .menu.two {left expand fill} + + button .menu.open -text "Open new" -command "open_child" + pack append .menu .menu.open {left expand fill} + + button .menu.exit -text "Exit" -command "destroy ." + +#"quit 0" + + pack append .menu .menu.exit {right expand fill} + + message .msg \ + -font -Adobe-helvetica-medium-r-normal--*-240* -aspect 200 \ + -width 500 -borderwidth 1 \ + -text "TK03: Multiple toplevels with plframes" + + pack append . \ + .menu {top fillx} \ + .msg {top padx 5 pady 5 fill} + + tk_menuBar .menu .menu.one .menu.two .menu.exit + + if { $use_plxframe == 1 } then { + plxframe .plw + pack append . .plw {left expand fill} + } else { + plframe .plwin + pack append . .plwin {left expand fill} + } +} + +############################################################################### +# Set up the second toplevel + +proc open_child {} { + + global child_count use_plxframe + + set w .$child_count + + toplevel $w + plstdwin $w + + if { $use_plxframe == 1 } then { + set plwin $w.plw.plwin + } else { + set plwin $w.plwin + } + +# Set up the second menubar and message widgets. + + frame $w.menu -relief raised -borderwidth 3 + + button $w.menu.three -text "Three" -command "plot2 $plwin" + pack append $w.menu $w.menu.three {left expand fill} + + button $w.menu.four -text "Four" -command "plot3 $plwin" + pack append $w.menu $w.menu.four {left expand fill} + + button $w.menu.exit -text "Dismiss" -command "destroy $w" + pack append $w.menu $w.menu.exit {right expand fill} + + message $w.msg \ + -font -Adobe-helvetica-medium-r-normal--*-240* -aspect 200 \ + -width 500 -borderwidth 1 \ + -text "TK03: toplevel $child_count" + + pack append $w \ + $w.menu {top fillx} \ + $w.msg {top padx 5 pady 5 fill} + + tk_menuBar $w.menu $w.menu.three $w.menu.four + +# This creates the plframe "megawidget". If you just want a bare plframe, +# change use_plxframe to 0. + + if { $use_plxframe == 1 } then { + plxframe $w.plw + pack append $w $w.plw {left expand fill} + } else { + plframe $w.plwin + pack append $w $w.plwin {left expand fill} + } + + incr child_count +} + +############################################################################### +# Utility routines + +# Punch eject and hold onto your seat !!! + +proc quit a { + exit +} + +# Utility routine. + +proc dpos w { + wm geometry $w +300+300 +} + +############################################################################### +# Plotting routines +############################################################################### + +proc 1 {w} { + global xscale yscale xoff yoff + + set xscale 6.0 + set yscale 1.0 + set xoff 0.0 + set yoff 0.0 + + plot1 $w +} + +proc 2 {w} { + global xscale yscale xoff yoff + + set xscale 1.0 + set yscale 0.0014 + set xoff 0.0 + set yoff 0.0185 + + $w cmd plsyax 5 + + plot1 $w +} + +# This is supposed to work just like the plot1() in x01c.c + +proc plot1 {w} { + global xscale yscale xoff yoff + + set npts 60 + matrix x f $npts + 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)] + } + + set xmax [x [expr $npts-1]] + 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] + x1 $i = [x $j] + y1 $i = [y $j] + } + + $w cmd plcol 1 + $w cmd plenv $xoff $xmax $yoff $ymax 0 0 + $w cmd plcol 6 + $w cmd pllab "(x)" "(y)" "#frPLplot Example 1 - y=x#u2" + + # plot the data points + + $w cmd plcol 9 + $w cmd plpoin 6 x1 y1 9 + + # draw the line through the data + + $w cmd plcol 4 + $w cmd plline $npts x y +} + +# This is supposed to work just like the plot2() in x01c.c + +proc plot2 {w} { + $w cmd plcol 1 + $w cmd plenv -2 10 -.4 1.2 0 1 + $w cmd plcol 2 + $w cmd pllab "(x)" "sin(x)/x" "#frPLplot Example 1 - Sinc Function" + + # Fill up the array + + matrix x1 f 101 + matrix y1 f 101 + + for {set i 0} {$i < 101} {incr i} { + set x [expr ($i - 19.)/6.] + x1 $i = $x + y1 $i = 1 + if {$x != 0} { y1 $i = [expr sin($x)/$x] } + } + + $w cmd plcol 3 + $w cmd plline 101 x1 y1 +} + +# This is supposed to work just like the plot3() in x01c.c + +proc plot3 {w} { + + $w cmd pladv + $w cmd plvsta + $w cmd plwind 0.0 360.0 -1.2 1.2 + +# Draw a box with ticks spaced 60 degrees apart in X, and 0.2 in Y. + + $w cmd plcol 1 + $w cmd plbox "bcnst" 60.0 2 "bcnstv" 0.2 2 + +# 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 + matrix space i 1 + + mark 0 = 1500 + space 0 = 1500 + $w cmd plstyl 1 mark space + + $w cmd plcol 2 + $w cmd plbox "g" 30.0 0 "g" 0.2 0 + + mark 0 = 0 + space 0 = 0 + $w cmd plstyl 0 mark space + + $w cmd plcol 3 + $w cmd pllab "Angle (degrees)" "sine" "#frPLplot Example 1 - Sine function" + + matrix x f 101 + matrix y f 101 + + for {set i 0} {$i < 101} {incr i} { + x $i = [expr 3.6 * $i] + y $i = [expr sin([x $i] * 3.141592654 / 180.0)] + } + + $w cmd plcol 4 + $w cmd plline 101 x y +} + +############################################################################### + +open_main + Property changes on: trunk/examples/tk/tk03.in ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Deleted: trunk/examples/tk/tk04 =================================================================== --- trunk/examples/tk/tk04 2010-03-01 20:52:41 UTC (rev 10837) +++ trunk/examples/tk/tk04 2010-03-03 02:13:34 UTC (rev 10838) @@ -1,122 +0,0 @@ -#!xtk04 -f -# -*-tcl-*- -# $Id$ -# Maurice LeBrun -# 30 Jun 1994 -# -# @> A script illustrating use of 2-d tcl api (plframe). -############################################################################### - -package require Itk - -wm title . "tk04" -plstdwin . - -############################################################################### -# Set up the menubar and message widgets. - -frame .menu -relief raised -borderwidth 3 - -button .menu.comp -text "Compute Function" -command "compute" -button .menu.contour -text "Line Contour" -command "contour" -button .menu.shade -text "Color Fill Contour" -command "shade" -pack .menu.comp .menu.contour .menu.shade -side left - -button .menu.exit -text "Exit" -command "destroy ." -pack .menu.exit -side right - -message .msg \ - -font -Adobe-helvetica-medium-r-normal--*-240* -aspect 200 \ - -width 500 -borderwidth 1 \ - -text "TK04: 2-d Tcl API" - -pack .menu .msg -fill x - -tk_menuBar .menu .menu.comp .menu.contour .menu.shade .menu.exit - -PLXWin .plw -pack .plw -side bottom -expand 1 -fill both - -matrix x f 64 64 - -# This is the front end to the data computation. Initially we just -# create the matrix to hold the data, and then vector down to the C -# side to set the data. However, one could easily embellish this to -# accept specifications from the user (via Tk entries), and act on -# them. For instance, choosing the size of the matrix, passing -# paramaters to the compiled side, etc. - -proc compute {} { - - global x - - get_data x -} - -# Draw a contour of the data. - -proc contour {} { - - global x - - .plw pladv - .plw plvpor 0.1 0.9 0.1 0.9 - .plw plwind 1. 64. 1. 64. - - .plw plcol 6 - .plw pllab "(x)" "(y)" "#frPLplot Example Tk04" - - # plot the data points - - .plw plcol 9 - - matrix clev f 10 - - set max [x max] - set min [x min] - - for {set i 0} {$i < 10} {incr i} { - clev $i = [expr $min + ($max-$min)*($i+.5)/10 ] - } - - .plw plcont x clev - - .plw plcol 1 - .plw plbox "bcnst" 0.0 0 "bcnstv" 0.0 0 -} - -proc shade {} { - - global x - - .plw pladv - .plw plvpor 0.1 0.9 0.1 0.9 - .plw plwind 0. 1. 0. 1. - - .plw plcol 6 - .plw pllab "(x)" "(y)" "Cool shade plot example from Tcl" - - set max [x max] - set min [x min] - - set xmin 0 - set xmax 1 - set ymin 0 - set ymax 1 - - for {set i 0} {$i < 20} {incr i} { - set sh_min [expr $min + ($max-$min)*$i/20.] - set sh_max [expr $min + ($max-$min)*($i+1)/20.] - set sh_col [expr $i/20.] - - .plw plshade x $xmin $xmax $ymin $ymax $sh_min $sh_max 1 $sh_col 0 \ - 1 0 0 0 \ - 1 - - } - - .plw plcol 1 - .plw plbox "bcnst" 0.0 0 "bcnstv" 0.0 0 -} - -############################################################################### Copied: trunk/examples/tk/tk04.in (from rev 10837, trunk/examples/tk/tk04) =================================================================== --- trunk/examples/tk/tk04.in (rev 0) +++ trunk/examples/tk/tk04.in 2010-03-03 02:13:34 UTC (rev 10838) @@ -0,0 +1,122 @@ +#!@xtk04_LOCATION@ -f +# -*-tcl-*- +# $Id$ +# Maurice LeBrun +# 30 Jun 1994 +# +# @> A script illustrating use of 2-d tcl api (plframe). +############################################################################### + +package require Itk + +wm title . "tk04" +plstdwin . + +############################################################################### +# Set up the menubar and message widgets. + +frame .menu -relief raised -borderwidth 3 + +button .menu.comp -text "Compute Function" -command "compute" +button .menu.contour -text "Line Contour" -command "contour" +button .menu.shade -text "Color Fill Contour" -command "shade" +pack .menu.comp .menu.contour .menu.shade -side left + +button .menu.exit -text "Exit" -command "destroy ." +pack .menu.exit -side right + +message .msg \ + -font -Adobe-helvetica-medium-r-normal--*-240* -aspect 200 \ + -width 500 -borderwidth 1 \ + -text "TK04: 2-d Tcl API" + +pack .menu .msg -fill x + +tk_menuBar .menu .menu.comp .menu.contour .menu.shade .menu.exit + +PLXWin .plw +pack .plw -side bottom -expand 1 -fill both + +matrix x f 64 64 + +# This is the front end to the data computation. Initially we just +# create the matrix to hold the data, and then vector down to the C +# side to set the data. However, one could easily embellish this to +# accept specifications from the user (via Tk entries), and act on +# them. For instance, choosing the size of the matrix, passing +# paramaters to the compiled side, etc. + +proc compute {} { + + global x + + get_data x +} + +# Draw a contour of the data. + +proc contour {} { + + global x + + .plw pladv + .plw plvpor 0.1 0.9 0.1 0.9 + .plw plwind 1. 64. 1. 64. + + .plw plcol 6 + .plw pllab "(x)" "(y)" "#frPLplot Example Tk04" + + # plot the data points + + .plw plcol 9 + + matrix clev f 10 + + set max [x max] + set min [x min] + + for {set i 0} {$i < 10} {incr i} { + clev $i = [expr $min + ($max-$min)*($i+.5)/10 ] + } + + .plw plcont x clev + + .plw plcol 1 + .plw plbox "bcnst" 0.0 0 "bcnstv" 0.0 0 +} + +proc shade {} { + + global x + + .plw pladv + .plw plvpor 0.1 0.9 0.1 0.9 + .plw plwind 0. 1. 0. 1. + + .plw plcol 6 + .plw pllab "(x)" "(y)" "Cool shade plot example from Tcl" + + set max [x max] + set min [x min] + + set xmin 0 + set xmax 1 + set ymin 0 + set ymax 1 + + for {set i 0} {$i < 20} {incr i} { + set sh_min [expr $min + ($max-$min)*$i/20.] + set sh_max [expr $min + ($max-$min)*($i+1)/20.] + set sh_col [expr $i/20.] + + .plw plshade x $xmin $xmax $ymin $ymax $sh_min $sh_max 1 $sh_col 0 \ + 1 0 0 0 \ + 1 + + } + + .plw plcol 1 + .plw plbox "bcnst" 0.0 0 "bcnstv" 0.0 0 +} + +############################################################################### Property changes on: trunk/examples/tk/tk04.in ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |